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