Search in sources :

Example 1 with AnnotationSimilarityPredicate

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

the class ObjectAnnotationSimilarityPredicateTest method shouldBeSimilar.

@Test
public void shouldBeSimilar() throws Exception {
    AnnotationSimilarityPredicate predicate = new ObjectSimilarityPredicate(Annotation::getAPICategory);
    Assert.assertTrue(predicate.isSimilar(mockAnnotation(AnnotationCategory.VARIANT), mockAnnotation(AnnotationCategory.VARIANT)));
}
Also used : AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 2 with AnnotationSimilarityPredicate

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

the class ObjectAnnotationSimilarityPredicateTest method sameObjectShouldBeSimilar.

@Test
public void sameObjectShouldBeSimilar() throws Exception {
    AnnotationSimilarityPredicate predicate = new ObjectSimilarityPredicate(Annotation::getAPICategory);
    Annotation annot = mockAnnotation(AnnotationCategory.VARIANT);
    Assert.assertTrue(predicate.isSimilar(annot, annot));
}
Also used : AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 3 with AnnotationSimilarityPredicate

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

the class ObjectAnnotationSimilarityPredicateTest method shouldBeDifferent.

@Test
public void shouldBeDifferent() throws Exception {
    AnnotationSimilarityPredicate predicate = new ObjectSimilarityPredicate(Annotation::getAPICategory);
    Assert.assertFalse(predicate.isSimilar(mockAnnotation(AnnotationCategory.VARIANT), mockAnnotation(AnnotationCategory.MUTAGENESIS)));
}
Also used : AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 4 with AnnotationSimilarityPredicate

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

the class AnnotationSimilarityPredicateChainTest method shouldNotBeSimilarWhenAtLeastOnePredicateFalse.

@Test
public void shouldNotBeSimilarWhenAtLeastOnePredicateFalse() throws Exception {
    AnnotationSimilarityPredicate predicate = new SimilarityPredicateChain(Arrays.asList((annotation1, annotation2) -> true, (annotation1, annotation2) -> false, (annotation1, annotation2) -> true));
    Assert.assertFalse(predicate.isSimilar(Mockito.mock(Annotation.class), Mockito.mock(Annotation.class)));
}
Also used : Mockito(org.mockito.Mockito) Arrays(java.util.Arrays) Annotation(org.nextprot.api.core.domain.annotation.Annotation) AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Test(org.junit.Test) Assert(org.junit.Assert) Collections(java.util.Collections) AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Test(org.junit.Test)

Example 5 with AnnotationSimilarityPredicate

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

the class AnnotationSimilarityPredicateChainTest method shouldBeSimilarWhenAllPredicateTrue.

@Test
public void shouldBeSimilarWhenAllPredicateTrue() throws Exception {
    AnnotationSimilarityPredicate predicate = new SimilarityPredicateChain(Arrays.asList((annotation1, annotation2) -> true, (annotation1, annotation2) -> true, (annotation1, annotation2) -> true));
    Assert.assertTrue(predicate.isSimilar(Mockito.mock(Annotation.class), Mockito.mock(Annotation.class)));
}
Also used : Mockito(org.mockito.Mockito) Arrays(java.util.Arrays) Annotation(org.nextprot.api.core.domain.annotation.Annotation) AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) Test(org.junit.Test) Assert(org.junit.Assert) Collections(java.util.Collections) AnnotationSimilarityPredicate(org.nextprot.api.core.service.annotation.merge.AnnotationSimilarityPredicate) 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