use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class CopyWorkflowOperationHandlerTest method testSuccessfullCopy.
@Test
public void testSuccessfullCopy() throws Exception {
String copyTargetDirectory = videoFile.getParent();
String copyFileName = "testCopy";
StringBuilder sb = new StringBuilder().append(copyTargetDirectory).append("/").append(copyFileName).append(".mov");
File copy = new File(sb.toString());
// operation configuration
Map<String, String> configurations = new HashMap<String, String>();
configurations.put(CopyWorkflowOperationHandler.OPT_SOURCE_FLAVORS, "presentation/source");
configurations.put(CopyWorkflowOperationHandler.OPT_SOURCE_TAGS, "first");
configurations.put(CopyWorkflowOperationHandler.OPT_TARGET_DIRECTORY, copyTargetDirectory);
configurations.put(CopyWorkflowOperationHandler.OPT_TARGET_FILENAME, copyFileName);
// run the operation handler
WorkflowOperationResult result = getWorkflowOperationResult(mp, configurations);
Assert.assertEquals(Action.CONTINUE, result.getAction());
Assert.assertTrue(copy.exists());
}
use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class CopyWorkflowOperationHandlerTest method testOptionalFilename.
@Test
public void testOptionalFilename() throws Exception {
File copy = new File(UrlSupport.concat(videoFile.getParent(), "copy", videoFile.getName()));
String copyTargetDirectory = copy.getParent();
FileUtils.forceMkdir(copy);
// operation configuration
Map<String, String> configurations = new HashMap<String, String>();
configurations.put(CopyWorkflowOperationHandler.OPT_SOURCE_FLAVORS, "presentation/source");
configurations.put(CopyWorkflowOperationHandler.OPT_SOURCE_TAGS, "first");
configurations.put(CopyWorkflowOperationHandler.OPT_TARGET_DIRECTORY, copyTargetDirectory);
// run the operation handler
WorkflowOperationResult result = getWorkflowOperationResult(mp, configurations);
Assert.assertEquals(Action.CONTINUE, result.getAction());
Assert.assertTrue(copy.exists());
}
use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class DuplicateEventWorkflowOperationHandlerTest method testOverrideTags.
@Test
public void testOverrideTags() throws Exception {
mockDependencies(1);
// operation configuration
Map<String, String> configurations = new HashMap<>();
configurations.put(SOURCE_FLAVORS_PROPERTY, "presenter/source");
configurations.put(SOURCE_TAGS_PROPERTY, "archive");
configurations.put(TARGET_TAGS_PROPERTY, "tag1,tag2");
configurations.put(NUMBER_PROPERTY, "" + 1);
configurations.put(MAX_NUMBER_PROPERTY, "" + 10);
configurations.put(PROPERTY_NAMESPACES_PROPERTY, "org.opencastproject.assetmanager.security");
configurations.put(COPY_NUMBER_PREFIX_PROPERTY, "copy");
// run the operation handler
WorkflowOperationResult result = getWorkflowOperationResult(mp, configurations);
Assert.assertEquals(Action.CONTINUE, result.getAction());
Track track = clonedMediaPackages.getValue().getTracksByTag("tag1")[0];
Assert.assertEquals("tag1", track.getTags()[0]);
Assert.assertEquals("tag2", track.getTags()[1]);
}
use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class SeriesWorkflowOperationHandlerTest method testExtraMetadata.
@Test
public void testExtraMetadata() throws WorkflowOperationException {
final EName otherProperty = new EName(DublinCore.TERMS_NS_URI, "my-custom-property");
final String otherValue = "foobar";
// Add extra metadata to the series catalog.
seriesCatalog.set(DublinCore.PROPERTY_LANGUAGE, "Opencastian");
seriesCatalog.set(otherProperty, otherValue);
seriesCatalog.set(DublinCore.PROPERTY_CONTRIBUTOR, Arrays.asList(new DublinCoreValue[] { DublinCoreValue.mk("Mr. Contry Bute"), DublinCoreValue.mk("Mrs. Jane Doe") }));
// Prepare "copy metadata" property
String[] extraMetadata = { // Append a full metadata field, with NS
DublinCore.PROPERTY_LANGUAGE.toString(), // Field without namespace
DublinCore.PROPERTY_CONTRIBUTOR.getLocalName(), // Field with a namespace different than the default
otherProperty.toString(), // Field that does not exist in the series catalog
"does-not-exist" };
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);
MediaPackage clone = (MediaPackage) mp.clone();
operation.setConfiguration(SeriesWorkflowOperationHandler.SERIES_PROPERTY, "series1");
operation.setConfiguration(SeriesWorkflowOperationHandler.ATTACH_PROPERTY, "*");
operation.setConfiguration(SeriesWorkflowOperationHandler.APPLY_ACL_PROPERTY, "false");
operation.setConfiguration(SeriesWorkflowOperationHandler.COPY_METADATA_PROPERTY, StringUtils.join(extraMetadata, ", "));
WorkflowOperationResult result = operationHandler.start(instance, null);
Assert.assertEquals(Action.CONTINUE, result.getAction());
MediaPackage resultingMediapackage = result.getMediaPackage();
// Get episode DublinCore
DublinCoreCatalog episodeCatalog = DublinCores.read(capturedStream.getValue());
Assert.assertEquals("series1", resultingMediapackage.getSeries());
Assert.assertEquals("Series 1", resultingMediapackage.getSeriesTitle());
Assert.assertEquals(clone.getElements().length + 1, resultingMediapackage.getElements().length);
// Check the extra metadata were copied into the dublincore (only those present in the series catalog)
Assert.assertTrue(episodeCatalog.hasValue(DublinCore.PROPERTY_CONTRIBUTOR));
Assert.assertEquals(seriesCatalog.get(DublinCore.PROPERTY_CONTRIBUTOR), episodeCatalog.get(DublinCore.PROPERTY_CONTRIBUTOR));
Assert.assertTrue(episodeCatalog.hasValue(DublinCore.PROPERTY_LANGUAGE));
Assert.assertEquals(seriesCatalog.get(DublinCore.PROPERTY_LANGUAGE), episodeCatalog.get(DublinCore.PROPERTY_LANGUAGE));
Assert.assertTrue(episodeCatalog.hasValue(otherProperty));
Assert.assertEquals(seriesCatalog.get(otherProperty), episodeCatalog.get(otherProperty));
Assert.assertFalse(episodeCatalog.hasValue(new EName(DublinCore.TERMS_NS_URI, "does-not-exist")));
}
use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.
the class SeriesWorkflowOperationHandlerTest method testAttachExtendedOnly.
@Test
public void testAttachExtendedOnly() 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(mp);
MediaPackage clone = (MediaPackage) mp.clone();
operation.setConfiguration(SeriesWorkflowOperationHandler.SERIES_PROPERTY, "series1");
operation.setConfiguration(SeriesWorkflowOperationHandler.ATTACH_PROPERTY, "creativecommons/*");
operation.setConfiguration(SeriesWorkflowOperationHandler.APPLY_ACL_PROPERTY, "false");
WorkflowOperationResult result = operationHandler.start(instance, null);
Assert.assertEquals(Action.CONTINUE, result.getAction());
MediaPackage resultingMediapackage = result.getMediaPackage();
Assert.assertEquals("series1", resultingMediapackage.getSeries());
Assert.assertEquals("Series 1", resultingMediapackage.getSeriesTitle());
Assert.assertEquals(clone.getElements().length + 1, resultingMediapackage.getElements().length);
}
Aggregations