use of eu.europeana.metis.schema.jibx.DateOfBirth 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