use of eu.europeana.metis.schema.jibx.Concept.Choice in project metis-framework by europeana.
the class DereferenceUtilsTest method testConceptListExtractedValues.
@Test
void testConceptListExtractedValues() {
RDF rdf = new RDF();
ProxyType proxy = new ProxyType();
ArrayList<ProxyType> proxyList = new ArrayList<>();
proxyList.add(proxy);
rdf.setProxyList(proxyList);
Concept concept = new Concept();
concept.setAbout("http://dummy1.dum");
Choice choice1 = new Choice();
BroadMatch broadMatch = new BroadMatch();
broadMatch.setResource("http://dummy2.dum");
choice1.setBroadMatch(broadMatch);
Choice choice2 = new Choice();
CloseMatch closeMatch = new CloseMatch();
closeMatch.setResource("http://dummy3.dum");
choice2.setCloseMatch(closeMatch);
Choice choice3 = new Choice();
ExactMatch exactMatch = new ExactMatch();
exactMatch.setResource("http://dummy4.dum");
choice3.setExactMatch(exactMatch);
Choice choice4 = new Choice();
NarrowMatch narrowMatch = new NarrowMatch();
narrowMatch.setResource("http://dummy5.dum");
choice4.setNarrowMatch(narrowMatch);
Choice choice5 = new Choice();
RelatedMatch relatedMatch = new RelatedMatch();
relatedMatch.setResource("http://dummy6.dum");
choice5.setRelatedMatch(relatedMatch);
Choice choice6 = new Choice();
Related related = new Related();
related.setResource("http://dummy7.dum");
choice6.setRelated(related);
Choice choice7 = new Choice();
Broader broader = new Broader();
broader.setResource("http://dummy8.dum");
choice7.setBroader(broader);
Choice choice8 = new Choice();
Note note = new Note();
note.setString("Note");
choice8.setNote(note);
ArrayList<Choice> choiceList = new ArrayList<>();
choiceList.add(choice1);
choiceList.add(choice2);
choiceList.add(choice3);
choiceList.add(choice4);
choiceList.add(choice5);
choiceList.add(choice6);
choiceList.add(choice7);
concept.setChoiceList(choiceList);
ArrayList<Concept> conceptList = new ArrayList<>();
conceptList.add(concept);
rdf.setConceptList(conceptList);
Set<String> result = DereferenceUtils.extractReferencesForDereferencing(rdf);
assertNotNull(result);
assertEquals(1, result.size());
assertTrue(result.contains("http://dummy8.dum"));
}
use of eu.europeana.metis.schema.jibx.Concept.Choice in project metis-framework by europeana.
the class ItemExtractorUtilsTest method testToChoices.
@Test
void testToChoices() {
List<Choice> choices = new ArrayList<>();
List<AltLabel> altLabels = new ArrayList<>();
AltLabel label1 = new AltLabel();
AltLabel label2 = new AltLabel();
AltLabel label3 = new AltLabel();
Lang lang1 = new Lang();
lang1.setLang("lang1");
Lang lang2 = new Lang();
lang2.setLang("lang2");
Lang lang3 = new Lang();
lang3.setLang("lang3");
label1.setString("value1");
label1.setLang(lang1);
label2.setString("value2");
label1.setLang(lang2);
label3.setString("value3");
label1.setLang(lang3);
altLabels.add(label1);
altLabels.add(label3);
altLabels.add(label3);
ItemExtractorUtils.toChoices(altLabels, Choice::setAltLabel, choices);
assertTrue(choices.size() > 0);
for (AltLabel label : altLabels) {
List<Choice> result = choices.stream().filter(x -> x.getAltLabel().equals(label)).collect(Collectors.toList());
assertTrue(result.size() > 0);
}
}
use of eu.europeana.metis.schema.jibx.Concept.Choice in project metis-framework by europeana.
the class ItemExtractorUtils method toChoices.
static <T> void toChoices(List<T> inputList, BiConsumer<Choice, T> propertySetter, List<Choice> destination) {
for (T input : inputList) {
final Choice choice = new Choice();
propertySetter.accept(choice, input);
destination.add(choice);
}
}
use of eu.europeana.metis.schema.jibx.Concept.Choice in project metis-framework by europeana.
the class ContextualClassesBreakdownClassifierTest method testEntityQualifiesForConcept.
@Test
void testEntityQualifiesForConcept() {
// Create objects
final ContextualClassesClassifier classifier = spy(new ContextualClassesClassifier());
final Concept concept = new Concept();
final PrefLabel prefLabel = new PrefLabel();
final Note note = new Note();
final Broader broader = new Broader();
final Narrower narrower = new Narrower();
final ExactMatch exactMatch = new ExactMatch();
final CloseMatch closeMatch = new CloseMatch();
final Related related = new Related();
// Test empty concept
concept.setChoiceList(null);
assertFalse(classifier.entityQualifies(concept));
concept.setChoiceList(new ArrayList<>());
assertFalse(classifier.entityQualifies(concept));
concept.getChoiceList().add(new Choice());
assertFalse(classifier.entityQualifies(concept));
// Set values
concept.setChoiceList(IntStream.range(0, 7).mapToObj(index -> new Choice()).collect(Collectors.toList()));
concept.getChoiceList().get(0).setPrefLabel(prefLabel);
concept.getChoiceList().get(1).setNote(note);
concept.getChoiceList().get(2).setBroader(broader);
concept.getChoiceList().get(3).setNarrower(narrower);
concept.getChoiceList().get(4).setExactMatch(exactMatch);
concept.getChoiceList().get(5).setCloseMatch(closeMatch);
concept.getChoiceList().get(6).setRelated(related);
// Test prefLabel absent (and rest present)
doReturn(false).when(classifier).hasProperty(prefLabel);
doReturn(true).when(classifier).hasProperty(note);
doReturn(true).when(classifier).hasProperty(broader);
doReturn(true).when(classifier).hasProperty(narrower);
doReturn(true).when(classifier).hasProperty(exactMatch);
doReturn(true).when(classifier).hasProperty(closeMatch);
doReturn(true).when(classifier).hasProperty(related);
assertFalse(classifier.entityQualifies(concept));
// Test prefLabel present (and rest absent)
doReturn(true).when(classifier).hasProperty(prefLabel);
doReturn(false).when(classifier).hasProperty(note);
doReturn(false).when(classifier).hasProperty(broader);
doReturn(false).when(classifier).hasProperty(narrower);
doReturn(false).when(classifier).hasProperty(exactMatch);
doReturn(false).when(classifier).hasProperty(closeMatch);
doReturn(false).when(classifier).hasProperty(related);
assertFalse(classifier.entityQualifies(concept));
// Test prefLabel and note present
doReturn(true).when(classifier).hasProperty(note);
assertTrue(classifier.entityQualifies(concept));
doReturn(false).when(classifier).hasProperty(note);
assertFalse(classifier.entityQualifies(concept));
// Test prefLabel and broader present
doReturn(true).when(classifier).hasProperty(broader);
assertTrue(classifier.entityQualifies(concept));
doReturn(false).when(classifier).hasProperty(broader);
assertFalse(classifier.entityQualifies(concept));
// Test prefLabel and narrower present
doReturn(true).when(classifier).hasProperty(narrower);
assertTrue(classifier.entityQualifies(concept));
doReturn(false).when(classifier).hasProperty(narrower);
assertFalse(classifier.entityQualifies(concept));
// Test prefLabel and exactMatch present
doReturn(true).when(classifier).hasProperty(exactMatch);
assertTrue(classifier.entityQualifies(concept));
doReturn(false).when(classifier).hasProperty(exactMatch);
assertFalse(classifier.entityQualifies(concept));
// Test prefLabel and closeMatch present
doReturn(true).when(classifier).hasProperty(closeMatch);
assertTrue(classifier.entityQualifies(concept));
doReturn(false).when(classifier).hasProperty(closeMatch);
assertFalse(classifier.entityQualifies(concept));
// Test prefLabel and related present
doReturn(true).when(classifier).hasProperty(related);
assertTrue(classifier.entityQualifies(concept));
doReturn(false).when(classifier).hasProperty(related);
assertFalse(classifier.entityQualifies(concept));
}
Aggregations