use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class DefaultsWorkflowOperationHandlerTest method usesEventLevelPreset.
@Test
public void usesEventLevelPreset() throws WorkflowOperationException {
Organization organization = EasyMock.createMock(Organization.class);
EasyMock.replay(organization);
String seriesID = "series-ID";
Map<String, String> workflowConfiguration = new HashMap<String, String>();
workflowConfiguration.put(OPT_KEY, WORKFLOW_PRESET_VALUE);
WorkflowInstance workflowInstance = setupInstance(organization, seriesID, workflowConfiguration, true);
DefaultsWorkflowOperationHandler handler = new DefaultsWorkflowOperationHandler();
handler.setPresetProvider(presetProvider);
WorkflowOperationResult result = handler.start(workflowInstance, null);
assertEquals(EVENT_PRESET_VALUE, result.getProperties().get(OPT_KEY));
}
use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class DefaultsWorkflowOperationHandlerTest method usesOrganizationLevelPresetNullSeries.
@Test
public void usesOrganizationLevelPresetNullSeries() throws WorkflowOperationException, NotFoundException {
Organization organization = EasyMock.createMock(Organization.class);
EasyMock.replay(organization);
String seriesID = null;
presetProvider = EasyMock.createMock(PresetProvider.class);
EasyMock.expect(presetProvider.getProperty(seriesID, OPT_KEY)).andReturn(ORGANIZATION_PRESET_VALUE);
EasyMock.replay(presetProvider);
// Workflow configuration
Map<String, String> workflowConfiguration = new HashMap<String, String>();
workflowConfiguration.put(OPT_KEY, WORKFLOW_PRESET_VALUE);
WorkflowInstance workflowInstance = setupInstance(organization, seriesID, workflowConfiguration, false);
DefaultsWorkflowOperationHandler handler = new DefaultsWorkflowOperationHandler();
handler.setPresetProvider(presetProvider);
WorkflowOperationResult result = handler.start(workflowInstance, null);
assertEquals(ORGANIZATION_PRESET_VALUE, result.getProperties().get(OPT_KEY));
}
use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class TagByDublinCoreTermWOHTest method testMatchDefaultDCTerm.
@Test
public void testMatchDefaultDCTerm() throws Exception {
// Match == Default Value
operation.setConfiguration(TagByDublinCoreTermWOH.SOURCE_FLAVORS_PROPERTY, "dublincore/*");
operation.setConfiguration(TagByDublinCoreTermWOH.DCCATALOG_PROPERTY, "episode");
operation.setConfiguration(TagByDublinCoreTermWOH.DCTERM_PROPERTY, "source");
operation.setConfiguration(TagByDublinCoreTermWOH.DEFAULT_VALUE_PROPERTY, "Timbuktu");
operation.setConfiguration(TagByDublinCoreTermWOH.MATCH_VALUE_PROPERTY, "Timbuktu");
operation.setConfiguration(TagByDublinCoreTermWOH.TARGET_TAGS_PROPERTY, "tag1,tag2");
operation.setConfiguration(TagByDublinCoreTermWOH.COPY_PROPERTY, "false");
WorkflowOperationResult result = operationHandler.start(instance, null);
MediaPackage resultingMediapackage = result.getMediaPackage();
Catalog catalog = resultingMediapackage.getCatalog("catalog-1");
Assert.assertEquals(2, catalog.getTags().length);
Assert.assertEquals("tag1", catalog.getTags()[0]);
Assert.assertEquals("tag2", catalog.getTags()[1]);
}
use of org.opencastproject.workflow.api.WorkflowOperationResult 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.WorkflowOperationResult 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);
}
}
Aggregations