use of org.opencastproject.workflow.api.WorkflowOperationInstanceImpl in project opencast by opencast.
the class TagWorkflowOperationHandlerTest method testAllTagsFlavors.
@Test
public void testAllTagsFlavors() 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(mp);
operation.setConfiguration(TagWorkflowOperationHandler.SOURCE_FLAVORS_PROPERTY, "presenter/source");
operation.setConfiguration(TagWorkflowOperationHandler.TARGET_FLAVOR_PROPERTY, "presenter/test");
operation.setConfiguration(TagWorkflowOperationHandler.TARGET_TAGS_PROPERTY, "tag1,tag2");
operation.setConfiguration(TagWorkflowOperationHandler.COPY_PROPERTY, "false");
WorkflowOperationResult result = operationHandler.start(instance, null);
MediaPackage resultingMediapackage = result.getMediaPackage();
Track track = resultingMediapackage.getTrack("track-2");
Assert.assertEquals("presenter/test", track.getFlavor().toString());
Assert.assertEquals("tag1", track.getTags()[0]);
Assert.assertEquals("tag2", track.getTags()[1]);
instance = new WorkflowInstanceImpl();
ops = new ArrayList<WorkflowOperationInstance>();
operation = new WorkflowOperationInstanceImpl("test", OperationState.INSTANTIATED);
ops.add(operation);
instance.setOperations(ops);
instance.setMediaPackage(resultingMediapackage);
operation.setConfiguration(TagWorkflowOperationHandler.SOURCE_TAGS_PROPERTY, "tag1");
operation.setConfiguration(TagWorkflowOperationHandler.TARGET_FLAVOR_PROPERTY, "presenter/source");
operation.setConfiguration(TagWorkflowOperationHandler.TARGET_TAGS_PROPERTY, "-tag1,+tag3");
operation.setConfiguration(TagWorkflowOperationHandler.COPY_PROPERTY, "false");
result = operationHandler.start(instance, null);
resultingMediapackage = result.getMediaPackage();
track = resultingMediapackage.getTrack("track-2");
Assert.assertEquals("presenter/source", track.getFlavor().toString());
Assert.assertEquals("tag2", track.getTags()[0]);
Assert.assertEquals("tag3", track.getTags()[1]);
}
use of org.opencastproject.workflow.api.WorkflowOperationInstanceImpl 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.workflow.api.WorkflowOperationInstanceImpl 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
}
}
use of org.opencastproject.workflow.api.WorkflowOperationInstanceImpl 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);
}
}
use of org.opencastproject.workflow.api.WorkflowOperationInstanceImpl 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
}
}
Aggregations