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