package com.grayben.riskExtractor.headingMarker;

import org.junit.*;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;

import java.util.List;

import static org.junit.Assert.*;

/**
 * Created by beng on 28/11/2015.
 */
@RunWith(MockitoJUnitRunner.class)
public class TextCandidateTest {

    TextCandidate textCandidateSUT;

    List<String> stringListReturned;

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    int index = 0;

    @Mock
    List<String> list;
    int listSize = 50;

    @Before
    public void setUp() throws Exception {
        Mockito.when(list.size()).thenReturn(listSize);
        textCandidateSUT = new TextCandidate(list, index);
        stringListReturned = textCandidateSUT.getList();
    }

    @After
    public void tearDown() throws Exception {

    }

    @Test
    public void
    test_ConstructorThrowsIndexOutOfBoundsException_WhenIndexIsNegative(){
        index = -1;

        thrown.expect(IndexOutOfBoundsException.class);

        textCandidateSUT = new TextCandidate(list, index);
    }

    @Test
    public void
    test_ConstructorThrowsIndexOutOfBoundsException_WhenIndexIsTooHigh
            () throws Exception {
        Mockito.when(list.size()).thenReturn(listSize);
        index = listSize + 1;

        thrown.expect(IndexOutOfBoundsException.class);

        textCandidateSUT = new TextCandidate(list, index);
    }

    @Test
    public void
    test_ConstructorThrowsNullPointerException_WhenListIsNull
            () throws Exception {

        thrown.expect(NullPointerException.class);

        textCandidateSUT = new TextCandidate(null, index);
    }

    @Test
    public void
    test_ReturnedTextListThrowsUnsupportedOperationException_WhenAddObject
            () throws Exception {
        fail("This test has not been implemented");
    }

    @Test
    public void
    test_ReturnedTextListThrowsUnsupportedOperationException_WhenAddObjectWithIndex
            () throws Exception {
        fail("This test has not been implemented");
    }

    @Test
    public void
    test_ReturnedTextListThrowsUnsupportedOperationException_WhenAddAllCollection
            () throws Exception {
        fail("This test has not been implemented");
    }

    @Test
    public void
    test_ReturnedTextListThrowsUnsupportedOperationException_WhenAddAllCollectionWithIndex
            () throws Exception {
        fail("This test has not been implemented");
    }

    @Test
    public void
    test_ReturnedTextListThrowsUnsupportedOperationException_WhenClear
            () throws Exception {
        fail("This test has not been implemented");
    }

    @Test
    public void
    test_ReturnedTextListThrowsUnsupportedOperationException_WhenRemoveAll
            () throws Exception {
        fail("This test has not been implemented");
    }

    @Test
    public void
    test_ReturnedTextListThrowsUnsupportedOperationException_WhenReplaceAll
            () throws Exception {
        fail("This test has not been implemented");
    }

    @Test
    public void
    test_ReturnedTextListThrowsUnsupportedOperationException_WhenRetainAll
            () throws Exception {
        fail("This test has not been implemented");
    }

    @Test
    public void
    test_ReturnedTextListThrowsUnsupportedOperationException_WhenSet
            () throws Exception {
        fail("This test has not been implemented");
    }

    @Test
    public void
    test_ReturnedTextListThrowsUnsupportedOperationException_WhenSort
            () throws Exception {
        fail("This test has not been implemented");
    }
}
@@ -260,13 +260,140 @@
 til.
+Array
 List;
+%0Aimport java.util.Collection;%0Aimport java.util.Comparator;%0Aimport java.util.List;%0Aimport java.util.function.UnaryOperator;
 %0A%0Aim
@@ -702,24 +702,48 @@
 index = 0;%0A%0A
+    int listSize = 50;%0A%0A
     @Mock%0A  
@@ -767,32 +767,65 @@
 st;%0A
+%0A
     
-int listSize = 50
+@Mock%0A    Collection%3CString%3E collectionOfStrings
 ;%0A%0A
+%0A
     
@@ -2093,49 +2093,103 @@
     
-fail(%22This test has not been implemented%22
+thrown.expect(UnsupportedOperationException.class);%0A        stringListReturned.add(new String()
 );%0A 
@@ -2350,49 +2350,106 @@
     
-fail(%22This test has not been implemented%22
+thrown.expect(UnsupportedOperationException.class);%0A        stringListReturned.add(0, new String()
 );%0A 
@@ -2608,49 +2608,113 @@
     
-fail(%22This test has not been implemented%22
+thrown.expect(UnsupportedOperationException.class);%0A        stringListReturned.addAll(collectionOfStrings
 );%0A 
@@ -2882,49 +2882,116 @@
     
-fail(%22This test has not been implemented%22
+thrown.expect(UnsupportedOperationException.class);%0A        stringListReturned.addAll(0, collectionOfStrings
 );%0A 
@@ -3139,49 +3139,93 @@
     
-fail(%22This test has not been implemented%22
+thrown.expect(UnsupportedOperationException.class);%0A        stringListReturned.clear(
 );%0A 
@@ -3377,49 +3377,116 @@
     
-fail(%22This test has not been implemented%22
+thrown.expect(UnsupportedOperationException.class);%0A        stringListReturned.removeAll(collectionOfStrings
 );%0A 
@@ -3639,49 +3639,246 @@
     
-fail(%22This test has not been implemented%22
+thrown.expect(UnsupportedOperationException.class);%0A        stringListReturned.replaceAll(new UnaryOperator%3CString%3E() %7B%0A            @Override%0A            public String apply(String s) %7B%0A                return null;%0A            %7D%0A        %7D
 );%0A 
@@ -4030,49 +4030,116 @@
     
-fail(%22This test has not been implemented%22
+thrown.expect(UnsupportedOperationException.class);%0A        stringListReturned.retainAll(collectionOfStrings
 );%0A 
@@ -4285,48 +4285,98 @@
     
-fail(%22This test has not been implemented
+thrown.expect(UnsupportedOperationException.class);%0A        stringListReturned.set(0, %22cow
 %22);%0A
@@ -4524,49 +4524,273 @@
     
-fail(%22This test has not been implemented%22
+thrown.expect(UnsupportedOperationException.class);%0A        stringListReturned.sort(new Comparator%3CString%3E() %7B%0A            @Override%0A            public int compare(String o1, String o2) %7B%0A                return o1.hashCode() - o2.hashCode();%0A            %7D%0A        %7D
 );%0A 

Implement tests for immutability