use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class DefaultsWorkflowOperationHandlerTest method usesWorkflowLevelPresetDueToNotFound.
@Test
public void usesWorkflowLevelPresetDueToNotFound() throws WorkflowOperationException, NotFoundException {
Organization organization = EasyMock.createMock(Organization.class);
EasyMock.replay(organization);
String seriesID = "series-ID";
presetProvider = EasyMock.createMock(PresetProvider.class);
EasyMock.expect(presetProvider.getProperty(seriesID, OPT_KEY)).andThrow(new NotFoundException());
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(WORKFLOW_PRESET_VALUE, result.getProperties().get(OPT_KEY));
}
use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class DefaultsWorkflowOperationHandlerTest method testDefault.
@Test
public void testDefault() throws Exception {
// Workflow configuration
Map<String, String> workflowConfiguration = new HashMap<String, String>();
// Operation configuration
Map<String, String> operationConfiguration = new HashMap<String, String>();
operationConfiguration.put(OPT_KEY, DEFAULT_VALUE);
// Run the operation handler
WorkflowOperationResult workflowOperationResult = getWorkflowOperationResult(mp, workflowConfiguration, operationConfiguration);
String configurationValue = workflowOperationResult.getProperties().get(OPT_KEY);
// Make sure the default value has been applied
Assert.assertEquals(DEFAULT_VALUE, configurationValue);
}
use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class DefaultsWorkflowOperationHandlerTest method getWorkflowOperationResult.
private WorkflowOperationResult getWorkflowOperationResult(MediaPackage mp, Map<String, String> workflowConfiguration, Map<String, String> operationConfiguration) throws WorkflowOperationException {
// Add the mediapackage to a workflow instance
WorkflowInstanceImpl workflowInstance = new WorkflowInstanceImpl();
workflowInstance.setId(1);
workflowInstance.setState(WorkflowState.RUNNING);
workflowInstance.setMediaPackage(mp);
// Apply the workflow configuration
for (Map.Entry<String, String> entry : workflowConfiguration.entrySet()) {
workflowInstance.setConfiguration(entry.getKey(), entry.getValue());
}
WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl();
operation.setTemplate("defaults");
operation.setState(OperationState.RUNNING);
// Apply the workflow operation configuration
for (Map.Entry<String, String> entry : operationConfiguration.entrySet()) {
operation.setConfiguration(entry.getKey(), entry.getValue());
}
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
WorkflowOperationResult result = operationHandler.start(workflowInstance, null);
Assert.assertEquals(result.getAction(), Action.CONTINUE);
return result;
}
use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class DefaultsWorkflowOperationHandlerTest method usesSeriesLevelPreset.
@Test
public void usesSeriesLevelPreset() throws WorkflowOperationException, NotFoundException {
Organization organization = EasyMock.createMock(Organization.class);
EasyMock.replay(organization);
String seriesID = "series-ID";
presetProvider = EasyMock.createMock(PresetProvider.class);
EasyMock.expect(presetProvider.getProperty(seriesID, OPT_KEY)).andReturn(SERIES_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(SERIES_PRESET_VALUE, result.getProperties().get(OPT_KEY));
}
use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class DefaultsWorkflowOperationHandlerTest method usesWorkflowLevelPreset.
@Test
public void usesWorkflowLevelPreset() throws WorkflowOperationException, NotFoundException {
Organization organization = EasyMock.createMock(Organization.class);
EasyMock.replay(organization);
String seriesID = "series-ID";
presetProvider = EasyMock.createMock(PresetProvider.class);
EasyMock.expect(presetProvider.getProperty(seriesID, OPT_KEY)).andReturn(null);
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(WORKFLOW_PRESET_VALUE, result.getProperties().get(OPT_KEY));
}
Aggregations