package uk.ac.ebi.quickgo.annotation.validation.model;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.mockito.Mockito.*;

/**
 * @author Tony Wardell
 * Date: 23/11/2016
 * Time: 11:37
 * Created with IntelliJ IDEA.
 */
public class ValidationEntitiesImplTest {

    private static final String INTERPRO = "INTERPRO";
    private ValidationEntities validationEntities;
    private ValidationEntity mockEntity;

    @Before
    public void setup(){
        ValidationEntitiesAggregator aggregator = new ValidationEntitiesAggregator();
        Map<String, List<ValidationEntity>> mappedEntities = new HashMap<>();
        mappedEntities.put("interpro", Arrays.asList(mockEntity,mockEntity));
        aggregator.mappedEntities = mappedEntities;

        validationEntities = new ValidationEntitiesImpl(aggregator);
        mockEntity = mock(ValidationEntity.class);
        when(mockEntity.keyValue()).thenReturn(INTERPRO);
    }

    @Test(expected = IllegalArgumentException.class)
    public void failsConstructionIfConstructorArgumentIsNull(){
        new ValidationEntitiesImpl(null);
    }


    @Test
    public void checkTwoSuccessfulElements(){
        assertThat(validationEntities.get(INTERPRO.toLowerCase()), hasSize(equalTo(2)));
    }

}

@@ -85,120 +85,93 @@
 ort 
-java.util.HashMap;%0Aimport java.util.Li
+org.junit.Before;%0Aimport org.junit.Te
 st;%0A
+%0A
 import 
-java.util.Map;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A
+static org.hamcrest.CoreMatchers.is;
 %0Aimp
@@ -678,303 +678,8 @@
 ()%7B%0A
-        ValidationEntitiesAggregator aggregator = new ValidationEntitiesAggregator();%0A        Map%3CString, List%3CValidationEntity%3E%3E mappedEntities = new HashMap%3C%3E();%0A        mappedEntities.put(%22interpro%22, Arrays.asList(mockEntity,mockEntity));%0A        aggregator.mappedEntities = mappedEntities;%0A%0A
     
@@ -734,18 +734,8 @@
 mpl(
-aggregator
 );%0A 
@@ -862,156 +862,129 @@
 Test
-(expected = IllegalArgumentException.class)%0A    public void failsConstructionIfConstructorArgumentIsNull()%7B%0A        new ValidationEntitiesImpl
+%0A    public void nothingReturnedIfNotWrittenTo()%7B%0A        assertThat(validationEntities.get(INTERPRO), is(equalTo
 (null)
+))
 ;%0A  
@@ -1057,86 +1057,316 @@
     
-assertThat(validationEntities.get(INTERPRO.toLowerCase()), hasSize(equalTo(2))
+validationEntities.addEntities( Arrays.asList(mockEntity,mockEntity));%0A        assertThat(validationEntities.get(INTERPRO.toLowerCase()), hasSize(equalTo(2)));%0A    %7D%0A%0A    @Test(expected = IllegalArgumentException.class)%0A    public void addingNullThrowsException()%7B%0A        validationEntities.addEntities(null
 );%0A 

Add test for null.