use of org.opencastproject.mediapackage.MediaPackageBuilderImpl in project opencast by opencast.
the class TestRestService method newAssetManager.
private static AssetManager newAssetManager() {
Snapshot snapshot = EasyMock.createNiceMock(Snapshot.class);
try {
EasyMock.expect(snapshot.getMediaPackage()).andReturn(new MediaPackageBuilderImpl().createNew()).anyTimes();
} catch (MediaPackageException e) {
throw new RuntimeException(e);
}
ARecord record = EasyMock.createNiceMock(ARecord.class);
EasyMock.expect(record.getSnapshot()).andReturn(Opt.some(snapshot)).anyTimes();
AResult result = EasyMock.createNiceMock(AResult.class);
EasyMock.expect(result.getRecords()).andReturn($(record)).anyTimes();
ASelectQuery select = EasyMock.createNiceMock(ASelectQuery.class);
EasyMock.expect(select.where(EasyMock.anyObject(Predicate.class))).andReturn(select).anyTimes();
EasyMock.expect(select.run()).andReturn(result).anyTimes();
Predicate predicate = EasyMock.createNiceMock(Predicate.class);
EasyMock.expect(predicate.and(EasyMock.anyObject(Predicate.class))).andReturn(predicate).anyTimes();
AQueryBuilder query = EasyMock.createNiceMock(AQueryBuilder.class);
VersionField version = EasyMock.createNiceMock(VersionField.class);
EasyMock.expect(query.version()).andReturn(version).anyTimes();
EasyMock.expect(query.mediaPackageId(EasyMock.anyString())).andReturn(predicate).anyTimes();
EasyMock.expect(query.select(EasyMock.anyObject(Target.class))).andReturn(select).anyTimes();
AssetManager assetManager = EasyMock.createNiceMock(AssetManager.class);
EasyMock.expect(assetManager.createQuery()).andReturn(query).anyTimes();
EasyMock.replay(assetManager, version, query, predicate, select, result, record, snapshot);
return assetManager;
}
use of org.opencastproject.mediapackage.MediaPackageBuilderImpl in project opencast by opencast.
the class AssetManagerMessageReceiverImplTest method testUpdateCreator.
@Test
public void testUpdateCreator() throws Exception {
MediaPackage mediaPackage = new MediaPackageBuilderImpl().loadFromXml(getClass().getResourceAsStream("/jobs_mediapackage1.xml"));
TakeSnapshot takeSnapshot = AssetManagerItem.add(workspace, mediaPackage, new AccessControlList(), 0, new Date());
// Test initial set of creator
assetManager.execute(takeSnapshot);
Event event = index.getEventResult();
assertNotNull(event);
assertEquals("Current user is expected to be creator as no other creator has been set explicitly", "Creator", event.getCreator());
// Test updating creator
event.setCreator("Hans");
index.setInitialEvent(event);
assetManager.execute(takeSnapshot);
event = index.getEventResult();
assertNotNull(event);
assertEquals("Creator has been updated", "Hans", event.getCreator());
}
use of org.opencastproject.mediapackage.MediaPackageBuilderImpl in project opencast by opencast.
the class WaveformWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
handler = new WaveformWorkflowOperationHandler() {
@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;
}
};
track = new TrackImpl();
track.setFlavor(MediaPackageElementFlavor.parseFlavor("xy/source"));
track.setAudio(Arrays.asList(null, null));
MediaPackageBuilder builder = new MediaPackageBuilderImpl();
MediaPackage mediaPackage = builder.createNew();
mediaPackage.setIdentifier(new IdImpl("123-456"));
mediaPackage.add(track);
instance = EasyMock.createNiceMock(WorkflowOperationInstanceImpl.class);
EasyMock.expect(instance.getConfiguration("target-flavor")).andReturn("*/*").anyTimes();
EasyMock.expect(instance.getConfiguration("target-tags")).andReturn("a,b,c").anyTimes();
workflow = EasyMock.createNiceMock(WorkflowInstanceImpl.class);
EasyMock.expect(workflow.getMediaPackage()).andReturn(mediaPackage).anyTimes();
EasyMock.expect(workflow.getCurrentOperation()).andReturn(instance).anyTimes();
Attachment payload = new AttachmentImpl();
payload.setIdentifier("x");
payload.setFlavor(MediaPackageElementFlavor.parseFlavor("xy/source"));
Job job = new JobImpl(0);
job.setPayload(MediaPackageElementParser.getAsXml(payload));
WaveformService waveformService = EasyMock.createNiceMock(WaveformService.class);
EasyMock.expect(waveformService.createWaveformImage(EasyMock.anyObject())).andReturn(job);
Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.replay(waveformService, workspace, workflow);
handler.setWaveformService(waveformService);
handler.setWorkspace(workspace);
}
use of org.opencastproject.mediapackage.MediaPackageBuilderImpl in project opencast by opencast.
the class LoggingWorkflowOperationHandlerTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageBuilder builder = new MediaPackageBuilderImpl();
MediaPackage mediaPackage = builder.createNew();
instance = EasyMock.createNiceMock(WorkflowOperationInstanceImpl.class);
EasyMock.expect(instance.getId()).andReturn(2L).anyTimes();
workflow = EasyMock.createNiceMock(WorkflowInstanceImpl.class);
EasyMock.expect(workflow.getMediaPackage()).andReturn(mediaPackage).anyTimes();
EasyMock.expect(workflow.getId()).andReturn(1L).anyTimes();
EasyMock.expect(workflow.getCurrentOperation()).andReturn(instance).anyTimes();
}
use of org.opencastproject.mediapackage.MediaPackageBuilderImpl 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