package uk.ac.ebi.quickgo.index.annotation.coterms;

import uk.ac.ebi.quickgo.index.annotation.Annotation;

import java.util.function.Predicate;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

/**
 * @author Tony Wardell
 * Date: 08/09/2016
 * Time: 13:59
 * Created with IntelliJ IDEA.
 */
@RunWith(MockitoJUnitRunner.class)
public class Co_occurringGoTermsFromAnnotationsTest {

    @Mock
    AnnotationCo_occurringTermsAggregator annotationCoOccurringTermsAggregator;

    @Mock
    Annotation annotation;

    @Test
    public void testAnnotationAddedToCoStatsIfPredicateAllows() throws Exception{
        Predicate<Annotation> toBeProcessed = t -> true;
        Co_occurringGoTermsFromAnnotations coOccurringGoTermsFromAnnotations = new Co_occurringGoTermsFromAnnotations
                (annotationCoOccurringTermsAggregator, toBeProcessed);
        coOccurringGoTermsFromAnnotations.process(annotation);
        verify(annotationCoOccurringTermsAggregator,times(1)).addRowToMatrix(annotation);
    }

    @Test
    public void testAnnotationNotAddedToCoStatsIfPredicateForbids() throws Exception{
        Predicate<Annotation> toBeProcessed = t -> false;
        Co_occurringGoTermsFromAnnotations coOccurringGoTermsFromAnnotations = new Co_occurringGoTermsFromAnnotations
                (annotationCoOccurringTermsAggregator, toBeProcessed);
        coOccurringGoTermsFromAnnotations.process(annotation);
        verify(annotationCoOccurringTermsAggregator,never()).addRowToMatrix(annotation);
    }
}

@@ -637,34 +637,8 @@
 or a
-nnotationCoOccurringTermsA
 ggre
@@ -701,37 +701,33 @@
     public void 
-testA
+a
 nnotationAddedTo
@@ -877,38 +877,12 @@
 s co
-OccurringGoTermsFromAnnotation
+Term
 s = 
@@ -923,53 +923,10 @@
 ions
-%0A                (annotationCoOccurringTermsA
+(a
 ggre
@@ -962,38 +962,12 @@
   co
-OccurringGoTermsFromAnnotation
+Term
 s.pr
@@ -1005,34 +1005,8 @@
 fy(a
-nnotationCoOccurringTermsA
 ggre
@@ -1086,13 +1086,9 @@
 oid 
-testA
+a
 nnot
@@ -1251,17 +1251,32 @@
 tions co
-O
+Terms = new Co_o
 ccurring
@@ -1301,39 +1301,62 @@
 ions
- = new Co_occurringGoTermsFromA
+(aggregator, toBeProcessed);%0A        coTerms.process(a
 nnot
@@ -1360,17 +1360,18 @@
 notation
-s
+);
 %0A       
@@ -1375,54 +1375,223 @@
     
+verify(aggregator,never()).addRowToMatrix(annotation);%0A
     
+%7D%0A%0A
     
-(annotationCoOccurringTermsAggregator,
+@Test (expected = IllegalArgumentException.class)%0A    public void exceptionThrownIfNullAggregatorPassedToConstructor()%7B%0A        Predicate%3CAnnotation%3E
  toB
@@ -1592,33 +1592,44 @@
 n%3E toBeProcessed
-)
+ = t -%3E true
 ;%0A        coOccu
@@ -1626,11 +1626,16 @@
     
-coO
+new Co_o
 ccur
@@ -1664,66 +1664,185 @@
 ions
-.process(annotation);%0A        verify(annotationCoO
+(null, toBeProcessed);%0A    %7D%0A%0A    @Test (expected = IllegalArgumentException.class)%0A    public void exceptionThrownIfNullPredicatePassedToConstructor()%7B%0A        new Co_o
 ccurring
 Term
@@ -1841,58 +1841,47 @@
 ring
+Go
 Terms
-Aggregator,never()).addRowToMatrix(annotation
+FromAnnotations(aggregator, null
 );%0A 

Rename AnnotationCo_occurringTermsAggregator member variable to something more usable. Add tests for passing nulls to constructor.