Search in sources :

Example 16 with IdImpl

use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.

the class LiveScheduleServiceImplTest method testAddLiveTracksUsingCaptureAgentProperties.

@Test
public void testAddLiveTracksUsingCaptureAgentProperties() throws Exception {
    Properties props = new Properties();
    props.put(LiveScheduleServiceImpl.CA_PROPERTY_RESOLUTION_URL_PREFIX + "960x270", STREAMING_SERVER_URL + "/c3d913f6-9af7-403a-91a9-33b73ee18193-another-capture-agent-presenter-delivery-stream-960x270_suffix_from_ca");
    props.put(LiveScheduleServiceImpl.CA_PROPERTY_RESOLUTION_URL_PREFIX + "1920x540", STREAMING_SERVER_URL + "/c3d913f6-9af7-403a-91a9-33b73ee18193-another-capture-agent-presenter-delivery-stream-1920x540_suffix_from_ca");
    EasyMock.expect(captureAgentService.getAgentCapabilities("another-capture-agent")).andReturn(props).anyTimes();
    replayServices();
    MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
    mp.setIdentifier(new IdImpl(MP_ID));
    mp.setDuration(DURATION);
    service.addLiveTracks(mp, "another-capture-agent");
    assertExpectedLiveTracks(mp.getTracks(), DURATION, "another-capture-agent", "_suffix_from_ca", false);
}
Also used : MediaPackage(org.opencastproject.mediapackage.MediaPackage) Properties(java.util.Properties) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) Test(org.junit.Test)

Example 17 with IdImpl

use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.

the class LiveScheduleServiceImplTest method testAddLiveTracksUsingDefaultProperties.

@Test
public void testAddLiveTracksUsingDefaultProperties() throws Exception {
    replayServices();
    MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
    mp.setIdentifier(new IdImpl(MP_ID));
    mp.setDuration(DURATION);
    service.addLiveTracks(mp, CAPTURE_AGENT_NAME);
    assertExpectedLiveTracks(mp.getTracks(), DURATION, CAPTURE_AGENT_NAME, "_suffix", false);
}
Also used : MediaPackage(org.opencastproject.mediapackage.MediaPackage) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) Test(org.junit.Test)

Example 18 with IdImpl

use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.

the class IndexServiceImplTest method testCreateEventInputNormalExpectsCreatedScheduledEvent.

@Test
public void testCreateEventInputNormalExpectsCreatedScheduledEvent() throws Exception {
    String expectedTitle = "Test Event Creation";
    String username = "akm220";
    String org = "mh_default_org";
    String[] creators = new String[] {};
    Id mpId = new IdImpl("mp-id");
    String testResourceLocation = "/events/create-scheduled-event.json";
    JSONObject metadataJson = (JSONObject) parser.parse(IOUtils.toString(IndexServiceImplTest.class.getResourceAsStream(testResourceLocation)));
    Capture<Catalog> result = EasyMock.newCapture();
    Capture<String> mediapackageIdResult = EasyMock.newCapture();
    Capture<String> catalogIdResult = EasyMock.newCapture();
    Capture<String> filenameResult = EasyMock.newCapture();
    Capture<InputStream> catalogResult = EasyMock.newCapture();
    Capture<String> mediapackageTitleResult = EasyMock.newCapture();
    SecurityService securityService = setupSecurityService(username, org);
    Workspace workspace = EasyMock.createMock(Workspace.class);
    EasyMock.expect(workspace.put(EasyMock.capture(mediapackageIdResult), EasyMock.capture(catalogIdResult), EasyMock.capture(filenameResult), EasyMock.capture(catalogResult))).andReturn(new URI("catalog.xml"));
    EasyMock.replay(workspace);
    // Create Common Event Catalog UI Adapter
    CommonEventCatalogUIAdapter commonEventCatalogUIAdapter = setupCommonCatalogUIAdapter(workspace).getA();
    // Setup mediapackage.
    MediaPackage mediapackage = EasyMock.createMock(MediaPackage.class);
    mediapackage.add(EasyMock.capture(result));
    EasyMock.expectLastCall();
    EasyMock.expect(mediapackage.getCatalogs(EasyMock.anyObject(MediaPackageElementFlavor.class))).andReturn(new Catalog[] {});
    EasyMock.expect(mediapackage.getIdentifier()).andReturn(mpId).anyTimes();
    EasyMock.expect(mediapackage.getCreators()).andReturn(creators);
    mediapackage.addCreator("");
    EasyMock.expectLastCall();
    mediapackage.setTitle(EasyMock.capture(mediapackageTitleResult));
    EasyMock.expectLastCall();
    EasyMock.expect(mediapackage.getElements()).andReturn(new MediaPackageElement[] {}).anyTimes();
    EasyMock.expect(mediapackage.getCatalogs(EasyMock.anyObject(MediaPackageElementFlavor.class))).andReturn(new Catalog[] {}).anyTimes();
    EasyMock.expect(mediapackage.getSeries()).andReturn(null).anyTimes();
    mediapackage.setSeries(EasyMock.anyString());
    EasyMock.expectLastCall();
    EasyMock.replay(mediapackage);
    IngestService ingestService = setupIngestService(mediapackage, Capture.<InputStream>newInstance());
    // Setup Authorization Service
    Tuple<MediaPackage, Attachment> returnValue = new Tuple<MediaPackage, Attachment>(mediapackage, null);
    AuthorizationService authorizationService = EasyMock.createMock(AuthorizationService.class);
    EasyMock.expect(authorizationService.setAcl(EasyMock.anyObject(MediaPackage.class), EasyMock.anyObject(AclScope.class), EasyMock.anyObject(AccessControlList.class))).andReturn(returnValue);
    EasyMock.replay(authorizationService);
    CaptureAgentStateService captureAgentStateService = setupCaptureAgentStateService();
    Capture<Date> captureStart = EasyMock.newCapture();
    Capture<Date> captureEnd = EasyMock.newCapture();
    SchedulerService schedulerService = EasyMock.createNiceMock(SchedulerService.class);
    schedulerService.addEvent(EasyMock.capture(captureStart), EasyMock.capture(captureEnd), EasyMock.anyString(), EasyMock.<Set<String>>anyObject(), EasyMock.anyObject(MediaPackage.class), EasyMock.<Map<String, String>>anyObject(), EasyMock.<Map<String, String>>anyObject(), EasyMock.<Opt<Boolean>>anyObject(), EasyMock.<Opt<String>>anyObject(), EasyMock.anyString());
    EasyMock.expectLastCall().once();
    EasyMock.replay(schedulerService);
    // Run Test
    IndexServiceImpl indexServiceImpl = new IndexServiceImpl();
    indexServiceImpl.setAuthorizationService(setupAuthorizationService(mediapackage));
    indexServiceImpl.setIngestService(ingestService);
    indexServiceImpl.setCommonEventCatalogUIAdapter(commonEventCatalogUIAdapter);
    indexServiceImpl.addCatalogUIAdapter(commonEventCatalogUIAdapter);
    indexServiceImpl.setSecurityService(securityService);
    indexServiceImpl.setUserDirectoryService(noUsersUserDirectoryService);
    indexServiceImpl.setWorkspace(workspace);
    indexServiceImpl.setCaptureAgentStateService(captureAgentStateService);
    indexServiceImpl.setSchedulerService(schedulerService);
    String scheduledEvent = indexServiceImpl.createEvent(metadataJson, mediapackage);
    Assert.assertEquals(mediapackage.getIdentifier().compact(), scheduledEvent);
    assertTrue("The catalog must be added to the mediapackage", result.hasCaptured());
    assertEquals("The catalog should have been added to the correct mediapackage", mpId.toString(), mediapackageIdResult.getValue());
    assertTrue("The catalog should have a new id", catalogIdResult.hasCaptured());
    assertTrue("The catalog should have a new filename", filenameResult.hasCaptured());
    assertTrue("The catalog should have been added to the input stream", catalogResult.hasCaptured());
    assertTrue("The mediapackage should have had its title updated", catalogResult.hasCaptured());
    assertEquals("The mediapackage title should have been updated.", expectedTitle, mediapackageTitleResult.getValue());
    assertTrue("The catalog should have been created", catalogResult.hasCaptured());
    assertTrue(captureStart.hasCaptured());
    assertTrue(captureEnd.hasCaptured());
    Assert.assertEquals(new Date(DateTimeSupport.fromUTC("2008-03-16T14:00:00Z")), captureStart.getValue());
    Assert.assertEquals(new Date(DateTimeSupport.fromUTC("2008-03-16T14:01:00Z")), captureEnd.getValue());
}
Also used : AccessControlList(org.opencastproject.security.api.AccessControlList) SchedulerService(org.opencastproject.scheduler.api.SchedulerService) Attachment(org.opencastproject.mediapackage.Attachment) AclScope(org.opencastproject.security.api.AclScope) URI(java.net.URI) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) SecurityService(org.opencastproject.security.api.SecurityService) MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) CommonEventCatalogUIAdapter(org.opencastproject.index.service.catalog.adapter.events.CommonEventCatalogUIAdapter) CaptureAgentStateService(org.opencastproject.capture.admin.api.CaptureAgentStateService) IngestService(org.opencastproject.ingest.api.IngestService) InputStream(java.io.InputStream) MediaPackageElementFlavor(org.opencastproject.mediapackage.MediaPackageElementFlavor) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Catalog(org.opencastproject.mediapackage.Catalog) Date(java.util.Date) JSONObject(org.json.simple.JSONObject) AuthorizationService(org.opencastproject.security.api.AuthorizationService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Id(org.opencastproject.mediapackage.identifier.Id) Tuple(org.opencastproject.util.data.Tuple) Workspace(org.opencastproject.workspace.api.Workspace) Test(org.junit.Test)

Example 19 with IdImpl

use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.

the class IndexServiceImplTest method testCreateEventInputNormalExpectsCreatedRecurringEvent.

@Test
public void testCreateEventInputNormalExpectsCreatedRecurringEvent() throws Exception {
    String expectedTitle = "Test Event Creation";
    String username = "akm220";
    String org = "mh_default_org";
    String[] creators = new String[] {};
    Id mpId = new IdImpl("mp-id");
    String testResourceLocation = "/events/create-recurring-event.json";
    JSONObject metadataJson = (JSONObject) parser.parse(IOUtils.toString(IndexServiceImplTest.class.getResourceAsStream(testResourceLocation)));
    Capture<String> mediapackageIdResult = EasyMock.newCapture();
    Capture<String> catalogIdResult = EasyMock.newCapture();
    Capture<String> filenameResult = EasyMock.newCapture();
    Capture<InputStream> catalogResult = EasyMock.newCapture();
    Capture<String> mediapackageTitleResult = EasyMock.newCapture();
    SecurityService securityService = setupSecurityService(username, org);
    Workspace workspace = EasyMock.createMock(Workspace.class);
    EasyMock.expect(workspace.put(EasyMock.capture(mediapackageIdResult), EasyMock.capture(catalogIdResult), EasyMock.capture(filenameResult), EasyMock.capture(catalogResult))).andReturn(new URI("catalog.xml"));
    EasyMock.expect(workspace.read(getClass().getResource("/dublincore.xml").toURI())).andAnswer(() -> getClass().getResourceAsStream("/dublincore.xml")).anyTimes();
    EasyMock.replay(workspace);
    // Create Common Event Catalog UI Adapter
    CommonEventCatalogUIAdapter commonEventCatalogUIAdapter = setupCommonCatalogUIAdapter(workspace).getA();
    // Setup mediapackage.
    MediaPackage mediapackage = EasyMock.createMock(MediaPackage.class);
    EasyMock.expect(mediapackage.clone()).andReturn(mediapackage).anyTimes();
    EasyMock.expect(mediapackage.getSeries()).andReturn(null).anyTimes();
    EasyMock.expect(mediapackage.getCatalogs(EasyMock.anyObject(MediaPackageElementFlavor.class))).andReturn(new Catalog[] { CatalogImpl.fromURI(getClass().getResource("/dublincore.xml").toURI()) });
    EasyMock.expect(mediapackage.getIdentifier()).andReturn(mpId).anyTimes();
    EasyMock.expect(mediapackage.getCreators()).andReturn(creators);
    mediapackage.addCreator("");
    EasyMock.expectLastCall();
    mediapackage.setTitle(EasyMock.capture(mediapackageTitleResult));
    EasyMock.expectLastCall().once();
    mediapackage.setTitle(EasyMock.anyString());
    EasyMock.expectLastCall().times(15);
    EasyMock.expect(mediapackage.getElements()).andReturn(new MediaPackageElement[] {}).anyTimes();
    EasyMock.expect(mediapackage.getCatalogs(EasyMock.anyObject(MediaPackageElementFlavor.class))).andReturn(new Catalog[] {}).anyTimes();
    mediapackage.setIdentifier(EasyMock.anyObject(Id.class));
    EasyMock.expectLastCall().anyTimes();
    mediapackage.setSeries(EasyMock.anyString());
    mediapackage.setSeriesTitle(EasyMock.anyString());
    EasyMock.expectLastCall();
    EasyMock.replay(mediapackage);
    CaptureAgentStateService captureAgentStateService = setupCaptureAgentStateService();
    // Setup scheduler service
    Capture<Date> recurrenceStart = EasyMock.newCapture();
    Capture<Date> recurrenceEnd = EasyMock.newCapture();
    Capture<RRule> rrule = EasyMock.newCapture();
    Capture duration = EasyMock.newCapture();
    Capture<TimeZone> tz = EasyMock.newCapture();
    Capture<Date> schedStart = EasyMock.newCapture();
    Capture<Date> schedEnd = EasyMock.newCapture();
    Capture<RRule> schedRRule = EasyMock.newCapture();
    Capture schedDuration = EasyMock.newCapture();
    Capture<TimeZone> schedTz = EasyMock.newCapture();
    Capture<MediaPackage> mp = EasyMock.newCapture();
    SchedulerService schedulerService = EasyMock.createNiceMock(SchedulerService.class);
    // Look up the expected periods
    EasyMock.expect(schedulerService.calculatePeriods(EasyMock.capture(rrule), EasyMock.capture(recurrenceStart), EasyMock.capture(recurrenceEnd), EasyMock.captureLong(duration), EasyMock.capture(tz))).andAnswer(new IAnswer<List<Period>>() {

        @Override
        public List<Period> answer() throws Throwable {
            return calculatePeriods(rrule.getValue(), recurrenceStart.getValue(), recurrenceEnd.getValue(), (Long) duration.getValue(), tz.getValue());
        }
    }).anyTimes();
    // The actual scheduling
    EasyMock.expect(schedulerService.addMultipleEvents(EasyMock.capture(schedRRule), EasyMock.capture(schedStart), EasyMock.capture(schedEnd), EasyMock.captureLong(schedDuration), EasyMock.capture(schedTz), EasyMock.anyString(), EasyMock.<Set<String>>anyObject(), EasyMock.capture(mp), EasyMock.<Map<String, String>>anyObject(), EasyMock.<Map<String, String>>anyObject(), EasyMock.<Opt<Boolean>>anyObject(), EasyMock.<Opt<String>>anyObject(), EasyMock.anyString())).andAnswer(new IAnswer<Map<String, Period>>() {

        @Override
        public Map<String, Period> answer() throws Throwable {
            List<Period> periods = calculatePeriods(schedRRule.getValue(), schedStart.getValue(), schedEnd.getValue(), (Long) schedDuration.getValue(), schedTz.getValue());
            Map<String, Period> mapping = new LinkedHashMap<>();
            int counter = 0;
            for (Period p : periods) {
                mapping.put(new IdImpl(UUID.randomUUID().toString()).compact(), p);
            }
            return mapping;
        }
    }).anyTimes();
    EasyMock.replay(schedulerService);
    // Run Test
    IndexServiceImpl indexServiceImpl = new IndexServiceImpl();
    indexServiceImpl.setAuthorizationService(setupAuthorizationService(mediapackage));
    indexServiceImpl.setIngestService(setupIngestService(mediapackage, Capture.<InputStream>newInstance()));
    indexServiceImpl.setCommonEventCatalogUIAdapter(commonEventCatalogUIAdapter);
    indexServiceImpl.addCatalogUIAdapter(commonEventCatalogUIAdapter);
    indexServiceImpl.setSecurityService(securityService);
    indexServiceImpl.setUserDirectoryService(noUsersUserDirectoryService);
    indexServiceImpl.setWorkspace(workspace);
    indexServiceImpl.setCaptureAgentStateService(captureAgentStateService);
    indexServiceImpl.setSchedulerService(schedulerService);
    String scheduledEvents = indexServiceImpl.createEvent(metadataJson, mediapackage);
    String[] ids = StringUtils.split(scheduledEvents, ",");
    // We should have as many scheduled events as we do periods
    Assert.assertTrue(ids.length == calculatePeriods(rrule.getValue(), recurrenceStart.getValue(), recurrenceEnd.getValue(), (Long) duration.getValue(), tz.getValue()).size());
    assertEquals("The catalog should have been added to the correct mediapackage", mpId.toString(), mediapackageIdResult.getValue());
    assertTrue("The catalog should have a new id", catalogIdResult.hasCaptured());
    assertTrue("The catalog should have a new filename", filenameResult.hasCaptured());
    assertTrue("The catalog should have been added to the input stream", catalogResult.hasCaptured());
    assertTrue("The mediapackage should have had its title updated", catalogResult.hasCaptured());
    assertEquals("The mediapackage title should have been updated.", expectedTitle, mediapackageTitleResult.getValue());
    assertTrue("The catalog should have been created", catalogResult.hasCaptured());
    // Assert that the start and end recurrence dates captured, along with the duration and recurrence rule
    // This is all used by the scheduling calculation, but not the actual scheduling call
    assertTrue(recurrenceStart.hasCaptured());
    assertTrue(recurrenceEnd.hasCaptured());
    assertTrue(duration.hasCaptured());
    assertTrue(rrule.hasCaptured());
    // Assert that the scheduling call has its necessary data
    assertTrue(schedStart.hasCaptured());
    assertTrue(schedEnd.hasCaptured());
    assertTrue(schedDuration.hasCaptured());
    assertTrue(schedRRule.hasCaptured());
    assertTrue(schedTz.hasCaptured());
    List<Period> pCheck = calculatePeriods(schedRRule.getValue(), schedStart.getValue(), schedEnd.getValue(), (Long) schedDuration.getValue(), schedTz.getValue());
    List<Period> pExpected = calculatePeriods(rrule.getValue(), recurrenceStart.getValue(), recurrenceEnd.getValue(), (Long) duration.getValue(), tz.getValue());
    // Assert that the first capture time is the same as the recurrence start
    assertEquals(pExpected.get(0).getStart(), pCheck.get(0).getStart());
    // Assert that the end of the last capture time is the same as the recurrence end
    assertEquals(pExpected.get(pExpected.size() - 1).getEnd(), pCheck.get(pCheck.size() - 1).getEnd());
}
Also used : SchedulerService(org.opencastproject.scheduler.api.SchedulerService) Set(java.util.Set) RRule(net.fortuna.ical4j.model.property.RRule) URI(java.net.URI) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) Capture(org.easymock.Capture) LinkedHashMap(java.util.LinkedHashMap) Opt(com.entwinemedia.fn.data.Opt) SecurityService(org.opencastproject.security.api.SecurityService) MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) CommonEventCatalogUIAdapter(org.opencastproject.index.service.catalog.adapter.events.CommonEventCatalogUIAdapter) CaptureAgentStateService(org.opencastproject.capture.admin.api.CaptureAgentStateService) InputStream(java.io.InputStream) Period(net.fortuna.ical4j.model.Period) MediaPackageElementFlavor(org.opencastproject.mediapackage.MediaPackageElementFlavor) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Catalog(org.opencastproject.mediapackage.Catalog) Date(java.util.Date) IAnswer(org.easymock.IAnswer) TimeZone(java.util.TimeZone) JSONObject(org.json.simple.JSONObject) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Id(org.opencastproject.mediapackage.identifier.Id) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Workspace(org.opencastproject.workspace.api.Workspace) Test(org.junit.Test)

Example 20 with IdImpl

use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.

the class IndexServiceImplTest method testCreateEventInputNoWorkflowConfigurationExpectsCreatedEvent.

@Test
public void testCreateEventInputNoWorkflowConfigurationExpectsCreatedEvent() throws Exception {
    String expectedTitle = "Test Event Creation";
    String username = "akm220";
    String org = "mh_default_org";
    String[] creators = new String[] {};
    Id mpId = new IdImpl("mp-id");
    String testResourceLocation = "/events/create-event-no-workflow-configuration.json";
    JSONObject metadataJson = (JSONObject) parser.parse(IOUtils.toString(IndexServiceImplTest.class.getResourceAsStream(testResourceLocation)));
    Capture<Catalog> result = EasyMock.newCapture();
    Capture<String> mediapackageIdResult = EasyMock.newCapture();
    Capture<String> catalogIdResult = EasyMock.newCapture();
    Capture<String> filenameResult = EasyMock.newCapture();
    Capture<InputStream> catalogResult = EasyMock.newCapture();
    Capture<String> mediapackageTitleResult = EasyMock.newCapture();
    SecurityService securityService = setupSecurityService(username, org);
    Workspace workspace = EasyMock.createMock(Workspace.class);
    EasyMock.expect(workspace.put(EasyMock.capture(mediapackageIdResult), EasyMock.capture(catalogIdResult), EasyMock.capture(filenameResult), EasyMock.capture(catalogResult))).andReturn(new URI("catalog.xml"));
    EasyMock.replay(workspace);
    CommonEventCatalogUIAdapter commonEventCatalogUIAdapter = setupCommonCatalogUIAdapter(workspace).getA();
    // Setup mediapackage.
    MediaPackage mediapackage = EasyMock.createMock(MediaPackage.class);
    mediapackage.add(EasyMock.capture(result));
    EasyMock.expectLastCall();
    EasyMock.expect(mediapackage.getIdentifier()).andReturn(mpId).anyTimes();
    EasyMock.expect(mediapackage.getCreators()).andReturn(creators);
    mediapackage.addCreator("");
    EasyMock.expectLastCall();
    mediapackage.setTitle(EasyMock.capture(mediapackageTitleResult));
    EasyMock.expectLastCall();
    EasyMock.expect(mediapackage.getElements()).andReturn(new MediaPackageElement[] {}).anyTimes();
    EasyMock.expect(mediapackage.getCatalogs(EasyMock.anyObject(MediaPackageElementFlavor.class))).andReturn(new Catalog[] {}).anyTimes();
    EasyMock.expect(mediapackage.getSeries()).andReturn(null).anyTimes();
    mediapackage.setSeries(EasyMock.anyString());
    EasyMock.expectLastCall();
    mediapackage.setSeriesTitle(EasyMock.anyString());
    EasyMock.expectLastCall();
    EasyMock.replay(mediapackage);
    IngestService ingestService = setupIngestService(mediapackage, Capture.<InputStream>newInstance());
    // Setup Authorization Service
    Tuple<MediaPackage, Attachment> returnValue = new Tuple<MediaPackage, Attachment>(mediapackage, null);
    AuthorizationService authorizationService = EasyMock.createMock(AuthorizationService.class);
    EasyMock.expect(authorizationService.setAcl(EasyMock.anyObject(MediaPackage.class), EasyMock.anyObject(AclScope.class), EasyMock.anyObject(AccessControlList.class))).andReturn(returnValue);
    EasyMock.replay(authorizationService);
    // Run Test
    IndexServiceImpl indexServiceImpl = new IndexServiceImpl();
    indexServiceImpl.setAuthorizationService(setupAuthorizationService(mediapackage));
    indexServiceImpl.setIngestService(ingestService);
    indexServiceImpl.setCommonEventCatalogUIAdapter(commonEventCatalogUIAdapter);
    indexServiceImpl.addCatalogUIAdapter(commonEventCatalogUIAdapter);
    indexServiceImpl.setUserDirectoryService(noUsersUserDirectoryService);
    indexServiceImpl.setSecurityService(securityService);
    indexServiceImpl.setWorkspace(workspace);
    indexServiceImpl.createEvent(metadataJson, mediapackage);
    assertTrue("The catalog must be added to the mediapackage", result.hasCaptured());
    assertEquals("The catalog should have been added to the correct mediapackage", mpId.toString(), mediapackageIdResult.getValue());
    assertTrue("The catalog should have a new id", catalogIdResult.hasCaptured());
    assertTrue("The catalog should have a new filename", filenameResult.hasCaptured());
    assertTrue("The catalog should have been added to the input stream", catalogResult.hasCaptured());
    assertTrue("The mediapackage should have had its title updated", catalogResult.hasCaptured());
    assertEquals("The mediapackage title should have been updated.", expectedTitle, mediapackageTitleResult.getValue());
    assertTrue("The catalog should have been created", catalogResult.hasCaptured());
}
Also used : AccessControlList(org.opencastproject.security.api.AccessControlList) Attachment(org.opencastproject.mediapackage.Attachment) AclScope(org.opencastproject.security.api.AclScope) URI(java.net.URI) IdImpl(org.opencastproject.mediapackage.identifier.IdImpl) SecurityService(org.opencastproject.security.api.SecurityService) MediaPackageElement(org.opencastproject.mediapackage.MediaPackageElement) CommonEventCatalogUIAdapter(org.opencastproject.index.service.catalog.adapter.events.CommonEventCatalogUIAdapter) IngestService(org.opencastproject.ingest.api.IngestService) InputStream(java.io.InputStream) DublinCoreCatalog(org.opencastproject.metadata.dublincore.DublinCoreCatalog) Catalog(org.opencastproject.mediapackage.Catalog) JSONObject(org.json.simple.JSONObject) AuthorizationService(org.opencastproject.security.api.AuthorizationService) MediaPackage(org.opencastproject.mediapackage.MediaPackage) Id(org.opencastproject.mediapackage.identifier.Id) Tuple(org.opencastproject.util.data.Tuple) Workspace(org.opencastproject.workspace.api.Workspace) Test(org.junit.Test)

Aggregations

IdImpl (org.opencastproject.mediapackage.identifier.IdImpl)28 MediaPackage (org.opencastproject.mediapackage.MediaPackage)26 Test (org.junit.Test)21 URI (java.net.URI)13 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)12 SecurityService (org.opencastproject.security.api.SecurityService)11 MediaPackageElement (org.opencastproject.mediapackage.MediaPackageElement)9 Id (org.opencastproject.mediapackage.identifier.Id)9 InputStream (java.io.InputStream)8 Date (java.util.Date)7 Workspace (org.opencastproject.workspace.api.Workspace)7 Catalog (org.opencastproject.mediapackage.Catalog)6 MediaPackageElementFlavor (org.opencastproject.mediapackage.MediaPackageElementFlavor)6 AccessControlList (org.opencastproject.security.api.AccessControlList)6 ArrayList (java.util.ArrayList)5 Attachment (org.opencastproject.mediapackage.Attachment)5 HashMap (java.util.HashMap)4 NotFoundException (org.opencastproject.util.NotFoundException)4 WorkflowInstance (org.opencastproject.workflow.api.WorkflowInstance)4 HashSet (java.util.HashSet)3