Search in sources :

Example 96 with Annotation

use of org.nextprot.api.core.domain.annotation.Annotation 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)

Example 97 with Annotation

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

the class ObjectAnnotationSimilarityPredicateTest method mockAnnotationWithBioObject.

public static Annotation mockAnnotationWithBioObject(String accession, BioObject.BioType type) {
    Annotation annotation = Mockito.mock(Annotation.class);
    BioObject bioObject = Mockito.mock(BioObject.class);
    when(bioObject.getAccession()).thenReturn(accession);
    when(bioObject.getBioType()).thenReturn(type);
    when(annotation.getBioObject()).thenReturn(bioObject);
    return annotation;
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) BioObject(org.nextprot.api.core.domain.BioObject)

Example 98 with Annotation

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

the class AnnotationSimilarityPredicateTest method mockAnnotation.

private static Annotation mockAnnotation(String accession, String database) {
    Annotation annot = Mockito.mock(Annotation.class);
    BioObject bo = Mockito.mock(BioObject.class);
    Mockito.when(bo.getAccession()).thenReturn(accession);
    Mockito.when(bo.getDatabase()).thenReturn(database);
    Mockito.when(annot.getBioObject()).thenReturn(bo);
    return annot;
}
Also used : Annotation(org.nextprot.api.core.domain.annotation.Annotation) BioObject(org.nextprot.api.core.domain.BioObject)

Example 99 with Annotation

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

the class AnnotationTest method testTwoNegative.

@Test
public void testTwoNegative() {
    Annotation a = new Annotation();
    List<AnnotationEvidence> evidences = new ArrayList<>();
    evidences.add(buildEvidence("negative"));
    evidences.add(buildEvidence("negative"));
    a.setEvidences(evidences);
    Assert.assertTrue(a.isExpressionLevelDetected().isPresent());
    Assert.assertTrue(!a.isExpressionLevelDetected().get());
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) ArrayList(java.util.ArrayList) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Test(org.junit.Test)

Example 100 with Annotation

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

the class AnnotationTest method testOneNegative.

@Test
public void testOneNegative() {
    Annotation a = new Annotation();
    List<AnnotationEvidence> evidences = new ArrayList<>();
    evidences.add(buildEvidence("negative"));
    a.setEvidences(evidences);
    Assert.assertTrue(a.isExpressionLevelDetected().isPresent());
    Assert.assertTrue(!a.isExpressionLevelDetected().get());
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) ArrayList(java.util.ArrayList) 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