Search in sources :

Example 1 with Note

use of eu.europeana.metis.schema.jibx.Note in project metis-framework by europeana.

the class PlaceFieldInputTest method testPlace.

@Test
void testPlace() {
    PlaceImpl placeImpl = new PlaceImpl();
    placeImpl.setAbout("test about");
    RecordDao mongoServerMock = mock(RecordDao.class);
    Datastore datastoreMock = mock(Datastore.class);
    @SuppressWarnings("unchecked") Query<PlaceImpl> queryMock = mock(Query.class);
    when(mongoServerMock.getDatastore()).thenReturn(datastoreMock);
    when(datastoreMock.find(PlaceImpl.class)).thenReturn(queryMock);
    when(datastoreMock.save(placeImpl)).thenReturn(placeImpl);
    when(queryMock.filter(Filters.eq("about", placeImpl.getAbout()))).thenReturn(queryMock);
    PlaceType place = new PlaceType();
    place.setAbout("test about");
    List<AltLabel> altLabelList = new ArrayList<>();
    AltLabel altLabel = new AltLabel();
    Lang lang = new Lang();
    lang.setLang("en");
    altLabel.setLang(lang);
    altLabel.setString("test alt label");
    assertNotNull(altLabel);
    altLabelList.add(altLabel);
    place.setAltLabelList(altLabelList);
    List<Note> noteList = new ArrayList<>();
    Note note = new Note();
    note.setString("test note");
    assertNotNull(note);
    noteList.add(note);
    place.setNoteList(noteList);
    List<PrefLabel> prefLabelList = new ArrayList<>();
    PrefLabel prefLabel = new PrefLabel();
    prefLabel.setLang(lang);
    prefLabel.setString("test pred label");
    assertNotNull(prefLabel);
    prefLabelList.add(prefLabel);
    place.setPrefLabelList(prefLabelList);
    List<IsPartOf> isPartOfList = new ArrayList<>();
    IsPartOf isPartOf = new IsPartOf();
    isPartOf.setString("test resource");
    isPartOfList.add(isPartOf);
    place.setIsPartOfList(isPartOfList);
    Lat posLat = new Lat();
    posLat.setLat(Float.valueOf("1.0"));
    place.setLat(posLat);
    _Long posLong = new _Long();
    posLong.setLong(Float.valueOf("1.0"));
    place.setLong(posLong);
    // create mongo place
    PlaceImpl placeMongo = new PlaceFieldInput().apply(place);
    mongoServerMock.getDatastore().save(placeMongo);
    assertEquals(place.getAbout(), placeMongo.getAbout());
    assertEquals(place.getNoteList().get(0).getString(), placeMongo.getNote().values().iterator().next().get(0));
    assertTrue(placeMongo.getAltLabel().containsKey(place.getAltLabelList().get(0).getLang().getLang()));
    assertEquals(place.getAltLabelList().get(0).getString(), placeMongo.getAltLabel().values().iterator().next().get(0));
    assertEquals(place.getPrefLabelList().get(0).getString(), placeMongo.getPrefLabel().values().iterator().next().get(0));
    assertEquals(place.getIsPartOfList().get(0).getString(), placeMongo.getIsPartOf().values().iterator().next().get(0));
    assertEquals(Float.toString(place.getLat().getLat()), Float.toString(placeMongo.getLatitude()));
    assertEquals(Float.toString(place.getLong().getLong()), Float.toString(placeMongo.getLongitude()));
}
Also used : PlaceType(eu.europeana.metis.schema.jibx.PlaceType) eu.europeana.metis.schema.jibx._Long(eu.europeana.metis.schema.jibx._Long) IsPartOf(eu.europeana.metis.schema.jibx.IsPartOf) ArrayList(java.util.ArrayList) Lang(eu.europeana.metis.schema.jibx.LiteralType.Lang) RecordDao(eu.europeana.metis.mongo.dao.RecordDao) Datastore(dev.morphia.Datastore) AltLabel(eu.europeana.metis.schema.jibx.AltLabel) Note(eu.europeana.metis.schema.jibx.Note) PlaceImpl(eu.europeana.corelib.solr.entity.PlaceImpl) PrefLabel(eu.europeana.metis.schema.jibx.PrefLabel) Lat(eu.europeana.metis.schema.jibx.Lat) Test(org.junit.jupiter.api.Test)

Example 2 with Note

use of eu.europeana.metis.schema.jibx.Note in project metis-framework by europeana.

the class TimespanFieldInputTest method testTimespan.

@Test
void testTimespan() {
    TimeSpanType timespan = new TimeSpanType();
    timespan.setAbout("test about");
    List<AltLabel> altLabelList = new ArrayList<>();
    AltLabel altLabel = new AltLabel();
    Lang lang = new Lang();
    lang.setLang("en");
    altLabel.setLang(lang);
    altLabel.setString("test alt label");
    assertNotNull(altLabel);
    altLabelList.add(altLabel);
    timespan.setAltLabelList(altLabelList);
    Begin begin = new Begin();
    begin.setString("test begin");
    timespan.setBegin(begin);
    End end = new End();
    end.setString("test end");
    timespan.setEnd(end);
    List<Note> noteList = new ArrayList<>();
    Note note = new Note();
    note.setString("test note");
    assertNotNull(note);
    noteList.add(note);
    timespan.setNoteList(noteList);
    List<PrefLabel> prefLabelList = new ArrayList<>();
    PrefLabel prefLabel = new PrefLabel();
    prefLabel.setLang(lang);
    prefLabel.setString("test pred label");
    assertNotNull(prefLabel);
    prefLabelList.add(prefLabel);
    timespan.setPrefLabelList(prefLabelList);
    List<HiddenLabel> hiddelLabelList = new ArrayList<>();
    HiddenLabel hiddenLabel = new HiddenLabel();
    hiddenLabel.setLang(lang);
    hiddenLabel.setString("test hidden label");
    assertNotNull(hiddenLabel);
    hiddelLabelList.add(hiddenLabel);
    timespan.setHiddenLabelList(hiddelLabelList);
    List<IsPartOf> isPartOfList = new ArrayList<>();
    IsPartOf isPartOf = new IsPartOf();
    eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource isPartOfResource = new eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource();
    isPartOfResource.setResource("test resource");
    isPartOf.setResource(isPartOfResource);
    isPartOfList.add(isPartOf);
    timespan.setIsPartOfList(isPartOfList);
    TimespanImpl timespanImpl = new TimespanImpl();
    timespanImpl.setAbout(timespan.getAbout());
    // create mongo
    RecordDao mongoServerMock = mock(RecordDao.class);
    Datastore datastoreMock = mock(Datastore.class);
    @SuppressWarnings("unchecked") Query<TimespanImpl> queryMock = mock(Query.class);
    when(mongoServerMock.getDatastore()).thenReturn(datastoreMock);
    when(datastoreMock.find(TimespanImpl.class)).thenReturn(queryMock);
    when(datastoreMock.save(timespanImpl)).thenReturn(timespanImpl);
    when(queryMock.filter(Filters.eq("about", timespan.getAbout()))).thenReturn(queryMock);
    TimespanImpl timespanMongo = new TimespanFieldInput().apply(timespan);
    mongoServerMock.getDatastore().save(timespanMongo);
    assertEquals(timespan.getAbout(), timespanMongo.getAbout());
    assertEquals(timespan.getBegin().getString(), timespanMongo.getBegin().values().iterator().next().get(0));
    assertEquals(timespan.getEnd().getString(), timespanMongo.getEnd().values().iterator().next().get(0));
    assertEquals(timespan.getNoteList().get(0).getString(), timespanMongo.getNote().values().iterator().next().get(0));
    assertTrue(timespanMongo.getAltLabel().containsKey(timespan.getAltLabelList().get(0).getLang().getLang()));
    assertTrue(timespanMongo.getPrefLabel().containsKey(timespan.getPrefLabelList().get(0).getLang().getLang()));
    assertTrue(timespanMongo.getHiddenLabel().containsKey(timespan.getHiddenLabelList().get(0).getLang().getLang()));
    assertEquals(timespan.getAltLabelList().get(0).getString(), timespanMongo.getAltLabel().values().iterator().next().get(0));
    assertEquals(timespan.getPrefLabelList().get(0).getString(), timespanMongo.getPrefLabel().values().iterator().next().get(0));
    assertEquals(timespan.getIsPartOfList().get(0).getResource().getResource(), timespanMongo.getIsPartOf().values().iterator().next().get(0));
}
Also used : HiddenLabel(eu.europeana.metis.schema.jibx.HiddenLabel) TimespanImpl(eu.europeana.corelib.solr.entity.TimespanImpl) ArrayList(java.util.ArrayList) RecordDao(eu.europeana.metis.mongo.dao.RecordDao) Begin(eu.europeana.metis.schema.jibx.Begin) PrefLabel(eu.europeana.metis.schema.jibx.PrefLabel) TimeSpanType(eu.europeana.metis.schema.jibx.TimeSpanType) IsPartOf(eu.europeana.metis.schema.jibx.IsPartOf) Lang(eu.europeana.metis.schema.jibx.LiteralType.Lang) Datastore(dev.morphia.Datastore) AltLabel(eu.europeana.metis.schema.jibx.AltLabel) Note(eu.europeana.metis.schema.jibx.Note) End(eu.europeana.metis.schema.jibx.End) Test(org.junit.jupiter.api.Test)

Example 3 with Note

use of eu.europeana.metis.schema.jibx.Note 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"));
}
Also used : Concept(eu.europeana.metis.schema.jibx.Concept) RelatedMatch(eu.europeana.metis.schema.jibx.RelatedMatch) Broader(eu.europeana.metis.schema.jibx.Broader) Choice(eu.europeana.metis.schema.jibx.Concept.Choice) CloseMatch(eu.europeana.metis.schema.jibx.CloseMatch) ArrayList(java.util.ArrayList) ExactMatch(eu.europeana.metis.schema.jibx.ExactMatch) Related(eu.europeana.metis.schema.jibx.Related) BroadMatch(eu.europeana.metis.schema.jibx.BroadMatch) RDF(eu.europeana.metis.schema.jibx.RDF) Note(eu.europeana.metis.schema.jibx.Note) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) NarrowMatch(eu.europeana.metis.schema.jibx.NarrowMatch) Test(org.junit.jupiter.api.Test)

Example 4 with Note

use of eu.europeana.metis.schema.jibx.Note in project metis-framework by europeana.

the class DereferenceUtilsTest method testPlaceListExtractedValues.

@Test
void testPlaceListExtractedValues() {
    RDF rdf = new RDF();
    ProxyType proxy = new ProxyType();
    ArrayList<ProxyType> proxyList = new ArrayList<>();
    proxyList.add(proxy);
    rdf.setProxyList(proxyList);
    PlaceType place = new PlaceType();
    place.setAbout("http://dummy1.dum");
    IsPartOf isPartOf = new IsPartOf();
    ResourceOrLiteralType.Resource resource3 = new ResourceOrLiteralType.Resource();
    resource3.setResource("http://dummy2.dum");
    isPartOf.setResource(resource3);
    ArrayList<IsPartOf> isPartOfList = new ArrayList<>();
    isPartOfList.add(isPartOf);
    place.setIsPartOfList(isPartOfList);
    SameAs sameAs = new SameAs();
    sameAs.setResource("http://dummy3.dum");
    ArrayList<SameAs> sameAsList = new ArrayList<>();
    sameAsList.add(sameAs);
    place.setSameAList(sameAsList);
    HasPart hasPart = new HasPart();
    Resource resource4 = new Resource();
    resource4.setResource("http://dummy4.dum");
    hasPart.setResource(resource4);
    ArrayList<HasPart> hasPartList = new ArrayList<>();
    hasPartList.add(hasPart);
    place.setHasPartList(hasPartList);
    // Should be rejected
    Note note = new Note();
    note.setString("Note");
    ArrayList<Note> noteList = new ArrayList<>();
    noteList.add(note);
    place.setNoteList(noteList);
    ArrayList<PlaceType> placeList = new ArrayList<>();
    placeList.add(place);
    rdf.setPlaceList(placeList);
    Set<String> result = DereferenceUtils.extractReferencesForDereferencing(rdf);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertTrue(result.contains("http://dummy2.dum"));
}
Also used : PlaceType(eu.europeana.metis.schema.jibx.PlaceType) IsPartOf(eu.europeana.metis.schema.jibx.IsPartOf) ArrayList(java.util.ArrayList) Resource(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource) Resource(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource) HasPart(eu.europeana.metis.schema.jibx.HasPart) SameAs(eu.europeana.metis.schema.jibx.SameAs) RDF(eu.europeana.metis.schema.jibx.RDF) Note(eu.europeana.metis.schema.jibx.Note) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Example 5 with Note

use of eu.europeana.metis.schema.jibx.Note in project metis-framework by europeana.

the class DereferenceUtilsTest method testTimeSpanListExtractedValues.

@Test
void testTimeSpanListExtractedValues() {
    RDF rdf = new RDF();
    ProxyType proxy = new ProxyType();
    ArrayList<ProxyType> proxyList = new ArrayList<>();
    proxyList.add(proxy);
    rdf.setProxyList(proxyList);
    TimeSpanType timeSpan = new TimeSpanType();
    timeSpan.setAbout("http://dummy1.dum");
    HasPart hasPart = new HasPart();
    Resource resource3 = new Resource();
    resource3.setResource("http://dummy2.dum");
    hasPart.setResource(resource3);
    ArrayList<HasPart> hasPartList = new ArrayList<>();
    hasPartList.add(hasPart);
    timeSpan.setHasPartList(hasPartList);
    IsPartOf isPartOf = new IsPartOf();
    ResourceOrLiteralType.Resource resource4 = new ResourceOrLiteralType.Resource();
    resource4.setResource("http://dummy4.dum");
    isPartOf.setResource(resource4);
    ArrayList<IsPartOf> isPartOfList = new ArrayList<>();
    isPartOfList.add(isPartOf);
    timeSpan.setIsPartOfList(isPartOfList);
    SameAs sameAs = new SameAs();
    sameAs.setResource("http://dummy5.dum");
    ArrayList<SameAs> sameAsList = new ArrayList<>();
    sameAsList.add(sameAs);
    timeSpan.setSameAList(sameAsList);
    // Should be rejected
    Note note = new Note();
    note.setString("Note");
    ArrayList<Note> noteList = new ArrayList<>();
    noteList.add(note);
    timeSpan.setNoteList(noteList);
    ArrayList<TimeSpanType> timeSpanList = new ArrayList<>();
    timeSpanList.add(timeSpan);
    rdf.setTimeSpanList(timeSpanList);
    Set<String> result = DereferenceUtils.extractReferencesForDereferencing(rdf);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertTrue(result.contains("http://dummy4.dum"));
}
Also used : TimeSpanType(eu.europeana.metis.schema.jibx.TimeSpanType) IsPartOf(eu.europeana.metis.schema.jibx.IsPartOf) ArrayList(java.util.ArrayList) Resource(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource) HasPart(eu.europeana.metis.schema.jibx.HasPart) Resource(eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource) SameAs(eu.europeana.metis.schema.jibx.SameAs) RDF(eu.europeana.metis.schema.jibx.RDF) Note(eu.europeana.metis.schema.jibx.Note) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) ResourceOrLiteralType(eu.europeana.metis.schema.jibx.ResourceOrLiteralType) Test(org.junit.jupiter.api.Test)

Aggregations

Note (eu.europeana.metis.schema.jibx.Note)9 Test (org.junit.jupiter.api.Test)9 ArrayList (java.util.ArrayList)8 IsPartOf (eu.europeana.metis.schema.jibx.IsPartOf)5 PrefLabel (eu.europeana.metis.schema.jibx.PrefLabel)5 Datastore (dev.morphia.Datastore)4 RecordDao (eu.europeana.metis.mongo.dao.RecordDao)4 AltLabel (eu.europeana.metis.schema.jibx.AltLabel)4 Lang (eu.europeana.metis.schema.jibx.LiteralType.Lang)4 ProxyType (eu.europeana.metis.schema.jibx.ProxyType)4 RDF (eu.europeana.metis.schema.jibx.RDF)4 Concept (eu.europeana.metis.schema.jibx.Concept)3 ResourceOrLiteralType (eu.europeana.metis.schema.jibx.ResourceOrLiteralType)3 Resource (eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource)3 AgentType (eu.europeana.metis.schema.jibx.AgentType)2 Begin (eu.europeana.metis.schema.jibx.Begin)2 Broader (eu.europeana.metis.schema.jibx.Broader)2 CloseMatch (eu.europeana.metis.schema.jibx.CloseMatch)2 Choice (eu.europeana.metis.schema.jibx.Concept.Choice)2 End (eu.europeana.metis.schema.jibx.End)2