Search in sources :

Example 1 with DateOfBirth

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));
}
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)1 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 PlaceOfBirth (eu.europeana.metis.schema.jibx.PlaceOfBirth)1 PlaceOfDeath (eu.europeana.metis.schema.jibx.PlaceOfDeath)1 PrefLabel (eu.europeana.metis.schema.jibx.PrefLabel)1 ProfessionOrOccupation (eu.europeana.metis.schema.jibx.ProfessionOrOccupation)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1