Search in sources :

Example 1 with CollectionName

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

the class RdfWrapperTest method testGetDatasetName.

@Test
void testGetDatasetName() {
    // Set up to return a europeana aggregation
    final EuropeanaAggregationType entity = mock(EuropeanaAggregationType.class);
    final RdfWrapper rdf = spy(new RdfWrapper(new RDF()));
    when(rdf.getEuropeanaAggregation()).thenReturn(Optional.of(entity));
    // Test if dataset name exists and collection name does not
    final DatasetName datasetName = new DatasetName();
    datasetName.setString("test1");
    when(entity.getDatasetName()).thenReturn(datasetName);
    assertEquals(datasetName.getString(), rdf.getDatasetName());
    // Test if dataset name and collection name exist
    final CollectionName collectionName = new CollectionName();
    collectionName.setString("test2");
    when(entity.getCollectionName()).thenReturn(collectionName);
    assertEquals(datasetName.getString(), rdf.getDatasetName());
    // Test if dataset name does not exist, but collection name does.
    datasetName.setString("");
    assertEquals(collectionName.getString(), rdf.getDatasetName());
    datasetName.setString(null);
    assertEquals(collectionName.getString(), rdf.getDatasetName());
    when(entity.getDatasetName()).thenReturn(null);
    assertEquals(collectionName.getString(), rdf.getDatasetName());
    // Test if neither dataset name nor collection name exists
    collectionName.setString("");
    assertTrue(rdf.getDatasetName().isEmpty());
    collectionName.setString(null);
    assertTrue(rdf.getDatasetName().isEmpty());
    when(entity.getCollectionName()).thenReturn(null);
    assertTrue(rdf.getDatasetName().isEmpty());
    // If there is no europeana aggregation
    when(rdf.getEuropeanaAggregation()).thenReturn(Optional.of(entity));
    assertTrue(rdf.getDatasetName().isEmpty());
}
Also used : RDF(eu.europeana.metis.schema.jibx.RDF) CollectionName(eu.europeana.metis.schema.jibx.CollectionName) DatasetName(eu.europeana.metis.schema.jibx.DatasetName) EuropeanaAggregationType(eu.europeana.metis.schema.jibx.EuropeanaAggregationType) Test(org.junit.jupiter.api.Test)

Aggregations

CollectionName (eu.europeana.metis.schema.jibx.CollectionName)1 DatasetName (eu.europeana.metis.schema.jibx.DatasetName)1 EuropeanaAggregationType (eu.europeana.metis.schema.jibx.EuropeanaAggregationType)1 RDF (eu.europeana.metis.schema.jibx.RDF)1 Test (org.junit.jupiter.api.Test)1