Search in sources :

Example 1 with RDF

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

the class RdfWrapperTest method testGetFirstResourceOfType.

@Test
void testGetFirstResourceOfType() {
    // Setup tests - create RDF and aggregations
    final Aggregation firstAggregation = new Aggregation();
    final Aggregation middleAggregation = new Aggregation();
    final Aggregation lastAggregation = new Aggregation();
    final RDF rdf = new RDF();
    rdf.setAggregationList(Arrays.asList(null, firstAggregation, middleAggregation, lastAggregation));
    final RdfWrapper instance = new RdfWrapper(rdf);
    // Test - try with non-existing values
    assertFalse(instance.getFirstResourceOfType(UrlType.OBJECT).isPresent());
    assertFalse(instance.getFirstResourceOfType(UrlType.HAS_VIEW).isPresent());
    assertFalse(instance.getFirstResourceOfType(UrlType.IS_SHOWN_AT).isPresent());
    assertFalse(instance.getFirstResourceOfType(UrlType.IS_SHOWN_BY).isPresent());
    // Setup tests - object links
    final String firstObject = "firstObject";
    final String lastObject = "lastObject";
    firstAggregation.setObject(new _Object());
    firstAggregation.getObject().setResource(firstObject);
    middleAggregation.setObject(new _Object());
    middleAggregation.getObject().setResource(lastObject);
    lastAggregation.setObject(null);
    // Setup tests - hasView links
    final String firstHasView = "firstHasView";
    final String middleHasView = "middleHasView";
    final String lastHasView = "lastHasView";
    firstAggregation.setHasViewList(null);
    middleAggregation.setHasViewList(Arrays.asList(null, new HasView(), new HasView(), new HasView()));
    middleAggregation.getHasViewList().get(2).setResource(firstHasView);
    middleAggregation.getHasViewList().get(3).setResource(middleHasView);
    lastAggregation.setHasViewList(Collections.singletonList(new HasView()));
    lastAggregation.getHasViewList().get(0).setResource(lastHasView);
    // Setup tests - isShownAt links
    final String firstIsShownAt = "firstIsShownAt";
    final String lastIsShownAt = "lastIsShownAt";
    firstAggregation.setIsShownAt(new IsShownAt());
    middleAggregation.setIsShownAt(new IsShownAt());
    middleAggregation.getIsShownAt().setResource(firstIsShownAt);
    lastAggregation.setIsShownAt(new IsShownAt());
    lastAggregation.getIsShownAt().setResource(lastIsShownAt);
    // Setup tests - isShownBy links
    final String firstIsShownBy = "firstIsShownBy";
    final String lastIsShownBy = "lastIsShownBy";
    firstAggregation.setIsShownBy(new IsShownBy());
    firstAggregation.getIsShownBy().setResource(" ");
    middleAggregation.setIsShownBy(new IsShownBy());
    middleAggregation.getIsShownBy().setResource(firstIsShownBy);
    lastAggregation.setIsShownBy(new IsShownBy());
    lastAggregation.getIsShownBy().setResource(lastIsShownBy);
    // Test - try with existing values
    assertEquals(firstObject, instance.getFirstResourceOfType(UrlType.OBJECT).orElse(null));
    assertEquals(firstHasView, instance.getFirstResourceOfType(UrlType.HAS_VIEW).orElse(null));
    assertEquals(firstIsShownAt, instance.getFirstResourceOfType(UrlType.IS_SHOWN_AT).orElse(null));
    assertEquals(firstIsShownBy, instance.getFirstResourceOfType(UrlType.IS_SHOWN_BY).orElse(null));
}
Also used : Aggregation(eu.europeana.metis.schema.jibx.Aggregation) IsShownAt(eu.europeana.metis.schema.jibx.IsShownAt) RDF(eu.europeana.metis.schema.jibx.RDF) IsShownBy(eu.europeana.metis.schema.jibx.IsShownBy) eu.europeana.metis.schema.jibx._Object(eu.europeana.metis.schema.jibx._Object) HasView(eu.europeana.metis.schema.jibx.HasView) Test(org.junit.jupiter.api.Test)

Example 2 with RDF

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

the class RdfWrapperTest method testGetWebResourcesWithProcessing.

@Test
void testGetWebResourcesWithProcessing() {
    // Create entities
    final WebResourceType entity0 = mock(WebResourceType.class);
    doReturn(" ").when(entity0).getAbout();
    final WebResourceType entity1 = mock(WebResourceType.class);
    doReturn("nonemptyabout").when(entity1).getAbout();
    final WebResourceType entity2 = mock(WebResourceType.class);
    doReturn(null).when(entity2).getAbout();
    // Test rdf that returns a real list
    final RDF rdf = mock(RDF.class);
    when(rdf.getWebResourceList()).thenReturn(Arrays.asList(entity0, entity1, entity2, null));
    assertEquals(Collections.singletonList(entity1.getAbout()), new RdfWrapper(rdf).getWebResources().stream().map(WebResourceType::getAbout).collect(Collectors.toList()));
    // Test rdf that returns null
    when(rdf.getWebResourceList()).thenReturn(null);
    assertTrue(new RdfWrapper(rdf).getWebResources().isEmpty());
}
Also used : WebResourceType(eu.europeana.metis.schema.jibx.WebResourceType) RDF(eu.europeana.metis.schema.jibx.RDF) Test(org.junit.jupiter.api.Test)

Example 3 with RDF

use of eu.europeana.metis.schema.jibx.RDF 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 4 with RDF

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

the class RdfWrapperTest method testGetAbout.

@Test
void testGetAbout() {
    // Create entities
    final ProvidedCHOType entity0 = mock(ProvidedCHOType.class);
    doReturn(" ").when(entity0).getAbout();
    final ProvidedCHOType entity1 = mock(ProvidedCHOType.class);
    doReturn("nonemptyabout").when(entity1).getAbout();
    final ProvidedCHOType entity2 = mock(ProvidedCHOType.class);
    doReturn(null).when(entity2).getAbout();
    // Test rdf that returns a real list
    final RDF rdf = mock(RDF.class);
    when(rdf.getProvidedCHOList()).thenReturn(Arrays.asList(entity0, entity1, entity2, null));
    assertEquals(entity1.getAbout(), new RdfWrapper(rdf).getAbout());
    // Test rdf that returns list without viable candidates
    when(rdf.getProvidedCHOList()).thenReturn(Arrays.asList(entity0, entity2));
    assertNull(new RdfWrapper(rdf).getAbout());
    // Test rdf that returns null
    when(rdf.getProvidedCHOList()).thenReturn(null);
    assertNull(new RdfWrapper(rdf).getAbout());
}
Also used : RDF(eu.europeana.metis.schema.jibx.RDF) ProvidedCHOType(eu.europeana.metis.schema.jibx.ProvidedCHOType) Test(org.junit.jupiter.api.Test)

Example 5 with RDF

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

the class IndexerImpl method index.

@Override
public void index(List<String> records, IndexingProperties indexingProperties) throws IndexingException {
    LOGGER.info("Parsing {} records...", records.size());
    final StringToFullBeanConverter stringToRdfConverter = stringToRdfConverterSupplier.get();
    final List<RDF> wrappedRecords = new ArrayList<>(records.size());
    for (String record : records) {
        wrappedRecords.add(stringToRdfConverter.convertStringToRdf(record));
    }
    indexRecords(wrappedRecords, indexingProperties);
}
Also used : RDF(eu.europeana.metis.schema.jibx.RDF) ArrayList(java.util.ArrayList) StringToFullBeanConverter(eu.europeana.indexing.fullbean.StringToFullBeanConverter)

Aggregations

RDF (eu.europeana.metis.schema.jibx.RDF)43 Test (org.junit.jupiter.api.Test)25 ArrayList (java.util.ArrayList)14 ProxyType (eu.europeana.metis.schema.jibx.ProxyType)12 ResourceOrLiteralType (eu.europeana.metis.schema.jibx.ResourceOrLiteralType)6 Resource (eu.europeana.metis.schema.jibx.ResourceOrLiteralType.Resource)6 EntityMergeEngine (eu.europeana.enrichment.utils.EntityMergeEngine)5 EnrichmentBase (eu.europeana.enrichment.api.external.model.EnrichmentBase)4 RecordParser (eu.europeana.enrichment.api.internal.RecordParser)4 SearchTermContext (eu.europeana.enrichment.api.internal.SearchTermContext)4 EnrichmentException (eu.europeana.enrichment.rest.client.exceptions.EnrichmentException)4 EuropeanaAggregationType (eu.europeana.metis.schema.jibx.EuropeanaAggregationType)4 HasPart (eu.europeana.metis.schema.jibx.HasPart)4 IsPartOf (eu.europeana.metis.schema.jibx.IsPartOf)4 EnrichmentResultBaseWrapper (eu.europeana.enrichment.api.external.model.EnrichmentResultBaseWrapper)3 ProxyFieldType (eu.europeana.enrichment.api.internal.ProxyFieldType)3 DereferenceException (eu.europeana.enrichment.rest.client.exceptions.DereferenceException)3 Note (eu.europeana.metis.schema.jibx.Note)3 AggregationFieldType (eu.europeana.enrichment.api.internal.AggregationFieldType)2 FieldType (eu.europeana.enrichment.api.internal.FieldType)2