use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.
the class IngestRestServiceTest method testLegacyMediaPackageIdPropertyUsingIngest.
@Test
public void testLegacyMediaPackageIdPropertyUsingIngest() throws Exception {
// Create a mock ingest service
Capture<Map<String, String>> workflowConfigCapture = EasyMock.newCapture();
IngestService ingestService = EasyMock.createNiceMock(IngestService.class);
EasyMock.expect(ingestService.createMediaPackage()).andReturn(MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew());
EasyMock.expect(ingestService.ingest(EasyMock.anyObject(MediaPackage.class), EasyMock.anyString(), EasyMock.capture(workflowConfigCapture))).andReturn(new WorkflowInstanceImpl());
EasyMock.replay(ingestService);
restService.setIngestService(ingestService);
String mpId = "6f7a7850-3232-4719-9064-24c9bad2832f";
MultivaluedMap<String, String> metadataMap = new MetadataMap<>();
Response createMediaPackage = restService.createMediaPackage();
MediaPackage mp = (MediaPackage) createMediaPackage.getEntity();
metadataMap.add("mediaPackage", MediaPackageParser.getAsXml(mp));
metadataMap.add(IngestRestService.WORKFLOW_INSTANCE_ID_PARAM, mpId);
Response response = restService.ingest(metadataMap);
Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus());
Map<String, String> config = workflowConfigCapture.getValue();
Assert.assertFalse(config.isEmpty());
Assert.assertEquals(mpId, config.get(IngestServiceImpl.LEGACY_MEDIAPACKAGE_ID_KEY));
}
use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.
the class IngestRestServiceTest method setupAddZippedMediaPackageIngestService.
@SuppressWarnings({ "unchecked", "deprecation" })
private IngestService setupAddZippedMediaPackageIngestService() {
// Create a mock ingest service
IngestService ingestService = EasyMock.createNiceMock(IngestService.class);
try {
EasyMock.expect(ingestService.addZippedMediaPackage(EasyMock.anyObject(InputStream.class), EasyMock.anyString(), EasyMock.anyObject(Map.class), EasyMock.anyLong())).andAnswer(() -> {
limitVerifier.callback();
return new WorkflowInstanceImpl();
}).anyTimes();
EasyMock.expect(ingestService.addZippedMediaPackage(EasyMock.anyObject(InputStream.class), EasyMock.anyString(), EasyMock.anyObject(Map.class))).andAnswer(() -> {
limitVerifier.callback();
return new WorkflowInstanceImpl();
}).anyTimes();
} catch (Exception e) {
Assert.fail("Threw exception " + e.getMessage());
}
EasyMock.replay(ingestService);
return ingestService;
}
use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.
the class IngestRestServiceTest method testLegacyMediaPackageIdPropertyUsingZippedIngest.
@Test
public void testLegacyMediaPackageIdPropertyUsingZippedIngest() throws Exception {
// Create a mock ingest service
Capture<Map<String, String>> workflowConfigCapture = EasyMock.newCapture();
IngestService ingestService = EasyMock.createNiceMock(IngestService.class);
EasyMock.expect(ingestService.addZippedMediaPackage(EasyMock.anyObject(InputStream.class), EasyMock.anyString(), EasyMock.capture(workflowConfigCapture))).andReturn(new WorkflowInstanceImpl());
EasyMock.replay(ingestService);
restService.setIngestService(ingestService);
String mpId = "6f7a7850-3232-4719-9064-24c9bad2832f";
Response response = restService.addZippedMediaPackage(setupAddZippedMediaPackageHttpServletRequest(), "test", mpId);
Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus());
Map<String, String> config = workflowConfigCapture.getValue();
Assert.assertFalse(config.isEmpty());
Assert.assertEquals(mpId, config.get(IngestServiceImpl.LEGACY_MEDIAPACKAGE_ID_KEY));
}
use of org.opencastproject.workflow.api.WorkflowInstanceImpl in project opencast by opencast.
the class CopyWorkflowOperationHandlerTest 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("copy");
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.WorkflowInstanceImpl in project opencast by opencast.
the class DuplicateEventWorkflowOperationHandlerTest 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("create-event");
operation.setState(OperationState.RUNNING);
for (String key : configurations.keySet()) {
operation.setConfiguration(key, configurations.get(key));
}
List<WorkflowOperationInstance> operationsList = new ArrayList<>();
operationsList.add(operation);
workflowInstance.setOperations(operationsList);
// Run the media package through the operation handler
return operationHandler.start(workflowInstance, null);
}
Aggregations