Search in sources :

Example 1 with EuropeanaAggregationType

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

the class RdfWrapperTest method testGetEuropeanaAggregation.

@Test
void testGetEuropeanaAggregation() {
    // Create entities
    final EuropeanaAggregationType entity1 = mock(EuropeanaAggregationType.class);
    final EuropeanaAggregationType entity2 = mock(EuropeanaAggregationType.class);
    // Test rdf that returns a real list
    final RDF rdf = mock(RDF.class);
    when(rdf.getEuropeanaAggregationList()).thenReturn(Arrays.asList(entity1, entity2));
    assertEquals(entity1, new RdfWrapper(rdf).getEuropeanaAggregation().get());
    // Test rdf that returns null
    when(rdf.getEuropeanaAggregationList()).thenReturn(null);
    assertFalse(new RdfWrapper(rdf).getEuropeanaAggregation().isPresent());
}
Also used : RDF(eu.europeana.metis.schema.jibx.RDF) EuropeanaAggregationType(eu.europeana.metis.schema.jibx.EuropeanaAggregationType) Test(org.junit.jupiter.api.Test)

Example 2 with EuropeanaAggregationType

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

the class MetisRecordParserTest method testSetAdditionalData.

@Test
public void testSetAdditionalData() throws Exception {
    String xml = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("sample_completeness.rdf"), "UTF-8");
    RDF rdf = RdfConversionUtils.convertStringToRdf(xml);
    EnrichmentUtils.setAdditionalData(rdf);
    EuropeanaAggregationType europeanaAggregationType = rdf.getEuropeanaAggregationList().stream().findAny().orElse(null);
    assertEquals("6", europeanaAggregationType.getCompleteness().getString());
}
Also used : RDF(eu.europeana.metis.schema.jibx.RDF) EuropeanaAggregationType(eu.europeana.metis.schema.jibx.EuropeanaAggregationType) Test(org.junit.jupiter.api.Test)

Example 3 with EuropeanaAggregationType

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

the class EnrichmentUtilsTest method testSetAdditionalDataEmptyProxies.

@Test
void testSetAdditionalDataEmptyProxies() {
    RDF newRdf = new RDF();
    RDF toCompare = new RDF();
    ProxyType emptyEuropeanaProxy = new ProxyType();
    emptyEuropeanaProxy.setEuropeanaProxy(new EuropeanaProxy());
    emptyEuropeanaProxy.getEuropeanaProxy().setEuropeanaProxy(true);
    ProxyType emptyProviderProxy = new ProxyType();
    EuropeanaAggregationType emptyAggregation = new EuropeanaAggregationType();
    List<ProxyType> proxyList = List.of(emptyEuropeanaProxy, emptyProviderProxy);
    newRdf.setEuropeanaAggregationList(Collections.singletonList(emptyAggregation));
    newRdf.setProxyList(proxyList);
    toCompare.setEuropeanaAggregationList(Collections.singletonList(emptyAggregation));
    toCompare.setProxyList(proxyList);
    EnrichmentUtils.setAdditionalData(newRdf);
    assertArrayEquals(toCompare.getProxyList().toArray(), newRdf.getProxyList().toArray());
    assertEquals(toCompare.getEuropeanaAggregationList().get(0), newRdf.getEuropeanaAggregationList().get(0));
}
Also used : RDF(eu.europeana.metis.schema.jibx.RDF) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) EuropeanaAggregationType(eu.europeana.metis.schema.jibx.EuropeanaAggregationType) EuropeanaProxy(eu.europeana.metis.schema.jibx.EuropeanaProxy) Test(org.junit.jupiter.api.Test)

Example 4 with EuropeanaAggregationType

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

the class EnrichmentUtilsTest method testSetAdditionalDataCompletenessMoreThanZero.

@Test
void testSetAdditionalDataCompletenessMoreThanZero() {
    Aggregation aggregation = spy(new Aggregation());
    Choice dateChoice = new Choice();
    Date date = new Date();
    Choice titleChoice = new Choice();
    Title title = new Title();
    date.setString("1990");
    dateChoice.setDate(date);
    title.setString("The Sudbury Neutrino Observatory: Observation of Flavor Change for Solar Neutrinos");
    titleChoice.setTitle(title);
    ArrayList<Choice> choices = new ArrayList<>();
    choices.add(dateChoice);
    choices.add(titleChoice);
    PROXY_PROVIDER.setChoiceList(choices);
    ArrayList<ProxyType> proxyList = new ArrayList<>();
    proxyList.add(PROXY_EUROPEANA);
    proxyList.add(PROXY_PROVIDER);
    TEST_RDF.setProxyList(proxyList);
    _Object object = new _Object();
    object.setResource("/260/_kmo_av_sid_45006");
    doReturn(object).when(aggregation).getObject();
    doReturn(Collections.singletonList(aggregation)).when(TEST_RDF).getAggregationList();
    EnrichmentUtils.setAdditionalData(TEST_RDF);
    EuropeanaAggregationType aggregationTypeResult = TEST_RDF.getEuropeanaAggregationList().get(0);
    assertTrue(Integer.parseInt(aggregationTypeResult.getCompleteness().getString()) > 0);
}
Also used : Aggregation(eu.europeana.metis.schema.jibx.Aggregation) Choice(eu.europeana.metis.schema.jibx.EuropeanaType.Choice) ArrayList(java.util.ArrayList) Title(eu.europeana.metis.schema.jibx.Title) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) eu.europeana.metis.schema.jibx._Object(eu.europeana.metis.schema.jibx._Object) EuropeanaAggregationType(eu.europeana.metis.schema.jibx.EuropeanaAggregationType) Date(eu.europeana.metis.schema.jibx.Date) Test(org.junit.jupiter.api.Test)

Example 5 with EuropeanaAggregationType

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

the class EnrichmentUtilsTest method testSetAdditionalDataCompletenessNone.

@Test
void testSetAdditionalDataCompletenessNone() {
    ArrayList<ProxyType> proxyList = new ArrayList<>();
    proxyList.add(PROXY_EUROPEANA);
    proxyList.add(PROXY_PROVIDER);
    TEST_RDF.setProxyList(proxyList);
    EnrichmentUtils.setAdditionalData(TEST_RDF);
    EuropeanaAggregationType aggregationTypeResult = TEST_RDF.getEuropeanaAggregationList().get(0);
    assertEquals("0", aggregationTypeResult.getCompleteness().getString());
}
Also used : ArrayList(java.util.ArrayList) ProxyType(eu.europeana.metis.schema.jibx.ProxyType) EuropeanaAggregationType(eu.europeana.metis.schema.jibx.EuropeanaAggregationType) Test(org.junit.jupiter.api.Test)

Aggregations

EuropeanaAggregationType (eu.europeana.metis.schema.jibx.EuropeanaAggregationType)10 Test (org.junit.jupiter.api.Test)7 ProxyType (eu.europeana.metis.schema.jibx.ProxyType)4 RDF (eu.europeana.metis.schema.jibx.RDF)4 Aggregation (eu.europeana.metis.schema.jibx.Aggregation)2 ArrayList (java.util.ArrayList)2 FullBeanImpl (eu.europeana.corelib.solr.bean.impl.FullBeanImpl)1 RecordRelatedIndexingException (eu.europeana.indexing.exception.RecordRelatedIndexingException)1 SetupRelatedIndexingException (eu.europeana.indexing.exception.SetupRelatedIndexingException)1 CollectionName (eu.europeana.metis.schema.jibx.CollectionName)1 Completeness (eu.europeana.metis.schema.jibx.Completeness)1 Created (eu.europeana.metis.schema.jibx.Created)1 DatasetName (eu.europeana.metis.schema.jibx.DatasetName)1 Date (eu.europeana.metis.schema.jibx.Date)1 EuropeanaProxy (eu.europeana.metis.schema.jibx.EuropeanaProxy)1 Choice (eu.europeana.metis.schema.jibx.EuropeanaType.Choice)1 HasBody (eu.europeana.metis.schema.jibx.HasBody)1 HasQualityAnnotation (eu.europeana.metis.schema.jibx.HasQualityAnnotation)1 HasTarget (eu.europeana.metis.schema.jibx.HasTarget)1 LiteralType (eu.europeana.metis.schema.jibx.LiteralType)1