Search in sources :

Example 1 with EnablingElementInventory

use of eu.europeana.indexing.tiers.metadata.EnablingElementsClassifier.EnablingElementInventory in project metis-framework by europeana.

the class EnablingElementsBreakdownClassifierTest method testPerformEnablingElementInventory.

@Test
void testPerformEnablingElementInventory() {
    // Create mocked objects
    final RdfWrapper entity = mock(RdfWrapper.class);
    final List<ProxyType> providerProxies = new ArrayList<>();
    doReturn(providerProxies).when(entity).getProviderProxies();
    final EnablingElementsClassifier classifier = spy(new EnablingElementsClassifier());
    final Map<String, Set<Class<? extends AboutType>>> contextualObjectMap = new HashMap<>();
    doReturn(contextualObjectMap).when(classifier).createContextualObjectMap(entity);
    // Set behavior of analyze result
    doReturn(Collections.emptySet()).when(classifier).analyzeForElement(any(), same(providerProxies), same(contextualObjectMap));
    doReturn(new HashSet<>(Arrays.asList(ContextualClassGroup.PERSONAL, ContextualClassGroup.CONCEPTUAL))).when(classifier).analyzeForElement(eq(EnablingElement.DCTERMS_ISSUED), same(providerProxies), same(contextualObjectMap));
    doReturn(Collections.singleton(ContextualClassGroup.PERSONAL)).when(classifier).analyzeForElement(eq(EnablingElement.DCTERMS_CREATED), same(providerProxies), same(contextualObjectMap));
    doReturn(Collections.singleton(ContextualClassGroup.PERSONAL)).when(classifier).analyzeForElement(eq(EnablingElement.EDM_HAS_MET), same(providerProxies), same(contextualObjectMap));
    doReturn(Collections.singleton(ContextualClassGroup.TEMPORAL)).when(classifier).analyzeForElement(eq(EnablingElement.DC_SUBJECT), same(providerProxies), same(contextualObjectMap));
    // Make the call and verify
    final EnablingElementInventory result = classifier.performEnablingElementInventory(entity);
    assertTrue(CollectionUtils.isEqualCollection(Set.of(ContextualClassGroup.PERSONAL, ContextualClassGroup.CONCEPTUAL, ContextualClassGroup.TEMPORAL), result.getGroups()));
    assertTrue(CollectionUtils.isEqualCollection(Set.of(EnablingElement.DC_SUBJECT, EnablingElement.DCTERMS_ISSUED, EnablingElement.DCTERMS_CREATED, EnablingElement.EDM_HAS_MET), result.getElements()));
}
Also used : HashSet(java.util.HashSet) EnumSet(java.util.EnumSet) Set(java.util.Set) RdfWrapper(eu.europeana.indexing.utils.RdfWrapper) HashMap(java.util.HashMap) EnablingElementInventory(eu.europeana.indexing.tiers.metadata.EnablingElementsClassifier.EnablingElementInventory) ArrayList(java.util.ArrayList) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) Test(org.junit.jupiter.api.Test)

Example 2 with EnablingElementInventory

use of eu.europeana.indexing.tiers.metadata.EnablingElementsClassifier.EnablingElementInventory in project metis-framework by europeana.

the class EnablingElementsBreakdownClassifierTest method testClassify.

@Test
void testClassify() {
    // Create mocked objects
    final RdfWrapper entity = mock(RdfWrapper.class);
    final EnablingElementsClassifier classifier = spy(new EnablingElementsClassifier());
    final EnablingElementInventory inventory = mock(EnablingElementInventory.class);
    doReturn(inventory).when(classifier).performEnablingElementInventory(entity);
    // Zero groups/elements
    doReturn(Collections.emptySet()).when(inventory).getElements();
    doReturn(Collections.emptySet()).when(inventory).getGroups();
    assertEquals(MetadataTier.T0, classifier.classifyBreakdown(entity).getMetadataTier());
    // One group, various element counts
    doReturn(Set.of(ContextualClassGroup.PERSONAL)).when(inventory).getGroups();
    doReturn(Set.of(EnablingElement.DC_TYPE)).when(inventory).getElements();
    assertEquals(MetadataTier.TA, classifier.classifyBreakdown(entity).getMetadataTier());
    doReturn(Set.of(EnablingElement.DC_TYPE, EnablingElement.DCTERMS_ISSUED)).when(inventory).getElements();
    assertEquals(MetadataTier.TA, classifier.classifyBreakdown(entity).getMetadataTier());
    doReturn(Set.of(EnablingElement.DC_TYPE, EnablingElement.DCTERMS_ISSUED, EnablingElement.DCTERMS_CREATED)).when(inventory).getElements();
    assertEquals(MetadataTier.TA, classifier.classifyBreakdown(entity).getMetadataTier());
    doReturn(Set.of(EnablingElement.DC_TYPE, EnablingElement.DCTERMS_ISSUED, EnablingElement.DCTERMS_CREATED, EnablingElement.EDM_HAS_MET)).when(inventory).getElements();
    assertEquals(MetadataTier.TA, classifier.classifyBreakdown(entity).getMetadataTier());
    // Two groups, various element counts
    doReturn(Set.of(ContextualClassGroup.PERSONAL, ContextualClassGroup.CONCEPTUAL)).when(inventory).getGroups();
    doReturn(Set.of(EnablingElement.DC_TYPE)).when(inventory).getElements();
    assertEquals(MetadataTier.TA, classifier.classifyBreakdown(entity).getMetadataTier());
    doReturn(Set.of(EnablingElement.DC_TYPE, EnablingElement.DCTERMS_ISSUED)).when(inventory).getElements();
    assertEquals(MetadataTier.TA, classifier.classifyBreakdown(entity).getMetadataTier());
    doReturn(Set.of(EnablingElement.DC_TYPE, EnablingElement.DCTERMS_ISSUED, EnablingElement.DCTERMS_CREATED)).when(inventory).getElements();
    assertEquals(MetadataTier.TB, classifier.classifyBreakdown(entity).getMetadataTier());
    doReturn(Set.of(EnablingElement.DC_TYPE, EnablingElement.DCTERMS_ISSUED, EnablingElement.DCTERMS_CREATED, EnablingElement.EDM_HAS_MET)).when(inventory).getElements();
    assertEquals(MetadataTier.TC, classifier.classifyBreakdown(entity).getMetadataTier());
}
Also used : RdfWrapper(eu.europeana.indexing.utils.RdfWrapper) EnablingElementInventory(eu.europeana.indexing.tiers.metadata.EnablingElementsClassifier.EnablingElementInventory) Test(org.junit.jupiter.api.Test)

Aggregations

EnablingElementInventory (eu.europeana.indexing.tiers.metadata.EnablingElementsClassifier.EnablingElementInventory)2 RdfWrapper (eu.europeana.indexing.utils.RdfWrapper)2 Test (org.junit.jupiter.api.Test)2 ProxyType (eu.europeana.metis.schema.jibx.ProxyType)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1