Search in sources :

Example 6 with Workspace

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);
}
Also used : MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) URI(java.net.URI) File(java.io.File) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Example 7 with 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);
}
Also used : AccessControlList(org.opencastproject.security.api.AccessControlList) MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) SeriesService(org.opencastproject.series.api.SeriesService) AuthorizationService(org.opencastproject.security.api.AuthorizationService) SecurityService(org.opencastproject.security.api.SecurityService) SeriesCatalogUIAdapter(org.opencastproject.metadata.dublincore.SeriesCatalogUIAdapter) URI(java.net.URI) File(java.io.File) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Example 8 with Workspace

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);
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) ArrayList(java.util.ArrayList) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Example 9 with 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);
}
Also used : MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) URI(java.net.URI) InspectWorkflowOperationHandler(org.opencastproject.workflow.handler.inspection.InspectWorkflowOperationHandler) Date(java.util.Date) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Example 10 with Workspace

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);
}
Also used : MediaPackageBuilder(org.opencastproject.mediapackage.MediaPackageBuilder) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) URI(java.net.URI) File(java.io.File) InspectWorkflowOperationHandler(org.opencastproject.workflow.handler.inspection.InspectWorkflowOperationHandler) Date(java.util.Date) Workspace(org.opencastproject.workspace.api.Workspace) Before(org.junit.Before)

Aggregations

Workspace (org.opencastproject.workspace.api.Workspace)71 Before (org.junit.Before)47 File (java.io.File)41 URI (java.net.URI)38 SecurityService (org.opencastproject.security.api.SecurityService)30 MediaPackageBuilder (org.opencastproject.mediapackage.MediaPackageBuilder)25 Job (org.opencastproject.job.api.Job)23 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)23 InputStream (java.io.InputStream)20 MediaPackage (org.opencastproject.mediapackage.MediaPackage)20 OrganizationDirectoryService (org.opencastproject.security.api.OrganizationDirectoryService)19 ServiceRegistry (org.opencastproject.serviceregistry.api.ServiceRegistry)18 Test (org.junit.Test)17 UserDirectoryService (org.opencastproject.security.api.UserDirectoryService)17 ArrayList (java.util.ArrayList)15 JaxbUser (org.opencastproject.security.api.JaxbUser)15 Organization (org.opencastproject.security.api.Organization)14 ServiceRegistryInMemoryImpl (org.opencastproject.serviceregistry.api.ServiceRegistryInMemoryImpl)14 AuthorizationService (org.opencastproject.security.api.AuthorizationService)13 JaxbRole (org.opencastproject.security.api.JaxbRole)13