Search in sources :

Example 1 with Related

use of eu.europeana.metis.schema.jibx.Related in project metis-framework by europeana.

the class DereferenceUtilsTest method testConceptListExtractedValues.

@Test
void testConceptListExtractedValues() {
    RDF rdf = new RDF();
    ProxyType proxy = new ProxyType();
    ArrayList<ProxyType> proxyList = new ArrayList<>();
    proxyList.add(proxy);
    rdf.setProxyList(proxyList);
    Concept concept = new Concept();
    concept.setAbout("http://dummy1.dum");
    Choice choice1 = new Choice();
    BroadMatch broadMatch = new BroadMatch();
    broadMatch.setResource("http://dummy2.dum");
    choice1.setBroadMatch(broadMatch);
    Choice choice2 = new Choice();
    CloseMatch closeMatch = new CloseMatch();
    closeMatch.setResource("http://dummy3.dum");
    choice2.setCloseMatch(closeMatch);
    Choice choice3 = new Choice();
    ExactMatch exactMatch = new ExactMatch();
    exactMatch.setResource("http://dummy4.dum");
    choice3.setExactMatch(exactMatch);
    Choice choice4 = new Choice();
    NarrowMatch narrowMatch = new NarrowMatch();
    narrowMatch.setResource("http://dummy5.dum");
    choice4.setNarrowMatch(narrowMatch);
    Choice choice5 = new Choice();
    RelatedMatch relatedMatch = new RelatedMatch();
    relatedMatch.setResource("http://dummy6.dum");
    choice5.setRelatedMatch(relatedMatch);
    Choice choice6 = new Choice();
    Related related = new Related();
    related.setResource("http://dummy7.dum");
    choice6.setRelated(related);
    Choice choice7 = new Choice();
    Broader broader = new Broader();
    broader.setResource("http://dummy8.dum");
    choice7.setBroader(broader);
    Choice choice8 = new Choice();
    Note note = new Note();
    note.setString("Note");
    choice8.setNote(note);
    ArrayList<Choice> choiceList = new ArrayList<>();
    choiceList.add(choice1);
    choiceList.add(choice2);
    choiceList.add(choice3);
    choiceList.add(choice4);
    choiceList.add(choice5);
    choiceList.add(choice6);
    choiceList.add(choice7);
    concept.setChoiceList(choiceList);
    ArrayList<Concept> conceptList = new ArrayList<>();
    conceptList.add(concept);
    rdf.setConceptList(conceptList);
    Set<String> result = DereferenceUtils.extractReferencesForDereferencing(rdf);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertTrue(result.contains("http://dummy8.dum"));
}
Also used : Concept(eu.europeana.metis.schema.jibx.Concept) RelatedMatch(eu.europeana.metis.schema.jibx.RelatedMatch) Broader(eu.europeana.metis.schema.jibx.Broader) Choice(eu.europeana.metis.schema.jibx.Concept.Choice) CloseMatch(eu.europeana.metis.schema.jibx.CloseMatch) ArrayList(java.util.ArrayList) ExactMatch(eu.europeana.metis.schema.jibx.ExactMatch) Related(eu.europeana.metis.schema.jibx.Related) BroadMatch(eu.europeana.metis.schema.jibx.BroadMatch) RDF(eu.europeana.metis.schema.jibx.RDF) Note(eu.europeana.metis.schema.jibx.Note) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) NarrowMatch(eu.europeana.metis.schema.jibx.NarrowMatch) Test(org.junit.jupiter.api.Test)

Example 2 with Related

use of eu.europeana.metis.schema.jibx.Related in project metis-framework by europeana.

the class ContextualClassesBreakdownClassifierTest method testEntityQualifiesForConcept.

@Test
void testEntityQualifiesForConcept() {
    // Create objects
    final ContextualClassesClassifier classifier = spy(new ContextualClassesClassifier());
    final Concept concept = new Concept();
    final PrefLabel prefLabel = new PrefLabel();
    final Note note = new Note();
    final Broader broader = new Broader();
    final Narrower narrower = new Narrower();
    final ExactMatch exactMatch = new ExactMatch();
    final CloseMatch closeMatch = new CloseMatch();
    final Related related = new Related();
    // Test empty concept
    concept.setChoiceList(null);
    assertFalse(classifier.entityQualifies(concept));
    concept.setChoiceList(new ArrayList<>());
    assertFalse(classifier.entityQualifies(concept));
    concept.getChoiceList().add(new Choice());
    assertFalse(classifier.entityQualifies(concept));
    // Set values
    concept.setChoiceList(IntStream.range(0, 7).mapToObj(index -> new Choice()).collect(Collectors.toList()));
    concept.getChoiceList().get(0).setPrefLabel(prefLabel);
    concept.getChoiceList().get(1).setNote(note);
    concept.getChoiceList().get(2).setBroader(broader);
    concept.getChoiceList().get(3).setNarrower(narrower);
    concept.getChoiceList().get(4).setExactMatch(exactMatch);
    concept.getChoiceList().get(5).setCloseMatch(closeMatch);
    concept.getChoiceList().get(6).setRelated(related);
    // Test prefLabel absent (and rest present)
    doReturn(false).when(classifier).hasProperty(prefLabel);
    doReturn(true).when(classifier).hasProperty(note);
    doReturn(true).when(classifier).hasProperty(broader);
    doReturn(true).when(classifier).hasProperty(narrower);
    doReturn(true).when(classifier).hasProperty(exactMatch);
    doReturn(true).when(classifier).hasProperty(closeMatch);
    doReturn(true).when(classifier).hasProperty(related);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel present (and rest absent)
    doReturn(true).when(classifier).hasProperty(prefLabel);
    doReturn(false).when(classifier).hasProperty(note);
    doReturn(false).when(classifier).hasProperty(broader);
    doReturn(false).when(classifier).hasProperty(narrower);
    doReturn(false).when(classifier).hasProperty(exactMatch);
    doReturn(false).when(classifier).hasProperty(closeMatch);
    doReturn(false).when(classifier).hasProperty(related);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and note present
    doReturn(true).when(classifier).hasProperty(note);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(note);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and broader present
    doReturn(true).when(classifier).hasProperty(broader);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(broader);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and narrower present
    doReturn(true).when(classifier).hasProperty(narrower);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(narrower);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and exactMatch present
    doReturn(true).when(classifier).hasProperty(exactMatch);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(exactMatch);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and closeMatch present
    doReturn(true).when(classifier).hasProperty(closeMatch);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(closeMatch);
    assertFalse(classifier.entityQualifies(concept));
    // Test prefLabel and related present
    doReturn(true).when(classifier).hasProperty(related);
    assertTrue(classifier.entityQualifies(concept));
    doReturn(false).when(classifier).hasProperty(related);
    assertFalse(classifier.entityQualifies(concept));
}
Also used : Concept(eu.europeana.metis.schema.jibx.Concept) ExactMatch(eu.europeana.metis.schema.jibx.ExactMatch) Broader(eu.europeana.metis.schema.jibx.Broader) Narrower(eu.europeana.metis.schema.jibx.Narrower) Related(eu.europeana.metis.schema.jibx.Related) Choice(eu.europeana.metis.schema.jibx.Concept.Choice) Note(eu.europeana.metis.schema.jibx.Note) CloseMatch(eu.europeana.metis.schema.jibx.CloseMatch) PrefLabel(eu.europeana.metis.schema.jibx.PrefLabel) Test(org.junit.jupiter.api.Test)

Aggregations

Broader (eu.europeana.metis.schema.jibx.Broader)2 CloseMatch (eu.europeana.metis.schema.jibx.CloseMatch)2 Concept (eu.europeana.metis.schema.jibx.Concept)2 Choice (eu.europeana.metis.schema.jibx.Concept.Choice)2 ExactMatch (eu.europeana.metis.schema.jibx.ExactMatch)2 Note (eu.europeana.metis.schema.jibx.Note)2 Related (eu.europeana.metis.schema.jibx.Related)2 Test (org.junit.jupiter.api.Test)2 BroadMatch (eu.europeana.metis.schema.jibx.BroadMatch)1 NarrowMatch (eu.europeana.metis.schema.jibx.NarrowMatch)1 Narrower (eu.europeana.metis.schema.jibx.Narrower)1 PrefLabel (eu.europeana.metis.schema.jibx.PrefLabel)1 ProxyType (eu.europeana.metis.schema.jibx.ProxyType)1 RDF (eu.europeana.metis.schema.jibx.RDF)1 RelatedMatch (eu.europeana.metis.schema.jibx.RelatedMatch)1 ArrayList (java.util.ArrayList)1