use of eu.europeana.corelib.solr.entity.ConceptImpl in project corelib by europeana.
the class MockFullBean method setConcepts.
private static void setConcepts(FullBeanImpl bean) {
List<ConceptImpl> concepts = new ArrayList<>();
ConceptImpl concept = new ConceptImpl();
concepts.add(concept);
concept.setRelated(new String[] { "http://dbpedia.org/resource/Category:Agriculture" });
concept.setExactMatch(new String[] { "http://bg.dbpedia.org/resource/Селско_стопанство", "http://ia.dbpedia.org/resource/Agricultura", "http://sl.dbpedia.org/resource/Kmetijstvo", "http://pnb.dbpedia.org/resource/وائی_بیجی", "http://el.dbpedia.org/resource/Γεωργία_(δραστηριότητα)" });
concept.setPrefLabel(new HashMap<>());
concept.getPrefLabel().put("no", new ArrayList<>());
concept.getPrefLabel().get("no").add(MockBeanConstants.CONCEPT_PREF_LABEL_1);
concept.getPrefLabel().put("de", new ArrayList<>());
concept.getPrefLabel().get("de").add(MockBeanConstants.CONCEPT_PREF_LABEL_2);
concept.setNote(new HashMap<>());
concept.getNote().put("no", new ArrayList<>());
concept.getNote().get("no").add(MockBeanConstants.CONCEPT_NOTE_1);
concept.getNote().put("de", new ArrayList<>());
concept.getNote().get("de").add(MockBeanConstants.CONCEPT_NOTE_2);
concept.setAbout(MockBeanConstants.DC_CREATOR_4);
bean.setConcepts(concepts);
}
use of eu.europeana.corelib.solr.entity.ConceptImpl in project metis-framework by europeana.
the class ConceptFieldInput method apply.
@Override
public ConceptImpl apply(Concept concept) {
ConceptImpl conceptMongo = new ConceptImpl();
conceptMongo.setAbout(concept.getAbout());
if (concept.getChoiceList() != null) {
for (Concept.Choice choice : concept.getChoiceList()) {
applyChoice(choice, conceptMongo);
}
}
return conceptMongo;
}
use of eu.europeana.corelib.solr.entity.ConceptImpl in project metis-framework by europeana.
the class FullBeanUpdaterTest method testUpdate.
@Test
void testUpdate() {
// Craete objects for execution
final FullBeanUpdater updater = new FullBeanUpdater(null);
@SuppressWarnings("unchecked") final MongoPropertyUpdater<FullBeanImpl> propertyUpdater = mock(MongoPropertyUpdater.class);
// Make the call
updater.update(propertyUpdater, null);
// Test all the values
testArrayPropertyUpdate(propertyUpdater, "title", FullBeanImpl::setTitle);
testArrayPropertyUpdate(propertyUpdater, "year", FullBeanImpl::setYear);
testArrayPropertyUpdate(propertyUpdater, "provider", FullBeanImpl::setProvider);
testArrayPropertyUpdate(propertyUpdater, "language", FullBeanImpl::setLanguage);
testArrayPropertyUpdate(propertyUpdater, "country", FullBeanImpl::setCountry);
testArrayPropertyUpdate(propertyUpdater, "europeanaCollectionName", FullBeanImpl::setEuropeanaCollectionName);
testObjectPropertyUpdate(propertyUpdater, "timestampCreated", FullBeanImpl::setTimestampCreated, new Date());
testObjectPropertyUpdate(propertyUpdater, "timestampUpdated", FullBeanImpl::setTimestampUpdated, new Date());
testObjectPropertyUpdate(propertyUpdater, "type", FullBeanImpl::setType, DocType.IMAGE.name());
testObjectPropertyUpdate(propertyUpdater, "europeanaCompleteness", FullBeanImpl::setEuropeanaCompleteness, 5);
this.<Place, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "places", FullBeanImpl::setPlaces, null, PlaceImpl::new);
this.<Agent, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "agents", FullBeanImpl::setAgents, null, AgentImpl::new);
this.<Timespan, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "timespans", FullBeanImpl::setTimespans, null, TimespanImpl::new);
this.<Concept, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "concepts", FullBeanImpl::setConcepts, null, ConceptImpl::new);
this.<ProvidedCHO, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "providedCHOs", FullBeanImpl::setProvidedCHOs, null, ProvidedCHOImpl::new);
this.<Aggregation, RootAboutWrapper>testReferencedEntitiesPropertyUpdate(propertyUpdater, "aggregations", FullBeanImpl::setAggregations, RootAboutWrapper.class, AggregationImpl::new);
this.<Organization, RootAboutWrapper>testReferencedEntitiesPropertyUpdate(propertyUpdater, "organizations", FullBeanImpl::setOrganizations, null, OrganizationImpl::new);
this.<EuropeanaAggregation, RootAboutWrapper>testReferencedEntityPropertyUpdate(propertyUpdater, "europeanaAggregation", FullBeanImpl::setEuropeanaAggregation, RootAboutWrapper.class, EuropeanaAggregationImpl::new);
this.<Proxy, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "proxies", FullBeanImpl::setProxies, null, ProxyImpl::new);
this.<Service, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "services", FullBeanImpl::setServices, null, ServiceImpl::new);
this.<License, Void>testReferencedEntitiesPropertyUpdate(propertyUpdater, "licenses", FullBeanImpl::setLicenses, null, LicenseImpl::new);
final FullBeanImpl fullBean = new FullBeanImpl();
fullBean.setQualityAnnotations(new ArrayList<>());
@SuppressWarnings("unchecked") final ArgumentCaptor<Function<FullBeanImpl, List<Object>>> getterCaptor = ArgumentCaptor.forClass(Function.class);
verify(propertyUpdater, times(1)).updateObjectList(eq("qualityAnnotations"), getterCaptor.capture());
assertSame(fullBean.getQualityAnnotations(), getterCaptor.getValue().apply(fullBean));
// And that should be it.
verifyNoMoreInteractions(propertyUpdater);
}
use of eu.europeana.corelib.solr.entity.ConceptImpl in project metis-framework by europeana.
the class ConceptFieldInputTest method testConcept.
@Test
void testConcept() {
// create concept from jibx bindings
Concept concept = new Concept();
concept.setAbout("test about");
ConceptImpl conceptImpl = new ConceptImpl();
conceptImpl.setAbout(concept.getAbout());
RecordDao mongoServerMock = mock(RecordDao.class);
Datastore datastoreMock = mock(Datastore.class);
@SuppressWarnings("unchecked") Query<ConceptImpl> queryMock = mock(Query.class);
when(mongoServerMock.getDatastore()).thenReturn(datastoreMock);
when(mongoServerMock.getDatastore()).thenReturn(datastoreMock);
when(datastoreMock.find(ConceptImpl.class)).thenReturn(queryMock);
when(datastoreMock.save(conceptImpl)).thenReturn(conceptImpl);
when(queryMock.filter(Filters.eq("about", concept.getAbout()))).thenReturn(queryMock);
Concept.Choice choice = new Concept.Choice();
AltLabel altLabel = new AltLabel();
Lang lang = new Lang();
lang.setLang("en");
altLabel.setLang(lang);
altLabel.setString("test alt label");
assertNotNull(altLabel);
choice.setAltLabel(altLabel);
choice.clearChoiceListSelect();
Note note = new Note();
note.setString("test note");
assertNotNull(note);
choice.setNote(note);
choice.clearChoiceListSelect();
PrefLabel prefLabel = new PrefLabel();
prefLabel.setLang(lang);
prefLabel.setString("test pred label");
assertNotNull(prefLabel);
choice.setPrefLabel(prefLabel);
choice.clearChoiceListSelect();
List<Concept.Choice> choiceList = new ArrayList<>();
choiceList.add(choice);
concept.setChoiceList(choiceList);
// store in mongo
ConceptImpl conceptMongo = new ConceptFieldInput().apply(concept);
mongoServerMock.getDatastore().save(conceptMongo);
assertEquals(concept.getAbout(), conceptMongo.getAbout());
for (Concept.Choice choice2 : concept.getChoiceList()) {
if (choice2.ifNote()) {
assertEquals(choice2.getNote().getString(), conceptMongo.getNote().values().iterator().next().get(0));
}
if (choice2.ifAltLabel()) {
assertTrue(conceptMongo.getAltLabel().containsKey(choice2.getAltLabel().getLang().getLang()));
assertEquals(choice2.getAltLabel().getString(), conceptMongo.getAltLabel().values().iterator().next().get(0));
}
if (choice2.ifPrefLabel()) {
assertTrue(conceptMongo.getPrefLabel().containsKey(choice2.getPrefLabel().getLang().getLang()));
assertEquals(choice2.getPrefLabel().getString(), conceptMongo.getPrefLabel().values().iterator().next().get(0));
}
}
}
Aggregations