Search in sources :

Example 71 with WorkflowInstance

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);
}
Also used : WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) InputStream(java.io.InputStream) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Attachment(org.opencastproject.mediapackage.Attachment) AttachmentImpl(org.opencastproject.mediapackage.attachment.AttachmentImpl) WorkflowInstance(org.opencastproject.workflow.api.WorkflowInstance) URI(java.net.URI) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Workspace(org.opencastproject.workspace.api.Workspace) Test(org.junit.Test)

Example 72 with WorkflowInstance

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));
}
Also used : Organization(org.opencastproject.security.api.Organization) PresetProvider(org.opencastproject.presets.api.PresetProvider) HashMap(java.util.HashMap) WorkflowInstance(org.opencastproject.workflow.api.WorkflowInstance) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 73 with WorkflowInstance

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));
}
Also used : Organization(org.opencastproject.security.api.Organization) PresetProvider(org.opencastproject.presets.api.PresetProvider) HashMap(java.util.HashMap) NotFoundException(org.opencastproject.util.NotFoundException) WorkflowInstance(org.opencastproject.workflow.api.WorkflowInstance) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 74 with WorkflowInstance

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));
}
Also used : Organization(org.opencastproject.security.api.Organization) PresetProvider(org.opencastproject.presets.api.PresetProvider) HashMap(java.util.HashMap) WorkflowInstance(org.opencastproject.workflow.api.WorkflowInstance) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 75 with WorkflowInstance

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));
}
Also used : Organization(org.opencastproject.security.api.Organization) PresetProvider(org.opencastproject.presets.api.PresetProvider) HashMap(java.util.HashMap) WorkflowInstance(org.opencastproject.workflow.api.WorkflowInstance) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Aggregations

WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)94 Test (org.junit.Test)48 MediaPackage (org.opencastproject.mediapackage.MediaPackage)40 NotFoundException (org.opencastproject.util.NotFoundException)26 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)24 HashMap (java.util.HashMap)22 WorkflowDatabaseException (org.opencastproject.workflow.api.WorkflowDatabaseException)20 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)19 ArrayList (java.util.ArrayList)16 WorkflowQuery (org.opencastproject.workflow.api.WorkflowQuery)16 IOException (java.io.IOException)15 Organization (org.opencastproject.security.api.Organization)15 WorkflowSet (org.opencastproject.workflow.api.WorkflowSet)14 WorkflowException (org.opencastproject.workflow.api.WorkflowException)13 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)12 WorkflowDefinitionImpl (org.opencastproject.workflow.api.WorkflowDefinitionImpl)12 WorkflowOperationResult (org.opencastproject.workflow.api.WorkflowOperationResult)11 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)10 IndexServiceException (org.opencastproject.index.service.exception.IndexServiceException)9 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)9