Search in sources :

Example 1 with WorkflowInstanceImpl

use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.

the class IngestRestServiceTest method testLegacyMediaPackageIdPropertyUsingIngest.

@Test
public void testLegacyMediaPackageIdPropertyUsingIngest() throws Exception {
    // Create a mock ingest service
    Capture<Map<String, String>> workflowConfigCapture = EasyMock.newCapture();
    IngestService ingestService = EasyMock.createNiceMock(IngestService.class);
    EasyMock.expect(ingestService.createMediaPackage()).andReturn(MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew());
    EasyMock.expect(ingestService.ingest(EasyMock.anyObject(MediaPackage.class), EasyMock.anyString(), EasyMock.capture(workflowConfigCapture))).andReturn(new WorkflowInstanceImpl());
    EasyMock.replay(ingestService);
    restService.setIngestService(ingestService);
    String mpId = "6f7a7850-3232-4719-9064-24c9bad2832f";
    MultivaluedMap<String, String> metadataMap = new MetadataMap<>();
    Response createMediaPackage = restService.createMediaPackage();
    MediaPackage mp = (MediaPackage) createMediaPackage.getEntity();
    metadataMap.add("mediaPackage", MediaPackageParser.getAsXml(mp));
    metadataMap.add(IngestRestService.WORKFLOW_INSTANCE_ID_PARAM, mpId);
    Response response = restService.ingest(metadataMap);
    Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus());
    Map<String, String> config = workflowConfigCapture.getValue();
    Assert.assertFalse(config.isEmpty());
    Assert.assertEquals(mpId, config.get(IngestServiceImpl.LEGACY_MEDIAPACKAGE_ID_KEY));
}
Also used : Response(javax.ws.rs.core.Response) MetadataMap(org.apache.cxf.jaxrs.impl.MetadataMap) WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) IngestService(org.opencastproject.ingest.api.IngestService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) MetadataMap(org.apache.cxf.jaxrs.impl.MetadataMap) Map(java.util.Map) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Test(org.junit.Test)

Example 2 with WorkflowInstanceImpl

use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.

the class IngestRestServiceTest method setupAddZippedMediaPackageIngestService.

@SuppressWarnings({ "unchecked", "deprecation" })
private IngestService setupAddZippedMediaPackageIngestService() {
    // Create a mock ingest service
    IngestService ingestService = EasyMock.createNiceMock(IngestService.class);
    try {
        EasyMock.expect(ingestService.addZippedMediaPackage(EasyMock.anyObject(InputStream.class), EasyMock.anyString(), EasyMock.anyObject(Map.class), EasyMock.anyLong())).andAnswer(() -> {
            limitVerifier.callback();
            return new WorkflowInstanceImpl();
        }).anyTimes();
        EasyMock.expect(ingestService.addZippedMediaPackage(EasyMock.anyObject(InputStream.class), EasyMock.anyString(), EasyMock.anyObject(Map.class))).andAnswer(() -> {
            limitVerifier.callback();
            return new WorkflowInstanceImpl();
        }).anyTimes();
    } catch (Exception e) {
        Assert.fail("Threw exception " + e.getMessage());
    }
    EasyMock.replay(ingestService);
    return ingestService;
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) IngestService(org.opencastproject.ingest.api.IngestService) IOException(java.io.IOException)

Example 3 with WorkflowInstanceImpl

use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.

the class IngestRestServiceTest method testLegacyMediaPackageIdPropertyUsingZippedIngest.

@Test
public void testLegacyMediaPackageIdPropertyUsingZippedIngest() throws Exception {
    // Create a mock ingest service
    Capture<Map<String, String>> workflowConfigCapture = EasyMock.newCapture();
    IngestService ingestService = EasyMock.createNiceMock(IngestService.class);
    EasyMock.expect(ingestService.addZippedMediaPackage(EasyMock.anyObject(InputStream.class), EasyMock.anyString(), EasyMock.capture(workflowConfigCapture))).andReturn(new WorkflowInstanceImpl());
    EasyMock.replay(ingestService);
    restService.setIngestService(ingestService);
    String mpId = "6f7a7850-3232-4719-9064-24c9bad2832f";
    Response response = restService.addZippedMediaPackage(setupAddZippedMediaPackageHttpServletRequest(), "test", mpId);
    Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus());
    Map<String, String> config = workflowConfigCapture.getValue();
    Assert.assertFalse(config.isEmpty());
    Assert.assertEquals(mpId, config.get(IngestServiceImpl.LEGACY_MEDIAPACKAGE_ID_KEY));
}
Also used : Response(javax.ws.rs.core.Response) WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) IngestService(org.opencastproject.ingest.api.IngestService) ServletInputStream(javax.servlet.ServletInputStream) InputStream(java.io.InputStream) MetadataMap(org.apache.cxf.jaxrs.impl.MetadataMap) Map(java.util.Map) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Test(org.junit.Test)

Example 4 with WorkflowInstanceImpl

use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.

the class CopyWorkflowOperationHandlerTest method getWorkflowOperationResult.

private WorkflowOperationResult getWorkflowOperationResult(MediaPackage mp, Map<String, String> configurations) throws WorkflowOperationException {
    // Add the mediapackage to a workflow instance
    WorkflowInstanceImpl workflowInstance = new WorkflowInstanceImpl();
    workflowInstance.setId(1);
    workflowInstance.setState(WorkflowState.RUNNING);
    workflowInstance.setMediaPackage(mp);
    WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("op", OperationState.RUNNING);
    operation.setTemplate("copy");
    operation.setState(OperationState.RUNNING);
    for (String key : configurations.keySet()) {
        operation.setConfiguration(key, configurations.get(key));
    }
    List<WorkflowOperationInstance> operationsList = new ArrayList<WorkflowOperationInstance>();
    operationsList.add(operation);
    workflowInstance.setOperations(operationsList);
    // Run the media package through the operation handler, ensuring that metadata gets added
    return operationHandler.start(workflowInstance, null);
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) ArrayList(java.util.ArrayList) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl)

Example 5 with WorkflowInstanceImpl

use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.

the class DuplicateEventWorkflowOperationHandlerTest method getWorkflowOperationResult.

private WorkflowOperationResult getWorkflowOperationResult(MediaPackage mp, Map<String, String> configurations) throws WorkflowOperationException {
    // Add the mediapackage to a workflow instance
    WorkflowInstanceImpl workflowInstance = new WorkflowInstanceImpl();
    workflowInstance.setId(1);
    workflowInstance.setState(WorkflowState.RUNNING);
    workflowInstance.setMediaPackage(mp);
    WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("op", OperationState.RUNNING);
    operation.setTemplate("create-event");
    operation.setState(OperationState.RUNNING);
    for (String key : configurations.keySet()) {
        operation.setConfiguration(key, configurations.get(key));
    }
    List<WorkflowOperationInstance> operationsList = new ArrayList<>();
    operationsList.add(operation);
    workflowInstance.setOperations(operationsList);
    // Run the media package through the operation handler
    return operationHandler.start(workflowInstance, null);
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) ArrayList(java.util.ArrayList) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) EasyMock.anyString(org.easymock.EasyMock.anyString)

Aggregations

WorkflowInstanceImpl (org.opencastproject.workflow.api.WorkflowInstanceImpl)57 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)37 ArrayList (java.util.ArrayList)34 WorkflowOperationInstanceImpl (org.opencastproject.workflow.api.WorkflowOperationInstanceImpl)31 Test (org.junit.Test)27 WorkflowOperationResult (org.opencastproject.workflow.api.WorkflowOperationResult)17 MediaPackage (org.opencastproject.mediapackage.MediaPackage)12 Job (org.opencastproject.job.api.Job)9 Track (org.opencastproject.mediapackage.Track)9 URI (java.net.URI)8 Before (org.junit.Before)8 HashMap (java.util.HashMap)7 NotFoundException (org.opencastproject.util.NotFoundException)7 WorkflowDefinitionImpl (org.opencastproject.workflow.api.WorkflowDefinitionImpl)7 MediaPackageBuilder (org.opencastproject.mediapackage.MediaPackageBuilder)6 WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)6 WorkflowOperationException (org.opencastproject.workflow.api.WorkflowOperationException)6 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)5 ServiceRegistry (org.opencastproject.serviceregistry.api.ServiceRegistry)5 File (java.io.File)4