use of org.opencastproject.index.service.resources.list.api.ListProvidersService in project opencast by opencast.
the class ListProvidersScannerTest method testInstallInputOrgInPropertiesFileExpectsAddedToService.
@Test
public void testInstallInputOrgInPropertiesFileExpectsAddedToService() throws Exception {
Organization org1 = EasyMock.createMock(Organization.class);
EasyMock.expect(org1.getId()).andReturn("org1").anyTimes();
EasyMock.replay(org1);
Organization org2 = EasyMock.createMock(Organization.class);
EasyMock.expect(org2.getId()).andReturn("org2").anyTimes();
EasyMock.replay(org2);
String listName = "BLACKLISTS.USERS.REASONS";
File file = new File(ListProvidersScannerTest.class.getResource("/ListProvidersScannerTest-WithOrg.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);
ResourceListQuery query = new ResourceListQueryImpl();
assertEquals(1, resourceListProvider.getValues().size());
assertEquals(listName, resourceListProvider.getValue().getListNames()[0]);
Map<String, String> stuff = resourceListProvider.getValue().getList(listName, query, org1);
for (String key : stuff.keySet()) {
logger.info("Key: {}, Value {}.", key, stuff.get(key));
}
assertEquals(3, resourceListProvider.getValue().getList(listName, query, org1).size());
assertNull(resourceListProvider.getValue().getList(listName, query, org2));
assertNull(resourceListProvider.getValue().getList(listName, query, null));
assertEquals("Sick Leave", resourceListProvider.getValue().getList(listName, null, org1).get("PM.BLACKLIST.REASONS.SICK_LEAVE"));
assertEquals("Leave", resourceListProvider.getValue().getList(listName, null, org1).get("PM.BLACKLIST.REASONS.LEAVE"));
assertEquals("Family Emergency", resourceListProvider.getValue().getList(listName, null, org1).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 testInstallInputEmptyListNameInPropertiesFileExpectsNotAddedToService.
@Test
public void testInstallInputEmptyListNameInPropertiesFileExpectsNotAddedToService() throws Exception {
File file = new File(ListProvidersScannerTest.class.getResource("/ListProvidersScannerTest-EmptyListName.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 EventCatalogUIAdapterTest method setUp.
@Before
public void setUp() throws URISyntaxException, NotFoundException, IOException, ListProviderException {
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.expect(listProvidersService.isTranslatable(EasyMock.anyString())).andThrow(new ListProviderException("not implemented")).anyTimes();
EasyMock.expect(listProvidersService.getDefault(EasyMock.anyString())).andThrow(new ListProviderException("not implemented")).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]);
URI eventDublincoreURI = getClass().getResource("/catalog-adapter/event-dublincore.xml").toURI();
workspace = EasyMock.createMock(Workspace.class);
EasyMock.expect(workspace.read(eventDublincoreURI)).andAnswer(() -> new FileInputStream(new File(eventDublincoreURI)));
EasyMock.replay(workspace);
Catalog eventCatalog = EasyMock.createMock(Catalog.class);
EasyMock.expect(eventCatalog.getURI()).andReturn(eventDublincoreURI).anyTimes();
EasyMock.replay(eventCatalog);
Catalog[] catalogs = { eventCatalog };
mediapackage = EasyMock.createMock(MediaPackage.class);
EasyMock.expect(mediapackage.getCatalogs(mediaPackageElementFlavor)).andReturn(catalogs).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