Search in sources :

Example 11 with WorkflowOperationResult

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

Example 12 with WorkflowOperationResult

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));
}
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 13 with WorkflowOperationResult

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]);
}
Also used : MediaPackage(org.opencastproject.mediapackage.MediaPackage) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Catalog(org.opencastproject.mediapackage.Catalog) Test(org.junit.Test)

Example 14 with WorkflowOperationResult

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
    }
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) ArrayList(java.util.ArrayList) WorkflowOperationException(org.opencastproject.workflow.api.WorkflowOperationException) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 15 with WorkflowOperationResult

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);
    }
}
Also used : WorkflowInstanceImpl(org.opencastproject.workflow.api.WorkflowInstanceImpl) WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) ArrayList(java.util.ArrayList) WorkflowOperationException(org.opencastproject.workflow.api.WorkflowOperationException) WorkflowOperationInstanceImpl(org.opencastproject.workflow.api.WorkflowOperationInstanceImpl) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Aggregations

WorkflowOperationResult (org.opencastproject.workflow.api.WorkflowOperationResult)101 Test (org.junit.Test)85 HashMap (java.util.HashMap)46 MediaPackage (org.opencastproject.mediapackage.MediaPackage)35 Track (org.opencastproject.mediapackage.Track)34 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)28 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)26 ArrayList (java.util.ArrayList)19 WorkflowOperationException (org.opencastproject.workflow.api.WorkflowOperationException)19 WorkflowInstanceImpl (org.opencastproject.workflow.api.WorkflowInstanceImpl)17 Job (org.opencastproject.job.api.Job)13 TrackImpl (org.opencastproject.mediapackage.track.TrackImpl)11 WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)11 WorkflowOperationInstanceImpl (org.opencastproject.workflow.api.WorkflowOperationInstanceImpl)11 Catalog (org.opencastproject.mediapackage.Catalog)10 TrackSelector (org.opencastproject.mediapackage.selector.TrackSelector)9 URI (java.net.URI)7 File (java.io.File)6 Attachment (org.opencastproject.mediapackage.Attachment)6 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)6