use of org.opencastproject.workflow.api.WorkflowOperationInstanceImpl in project opencast by opencast.
the class ComposeWorkflowOperationHandlerTest method getWorkflowOperationResult.
private WorkflowOperationResult getWorkflowOperationResult(MediaPackage mp, Map<String, String> configurations) throws WorkflowOperationException {
// Add the mediapackage to a workflow instance
WorkflowInstanceImpl workflowInstance = new WorkflowInstanceImpl();
workflowInstance.setId(1);
workflowInstance.setState(WorkflowState.RUNNING);
workflowInstance.setMediaPackage(mp);
WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("op", OperationState.RUNNING);
operation.setTemplate("compose");
operation.setState(OperationState.RUNNING);
for (String key : configurations.keySet()) {
operation.setConfiguration(key, configurations.get(key));
}
List<WorkflowOperationInstance> operationsList = new ArrayList<WorkflowOperationInstance>();
operationsList.add(operation);
workflowInstance.setOperations(operationsList);
// Run the media package through the operation handler, ensuring that metadata gets added
return operationHandler.start(workflowInstance, null);
}
use of org.opencastproject.workflow.api.WorkflowOperationInstanceImpl in project opencast by opencast.
the class CompositeWorkflowOperationHandlerTest method getWorkflowOperationResult.
private WorkflowOperationResult getWorkflowOperationResult(MediaPackage mp, Map<String, String> configurations) throws WorkflowOperationException {
// Add the mediapackage to a workflow instance
WorkflowInstanceImpl workflowInstance = new WorkflowInstanceImpl();
workflowInstance.setId(1);
workflowInstance.setState(WorkflowState.RUNNING);
workflowInstance.setMediaPackage(mp);
WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("op", OperationState.RUNNING);
operation.setTemplate("composite");
operation.setState(OperationState.RUNNING);
for (String key : configurations.keySet()) {
operation.setConfiguration(key, configurations.get(key));
}
List<WorkflowOperationInstance> operationsList = new ArrayList<WorkflowOperationInstance>();
operationsList.add(operation);
workflowInstance.setOperations(operationsList);
// Run the media package through the operation handler, ensuring that metadata gets added
return operationHandler.start(workflowInstance, null);
}
use of org.opencastproject.workflow.api.WorkflowOperationInstanceImpl in project opencast by opencast.
the class VideoEditorWorkflowOperationHandlerTest method getWorkflowInstance.
private WorkflowInstanceImpl getWorkflowInstance(MediaPackage mp, Map<String, String> configurations) {
WorkflowInstanceImpl workflowInstance = new WorkflowInstanceImpl();
workflowInstance.setId(1);
workflowInstance.setState(WorkflowInstance.WorkflowState.RUNNING);
workflowInstance.setMediaPackage(mp);
WorkflowOperationInstanceImpl operation = new WorkflowOperationInstanceImpl("op", WorkflowOperationInstance.OperationState.RUNNING);
operation.setTemplate("editor");
operation.setState(WorkflowOperationInstance.OperationState.RUNNING);
for (String key : configurations.keySet()) {
operation.setConfiguration(key, configurations.get(key));
}
List<WorkflowOperationInstance> operations = new ArrayList<WorkflowOperationInstance>(1);
operations.add(operation);
workflowInstance.setOperations(operations);
return workflowInstance;
}
use of org.opencastproject.workflow.api.WorkflowOperationInstanceImpl in project opencast by opencast.
the class EmailWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
uriMP = EmailWorkflowOperationHandlerTest.class.getResource("/email_mediapackage.xml").toURI();
mp = builder.loadFromXml(uriMP.toURL().openStream());
operationHandler = new EmailWorkflowOperationHandler();
EmailTemplateService emailTemplateService = EasyMock.createMock(EmailTemplateService.class);
EasyMock.expect(emailTemplateService.applyTemplate("DCE_workflow_2_body", "This is the media package: ${mediaPackage.identifier}", workflowInstance)).andReturn("This is the media package: 3e7bb56d-2fcc-4efe-9f0e-d6e56422f557");
EasyMock.expect(emailTemplateService.applyTemplate("template1", null, workflowInstance)).andReturn("This is the media package: 3e7bb56d-2fcc-4efe-9f0e-d6e56422f557");
EasyMock.expect(emailTemplateService.applyTemplate("templateNotFound", null, workflowInstance)).andReturn("TEMPLATE NOT FOUND!");
EasyMock.replay(emailTemplateService);
operationHandler.setEmailTemplateService(emailTemplateService);
SmtpService smtpService = EasyMock.createMock(SmtpService.class);
capturedTo = Capture.newInstance();
capturedCC = Capture.newInstance();
capturedBCC = Capture.newInstance();
capturedSubject = Capture.newInstance();
capturedBody = Capture.newInstance();
smtpService.send(EasyMock.capture(capturedTo), EasyMock.capture(capturedCC), EasyMock.capture(capturedBCC), EasyMock.capture(capturedSubject), EasyMock.capture(capturedBody));
EasyMock.expectLastCall().once();
EasyMock.replay(smtpService);
operationHandler.setSmtpService(smtpService);
workflowInstance.setId(1);
workflowInstance.setState(WorkflowState.RUNNING);
workflowInstance.setTemplate("DCE-workflow");
workflowInstance.setMediaPackage(mp);
WorkflowOperationInstanceImpl failedOperation1 = new WorkflowOperationInstanceImpl("operation1", OperationState.FAILED);
failedOperation1.setFailWorkflowOnException(true);
WorkflowOperationInstanceImpl failedOperation2 = new WorkflowOperationInstanceImpl("operation2", OperationState.FAILED);
failedOperation2.setFailWorkflowOnException(false);
operation = new WorkflowOperationInstanceImpl("email", OperationState.RUNNING);
List<WorkflowOperationInstance> operationList = new ArrayList<WorkflowOperationInstance>();
operationList.add(failedOperation1);
operationList.add(failedOperation2);
operationList.add(operation);
workflowInstance.setOperations(operationList);
}
use of org.opencastproject.workflow.api.WorkflowOperationInstanceImpl in project opencast by opencast.
the class StartTranscriptionOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder();
// Media package set up
URI mediaPackageURI = StartTranscriptionOperationHandlerTest.class.getResource("/mp.xml").toURI();
mediaPackage = builder.loadFromXml(mediaPackageURI.toURL().openStream());
// Service registry set up
Job job1 = EasyMock.createNiceMock(Job.class);
EasyMock.expect(job1.getId()).andReturn(1L);
EasyMock.expect(job1.getPayload()).andReturn(null).anyTimes();
EasyMock.expect(job1.getStatus()).andReturn(Job.Status.FINISHED);
EasyMock.expect(job1.getDateCreated()).andReturn(new Date());
EasyMock.expect(job1.getDateStarted()).andReturn(new Date());
EasyMock.expect(job1.getQueueTime()).andReturn(new Long(0));
EasyMock.replay(job1);
ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(job1);
EasyMock.replay(serviceRegistry);
// Transcription service set up
service = EasyMock.createStrictMock(TranscriptionService.class);
capturedTrack = Capture.newInstance();
EasyMock.expect(service.startTranscription(EasyMock.anyObject(String.class), EasyMock.capture(capturedTrack))).andReturn(null);
EasyMock.replay(service);
// Workflow set up
WorkflowDefinitionImpl def = new WorkflowDefinitionImpl();
def.setId("DCE-start-transcription");
def.setPublished(true);
workflowInstance = new WorkflowInstanceImpl(def, mediaPackage, null, null, null, null);
workflowInstance.setId(1);
operation = new WorkflowOperationInstanceImpl("start-transcript", OperationState.RUNNING);
List<WorkflowOperationInstance> operationList = new ArrayList<WorkflowOperationInstance>();
operationList.add(operation);
workflowInstance.setOperations(operationList);
// Operation handler set up
operationHandler = new StartTranscriptionOperationHandler();
operationHandler.setTranscriptionService(service);
operationHandler.setServiceRegistry(serviceRegistry);
}
Aggregations