<commit_before>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 <NAME>
 * 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);
    }
}<commit_msg>Rename AnnotationCo_occurringTermsAggregator member variable to something more usable. Add tests for passing nulls to constructor.<commit_after>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 <NAME>
 * Date: 08/09/2016
 * Time: 13:59
 * Created with IntelliJ IDEA.
 */
@RunWith(MockitoJUnitRunner.class)
public class Co_occurringGoTermsFromAnnotationsTest {

    @Mock
    AnnotationCo_occurringTermsAggregator aggregator;

    @Mock
    Annotation annotation;

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

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

    @Test (expected = IllegalArgumentException.class)
    public void exceptionThrownIfNullAggregatorPassedToConstructor(){
        Predicate<Annotation> toBeProcessed = t -> true;
        new Co_occurringGoTermsFromAnnotations(null, toBeProcessed);
    }

    @Test (expected = IllegalArgumentException.class)
    public void exceptionThrownIfNullPredicatePassedToConstructor(){
        new Co_occurringGoTermsFromAnnotations(aggregator, null);
    }
}
{'fraction_non_alphanumeric': 0.07961783439490445, 'fraction_numerical': 0.006900212314225053, 'mean_word_length': 4.870716510903427, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7326737', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1115, 'n_words': 192}