use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class CopyWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
// test resources
URI uriMP = getClass().getResource("/copy_mediapackage.xml").toURI();
mp = builder.loadFromXml(uriMP.toURL().openStream());
// set up mock workspace
workspace = EasyMock.createNiceMock(Workspace.class);
// set up service
operationHandler = new CopyWorkflowOperationHandler();
// Prepare file to returne from workflow
videoFile = new File(getClass().getResource("/av.mov").toURI());
EasyMock.expect(workspace.get((URI) EasyMock.anyObject())).andReturn(videoFile).anyTimes();
EasyMock.replay(workspace);
operationHandler.setWorkspace(workspace);
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class SeriesWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
mp = builder.loadFromXml(getClass().getResourceAsStream("/series_mediapackage.xml"));
URI uri = getClass().getResource("/dublincore.xml").toURI();
File file = new File(uri);
seriesCatalog = DublinCores.mkOpencast().getCatalog();
seriesCatalog.set(DublinCore.PROPERTY_TITLE, "Series 1");
SeriesService seriesService = EasyMock.createNiceMock(SeriesService.class);
EasyMock.expect(seriesService.getSeries(EasyMock.anyString())).andReturn(seriesCatalog).anyTimes();
EasyMock.expect(seriesService.getSeriesAccessControl(EasyMock.anyString())).andReturn(new AccessControlList()).anyTimes();
EasyMock.expect(seriesService.getSeriesElementData(EasyMock.anyString(), EasyMock.anyString())).andReturn(Opt.some(FileUtils.readFileToByteArray(file))).anyTimes();
EasyMock.replay(seriesService);
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getOrganization()).andReturn(new DefaultOrganization()).anyTimes();
EasyMock.replay(securityService);
capturedStream = Capture.newInstance(CaptureType.FIRST);
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.get(EasyMock.anyObject(URI.class))).andReturn(file).anyTimes();
EasyMock.expect(workspace.read(EasyMock.anyObject(URI.class))).andAnswer(() -> getClass().getResourceAsStream("/dublincore.xml")).anyTimes();
EasyMock.expect(workspace.put(EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString(), EasyMock.capture(capturedStream))).andReturn(uri).anyTimes();
EasyMock.replay(workspace);
AuthorizationService authorizationService = EasyMock.createNiceMock(AuthorizationService.class);
EasyMock.replay(authorizationService);
SeriesCatalogUIAdapter adapter = EasyMock.createNiceMock(SeriesCatalogUIAdapter.class);
EasyMock.expect(adapter.getOrganization()).andReturn(new DefaultOrganization().getId()).anyTimes();
EasyMock.expect(adapter.getFlavor()).andReturn("creativecommons/series").anyTimes();
EasyMock.replay(adapter);
SeriesCatalogUIAdapter seriesAdapter = EasyMock.createNiceMock(SeriesCatalogUIAdapter.class);
EasyMock.expect(seriesAdapter.getOrganization()).andReturn(new DefaultOrganization().getId()).anyTimes();
EasyMock.expect(seriesAdapter.getFlavor()).andReturn("dublincore/series").anyTimes();
EasyMock.replay(seriesAdapter);
// set up the handler
operationHandler = new SeriesWorkflowOperationHandler();
operationHandler.setSeriesService(seriesService);
operationHandler.setSecurityService(securityService);
operationHandler.setWorkspace(workspace);
operationHandler.setAuthorizationService(authorizationService);
operationHandler.addCatalogUIAdapter(adapter);
operationHandler.addCatalogUIAdapter(seriesAdapter);
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class ConfigureByDublinCoreTermWOHTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
mp = builder.loadFromXml(this.getClass().getResourceAsStream("/archive_mediapackage.xml"));
mp.getCatalog("catalog-1").setURI(this.getClass().getResource("/dublincore.xml").toURI());
// set up the handler
operationHandler = new ConfigureByDublinCoreTermWOH();
// Initialize the workflow
instance = new WorkflowInstanceImpl();
operation = new WorkflowOperationInstanceImpl("test", OperationState.INSTANTIATED);
List<WorkflowOperationInstance> ops = new ArrayList<WorkflowOperationInstance>();
ops.add(operation);
instance.setOperations(ops);
instance.setConfiguration("oldConfigProperty", "foo");
instance.setMediaPackage(mp);
workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.read(EasyMock.anyObject())).andAnswer(() -> getClass().getResourceAsStream("/dublincore.xml"));
EasyMock.replay(workspace);
operationHandler.setWorkspace(workspace);
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class ComposeWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
// test resources
URI uriMP = InspectWorkflowOperationHandler.class.getResource("/compose_mediapackage.xml").toURI();
URI uriMPEncode = InspectWorkflowOperationHandler.class.getResource("/compose_encode_mediapackage.xml").toURI();
mp = builder.loadFromXml(uriMP.toURL().openStream());
mpEncode = builder.loadFromXml(uriMPEncode.toURL().openStream());
encodedTracks = mpEncode.getTracks();
// set up mock workspace
workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.moveTo((URI) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(uriMP);
EasyMock.replay(workspace);
// set up mock receipt
job = EasyMock.createNiceMock(Job.class);
EasyMock.expect(job.getPayload()).andReturn(MediaPackageElementParser.getAsXml(encodedTracks[0])).anyTimes();
EasyMock.expect(job.getStatus()).andReturn(Job.Status.FINISHED);
EasyMock.expect(job.getDateCreated()).andReturn(new Date());
EasyMock.expect(job.getDateStarted()).andReturn(new Date());
EasyMock.expect(job.getQueueTime()).andReturn(new Long(0));
EasyMock.replay(job);
// set up mock service registry
ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.getJob(EasyMock.anyLong())).andReturn(job);
EasyMock.replay(serviceRegistry);
// set up service
operationHandler = new ComposeWorkflowOperationHandler();
operationHandler.setJobBarrierPollingInterval(0);
operationHandler.setWorkspace(workspace);
operationHandler.setServiceRegistry(serviceRegistry);
}
use of org.opencastproject.workspace.api.Workspace in project opencast by opencast.
the class CompositeWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
// test resources
URI uriMP = InspectWorkflowOperationHandler.class.getResource("/composite_mediapackage.xml").toURI();
URI uriMPEncode = InspectWorkflowOperationHandler.class.getResource("/compound_mediapackage.xml").toURI();
mp = builder.loadFromXml(uriMP.toURL().openStream());
mpEncode = builder.loadFromXml(uriMPEncode.toURL().openStream());
encodedTracks = mpEncode.getTracks();
// set up mock workspace
workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.moveTo((URI) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject())).andReturn(uriMPEncode);
EasyMock.expect(workspace.get((URI) EasyMock.anyObject())).andReturn(new File(getClass().getResource("/watermark.jpg").toURI()));
EasyMock.replay(workspace);
// set up mock receipt
job = EasyMock.createNiceMock(Job.class);
EasyMock.expect(job.getPayload()).andReturn(MediaPackageElementParser.getAsXml(encodedTracks[0])).anyTimes();
EasyMock.expect(job.getStatus()).andReturn(Job.Status.FINISHED);
EasyMock.expect(job.getDateCreated()).andReturn(new Date());
EasyMock.expect(job.getDateStarted()).andReturn(new Date());
EasyMock.expect(job.getQueueTime()).andReturn(new Long(0));
EasyMock.replay(job);
// set up mock service registry
ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.getJob(EasyMock.anyLong())).andReturn(job);
EasyMock.replay(serviceRegistry);
// set up service
operationHandler = new CompositeWorkflowOperationHandler();
operationHandler.setJobBarrierPollingInterval(0);
operationHandler.setWorkspace(workspace);
operationHandler.setServiceRegistry(serviceRegistry);
}
Aggregations