use of org.opencastproject.assetmanager.api.Version in project opencast by opencast.
the class LiveScheduleServiceImplTest method testCreateLiveEvent.
@Test
public void testCreateLiveEvent() throws Exception {
URI mpURI = LiveScheduleServiceImplTest.class.getResource("/assetmanager-mp.xml").toURI();
MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().loadFromXml(mpURI.toURL().openStream());
setUpAssetManager(mp);
URI catalogURI = LiveScheduleServiceImplTest.class.getResource("/episode.xml").toURI();
DublinCoreCatalog episodeDC = DublinCores.read(catalogURI.toURL().openStream());
catalogURI = LiveScheduleServiceImplTest.class.getResource("/series.xml").toURI();
DublinCoreCatalog seriesDC = DublinCores.read(catalogURI.toURL().openStream());
EasyMock.expect(seriesService.getSeries(SERIES_ID)).andReturn(seriesDC).anyTimes();
Job job = createJob(1L, "anything", "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<catalog id=\"9ad6ebcb-b414-4b15-ab62-5e5ddede447e\" type=\"dublincore/episode\" xmlns=\"http://mediapackage.opencastproject.org\">" + "<mimetype>text/xml</mimetype>" + "<url>http://10.10.10.50/static/mh_default_org/engage-live/episode.xml</url></catalog>" + "###<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<catalog id=\"23113662-1a84-457a-85d5-0b3e32d2413a\" type=\"dublincore/series\" xmlns=\"http://mediapackage.opencastproject.org\">" + "<mimetype>text/xml</mimetype>" + "<url>http://10.10.10.50/static/mh_default_org/engage-live/series.xml</url></catalog>" + "###<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<attachment id=\"security-policy-episode\" type=\"security/xacml+episode\" xmlns=\"http://mediapackage.opencastproject.org\">" + "<mimetype>text/xml</mimetype>" + "<url>http://10.10.10.50/static/mh_default_org/engage-live/security_policy_episode.xml</url></attachment>");
EasyMock.expect(downloadDistributionService.distribute(EasyMock.anyString(), EasyMock.anyObject(MediaPackage.class), EasyMock.anyObject(Set.class), EasyMock.anyBoolean())).andReturn(job);
EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(job).anyTimes();
Job jobPub = createJob(2L, "anything", "anything");
Capture<MediaPackage> capturedMp = Capture.newInstance();
EasyMock.expect(searchService.add(EasyMock.capture(capturedMp))).andReturn(jobPub);
EasyMock.expect(serviceRegistry.getJob(2L)).andReturn(job).anyTimes();
Capture<MediaPackage> capturedSnapshotMp = Capture.newInstance();
Version v = EasyMock.createNiceMock(Version.class);
Snapshot s = EasyMock.createNiceMock(Snapshot.class);
EasyMock.expect(s.getVersion()).andReturn(v);
EasyMock.replay(s, v);
EasyMock.expect(assetManager.takeSnapshot(EasyMock.capture(capturedSnapshotMp))).andReturn(s);
replayServices();
service.setDownloadDistributionService(downloadDistributionService);
service.createLiveEvent(MP_ID, episodeDC);
// Check published live media package
MediaPackage searchMp = capturedMp.getValue();
Assert.assertEquals(MP_ID, searchMp.getIdentifier().compact());
Assert.assertEquals(DURATION, searchMp.getDuration().longValue());
Assert.assertEquals(2, searchMp.getCatalogs().length);
assertExpectedLiveTracks(searchMp.getTracks(), DURATION, CAPTURE_AGENT_NAME, "_suffix", false);
// Check archived media package
MediaPackage archivedMp = capturedSnapshotMp.getValue();
Assert.assertEquals(MP_ID, archivedMp.getIdentifier().compact());
Assert.assertEquals(1, archivedMp.getPublications().length);
Assert.assertEquals(LiveScheduleService.CHANNEL_ID, archivedMp.getPublications()[0].getChannel());
// Check that version got into local cache
Assert.assertEquals(v, service.getSnapshotVersionCache().getIfPresent(MP_ID));
}
use of org.opencastproject.assetmanager.api.Version in project opencast by opencast.
the class LiveScheduleServiceImplTest method setUpAssetManager.
private void setUpAssetManager(MediaPackage mp) {
version = EasyMock.createNiceMock(Version.class);
snapshot = EasyMock.createNiceMock(Snapshot.class);
EasyMock.expect(snapshot.getMediaPackage()).andReturn(mp).anyTimes();
EasyMock.expect(snapshot.getOrganizationId()).andReturn(org.getId()).anyTimes();
EasyMock.expect(snapshot.getVersion()).andReturn(version);
ARecord aRec = EasyMock.createNiceMock(ARecord.class);
EasyMock.expect(aRec.getSnapshot()).andReturn(Opt.some(snapshot)).anyTimes();
Stream<ARecord> recStream = Stream.mk(aRec);
Predicate p = EasyMock.createNiceMock(Predicate.class);
EasyMock.expect(p.and(p)).andReturn(p).anyTimes();
AResult r = EasyMock.createNiceMock(AResult.class);
EasyMock.expect(r.getSize()).andReturn(1L).anyTimes();
EasyMock.expect(r.getRecords()).andReturn(recStream).anyTimes();
Target t = EasyMock.createNiceMock(Target.class);
ASelectQuery selectQuery = EasyMock.createNiceMock(ASelectQuery.class);
EasyMock.expect(selectQuery.where(EasyMock.anyObject(Predicate.class))).andReturn(selectQuery).anyTimes();
EasyMock.expect(selectQuery.run()).andReturn(r).anyTimes();
AQueryBuilder query = EasyMock.createNiceMock(AQueryBuilder.class);
EasyMock.expect(query.snapshot()).andReturn(t).anyTimes();
EasyMock.expect(query.mediaPackageId(EasyMock.anyObject(String.class))).andReturn(p).anyTimes();
EasyMock.expect(query.select(EasyMock.anyObject(Target.class))).andReturn(selectQuery).anyTimes();
VersionField v = EasyMock.createNiceMock(VersionField.class);
EasyMock.expect(v.isLatest()).andReturn(p).anyTimes();
EasyMock.expect(query.version()).andReturn(v).anyTimes();
EasyMock.expect(assetManager.createQuery()).andReturn(query).anyTimes();
EasyMock.replay(snapshot, aRec, p, r, t, selectQuery, query, v);
}
use of org.opencastproject.assetmanager.api.Version in project opencast by opencast.
the class SchedulerServiceImplTest method testGetArchivedOnly.
@Test
public void testGetArchivedOnly() throws Exception {
MediaPackage mediaPackage = generateEvent(Opt.some("1"));
Version version = assetManager.takeSnapshot("test", mediaPackage).getVersion();
Assert.assertEquals(VersionImpl.FIRST, version);
String mediaPackageId = mediaPackage.getIdentifier().compact();
try {
schedSvc.getMediaPackage(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.getDublinCore(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.getAccessControlList(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.getWorkflowConfig(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.getCaptureAgentConfiguration(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.isOptOut(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.isBlacklisted(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.getReviewStatus(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.getRecordingState(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.removeRecording(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.removeEvent(mediaPackageId);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.updateRecordingState(mediaPackageId, RecordingState.CAPTURING);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.updateReviewStatus(mediaPackageId, ReviewStatus.CONFIRMED);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
try {
schedSvc.updateEvent(mediaPackageId, Opt.<Date>none(), Opt.<Date>none(), Opt.<String>none(), Opt.<Set<String>>none(), Opt.<MediaPackage>none(), Opt.<Map<String, String>>none(), Opt.<Map<String, String>>none(), Opt.<Opt<Boolean>>none(), SchedulerService.ORIGIN);
fail();
} catch (NotFoundException e) {
Assert.assertNotNull(e);
}
}
use of org.opencastproject.assetmanager.api.Version in project opencast by opencast.
the class LiveScheduleServiceImplTest method testRetractLiveEvent.
@Test
public void testRetractLiveEvent() throws Exception {
URI mpURI = LiveScheduleServiceImplTest.class.getResource("/assetmanager-mp-with-live.xml").toURI();
MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().loadFromXml(mpURI.toURL().openStream());
setUpAssetManager(mp);
mpURI = LiveScheduleServiceImplTest.class.getResource("/live-mp.xml").toURI();
mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().loadFromXml(mpURI.toURL().openStream());
Job job1 = createJob(1L, "anything", "anything");
Capture<String> capturedMpId = Capture.newInstance();
EasyMock.expect(searchService.delete(EasyMock.capture(capturedMpId))).andReturn(job1);
EasyMock.expect(serviceRegistry.getJob(1L)).andReturn(job1).anyTimes();
Job job2 = createJob(2L, "anything", "anything");
EasyMock.expect(downloadDistributionService.retract(EasyMock.anyString(), EasyMock.anyObject(MediaPackage.class), EasyMock.anyObject(Set.class))).andReturn(job2);
EasyMock.expect(serviceRegistry.getJob(2L)).andReturn(job2).anyTimes();
Capture<MediaPackage> capturedSnapshotMp = Capture.newInstance();
Version v = EasyMock.createNiceMock(Version.class);
Snapshot s = EasyMock.createNiceMock(Snapshot.class);
EasyMock.expect(s.getVersion()).andReturn(v);
EasyMock.replay(s, v);
EasyMock.expect(assetManager.takeSnapshot(EasyMock.capture(capturedSnapshotMp))).andReturn(s);
replayServices();
service.setDownloadDistributionService(downloadDistributionService);
service.retractLiveEvent(mp);
// Check archived media package
MediaPackage archivedMp = capturedSnapshotMp.getValue();
Assert.assertEquals(MP_ID, archivedMp.getIdentifier().compact());
Assert.assertEquals(0, archivedMp.getPublications().length);
EasyMock.verify(searchService, downloadDistributionService);
}
use of org.opencastproject.assetmanager.api.Version in project opencast by opencast.
the class AbstractAssetManagerSelectTest method testSelectByMultipleProperties.
@Test
public void testSelectByMultipleProperties() throws Exception {
final String[] mp = createAndAddMediaPackagesSimple(5, 1, 1);
final Version v3 = am.toVersion("3").get();
am.setProperty(p.agent.mk(mp[0], "agent"));
am.setProperty(p.versionId.mk(mp[0], v3));
am.setProperty(p.approved.mk(mp[0], true));
assertThat(q.select(p.agent.target(), p.approved.target()).where(p.approved.eq(true).and(p.versionId.eq(v3))).run().getRecords().head().get().getProperties().map(Properties.getValue), Matchers.containsInAnyOrder(equalTo((Value) Value.mk("agent")), equalTo((Value) Value.mk(true))));
}
Aggregations