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