Search in sources :

Example 1 with ListProvidersService

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));
}
Also used : ResourceListProvider(org.opencastproject.index.service.resources.list.api.ResourceListProvider) ListProvidersService(org.opencastproject.index.service.resources.list.api.ListProvidersService) File(java.io.File) Capture(org.easymock.Capture) Test(org.junit.Test)

Example 2 with ListProvidersService

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"));
}
Also used : ResourceListProvider(org.opencastproject.index.service.resources.list.api.ResourceListProvider) ListProvidersService(org.opencastproject.index.service.resources.list.api.ListProvidersService) File(java.io.File) Capture(org.easymock.Capture) Test(org.junit.Test)

Example 3 with ListProvidersService

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);
}
Also used : ListProvidersService(org.opencastproject.index.service.resources.list.api.ListProvidersService) File(java.io.File) Test(org.junit.Test)

Example 4 with ListProvidersService

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);
}
Also used : ListProvidersService(org.opencastproject.index.service.resources.list.api.ListProvidersService) File(java.io.File) Test(org.junit.Test)

Example 5 with ListProvidersService

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);
}
Also used : ListProvidersService(org.opencastproject.index.service.resources.list.api.ListProvidersService) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) TreeMap(java.util.TreeMap) Properties(java.util.Properties) MediaPackageElementFlavor(org.opencastproject.mediapackage.MediaPackageElementFlavor) FileInputStream(java.io.FileInputStream) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Catalog(org.opencastproject.mediapackage.Catalog) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Id(org.opencastproject.mediapackage.identifier.Id) File(java.io.File) BundleContext(org.osgi.framework.BundleContext) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Aggregations

File (java.io.File)8 ListProvidersService (org.opencastproject.index.service.resources.list.api.ListProvidersService)8 Test (org.junit.Test)6 Capture (org.easymock.Capture)3 ResourceListProvider (org.opencastproject.index.service.resources.list.api.ResourceListProvider)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 Properties (java.util.Properties)2 TreeMap (java.util.TreeMap)2 Before (org.junit.Before)2 Catalog (org.opencastproject.mediapackage.Catalog)2 MediaPackage (org.opencastproject.mediapackage.MediaPackage)2 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)2 Workspace (org.opencastproject.workspace.api.Workspace)2 BundleContext (org.osgi.framework.BundleContext)2 URI (java.net.URI)1 ListProviderException (org.opencastproject.index.service.exception.ListProviderException)1 ResourceListQuery (org.opencastproject.index.service.resources.list.api.ResourceListQuery)1 ResourceListQueryImpl (org.opencastproject.index.service.resources.list.query.ResourceListQueryImpl)1 Id (org.opencastproject.mediapackage.identifier.Id)1