package com.grayben.riskExtractor.htmlScorer;

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

import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.*;

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

    ScoredTextElement scoredTextElementSUT;

    Map<String, Integer> scoresMapArgument;

    String textElementArgument;

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

    @Before
    public void setUp() throws Exception {
        scoresMapArgument = new HashMap<>();
        textElementArgument = "foo";
        scoredTextElementSUT = new ScoredTextElement(textElementArgument, scoresMapArgument);
    }

    @After
    public void tearDown() throws Exception {

    }

    @Test
    public void
    test_InitThrowsNullPointerException_WhenTextElementArgumentIsNull
            () throws Exception {
        thrown.expect(NullPointerException.class);

        new ScoredTextElement(null, scoresMapArgument);
    }

    @Test
    public void
    test_InitThrowsNullPointerException_WhenScoresMapIsNull
            () throws Exception {
        thrown.expect(NullPointerException.class);

        new ScoredTextElement(textElementArgument, null);
    }

    @Test
    public void
    test_InitThrowsIllegalArgumentException_WhenTextArgumentIsEmpty
            () throws Exception {
        fail("Test not implemented");
    }

    @Test
    public void
    test_InitThrowsIllegalArgumentException_WhenTextArgumentIsWhitespaceOnly
            () throws Exception {
        fail("Test not implemented");
    }

    @Test
    public void
    test_InitThrowsIllegalArgumentException_WhenScoresIsEmpty
            () throws Exception {
        fail("Test not implemented");
    }

    @Test
    public void test_GetTextElement_IsNotNull_Always
            () throws Exception {
        String textElementReturned = scoredTextElementSUT.getTextElement();

        assertNotNull(textElementReturned);
    }

    @Test
    public void test_GetScores_IsNotNull_Always
            () throws Exception {
        Map<String, Integer> scoresReturned = scoredTextElementSUT.getScores();

        assertNotNull(scoresReturned);
    }

    @Test
    public void testGetTextElement_ReturnsMockedScores_Always() throws Exception {
        Map scoresReturned = scoredTextElementSUT.getScores();

        assertEquals(scoresMapArgument, scoresReturned);
    }

    @Test
    public void testGetTextElement_ReturnsMockedTextElement_Always() throws Exception {
        String textElementReturned;
        textElementReturned = scoredTextElementSUT.getTextElement();

        assertEquals(textElementArgument, textElementReturned);
    }
}
@@ -680,16 +680,69 @@
 ap%3C%3E();%0A
+        scoresMapArgument.put(%22awesomeness%22, 9001);%0A%0A
         
@@ -1558,35 +1558,107 @@
     
-fail(%22Test not implemented%22
+thrown.expect(IllegalArgumentException.class);%0A%0A        new ScoredTextElement(%22%22, scoresMapArgument
 );%0A 
@@ -1812,35 +1812,114 @@
     
-fail(%22Test not imple
+thrown.expect(IllegalArgumentException.class);%0A%0A        new ScoredTextElement(%22   %5Cn%5Ct%22, scoresMapArgu
 ment
-ed%22
 );%0A 
@@ -2058,35 +2058,122 @@
     
-fail(%22Test not implemented%22
+thrown.expect(IllegalArgumentException.class);%0A%0A        new ScoredTextElement(textElementArgument, new HashMap%3C%3E()
 );%0A 

Implement tests