<commit_before>package uk.ac.ebi.quickgo.annotation.validation.service;

import uk.ac.ebi.quickgo.annotation.validation.model.ValidationEntities;
import uk.ac.ebi.quickgo.annotation.validation.model.ValidationEntity;

import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

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

/**
 * Test the
 * @author <NAME>
 * Date: 09/11/2016
 * Time: 17:27
 * Created with IntelliJ IDEA.
 */
@RunWith(MockitoJUnitRunner.class)
public class ValidationEntityCheckerTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();
    private ValidationEntityChecker checker;

    @Before
    public void setup() throws Exception {
        ValidationEntity validationEntity = mock(ValidationEntity.class);
        List<ValidationEntity> entities = Collections.singletonList(validationEntity);
        ValidationEntities validationEntities = mock(ValidationEntities.class);

        checker = new ValidationEntityChecker(validationEntities);
        when(validationEntities.get("interpro")).thenReturn(entities);
        when(validationEntity.test("IPR123456")).thenReturn(true);
        when(validationEntity.test("ZZZ123456")).thenReturn(false);
    }

    @Test
    public void verificationPasses() {
        assertThat(checker.isValid("InterPro:IPR123456"), is(true));
    }

    @Test
    public void idWithDatabasePassesVerification() {
        assertThat(checker.isValid("Zebra:ZZZ123456"), is(false));
    }

    @Test
    public void idWithoutDatabasePassesVerification() {
        assertThat(checker.isValid("xxx"), is(true));
    }

    @Test
    public void idWithKnownDatabaseButNoIdPartFailsVerification() {
        assertThat(checker.isValid("InterPro:"), is(false));
    }

    @Test
    public void idWithUnknownDatabaseButNoIdPartFailsVerification() {
        assertThat(checker.isValid("Dell:"), is(false));
    }

    @Test
    public void idWithUnknownDatabaseAndIdPartFailsVerification() {
        assertThat(checker.isValid("Dell:12345"), is(false));
    }

    @Test
    public void idContainsOnlyColonIsNotVerified() {
        assertThat(checker.isValid(":"), is(false));
    }

    @Test
    public void nullIdFailsVerification() {
        assertThat(checker.isValid(null), is(false));
    }
}
<commit_msg>Add generic type for ValidationEntities.<commit_after>package uk.ac.ebi.quickgo.annotation.validation.service;

import uk.ac.ebi.quickgo.annotation.validation.model.ValidationEntities;
import uk.ac.ebi.quickgo.annotation.validation.model.ValidationEntity;

import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

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

/**
 * Test the
 * @author <NAME>
 * Date: 09/11/2016
 * Time: 17:27
 * Created with IntelliJ IDEA.
 */
@RunWith(MockitoJUnitRunner.class)
public class ValidationEntityCheckerTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();
    private ValidationEntityChecker checker;

    @Before
    public void setup() throws Exception {
        ValidationEntity validationEntity = mock(ValidationEntity.class);
        List<ValidationEntity> entities = Collections.singletonList(validationEntity);
        ValidationEntities<ValidationEntity> validationEntities = mock(ValidationEntities.class);

        checker = new ValidationEntityChecker(validationEntities);
        when(validationEntities.get("interpro")).thenReturn(entities);
        when(validationEntity.test("IPR123456")).thenReturn(true);
        when(validationEntity.test("ZZZ123456")).thenReturn(false);
    }

    @Test
    public void verificationPasses() {
        assertThat(checker.isValid("InterPro:IPR123456"), is(true));
    }

    @Test
    public void idWithDatabasePassesVerification() {
        assertThat(checker.isValid("Zebra:ZZZ123456"), is(false));
    }

    @Test
    public void idWithoutDatabasePassesVerification() {
        assertThat(checker.isValid("xxx"), is(true));
    }

    @Test
    public void idWithKnownDatabaseButNoIdPartFailsVerification() {
        assertThat(checker.isValid("InterPro:"), is(false));
    }

    @Test
    public void idWithUnknownDatabaseButNoIdPartFailsVerification() {
        assertThat(checker.isValid("Dell:"), is(false));
    }

    @Test
    public void idWithUnknownDatabaseAndIdPartFailsVerification() {
        assertThat(checker.isValid("Dell:12345"), is(false));
    }

    @Test
    public void idContainsOnlyColonIsNotVerified() {
        assertThat(checker.isValid(":"), is(false));
    }

    @Test
    public void nullIdFailsVerification() {
        assertThat(checker.isValid(null), is(false));
    }
}

{'fraction_non_alphanumeric': 0.11279363230440691, 'fraction_numerical': 0.015919238982721802, 'mean_word_length': 4.235772357723577, 'pattern_counts': {'":': 2, '<': 8, '<?xml version=': 0, '>': 8, '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': '2283220', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1510, 'n_words': 252}