Search in sources :

Example 6 with AnnotationSimilarityPredicate

use of org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate 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 7 with AnnotationSimilarityPredicate

use of org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate 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)

Example 8 with AnnotationSimilarityPredicate

use of org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate in project nextprot-api by calipho-sib.

the class ObjectAnnotationSimilarityPredicateTest method shouldBeSimilarBasedOnBioObjectAccessionEquals.

@Test
public void shouldBeSimilarBasedOnBioObjectAccessionEquals() throws Exception {
    AnnotationSimilarityPredicate predicateBasedOnBioObjectAccessionEquals = new ObjectSimilarityPredicate(Annotation::getBioObject, (o1, o2) -> Objects.equals(((BioObject) o1).getAccession(), ((BioObject) o2).getAccession()));
    Assert.assertTrue(predicateBasedOnBioObjectAccessionEquals.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) BioObject(org.nextprot.api.core.domain.BioObject) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 Annotation (org.nextprot.api.core.domain.annotation.Annotation)8 AnnotationSimilarityPredicate (org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate)8 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 Assert (org.junit.Assert)2 Mockito (org.mockito.Mockito)2 BioObject (org.nextprot.api.core.domain.BioObject)1 ObjectAnnotationSimilarityPredicateTest.mockAnnotation (org.nextprot.api.core.service.annotation.merge.impl.ObjectAnnotationSimilarityPredicateTest.mockAnnotation)1