Search in sources :

Example 66 with WorkflowOperationResult

use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.

the class StartTranscriptionOperationHandlerTest method testStartSelectByFlavor.

@Test
public void testStartSelectByFlavor() throws Exception {
    operation.setConfiguration(StartTranscriptionOperationHandler.SOURCE_FLAVOR, "audio/ogg");
    WorkflowOperationResult result = operationHandler.start(workflowInstance, null);
    Assert.assertEquals(Action.CONTINUE, result.getAction());
    Assert.assertEquals("audioTrack1", capturedTrack.getValue().getIdentifier());
}
Also used : WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 67 with WorkflowOperationResult

use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.

the class AttachTranscriptionOperationHandlerTest method testStartWebVtt.

@Test
public void testStartWebVtt() throws Exception {
    EasyMock.expect(captionService.convert(EasyMock.anyObject(Attachment.class), EasyMock.anyObject(String.class), EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn(job2);
    EasyMock.replay(captionService);
    operation.setConfiguration(AttachTranscriptionOperationHandler.TRANSCRIPTION_JOB_ID, "transcriptionJob");
    // operation.setConfiguration(AttachTranscriptionOperationHandler.TARGET_FLAVOR, "captions/timedtext");
    operation.setConfiguration(AttachTranscriptionOperationHandler.TARGET_TAG, "tag1,tag2");
    operation.setConfiguration(AttachTranscriptionOperationHandler.TARGET_CAPTION_FORMAT, "vtt");
    WorkflowOperationResult result = operationHandler.start(workflowInstance, null);
    Assert.assertEquals(Action.CONTINUE, result.getAction());
    MediaPackage updatedMp = result.getMediaPackage();
    Attachment[] attachments = updatedMp.getAttachments(MediaPackageElementFlavor.parseFlavor("captions/vtt+en"));
    Assert.assertNotNull(attachments);
    Assert.assertEquals(1, attachments.length);
    Assert.assertNotNull(attachments[0].getTags());
    Assert.assertEquals(3, attachments[0].getTags().length);
    Assert.assertEquals("lang:en", attachments[0].getTags()[0]);
    Assert.assertEquals("tag1", attachments[0].getTags()[1]);
    Assert.assertEquals("tag2", attachments[0].getTags()[2]);
}
Also used : MediaPackage(org.opencastproject.mediapackage.MediaPackage) Attachment(org.opencastproject.mediapackage.Attachment) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 68 with WorkflowOperationResult

use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.

the class AttachTranscriptionOperationHandlerTest method testStartDfxp.

@Test
public void testStartDfxp() throws Exception {
    EasyMock.expect(captionService.convert(EasyMock.anyObject(Attachment.class), EasyMock.anyObject(String.class), EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn(job1);
    EasyMock.replay(captionService);
    operation.setConfiguration(AttachTranscriptionOperationHandler.TRANSCRIPTION_JOB_ID, "transcriptionJob");
    // operation.setConfiguration(AttachTranscriptionOperationHandler.TARGET_FLAVOR, "captions/timedtext");
    operation.setConfiguration(AttachTranscriptionOperationHandler.TARGET_TAG, "tag1,tag2");
    operation.setConfiguration(AttachTranscriptionOperationHandler.TARGET_CAPTION_FORMAT, "dfxp");
    WorkflowOperationResult result = operationHandler.start(workflowInstance, null);
    Assert.assertEquals(Action.CONTINUE, result.getAction());
    MediaPackage updatedMp = result.getMediaPackage();
    Attachment[] attachments = updatedMp.getAttachments(MediaPackageElementFlavor.parseFlavor("captions/dfxp+en"));
    Assert.assertNotNull(attachments);
    Assert.assertEquals(1, attachments.length);
    Assert.assertNotNull(attachments[0].getTags());
    Assert.assertEquals(3, attachments[0].getTags().length);
    Assert.assertEquals("lang:en", attachments[0].getTags()[0]);
    Assert.assertEquals("tag1", attachments[0].getTags()[1]);
    Assert.assertEquals("tag2", attachments[0].getTags()[2]);
}
Also used : MediaPackage(org.opencastproject.mediapackage.MediaPackage) Attachment(org.opencastproject.mediapackage.Attachment) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 69 with WorkflowOperationResult

use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.

the class CopyWorkflowOperationHandlerTest method testCopyWithNoElementMatchingFlavorsTags.

@Test
public void testCopyWithNoElementMatchingFlavorsTags() throws Exception {
    // operation configuration
    Map<String, String> configurations = new HashMap<String, String>();
    configurations.put(CopyWorkflowOperationHandler.OPT_SOURCE_FLAVORS, "no-video/source");
    configurations.put(CopyWorkflowOperationHandler.OPT_SOURCE_TAGS, "engage,rss");
    configurations.put(CopyWorkflowOperationHandler.OPT_TARGET_DIRECTORY, videoFile.getParent());
    configurations.put(CopyWorkflowOperationHandler.OPT_TARGET_FILENAME, "testCopy");
    // run the operation handler
    WorkflowOperationResult result = getWorkflowOperationResult(mp, configurations);
    Assert.assertEquals(Action.SKIP, result.getAction());
}
Also used : HashMap(java.util.HashMap) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Test(org.junit.Test)

Example 70 with WorkflowOperationResult

use of org.opencastproject.workflow.api.WorkflowOperationResult in project opencast by opencast.

the class DuplicateEventWorkflowOperationHandlerTest method testRemoveAndAddTags.

@Test
public void testRemoveAndAddTags() throws Exception {
    mockDependencies(1);
    Map<String, String> configurations = new HashMap<>();
    configurations.put(SOURCE_FLAVORS_PROPERTY, "*/*");
    configurations.put(SOURCE_TAGS_PROPERTY, "part1");
    configurations.put(TARGET_TAGS_PROPERTY, "-part1,+tag3");
    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("tag3")[0];
    final List<String> newTags = Arrays.asList(track.getTags());
    final List<String> originalTags = Arrays.asList(mp.getTracksByTag("part1")[0].getTags());
    Assert.assertEquals(originalTags.size(), newTags.size());
    Assert.assertTrue(newTags.contains("tag3"));
    Assert.assertFalse(newTags.contains("part1"));
}
Also used : HashMap(java.util.HashMap) EasyMock.anyString(org.easymock.EasyMock.anyString) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) Track(org.opencastproject.mediapackage.Track) 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