Search in sources :

Example 91 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.

the class ByIsoformPositionComparatorTest method assertExpectedIds.

private static void assertExpectedIds(List<Annotation> observedAnnots, long... expectedAnnotIds) {
    Assert.assertEquals(observedAnnots.size(), expectedAnnotIds.length);
    int i = 0;
    for (Annotation observedAnnot : observedAnnots) {
        Assert.assertEquals(expectedAnnotIds[i++], observedAnnot.getAnnotationId());
    }
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 92 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.

the class AnnotationFinderTest method shouldFindOneAnnotIfMultipleMatches.

@Test
public void shouldFindOneAnnotIfMultipleMatches() throws Exception {
    AnnotationFinder finder = new AnnotationFinder() {

        @Override
        protected Optional<AnnotationSimilarityPredicate> newPredicate(Annotation annotation) {
            return Optional.of(newApiCatCriteria());
        }
    };
    Annotation annot = new Annotation();
    annot.setAnnotationName("joe");
    annot.setAnnotationCategory(AnnotationCategory.VARIANT);
    Optional<Annotation> optAnnotation = finder.find(mockAnnotation(AnnotationCategory.VARIANT), Arrays.asList(annot, mockAnnotation(AnnotationCategory.VARIANT)));
    Assert.assertTrue(optAnnotation.isPresent());
    Assert.assertEquals(AnnotationCategory.VARIANT, optAnnotation.get().getAPICategory());
    Assert.assertEquals("joe", optAnnotation.get().getAnnotationName());
}
Also used : AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Annotation(org.nextprot.api.core.domain.annotation.Annotation) ObjectAnnotationSimilarityPredicateTest.mockAnnotation(org.nextprot.api.core.service.annotation.merge.impl.ObjectAnnotationSimilarityPredicateTest.mockAnnotation) Test(org.junit.Test)

Example 93 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.

the class ObjectAnnotationSimilarityPredicateTest method mockAnnotation.

public static Annotation mockAnnotation(AnnotationCategory cat) {
    Annotation annotation = Mockito.mock(Annotation.class);
    when(annotation.getAPICategory()).thenReturn(cat);
    return annotation;
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 94 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.

the class ObjectAnnotationSimilarityPredicateTest method shouldGetProperAnnotationObject.

@Test
public void shouldGetProperAnnotationObject() throws Exception {
    ObjectSimilarityPredicate predicate = new ObjectSimilarityPredicate(Annotation::getAPICategory);
    Annotation annot = mockAnnotation(AnnotationCategory.VARIANT);
    Assert.assertEquals(AnnotationCategory.VARIANT, predicate.getObject(annot));
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 95 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.

the class ObjectAnnotationSimilarityPredicateTest method shouldBeDifferentBasedOnBioObjectEquals.

@Test
public void shouldBeDifferentBasedOnBioObjectEquals() throws Exception {
    AnnotationSimilarityPredicate predicateBasedOnBioObjectEquals = new ObjectSimilarityPredicate(Annotation::getBioObject);
    Assert.assertFalse(predicateBasedOnBioObjectEquals.isSimilar(mockAnnotationWithBioObject("toto", BioObject.BioType.CHEMICAL), mockAnnotationWithBioObject("toto", BioObject.BioType.GROUP)));
}
Also used : AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Aggregations

Annotation (org.nextprot.api.core.domain.annotation.Annotation)120 Test (org.junit.Test)79 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)32 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)28 AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)22 ArrayList (java.util.ArrayList)19 Isoform (org.nextprot.api.core.domain.Isoform)17 Entry (org.nextprot.api.core.domain.Entry)9 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)7 BioObject (org.nextprot.api.core.domain.BioObject)7 PepXIsoformMatch (org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch)7 AnnotationProperty (org.nextprot.api.core.domain.annotation.AnnotationProperty)6 AnnotationSimilarityPredicate (org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate)6 Collectors (java.util.stream.Collectors)5 NextProtException (org.nextprot.api.commons.exception.NextProtException)5 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)5 Assert (org.junit.Assert)4 CvTerm (org.nextprot.api.core.domain.CvTerm)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 java.util (java.util)3