use of org.opencastproject.index.service.resources.list.api.ListProvidersService in project opencast by opencast.
the class ListProvidersScannerTest method testInstall.
@Test
public void testInstall() throws Exception {
String listName = "BLACKLISTS.USERS.REASONS";
File file = new File(ListProvidersScannerTest.class.getResource("/ListProvidersScannerTest-GoodProperties.properties").toURI());
Capture<ResourceListProvider> resourceListProvider = new Capture<>();
Capture<String> captureListName = new Capture<>();
ListProvidersService listProvidersService = EasyMock.createNiceMock(ListProvidersService.class);
listProvidersService.addProvider(EasyMock.capture(captureListName), EasyMock.capture(resourceListProvider));
EasyMock.expectLastCall();
EasyMock.replay(listProvidersService);
ListProvidersScanner listProvidersScanner = new ListProvidersScanner();
listProvidersScanner.setListProvidersService(listProvidersService);
listProvidersScanner.install(file);
assertEquals(1, resourceListProvider.getValues().size());
assertEquals(listName, resourceListProvider.getValue().getListNames()[0]);
assertEquals("Sick Leave", resourceListProvider.getValue().getList(listName, null, null).get("PM.BLACKLIST.REASONS.SICK_LEAVE"));
assertEquals("Leave", resourceListProvider.getValue().getList(listName, null, null).get("PM.BLACKLIST.REASONS.LEAVE"));
assertEquals("Family Emergency", resourceListProvider.getValue().getList(listName, null, null).get("PM.BLACKLIST.REASONS.FAMILY_EMERGENCY"));
assertNull(resourceListProvider.getValue().getList("Wrong List Name", null, null));
}
use of org.opencastproject.index.service.resources.list.api.ListProvidersService in project opencast by opencast.
the class ListProvidersScannerTest method testUpdate.
@Test
public void testUpdate() throws Exception {
String listName = "BLACKLISTS.USERS.REASONS";
File file = new File(ListProvidersScannerTest.class.getResource("/ListProvidersScannerTest-GoodProperties.properties").toURI());
Capture<ResourceListProvider> resourceListProvider = new Capture<>();
Capture<String> captureListName = new Capture<>();
ListProvidersService listProvidersService = EasyMock.createNiceMock(ListProvidersService.class);
listProvidersService.addProvider(EasyMock.capture(captureListName), EasyMock.capture(resourceListProvider));
EasyMock.expectLastCall();
EasyMock.replay(listProvidersService);
ListProvidersScanner listProvidersScanner = new ListProvidersScanner();
listProvidersScanner.setListProvidersService(listProvidersService);
listProvidersScanner.update(file);
assertEquals(1, resourceListProvider.getValues().size());
assertEquals(listName, resourceListProvider.getValue().getListNames()[0]);
assertEquals("Sick Leave", resourceListProvider.getValue().getList(listName, null, null).get("PM.BLACKLIST.REASONS.SICK_LEAVE"));
assertEquals("Leave", resourceListProvider.getValue().getList(listName, null, null).get("PM.BLACKLIST.REASONS.LEAVE"));
assertEquals("Family Emergency", resourceListProvider.getValue().getList(listName, null, null).get("PM.BLACKLIST.REASONS.FAMILY_EMERGENCY"));
}
use of org.opencastproject.index.service.resources.list.api.ListProvidersService in project opencast by opencast.
the class ListProvidersScannerTest method testUninstall.
@Test
public void testUninstall() throws Exception {
String listName = "BLACKLISTS.USERS.REASONS";
File file = new File(ListProvidersScannerTest.class.getResource("/ListProvidersScannerTest-GoodProperties.properties").toURI());
ListProvidersService listProvidersService = EasyMock.createNiceMock(ListProvidersService.class);
listProvidersService.removeProvider(listName);
EasyMock.expectLastCall();
EasyMock.replay(listProvidersService);
ListProvidersScanner listProvidersScanner = new ListProvidersScanner();
listProvidersScanner.setListProvidersService(listProvidersService);
listProvidersScanner.uninstall(file);
}
use of org.opencastproject.index.service.resources.list.api.ListProvidersService in project opencast by opencast.
the class ListProvidersScannerTest method testInstallInputMissingListNameInPropertiesFileExpectsNotAddedToService.
@Test
public void testInstallInputMissingListNameInPropertiesFileExpectsNotAddedToService() throws Exception {
File file = new File(ListProvidersScannerTest.class.getResource("/ListProvidersScannerTest-MissingListName.properties").toURI());
ListProvidersService listProvidersService = EasyMock.createMock(ListProvidersService.class);
EasyMock.replay(listProvidersService);
ListProvidersScanner listProvidersScanner = new ListProvidersScanner();
listProvidersScanner.setListProvidersService(listProvidersService);
listProvidersScanner.install(file);
}
use of org.opencastproject.index.service.resources.list.api.ListProvidersService in project opencast by opencast.
the class DublinCoreCatalogUIAdapterTest method setUp.
@Before
public void setUp() throws URISyntaxException, NotFoundException, IOException, ListProviderException {
startDateTimeDurationCatalog = new FileInputStream(new File(getClass().getResource("/catalog-adapter/start-date-time-duration.xml").toURI()));
dc = DublinCores.read(startDateTimeDurationCatalog);
metadata = new DublinCoreMetadataCollection();
startDateMetadataField = MetadataField.createTemporalStartDateMetadata(TEMPORAL_DUBLIN_CORE_KEY, Opt.some("startDate"), "START_DATE_LABEL", false, false, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Opt.<Integer>none(), Opt.<String>none());
durationMetadataField = MetadataField.createDurationMetadataField(TEMPORAL_DUBLIN_CORE_KEY, Opt.some("duration"), "DURATION_LABEL", false, false, Opt.<Integer>none(), Opt.<String>none());
TreeMap<String, String> collection = new TreeMap<String, String>();
collection.put("Entry 1", "Value 1");
collection.put("Entry 2", "Value 2");
collection.put("Entry 3", "Value 3");
BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
EasyMock.replay(bundleContext);
listProvidersService = EasyMock.createMock(ListProvidersService.class);
EasyMock.expect(listProvidersService.getList(EasyMock.anyString(), EasyMock.anyObject(ResourceListQueryImpl.class), EasyMock.anyObject(Organization.class), EasyMock.anyBoolean())).andReturn(collection).anyTimes();
EasyMock.replay(listProvidersService);
Properties props = new Properties();
InputStream in = getClass().getResourceAsStream("/catalog-adapter/event.properties");
props.load(in);
in.close();
eventProperties = PropertiesUtil.toDictionary(props);
mediaPackageElementFlavor = new MediaPackageElementFlavor(FLAVOR_STRING.split("/")[0], FLAVOR_STRING.split("/")[1]);
eventDublincoreURI = getClass().getResource("/catalog-adapter/dublincore.xml").toURI();
outputCatalog = testFolder.newFile("out.xml");
Capture<String> mediapackageIDCapture = EasyMock.newCapture();
Capture<String> catalogIDCapture = EasyMock.newCapture();
Capture<String> filenameCapture = EasyMock.newCapture();
writtenCatalog = EasyMock.newCapture();
workspace = EasyMock.createMock(Workspace.class);
EasyMock.expect(workspace.read(eventDublincoreURI)).andAnswer(() -> new FileInputStream(new File(eventDublincoreURI)));
EasyMock.expect(workspace.put(EasyMock.capture(mediapackageIDCapture), EasyMock.capture(catalogIDCapture), EasyMock.capture(filenameCapture), EasyMock.capture(writtenCatalog))).andReturn(outputCatalog.toURI());
EasyMock.replay(workspace);
Catalog eventCatalog = EasyMock.createMock(Catalog.class);
EasyMock.expect(eventCatalog.getIdentifier()).andReturn("CatalogID").anyTimes();
EasyMock.expect(eventCatalog.getURI()).andReturn(eventDublincoreURI).anyTimes();
eventCatalog.setURI(outputCatalog.toURI());
EasyMock.expectLastCall();
eventCatalog.setChecksum(null);
EasyMock.expectLastCall();
EasyMock.replay(eventCatalog);
Catalog[] catalogs = { eventCatalog };
Id id = EasyMock.createMock(Id.class);
EasyMock.replay(id);
mediapackage = EasyMock.createMock(MediaPackage.class);
EasyMock.expect(mediapackage.getCatalogs(mediaPackageElementFlavor)).andReturn(catalogs).anyTimes();
EasyMock.expect(mediapackage.getIdentifier()).andReturn(id).anyTimes();
EasyMock.replay(mediapackage);
dictionary = new Hashtable<String, String>();
dictionary.put(CONF_ORGANIZATION_KEY, ORGANIZATION_STRING);
dictionary.put(CONF_FLAVOR_KEY, FLAVOR_STRING);
dictionary.put(CONF_TITLE_KEY, TITLE_STRING);
dictionary.put(MetadataField.CONFIG_PROPERTY_PREFIX + ".title." + MetadataField.CONFIG_INPUT_ID_KEY, title);
dictionary.put(MetadataField.CONFIG_PROPERTY_PREFIX + ".title." + MetadataField.CONFIG_LABEL_KEY, label);
dictionary.put(MetadataField.CONFIG_PROPERTY_PREFIX + ".title." + MetadataField.CONFIG_TYPE_KEY, type);
dictionary.put(MetadataField.CONFIG_PROPERTY_PREFIX + ".title." + MetadataField.CONFIG_READ_ONLY_KEY, readOnly);
dictionary.put(MetadataField.CONFIG_PROPERTY_PREFIX + ".title." + MetadataField.CONFIG_REQUIRED_KEY, required);
dictionary.put(MetadataField.CONFIG_PROPERTY_PREFIX + ".title." + MetadataField.CONFIG_LIST_PROVIDER_KEY, listProvider);
dictionary.put(MetadataField.CONFIG_PROPERTY_PREFIX + ".title." + MetadataField.CONFIG_COLLECTION_ID_KEY, collectionID);
}
Aggregations