Search in sources :

Example 1 with IsShownAt

use of eu.europeana.metis.schema.jibx.IsShownAt 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)

Aggregations

Aggregation (eu.europeana.metis.schema.jibx.Aggregation)1 HasView (eu.europeana.metis.schema.jibx.HasView)1 IsShownAt (eu.europeana.metis.schema.jibx.IsShownAt)1 IsShownBy (eu.europeana.metis.schema.jibx.IsShownBy)1 RDF (eu.europeana.metis.schema.jibx.RDF)1 eu.europeana.metis.schema.jibx._Object (eu.europeana.metis.schema.jibx._Object)1 Test (org.junit.jupiter.api.Test)1