use of org.opencastproject.workflow.api.WorkflowInstance in project opencast by opencast.
the class ImportWorkflowPropertiesWOHTest method testStartOp.
@Test
public void testStartOp() throws Exception {
final WorkflowOperationInstance woi = createMock(WorkflowOperationInstance.class);
expect(woi.getConfiguration("source-flavor")).andStubReturn(FLAVOR);
expect(woi.getConfiguration("keys")).andStubReturn("chapter, presenter_position, cover_marker_in_s");
replay(woi);
final Attachment att = new AttachmentImpl();
att.setURI(new URI(WF_PROPS_ATT_URI));
att.setFlavor(MediaPackageElementFlavor.parseFlavor(FLAVOR));
final MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
mp.add(att);
WorkflowInstance wi = createMock(WorkflowInstance.class);
expect(wi.getCurrentOperation()).andStubReturn(woi);
expect(wi.getMediaPackage()).andStubReturn(mp);
replay(wi);
try (InputStream is = ImportWorkflowPropertiesWOHTest.class.getResourceAsStream("/workflow-properties.xml")) {
Files.copy(is, tmpPropsFile, StandardCopyOption.REPLACE_EXISTING);
}
final Workspace workspace = createNiceMock(Workspace.class);
expect(workspace.get(new URI(WF_PROPS_ATT_URI))).andStubReturn(tmpPropsFile.toFile());
replay(workspace);
final ImportWorkflowPropertiesWOH woh = new ImportWorkflowPropertiesWOH();
woh.setWorkspace(workspace);
WorkflowOperationResult result = woh.start(wi, null);
Map<String, String> properties = result.getProperties();
Assert.assertTrue(properties.containsKey("chapter"));
Assert.assertEquals("true", properties.get("chapter"));
Assert.assertTrue(properties.containsKey("presenter_position"));
Assert.assertEquals("left", properties.get("presenter_position"));
Assert.assertTrue(properties.containsKey("cover_marker_in_s"));
Assert.assertEquals("30.674", properties.get("cover_marker_in_s"));
verify(wi);
}
use of org.opencastproject.workflow.api.WorkflowInstance in project opencast by opencast.
the class DefaultsWorkflowOperationHandlerTest method usesOrganizationLevelPreset.
@Test
public void usesOrganizationLevelPreset() 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(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.WorkflowInstance 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.WorkflowInstance 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.WorkflowInstance 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