package uk.ac.ebi.quickgo.annotation.service.statistics;

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

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;

/**
 * @author Tony Wardell
 * Date: 03/01/2018
 * Time: 15:46
 * Created with IntelliJ IDEA.
 */
public class RequiredStatisticsProviderTest {

    // the configured stats limits used in this test
    private StatisticsTypeConfigurer standard;
    private StatisticsTypeConfigurer download;

    @Before
    public void setup() {
        standard = new StatisticsTypeConfigurer(new HashMap<>());
        download = new StatisticsTypeConfigurer(new HashMap<>());
    }

    @Test(expected = IllegalArgumentException.class)
    public void statisticsTypeConfigurerForStandardUseCannotBeNull() {
        new RequiredStatisticsProvider(null, download);
    }

    @Test(expected = IllegalArgumentException.class)
    public void statisticsTypeConfigurerForDownloadUseCannotBeNull() {
        new RequiredStatisticsProvider(standard, null);
    }

    @Test
    public void requiredStatisticsAreBuiltWithTheCorrectLimits() {
        RequiredStatisticsProvider provider = new RequiredStatisticsProvider(standard, download);

        List<RequiredStatistic> requiredStatistics = provider.getStandardUsage();
        assertThat(requiredStatistics.get(0).getTypes(), hasSize(6));

        requiredStatistics = provider.getDownloadUsage();
        assertThat(requiredStatistics.get(0).getTypes(), hasSize(6));

        requiredStatistics = provider.getStandardUsageWithGeneProductFiltering();
        assertThat(requiredStatistics.get(0).getTypes(), hasSize(7));

        requiredStatistics = provider.getDownloadUsageWithGeneProductFiltering();
        assertThat(requiredStatistics.get(0).getTypes(), hasSize(7));
    }
}

@@ -55,34 +55,8 @@
 s;%0A%0A
-import java.util.HashMap;%0A
 impo
@@ -91,22 +91,20 @@
 g.junit.
-Before
+Test
 ;%0Aimport
@@ -108,26 +108,28 @@
 ort org.
-junit.Test
+mockito.Mock
 ;%0A%0Aimpor
@@ -398,56 +398,13 @@
     
-// the configured stats limits used in this test
+@Mock
 %0A   
@@ -447,24 +447,34 @@
 andard;%0A    
+@Mock%0A    
 private Stat
@@ -507,185 +507,8 @@
 oad;
-%0A%0A    @Before%0A    public void setup() %7B%0A        standard = new StatisticsTypeConfigurer(new HashMap%3C%3E());%0A        download = new StatisticsTypeConfigurer(new HashMap%3C%3E());%0A    %7D
 %0A%0A  

Replace concrete configuration classes with mocks, because StatisticsTypeConfigurer does it's own checking and we want to make sure this is happening in the class being tested.