use of org.opencastproject.animate.api.AnimateService in project opencast by opencast.
the class AnimateWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
handler = new AnimateWorkflowOperationHandler() {
@Override
protected JobBarrier.Result waitForStatus(Job... jobs) throws IllegalStateException, IllegalArgumentException {
JobBarrier.Result result = EasyMock.createNiceMock(JobBarrier.Result.class);
EasyMock.expect(result.isSuccess()).andReturn(true).anyTimes();
EasyMock.replay(result);
return result;
}
};
file = new File(getClass().getResource("/dc-episode.xml").toURI());
MediaPackage mediaPackage = new MediaPackageBuilderImpl().createNew();
mediaPackage.setIdentifier(new IdImpl("123-456"));
InputStream in = new FileInputStream(file);
Catalog catalog = DublinCores.read(in);
catalog.setFlavor(MediaPackageElements.EPISODE);
// catalog.setURI(getClass().getResource("/dc-episode.xml").toURI());
mediaPackage.add(catalog);
instance = EasyMock.createNiceMock(WorkflowOperationInstanceImpl.class);
EasyMock.expect(instance.getConfiguration("target-flavor")).andReturn("a/b").anyTimes();
EasyMock.expect(instance.getConfiguration("target-tags")).andReturn("a,b,c").anyTimes();
workflow = EasyMock.createMock(WorkflowInstanceImpl.class);
EasyMock.expect(workflow.getMediaPackage()).andReturn(mediaPackage).anyTimes();
EasyMock.expect(workflow.getCurrentOperation()).andReturn(instance).anyTimes();
Job job = new JobImpl(0);
job.setPayload(file.getAbsolutePath());
AnimateService animateService = EasyMock.createMock(AnimateService.class);
EasyMock.expect(animateService.animate(anyObject(), anyObject(), anyObject())).andReturn(job);
Workspace workspace = EasyMock.createMock(Workspace.class);
EasyMock.expect(workspace.put(anyString(), anyString(), anyString(), anyObject())).andReturn(file.toURI()).anyTimes();
EasyMock.expect(workspace.read(anyObject())).andAnswer(() -> getClass().getResourceAsStream("/dc-episode.xml")).anyTimes();
workspace.cleanup(anyObject(Id.class));
EasyMock.expectLastCall();
workspace.delete(anyObject(URI.class));
EasyMock.expectLastCall();
job = new JobImpl(1);
job.setPayload(MediaPackageElementParser.getAsXml(new TrackImpl()));
MediaInspectionService mediaInspectionService = EasyMock.createMock(MediaInspectionService.class);
EasyMock.expect(mediaInspectionService.enrich(anyObject(), anyBoolean())).andReturn(job).once();
EasyMock.replay(animateService, workspace, workflow, mediaInspectionService);
handler.setAnimateService(animateService);
handler.setMediaInspectionService(mediaInspectionService);
handler.setWorkspace(workspace);
}
Aggregations