Search in sources :

Example 1 with ConfigurableEventDCCatalogUIAdapter

use of org.opencastproject.index.service.catalog.adapter.events.ConfigurableEventDCCatalogUIAdapter in project opencast by opencast.

the class EventCatalogUIAdapterTest method testGetFields.

@Test
public void testGetFields() throws Exception {
    String eventJson = IOUtils.toString(getClass().getResource("/catalog-adapter/event.json"));
    ConfigurableEventDCCatalogUIAdapter configurationDublinCoreCatalogUIAdapter = new ConfigurableEventDCCatalogUIAdapter();
    configurationDublinCoreCatalogUIAdapter.setListProvidersService(listProvidersService);
    configurationDublinCoreCatalogUIAdapter.setWorkspace(workspace);
    configurationDublinCoreCatalogUIAdapter.updated(eventProperties);
    MetadataCollection abstractMetadata = configurationDublinCoreCatalogUIAdapter.getFields(mediapackage);
    assertThat(eventJson, SameJSONAs.sameJSONAs(RestUtils.getJsonString(abstractMetadata.toJSON())).allowingAnyArrayOrdering());
}
Also used : MetadataCollection(org.opencastproject.metadata.dublincore.MetadataCollection) ConfigurableEventDCCatalogUIAdapter(org.opencastproject.index.service.catalog.adapter.events.ConfigurableEventDCCatalogUIAdapter) Test(org.junit.Test)

Example 2 with ConfigurableEventDCCatalogUIAdapter

use of org.opencastproject.index.service.catalog.adapter.events.ConfigurableEventDCCatalogUIAdapter in project opencast by opencast.

the class DublinCoreCatalogUIAdapterTest method testStoreFields.

@Test
public void testStoreFields() throws Exception {
    String temporal = "temporal";
    String expectedTemporal = "start=2016-03-01T09:27:35Z; end=2016-03-01T11:43:12Z; scheme=W3C-DTF;";
    String expectedTitle = "New Value for Title";
    String expectedMissing = "New Value for Missing";
    ConfigurableEventDCCatalogUIAdapter configurationDublinCoreCatalogUIAdapter = new ConfigurableEventDCCatalogUIAdapter();
    configurationDublinCoreCatalogUIAdapter.setListProvidersService(listProvidersService);
    configurationDublinCoreCatalogUIAdapter.setWorkspace(workspace);
    configurationDublinCoreCatalogUIAdapter.updated(eventProperties);
    DublinCoreMetadataCollection dublinCoreMetadata = new DublinCoreMetadataCollection();
    MetadataField<String> titleField = MetadataField.createTextMetadataField(title, Opt.some(title), "New Label for Title", true, false, Opt.<Boolean>none(), Opt.<Map<String, String>>none(), Opt.<String>none(), Opt.<Integer>none(), Opt.<String>none());
    dublinCoreMetadata.addField(titleField, expectedTitle, listProvidersService);
    MetadataField<String> missingField = MetadataField.createTextMetadataField("missing", Opt.<String>none(), "The Missing's Label", false, false, Opt.<Boolean>none(), Opt.<Map<String, String>>none(), Opt.<String>none(), Opt.<Integer>none(), Opt.<String>none());
    dublinCoreMetadata.addField(missingField, expectedMissing, listProvidersService);
    MetadataField<String> durationField = MetadataField.createDurationMetadataField(temporal, Opt.some("duration"), label, true, true, Opt.<Integer>none(), Opt.<String>none());
    dublinCoreMetadata.addField(durationField, "02:15:37", listProvidersService);
    MetadataField<String> startDate = MetadataField.createTemporalStartDateMetadata(temporal, Opt.some("startDate"), label, true, true, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Opt.<Integer>none(), Opt.<String>none());
    dublinCoreMetadata.addField(startDate, "2016-03-01T09:27:35.000Z", listProvidersService);
    configurationDublinCoreCatalogUIAdapter.storeFields(mediapackage, dublinCoreMetadata);
    assertTrue(writtenCatalog.hasCaptured());
    DublinCoreCatalog updatedCatalog = DublinCores.read(writtenCatalog.getValue());
    assertEquals(expectedTitle, updatedCatalog.get(new EName(DublinCore.TERMS_NS_URI, "title")).get(0).getValue());
    assertEquals(expectedMissing, updatedCatalog.get(new EName(DublinCore.TERMS_NS_URI, "missing")).get(0).getValue());
    assertEquals(expectedTemporal, updatedCatalog.get(new EName(DublinCore.TERMS_NS_URI, temporal)).get(0).getValue());
}
Also used : EName(org.opencastproject.mediapackage.EName) ConfigurableEventDCCatalogUIAdapter(org.opencastproject.index.service.catalog.adapter.events.ConfigurableEventDCCatalogUIAdapter) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ConfigurableEventDCCatalogUIAdapter (org.opencastproject.index.service.catalog.adapter.events.ConfigurableEventDCCatalogUIAdapter)2 EName (org.opencastproject.mediapackage.EName)1 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)1 MetadataCollection (org.opencastproject.metadata.dublincore.MetadataCollection)1