Search in sources :

Example 11 with WorkflowInstanceImpl

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

the class ZipWorkflowOperationHandlerTest method testInvalidMediaPackage.

/*
   * MH-9759
   */
@Test
public void testInvalidMediaPackage() throws Exception {
    WorkflowInstanceImpl instance = new WorkflowInstanceImpl();
    List<WorkflowOperationInstance> ops = new ArrayList<WorkflowOperationInstance>();
    WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("test", OperationState.INSTANTIATED);
    ops.add(operation);
    instance.setOperations(ops);
    instance.setMediaPackage(null);
    operation.setConfiguration(ZipWorkflowOperationHandler.ZIP_COLLECTION_PROPERTY, "failed-zips");
    operation.setConfiguration(ZipWorkflowOperationHandler.INCLUDE_FLAVORS_PROPERTY, "*/source,dublincore/*");
    operation.setConfiguration(ZipWorkflowOperationHandler.TARGET_FLAVOR_PROPERTY, "archive/zip");
    operation.setConfiguration(ZipWorkflowOperationHandler.COMPRESS_PROPERTY, "false");
    try {
        WorkflowOperationResult result = operationHandler.start(instance, null);
        Assert.fail("A null mediapackage is passed so an exception should be thrown");
    } catch (WorkflowOperationException e) {
    // expecting exception
    }
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) ArrayList(java.util.ArrayList) WorkflowOperationException(org.opencastproject.workflow.api.WorkflowOperationException) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 12 with WorkflowInstanceImpl

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

the class ZipWorkflowOperationHandlerTest method testConfigKeyTargetFlavorDefaultValue.

/*
   * MH-10043
   */
@Test
public void testConfigKeyTargetFlavorDefaultValue() {
    WorkflowInstanceImpl instance = new WorkflowInstanceImpl();
    List<WorkflowOperationInstance> ops = new ArrayList<WorkflowOperationInstance>();
    WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("test", OperationState.INSTANTIATED);
    ops.add(operation);
    instance.setOperations(ops);
    instance.setMediaPackage(mp);
    operation.setConfiguration(ZipWorkflowOperationHandler.ZIP_COLLECTION_PROPERTY, "failed-zips");
    operation.setConfiguration(ZipWorkflowOperationHandler.INCLUDE_FLAVORS_PROPERTY, "*/source,dublincore/*");
    // targe-flavor is not mandatory
    // operation.setConfiguration(ZipWorkflowOperationHandler.TARGET_FLAVOR_PROPERTY, "archive/zip");
    operation.setConfiguration(ZipWorkflowOperationHandler.COMPRESS_PROPERTY, "false");
    try {
        WorkflowOperationResult result = operationHandler.start(instance, null);
        Assert.assertEquals("workflow result action not CONTINUE: " + result.getAction(), WorkflowOperationResult.Action.CONTINUE, result.getAction());
    } catch (WorkflowOperationException e) {
        Assert.fail("missing target-flavor and no default value kicked in: " + e);
    }
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) ArrayList(java.util.ArrayList) WorkflowOperationException(org.opencastproject.workflow.api.WorkflowOperationException) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 13 with WorkflowInstanceImpl

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

the class ZipWorkflowOperationHandlerTest method testInvalidWorkflow.

/*
   * MH-9757
   */
@Test
public void testInvalidWorkflow() throws Exception {
    WorkflowInstanceImpl instance = new WorkflowInstanceImpl();
    List<WorkflowOperationInstance> ops = new ArrayList<WorkflowOperationInstance>();
    WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("test", OperationState.INSTANTIATED);
    ops.add(operation);
    instance.setOperations(ops);
    operation.setConfiguration(ZipWorkflowOperationHandler.ZIP_COLLECTION_PROPERTY, "failed-zips");
    operation.setConfiguration(ZipWorkflowOperationHandler.INCLUDE_FLAVORS_PROPERTY, "*/source,dublincore/*");
    operation.setConfiguration(ZipWorkflowOperationHandler.TARGET_FLAVOR_PROPERTY, "archive/zip");
    operation.setConfiguration(ZipWorkflowOperationHandler.COMPRESS_PROPERTY, "false");
    try {
        WorkflowOperationResult result = operationHandler.start(null, null);
        Assert.fail("A null workflow is passed so an exception should be thrown");
    } catch (WorkflowOperationException e) {
    // expecting exception
    }
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) ArrayList(java.util.ArrayList) WorkflowOperationException(org.opencastproject.workflow.api.WorkflowOperationException) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 14 with WorkflowInstanceImpl

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

the class ComposeWorkflowOperationHandlerTest 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("compose");
    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 15 with WorkflowInstanceImpl

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

the class CompositeWorkflowOperationHandlerTest 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("composite");
    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)

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