package com.grayben.riskExtractor.headingMarker.markedText;

import com.grayben.riskExtractor.headingMarker.MarkedText;
import com.grayben.riskExtractor.headingMarker.elector.ElectedText;
import com.grayben.riskExtractor.headingMarker.elector.ElectedTextTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import java.util.Collection;
import java.util.List;

import static org.junit.Assert.*;

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


    //TODO: check setup methods

    @Mock
    ElectedText electedTextListMock;

    MarkedText markedTextSUT;

    @Before
    public void setUp() throws Exception {
        markedTextSUT = new MarkedText(electedTextListMock);
    }

    @After
    public void tearDown() throws Exception {

    }

    @Test
    public void test_Init_ThrowsNullPointerException_WhenTextArgumentIsNull
            () throws Exception {
        thrown.expect(NullPointerException.class);
        ElectedText electedTextListArgument = null;
        markedTextSUT = new MarkedText(electedTextListArgument);
    }

    @Test
    public void test_SubSelections_ReturnNonNull_Always() throws Exception {
        Collection<String> subSelectionsReturned = markedTextSUT.subSelections();
        assertNotNull(subSelectionsReturned);
    }

    private void
    setupElectedTextList(){
        //define test data output



    }


    @Test
    public void
    test_SubSelectionsReturnsExpectedOutput_Simple
            () throws Exception {

        MarkedTextOracle oracle = new MarkedTextOracle();
        ElectedText input = oracle.getTestInput();
        markedTextSUT = new MarkedText(input);
        List<String> output = markedTextSUT.subSelections();

        System.out.println("//////////////////////////");
        System.out.println("## OUTPUT ################");
        System.out.println(output.toString());
        System.out.println();
        System.out.println("## EXPECTED OUTPUT #######");
        System.out.println(oracle.getTestExpectedOutput());
        System.out.println();
        System.out.println("## ORACLE STATE #########");
        oracle.printData();
        System.out.println("//////////////////////////");

        assertTrue("The oracle determined that the expected " +
                "output was not valid", oracle.validateResult(output));
    }
}
@@ -496,16 +496,86 @@
 unner;%0A%0A
+import java.text.StringCharacterIterator;%0Aimport java.util.ArrayList;%0A
 import j
@@ -903,16 +903,46 @@
 xtSUT;%0A%0A
+    MarkedTextOracle oracle;%0A%0A
     @Bef
@@ -988,32 +988,37 @@
 ption %7B%0A        
+this.
 markedTextSUT = 
@@ -1054,16 +1054,62 @@
 tMock);%0A
+        this.oracle = new MarkedTextOracle();%0A
     %7D%0A%0A 
@@ -1239,16 +1239,23 @@
 ion_When
+Elected
 TextArgu
@@ -1354,60 +1354,8 @@
 s);%0A
-        ElectedText electedTextListArgument = null;%0A
     
@@ -1393,31 +1393,12 @@
 ext(
-electedTextListArgument
+null
 );%0A 
@@ -1714,16 +1714,479 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void%0A    test_SubselectionReturnsNonNull_Normally%0A            () throws Exception %7B%0A        markedTextSUT = new MarkedText(oracle.getTestInput());%0A        assertNotNull(markedTextSUT.subSelections());%0A    %7D%0A%0A    @Test%0A    public void%0A    test_SubselectionsReturnsNonNull_WhenTextInputIsEmpty%0A            () throws Exception %7B%0A        List%3CTextElementClass%3E textElementClasses = new ArrayList();%0A        //oracle = new MarkedTextOracle()%0A    %7D
 %0A    @Te
@@ -2294,66 +2294,8 @@
  %7B%0A%0A
-        MarkedTextOracle oracle = new MarkedTextOracle();%0A
     

Add test