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