Search in sources :

Example 1 with ProfessionOrOccupation

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

the class DereferenceUtilsTest method testAgentListExtractedValues.

@Test
void testAgentListExtractedValues() {
    RDF rdf = new RDF();
    ProxyType proxy = new ProxyType();
    ArrayList<ProxyType> proxyList = new ArrayList<>();
    proxyList.add(proxy);
    rdf.setProxyList(proxyList);
    AgentType agent = new AgentType();
    agent.setAbout("http://dummy1.dum");
    HasMet hasMet = new HasMet();
    hasMet.setResource("http://dummy2.dum");
    ArrayList<HasMet> hasMetList = new ArrayList<>();
    hasMetList.add(hasMet);
    agent.setHasMetList(hasMetList);
    IsRelatedTo isRelatedTo = new IsRelatedTo();
    ResourceOrLiteralType.Resource resource3 = new ResourceOrLiteralType.Resource();
    resource3.setResource("http://dummy3.dum");
    isRelatedTo.setResource(resource3);
    ArrayList<IsRelatedTo> isRelatedToList = new ArrayList<>();
    isRelatedToList.add(isRelatedTo);
    agent.setIsRelatedToList(isRelatedToList);
    IsPartOf isPartOf = new IsPartOf();
    ResourceOrLiteralType.Resource resource4 = new ResourceOrLiteralType.Resource();
    resource4.setResource("http://dummy4.dum");
    isPartOf.setResource(resource4);
    ArrayList<IsPartOf> isPartOfList = new ArrayList<>();
    isPartOfList.add(isPartOf);
    agent.setIsPartOfList(isPartOfList);
    ProfessionOrOccupation professionOrOccupation = new ProfessionOrOccupation();
    ResourceOrLiteralType.Resource resource5 = new ResourceOrLiteralType.Resource();
    resource5.setResource("http://dummy5.dum");
    professionOrOccupation.setResource(resource5);
    agent.setProfessionOrOccupationList(Collections.singletonList(professionOrOccupation));
    Note note = new Note();
    note.setString("Note");
    ArrayList<Note> noteList = new ArrayList<>();
    noteList.add(note);
    agent.setNoteList(noteList);
    ArrayList<AgentType> agentList = new ArrayList<>();
    agentList.add(agent);
    rdf.setAgentList(agentList);
    Set<String> result = DereferenceUtils.extractReferencesForDereferencing(rdf);
    assertNotNull(result);
    assertEquals(2, result.size());
    assertTrue(result.contains("http://dummy4.dum"));
    assertTrue(result.contains("http://dummy5.dum"));
}
Also used : IsPartOf(eu.europeana.metis.schema.jibx.IsPartOf) ArrayList(java.util.ArrayList) Resource(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource) HasMet(eu.europeana.metis.schema.jibx.HasMet) IsRelatedTo(eu.europeana.metis.schema.jibx.IsRelatedTo) Resource(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource) AgentType(eu.europeana.metis.schema.jibx.AgentType) RDF(eu.europeana.metis.schema.jibx.RDF) Note(eu.europeana.metis.schema.jibx.Note) ProfessionOrOccupation(eu.europeana.metis.schema.jibx.ProfessionOrOccupation) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 2 with ProfessionOrOccupation

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

the class ContextualClassesBreakdownClassifierTest method testEntityQualifiesForAgent.

@Test
void testEntityQualifiesForAgent() {
    // Create objects
    final ContextualClassesClassifier classifier = spy(new ContextualClassesClassifier());
    final AgentType agent = new AgentType();
    final List<PrefLabel> prefLabelList = new ArrayList<>();
    final Begin begin = new Begin();
    final DateOfBirth dateOfBirth = new DateOfBirth();
    final List<PlaceOfBirth> placeOfBirthList = new ArrayList<>();
    final End end = new End();
    final DateOfDeath dateOfDeath = new DateOfDeath();
    final List<PlaceOfDeath> placeOfDeathList = new ArrayList<>();
    final List<ProfessionOrOccupation> professionOrOccupationList = new ArrayList<>();
    // Test empty agent
    assertFalse(classifier.entityQualifies(agent));
    // Set values
    agent.setPrefLabelList(prefLabelList);
    agent.setBegin(begin);
    agent.setDateOfBirth(dateOfBirth);
    agent.setPlaceOfBirthList(placeOfBirthList);
    agent.setEnd(end);
    agent.setDateOfDeath(dateOfDeath);
    agent.setPlaceOfDeathList(placeOfDeathList);
    agent.setProfessionOrOccupationList(professionOrOccupationList);
    // Test prefLabel absent (and rest present)
    doReturn(false).when(classifier).hasLiteralProperty(prefLabelList);
    doReturn(true).when(classifier).hasProperty(begin);
    doReturn(true).when(classifier).hasProperty(dateOfBirth);
    doReturn(true).when(classifier).hasResourceOrLiteralProperty(placeOfBirthList);
    doReturn(true).when(classifier).hasProperty(end);
    doReturn(true).when(classifier).hasProperty(dateOfDeath);
    doReturn(true).when(classifier).hasResourceOrLiteralProperty(placeOfDeathList);
    doReturn(true).when(classifier).hasResourceOrLiteralProperty(professionOrOccupationList);
    assertFalse(classifier.entityQualifies(agent));
    // Test prefLabel present (and rest absent)
    doReturn(true).when(classifier).hasLiteralProperty(prefLabelList);
    doReturn(false).when(classifier).hasProperty(begin);
    doReturn(false).when(classifier).hasProperty(dateOfBirth);
    doReturn(false).when(classifier).hasResourceOrLiteralProperty(placeOfBirthList);
    doReturn(false).when(classifier).hasProperty(end);
    doReturn(false).when(classifier).hasProperty(dateOfDeath);
    doReturn(false).when(classifier).hasResourceOrLiteralProperty(placeOfDeathList);
    doReturn(false).when(classifier).hasResourceOrLiteralProperty(professionOrOccupationList);
    assertFalse(classifier.entityQualifies(agent));
    // Test prefLabel and begin present
    doReturn(true).when(classifier).hasProperty(begin);
    assertTrue(classifier.entityQualifies(agent));
    doReturn(false).when(classifier).hasProperty(begin);
    assertFalse(classifier.entityQualifies(agent));
    // Test prefLabel and dateOfBirth present
    doReturn(true).when(classifier).hasProperty(dateOfBirth);
    assertTrue(classifier.entityQualifies(agent));
    doReturn(false).when(classifier).hasProperty(dateOfBirth);
    assertFalse(classifier.entityQualifies(agent));
    // Test prefLabel and placeOfBirth present
    doReturn(true).when(classifier).hasResourceOrLiteralProperty(placeOfBirthList);
    assertTrue(classifier.entityQualifies(agent));
    doReturn(false).when(classifier).hasResourceOrLiteralProperty(placeOfBirthList);
    assertFalse(classifier.entityQualifies(agent));
    // Test prefLabel and end present
    doReturn(true).when(classifier).hasProperty(end);
    assertTrue(classifier.entityQualifies(agent));
    doReturn(false).when(classifier).hasProperty(end);
    assertFalse(classifier.entityQualifies(agent));
    // Test prefLabel and dateOfDeath present
    doReturn(true).when(classifier).hasProperty(dateOfDeath);
    assertTrue(classifier.entityQualifies(agent));
    doReturn(false).when(classifier).hasProperty(dateOfDeath);
    assertFalse(classifier.entityQualifies(agent));
    // Test prefLabel and placeOfDeath present
    doReturn(true).when(classifier).hasResourceOrLiteralProperty(placeOfDeathList);
    assertTrue(classifier.entityQualifies(agent));
    doReturn(false).when(classifier).hasResourceOrLiteralProperty(placeOfDeathList);
    assertFalse(classifier.entityQualifies(agent));
    // Test prefLabel and professionOrOccupation present
    doReturn(true).when(classifier).hasResourceOrLiteralProperty(professionOrOccupationList);
    assertTrue(classifier.entityQualifies(agent));
}
Also used : DateOfBirth(eu.europeana.metis.schema.jibx.DateOfBirth) ArrayList(java.util.ArrayList) PlaceOfBirth(eu.europeana.metis.schema.jibx.PlaceOfBirth) AgentType(eu.europeana.metis.schema.jibx.AgentType) Begin(eu.europeana.metis.schema.jibx.Begin) PrefLabel(eu.europeana.metis.schema.jibx.PrefLabel) ProfessionOrOccupation(eu.europeana.metis.schema.jibx.ProfessionOrOccupation) End(eu.europeana.metis.schema.jibx.End) DateOfDeath(eu.europeana.metis.schema.jibx.DateOfDeath) PlaceOfDeath(eu.europeana.metis.schema.jibx.PlaceOfDeath) Test(org.junit.jupiter.api.Test)

Aggregations

AgentType (eu.europeana.metis.schema.jibx.AgentType)2 ProfessionOrOccupation (eu.europeana.metis.schema.jibx.ProfessionOrOccupation)2 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 Begin (eu.europeana.metis.schema.jibx.Begin)1 DateOfBirth (eu.europeana.metis.schema.jibx.DateOfBirth)1 DateOfDeath (eu.europeana.metis.schema.jibx.DateOfDeath)1 End (eu.europeana.metis.schema.jibx.End)1 HasMet (eu.europeana.metis.schema.jibx.HasMet)1 IsPartOf (eu.europeana.metis.schema.jibx.IsPartOf)1 IsRelatedTo (eu.europeana.metis.schema.jibx.IsRelatedTo)1 Note (eu.europeana.metis.schema.jibx.Note)1 PlaceOfBirth (eu.europeana.metis.schema.jibx.PlaceOfBirth)1 PlaceOfDeath (eu.europeana.metis.schema.jibx.PlaceOfDeath)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 ResourceOrLiteralType (eu.europeana.metis.schema.jibx.ResourceOrLiteralType)1 Resource (eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource)1