use of org.opencastproject.security.api.SecurityService in project opencast by opencast.
the class IndexServiceImplTest method setupSecurityService.
private SecurityService setupSecurityService(String username, String org) {
// Setup Security Service, Organization and User
Organization organization = EasyMock.createNiceMock(Organization.class);
EasyMock.expect(organization.getId()).andReturn(org).anyTimes();
EasyMock.replay(organization);
User user = EasyMock.createMock(User.class);
EasyMock.expect(user.getOrganization()).andReturn(organization).anyTimes();
EasyMock.expect(user.getUsername()).andReturn(username);
EasyMock.replay(user);
SecurityService securityService = EasyMock.createMock(SecurityService.class);
EasyMock.expect(securityService.getOrganization()).andReturn(organization).anyTimes();
EasyMock.expect(securityService.getUser()).andReturn(user);
EasyMock.replay(securityService);
return securityService;
}
use of org.opencastproject.security.api.SecurityService 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());
}
use of org.opencastproject.security.api.SecurityService 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());
}
use of org.opencastproject.security.api.SecurityService in project opencast by opencast.
the class IndexServiceImplTest method updatePresenters.
@Test
public void updatePresenters() throws IOException, org.osgi.service.cm.ConfigurationException {
String nonUser1 = "Non User 1";
String nonUser2 = "Non User 2";
String nonUser3 = "Non User 3";
Properties eventProperties = new Properties();
InputStream in = getClass().getResourceAsStream("/episode-catalog.properties");
eventProperties.load(in);
in.close();
Dictionary<String, String> properties = PropertiesUtil.toDictionary(eventProperties);
SecurityService securityService = EasyMock.createMock(SecurityService.class);
EasyMock.expect(securityService.getOrganization()).andStubReturn(organization);
EasyMock.replay(securityService);
UserDirectoryService userDirectoryService = EasyMock.createMock(UserDirectoryService.class);
EasyMock.expect(userDirectoryService.loadUser(user1.getUsername())).andStubReturn(user1);
EasyMock.expect(userDirectoryService.loadUser(user2.getUsername())).andStubReturn(user2);
EasyMock.expect(userDirectoryService.loadUser(user3.getUsername())).andStubReturn(user3);
EasyMock.expect(userDirectoryService.loadUser(nonUser1)).andStubReturn(null);
EasyMock.expect(userDirectoryService.loadUser(nonUser2)).andStubReturn(null);
EasyMock.expect(userDirectoryService.loadUser(nonUser3)).andStubReturn(null);
EasyMock.replay(userDirectoryService);
IndexServiceImpl indexServiceImpl = new IndexServiceImpl();
CommonEventCatalogUIAdapter commonEventCatalogUIAdapter = new CommonEventCatalogUIAdapter();
commonEventCatalogUIAdapter.updated(properties);
indexServiceImpl.setCommonEventCatalogUIAdapter(commonEventCatalogUIAdapter);
indexServiceImpl.setUserDirectoryService(userDirectoryService);
indexServiceImpl.setSecurityService(securityService);
MetadataCollection metadata = commonEventCatalogUIAdapter.getRawFields();
// Possible presenter combinations
MetadataField<Iterable<String>> emptyUpdatedPresenter = createCreatorMetadataField(new ArrayList<String>());
ArrayList<String> oneNonUserList = new ArrayList<>();
oneNonUserList.add(nonUser1);
MetadataField<Iterable<String>> nonUserUpdatedPresenter = createCreatorMetadataField(oneNonUserList);
ArrayList<String> multiNonUserList = new ArrayList<>();
multiNonUserList.add(nonUser1);
multiNonUserList.add(nonUser2);
multiNonUserList.add(nonUser3);
MetadataField<Iterable<String>> multiNonUserUpdatedPresenter = createCreatorMetadataField(multiNonUserList);
ArrayList<String> oneUserList = new ArrayList<>();
oneUserList.add(user1.getUsername());
MetadataField<Iterable<String>> userUpdatedPresenter = createCreatorMetadataField(oneUserList);
ArrayList<String> multiUserList = new ArrayList<>();
multiUserList.add(user1.getUsername());
multiUserList.add(user2.getUsername());
multiUserList.add(user3.getUsername());
MetadataField<Iterable<String>> multiUserUpdatedPresenter = createCreatorMetadataField(multiUserList);
ArrayList<String> mixedUserList = new ArrayList<>();
mixedUserList.add(user1.getUsername());
mixedUserList.add(nonUser1);
mixedUserList.add(user2.getUsername());
mixedUserList.add(nonUser2);
mixedUserList.add(nonUser3);
mixedUserList.add(user3.getUsername());
MetadataField<Iterable<String>> mixedPresenters = createCreatorMetadataField(mixedUserList);
ArrayList<String> userFullNames = new ArrayList<>();
userFullNames.add(user1.getName());
userFullNames.add(user2.getName());
userFullNames.add(user3.getUsername());
// Empty presenters
metadata.removeField(metadata.getOutputFields().get(DublinCore.PROPERTY_CREATOR.getLocalName()));
metadata.addField(emptyUpdatedPresenter);
Tuple<List<String>, Set<String>> updatedPresenters = indexServiceImpl.getTechnicalPresenters(metadata);
assertTrue("The presenters dublincore metadata should be empty", updatedPresenters.getA().isEmpty());
assertTrue("The technical presenters should be empty", updatedPresenters.getB().isEmpty());
// Non-user presenter
metadata.removeField(metadata.getOutputFields().get(DublinCore.PROPERTY_CREATOR.getLocalName()));
metadata.addField(nonUserUpdatedPresenter);
updatedPresenters = indexServiceImpl.getTechnicalPresenters(metadata);
assertTrue("There should be one presenter", updatedPresenters.getA().size() == 1);
assertTrue("There should be no technical presenters", updatedPresenters.getB().isEmpty());
// Multi non-user presenter
metadata.removeField(metadata.getOutputFields().get(DublinCore.PROPERTY_CREATOR.getLocalName()));
metadata.addField(multiNonUserUpdatedPresenter);
updatedPresenters = indexServiceImpl.getTechnicalPresenters(metadata);
assertTrue("There should be three presenters", updatedPresenters.getA().size() == 3);
assertTrue("The value for technical presenters should be empty", updatedPresenters.getB().isEmpty());
// User presenter
metadata.removeField(metadata.getOutputFields().get(DublinCore.PROPERTY_CREATOR.getLocalName()));
metadata.addField(userUpdatedPresenter);
updatedPresenters = indexServiceImpl.getTechnicalPresenters(metadata);
assertTrue("There should be one presenter", updatedPresenters.getA().size() == 1);
assertEquals("The one presenter should have the user's full name", "User 1", updatedPresenters.getA().get(0));
assertTrue("The one technical presenter", updatedPresenters.getB().size() == 1);
assertEquals("The one technical presenter has the correct username", "user1", updatedPresenters.getB().iterator().next());
// Multi user presenter
metadata.removeField(metadata.getOutputFields().get(DublinCore.PROPERTY_CREATOR.getLocalName()));
metadata.addField(multiUserUpdatedPresenter);
updatedPresenters = indexServiceImpl.getTechnicalPresenters(metadata);
assertTrue("There should be three presenters", updatedPresenters.getA().size() == 3);
assertTrue("There should be three technical presenters", updatedPresenters.getB().size() == 3);
assertTrue("The list of technical presenters should contain all of the user names", updatedPresenters.getB().containsAll(multiUserList));
// Mixed non-user and user presenters
metadata.removeField(metadata.getOutputFields().get(DublinCore.PROPERTY_CREATOR.getLocalName()));
metadata.addField(mixedPresenters);
updatedPresenters = indexServiceImpl.getTechnicalPresenters(metadata);
assertTrue("There should be six presenters", updatedPresenters.getA().size() == 6);
assertTrue("There should be three technical presenters", updatedPresenters.getB().size() == 3);
assertTrue("The list of presenters should contain all of the non-user names", updatedPresenters.getA().containsAll(multiNonUserList));
assertTrue("The list of presenters should contain all of the user full names", updatedPresenters.getA().containsAll(userFullNames));
assertTrue("The list of technical presenters should contain all of the usernames", updatedPresenters.getB().containsAll(multiUserList));
}
use of org.opencastproject.security.api.SecurityService in project opencast by opencast.
the class IndexServiceImplTest method testUpdateMediaPackageMetadata.
@Test
public void testUpdateMediaPackageMetadata() throws Exception {
// mock/initialize dependencies
String username = "user1";
String org = "mh_default_org";
String testResourceLocation = "/events/update-event.json";
String metadataJson = IOUtils.toString(getClass().getResourceAsStream(testResourceLocation));
MetadataCollection metadataCollection = new DublinCoreMetadataCollection();
metadataCollection.addField(MetadataField.createTextMetadataField("title", Opt.some("title"), "EVENTS.EVENTS.DETAILS.METADATA.TITLE", false, true, Opt.none(), Opt.none(), Opt.none(), Opt.none(), Opt.none()));
metadataCollection.addField(MetadataField.createTextLongMetadataField("creator", Opt.some("creator"), "EVENTS.EVENTS.DETAILS.METADATA.PRESENTERS", false, false, Opt.none(), Opt.none(), Opt.none(), Opt.none(), Opt.none()));
metadataCollection.addField(MetadataField.createTextMetadataField("isPartOf", Opt.some("isPartOf"), "EVENTS.EVENTS.DETAILS.METADATA.SERIES", false, false, Opt.none(), Opt.none(), Opt.none(), Opt.none(), Opt.none()));
MetadataList metadataList = new MetadataList(metadataCollection, metadataJson);
String eventId = "event-1";
Event event = new Event(eventId, org);
event.setTitle("Test Event 1");
SearchQuery query = EasyMock.createMock(SearchQuery.class);
EasyMock.expect(query.getLimit()).andReturn(100);
EasyMock.expect(query.getOffset()).andReturn(0);
EasyMock.replay(query);
SearchResultItemImpl<Event> searchResultItem = new SearchResultItemImpl<>(1.0, event);
SearchResultImpl<Event> searchResult = new SearchResultImpl<>(query, 0, 0);
searchResult.addResultItem(searchResultItem);
SecurityService securityService = setupSecurityService(username, org);
AbstractSearchIndex index = EasyMock.createMock(AbstractSearchIndex.class);
MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().loadFromXml(getClass().getResourceAsStream("/events/update-event-mp.xml"));
EasyMock.expect(index.getByQuery(EasyMock.anyObject(EventSearchQuery.class))).andReturn(searchResult);
EasyMock.replay(index);
Workspace workspace = EasyMock.createMock(Workspace.class);
EasyMock.expect(workspace.put(EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyObject())).andReturn(getClass().getResource("/dublincore.xml").toURI()).anyTimes();
EasyMock.expect(workspace.read(EasyMock.anyObject())).andAnswer(() -> getClass().getResourceAsStream("/dublincore.xml")).anyTimes();
EasyMock.replay(workspace);
CommonEventCatalogUIAdapter commonEventCatalogUIAdapter = setupCommonCatalogUIAdapter(workspace).getA();
// Using scheduler as the source of the media package here.
SchedulerService schedulerService = EasyMock.createMock(SchedulerService.class);
EasyMock.expect(schedulerService.getMediaPackage(EasyMock.anyString())).andReturn(mp);
Capture<Opt<MediaPackage>> mpCapture = new Capture<>();
schedulerService.updateEvent(EasyMock.anyString(), EasyMock.anyObject(Opt.class), EasyMock.anyObject(Opt.class), EasyMock.anyObject(Opt.class), EasyMock.anyObject(Opt.class), EasyMock.capture(mpCapture), EasyMock.anyObject(Opt.class), EasyMock.anyObject(Opt.class), EasyMock.anyObject(Opt.class), EasyMock.anyString());
EasyMock.expectLastCall();
EasyMock.replay(schedulerService);
SeriesService seriesService = EasyMock.createMock(SeriesService.class);
DublinCoreCatalog seriesDC = DublinCores.read(getClass().getResourceAsStream("/events/update-event-series.xml"));
EasyMock.expect(seriesService.getSeries(EasyMock.anyString())).andReturn(seriesDC);
EasyMock.expect(seriesService.getSeriesAccessControl(EasyMock.anyString())).andReturn(null);
EasyMock.expect(seriesService.getSeriesElements(EasyMock.anyString())).andReturn(Opt.none());
EasyMock.replay(seriesService);
// create service
IndexServiceImpl indexService = new IndexServiceImpl();
indexService.setSecurityService(securityService);
indexService.setSchedulerService(schedulerService);
indexService.setCommonEventCatalogUIAdapter(commonEventCatalogUIAdapter);
indexService.addCatalogUIAdapter(commonEventCatalogUIAdapter);
indexService.setSeriesService(seriesService);
indexService.setWorkspace(workspace);
MetadataList updateEventMetadata = indexService.updateEventMetadata(org, metadataList, index);
Assert.assertTrue(mpCapture.hasCaptured());
Assert.assertEquals("series-1", mp.getSeries());
Assert.assertEquals(1, mp.getCatalogs(MediaPackageElements.SERIES).length);
}
Aggregations