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());
}
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)));
}
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)));
}
Aggregations