use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class TimelinePreviewsServiceImplTest method testProcess.
/**
* Test of process method of class TimelinePreviewsServiceImpl.
* @throws java.lang.Exception
*/
@Test
public void testProcess() throws Exception {
File file = new File(track.getURI());
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.get((URI) EasyMock.anyObject())).andReturn(file);
Capture filenameCapture = new Capture();
EasyMock.expect(workspace.putInCollection(EasyMock.anyString(), (String) EasyMock.capture(filenameCapture), (InputStream) EasyMock.anyObject())).andReturn(new URI("timelinepreviews.png"));
EasyMock.replay(workspace);
TimelinePreviewsServiceImpl instance = new TimelinePreviewsServiceImpl();
instance.setWorkspace(workspace);
String trackXml = MediaPackageElementParser.getAsXml(track);
Job job = new JobImpl(1);
job.setJobType(TimelinePreviewsServiceImpl.JOB_TYPE);
job.setOperation(TimelinePreviewsServiceImpl.Operation.TimelinePreview.toString());
job.setArguments(Arrays.asList(trackXml, String.valueOf(10)));
String result = instance.process(job);
assertNotNull(result);
MediaPackageElement timelinepreviewsAttachment = MediaPackageElementParser.getFromXml(result);
assertEquals(new URI("timelinepreviews.png"), timelinepreviewsAttachment.getURI());
assertTrue(filenameCapture.hasCaptured());
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class CommentSchedulerConflictNotifierTest method setUp.
@Before
public void setUp() throws Exception {
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andReturn(new JaxbUser("admin", "provider", new DefaultOrganization(), new JaxbRole("admin", new DefaultOrganization(), "test"))).anyTimes();
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.get(EasyMock.anyObject(URI.class))).andReturn(IoSupport.classPathResourceAsFile("/dublincore.xml").get()).anyTimes();
EasyMock.replay(workspace);
EventCatalogUIAdapter episodeAdapter = EasyMock.createMock(EventCatalogUIAdapter.class);
EasyMock.expect(episodeAdapter.getFlavor()).andReturn(new MediaPackageElementFlavor("dublincore", "episode")).anyTimes();
EasyMock.expect(episodeAdapter.getOrganization()).andReturn(new DefaultOrganization().getId()).anyTimes();
EasyMock.replay(episodeAdapter);
EventCatalogUIAdapter extendedAdapter = EasyMock.createMock(EventCatalogUIAdapter.class);
EasyMock.expect(extendedAdapter.getFlavor()).andReturn(new MediaPackageElementFlavor("extended", "episode")).anyTimes();
EasyMock.expect(extendedAdapter.getOrganization()).andReturn(new DefaultOrganization().getId()).anyTimes();
EasyMock.replay(extendedAdapter);
conflictNotifier = new CommentSchedulerConflictNotifier();
conflictNotifier.setSecurityService(securityService);
conflictNotifier.setWorkspace(workspace);
conflictNotifier.addCatalogUIAdapter(episodeAdapter);
conflictNotifier.addCatalogUIAdapter(extendedAdapter);
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class EmailSchedulerConflictNotifierTest method setUp.
@Before
public void setUp() throws Exception {
Dictionary<String, String> properties = new Hashtable<>();
properties.put("to", "test@test.com");
properties.put("subject", "Test email scheduler conflict");
properties.put("template", "Dear Administrator,\n\nthe following recording schedules are conflicting with existing ones:\n\n${recordings}\nBye!");
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getUser()).andReturn(new JaxbUser("admin", "provider", new DefaultOrganization(), new JaxbRole("admin", new DefaultOrganization(), "test"))).anyTimes();
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.get(EasyMock.anyObject(URI.class))).andReturn(IoSupport.classPathResourceAsFile("/dublincore.xml").get()).anyTimes();
EasyMock.replay(workspace);
EventCatalogUIAdapter episodeAdapter = EasyMock.createMock(EventCatalogUIAdapter.class);
EasyMock.expect(episodeAdapter.getFlavor()).andReturn(new MediaPackageElementFlavor("dublincore", "episode")).anyTimes();
EasyMock.expect(episodeAdapter.getOrganization()).andReturn(new DefaultOrganization().getId()).anyTimes();
EasyMock.replay(episodeAdapter);
EventCatalogUIAdapter extendedAdapter = EasyMock.createMock(EventCatalogUIAdapter.class);
EasyMock.expect(extendedAdapter.getFlavor()).andReturn(new MediaPackageElementFlavor("extended", "episode")).anyTimes();
EasyMock.expect(extendedAdapter.getOrganization()).andReturn(new DefaultOrganization().getId()).anyTimes();
EasyMock.replay(extendedAdapter);
BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
EasyMock.expect(bundleContext.getProperty(OpencastConstants.SERVER_URL_PROPERTY)).andReturn("http://localhost:8080").anyTimes();
EasyMock.replay(bundleContext);
ComponentContext componentContext = EasyMock.createNiceMock(ComponentContext.class);
EasyMock.expect(componentContext.getBundleContext()).andReturn(bundleContext).anyTimes();
EasyMock.expect(componentContext.getProperties()).andReturn(new Hashtable<String, Object>()).anyTimes();
EasyMock.replay(componentContext);
conflictNotifier = new EmailSchedulerConflictNotifier();
conflictNotifier.setSecurityService(securityService);
conflictNotifier.setWorkspace(workspace);
conflictNotifier.addCatalogUIAdapter(episodeAdapter);
conflictNotifier.addCatalogUIAdapter(extendedAdapter);
conflictNotifier.activate(componentContext);
conflictNotifier.updated(properties);
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class OaiPmhRepositoryPersistenceTest method oaiPmhDatabase.
private static AbstractOaiPmhDatabase oaiPmhDatabase(MediaPackage... mps) {
try {
final Organization org = new DefaultOrganization();
final SecurityService secSvc = EasyMock.createNiceMock(SecurityService.class);
// security service
final User user = createSystemUser("admin", org);
expect(secSvc.getOrganization()).andReturn(org).anyTimes();
expect(secSvc.getUser()).andReturn(user).anyTimes();
EasyMock.replay(secSvc);
// series service
final SeriesService seriesService = EasyMock.createNiceMock(SeriesService.class);
final String xacml = IOUtils.toString(OaiPmhRepositoryPersistenceTest.class.getResource("/xacml.xml").toURI());
final AccessControlList securityACL = AccessControlParser.parseAcl(xacml);
EasyMock.expect(seriesService.getSeriesAccessControl("10.0000/1")).andReturn(securityACL).anyTimes();
EasyMock.replay(seriesService);
// workspace
final Workspace workspace = EasyMock.createNiceMock(Workspace.class);
final File episodeDublinCore = new File(OaiPmhRepositoryPersistenceTest.class.getResource("/episode-dublincore.xml").toURI());
final File seriesDublinCore = new File(OaiPmhRepositoryPersistenceTest.class.getResource("/series-dublincore.xml").toURI());
expect(workspace.read(EasyMock.anyObject())).andAnswer(() -> {
final String uri = getCurrentArguments()[0].toString();
if ("dublincore.xml".equals(uri))
return new FileInputStream(episodeDublinCore);
if ("series-dublincore.xml".equals(uri))
return new FileInputStream(seriesDublinCore);
throw new Error("Workspace mock does not know about file " + uri);
}).anyTimes();
EasyMock.replay(workspace);
// oai-pmh database
final EntityManagerFactory emf = PersistenceUtil.newTestEntityManagerFactory(OaiPmhDatabaseImpl.PERSISTENCE_UNIT_NAME);
final AbstractOaiPmhDatabase db = new AbstractOaiPmhDatabase() {
@Override
public EntityManagerFactory getEmf() {
return emf;
}
@Override
public SecurityService getSecurityService() {
return secSvc;
}
@Override
public Workspace getWorkspace() {
return workspace;
}
@Override
public Date currentDate() {
return new Date();
}
};
for (MediaPackage mp : mps) db.store(mp, REPOSITORY_ID);
return db;
} catch (Exception e) {
return chuck(e);
}
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class YouTubeV3PublicationServiceImplTest method before.
@Before
public void before() throws Exception {
youTubeService = createMock(YouTubeAPIVersion3Service.class);
youTubeService.initialize(anyObject(ClientCredentials.class));
expectLastCall();
orgDirectory = createMock(OrganizationDirectoryService.class);
security = createMock(SecurityService.class);
registry = createMock(ServiceRegistry.class);
List<HostRegistration> hosts = new LinkedList<HostRegistration>();
HostRegistration host = new HostRegistrationInMemory("localhost", "localhost", 1.0F, 1, 1024L);
hosts.add(host);
expect(registry.getHostRegistrations()).andReturn(hosts).anyTimes();
userDirectoryService = createMock(UserDirectoryService.class);
workspace = createMock(Workspace.class);
//
service = new YouTubeV3PublicationServiceImpl(youTubeService);
service.setOrganizationDirectoryService(orgDirectory);
service.setSecurityService(security);
service.setServiceRegistry(registry);
service.setUserDirectoryService(userDirectoryService);
service.setWorkspace(workspace);
}
Aggregations