use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.
the class ConfigurablePublishWorkflowOperationHandlerTest method testTemplateReplacement.
@Test
public void testTemplateReplacement() throws WorkflowOperationException, URISyntaxException {
URI elementUri = new URI("http://element.com/path/to/element/element.mp4");
String mpId = "mp-id";
String pubUUID = "test-uuid";
String seriesId = "series-id";
MediaPackage mp = EasyMock.createNiceMock(MediaPackage.class);
Id id = new IdImpl(mpId);
EasyMock.expect(mp.getIdentifier()).andStubReturn(id);
MediaPackageElement element = EasyMock.createNiceMock(MediaPackageElement.class);
EasyMock.expect(element.getURI()).andStubReturn(elementUri);
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getOrganization()).andStubReturn(org);
EasyMock.replay(element, mp, securityService);
// Test player path and mediapackage id
ConfigurablePublishWorkflowOperationHandler configurePublish = new ConfigurablePublishWorkflowOperationHandler();
configurePublish.setSecurityService(securityService);
URI result = configurePublish.populateUrlWithVariables("${player_path}${event_id}", mp, pubUUID);
assertEquals(examplePlayer + "mp-id", result.toString());
// Test without series
configurePublish = new ConfigurablePublishWorkflowOperationHandler();
configurePublish.setSecurityService(securityService);
result = configurePublish.populateUrlWithVariables("${series_id}/${event_id}", mp, pubUUID);
assertEquals("/mp-id", result.toString());
// Test with series
mp = EasyMock.createNiceMock(MediaPackage.class);
EasyMock.expect(mp.getIdentifier()).andStubReturn(id);
EasyMock.expect(mp.getSeries()).andStubReturn(seriesId);
EasyMock.replay(mp);
configurePublish = new ConfigurablePublishWorkflowOperationHandler();
configurePublish.setSecurityService(securityService);
result = configurePublish.populateUrlWithVariables("${series_id}/${event_id}", mp, pubUUID);
assertEquals("series-id/mp-id", result.toString());
// Test publication uuid
configurePublish = new ConfigurablePublishWorkflowOperationHandler();
configurePublish.setSecurityService(securityService);
result = configurePublish.populateUrlWithVariables("${publication_id}", mp, pubUUID);
assertEquals(pubUUID, result.toString());
}
use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.
the class CommentWorkflowOperationHandlerTest method testDuplicateComments.
@Test
public void testDuplicateComments() throws WorkflowOperationException, EventCommentException {
// Testing that a duplicate comment won't be created but a different one will still be created.
Long workflowId = 10L;
String mediaPackageId = "abc-def";
String action = "create";
String reason = "Waiting for Trim";
String description = "The comment description";
Organization org = createNiceMock(Organization.class);
expect(org.getId()).andStubReturn("demo");
replay(org);
SecurityService secSrv = createNiceMock(SecurityService.class);
expect(secSrv.getOrganization()).andStubReturn(org);
replay(secSrv);
// Setup WorkflowOperation Instance
WorkflowOperationInstance workflowOperationInstance = EasyMock.createMock(WorkflowOperationInstance.class);
EasyMock.expect(workflowOperationInstance.getConfiguration(CommentWorkflowOperationHandler.ACTION)).andReturn(action).anyTimes();
EasyMock.expect(workflowOperationInstance.getConfiguration(CommentWorkflowOperationHandler.REASON)).andReturn(reason).anyTimes();
EasyMock.expect(workflowOperationInstance.getConfiguration(CommentWorkflowOperationHandler.DESCRIPTION)).andReturn(description).anyTimes();
// Setup mediaPackage
MediaPackage mediaPackage = EasyMock.createMock(MediaPackage.class);
EasyMock.expect(mediaPackage.getIdentifier()).andReturn(new IdImpl(mediaPackageId)).anyTimes();
// Setup user
User creator = EasyMock.createMock(User.class);
// Setup WorkflowInstance
WorkflowInstance workflowInstance = EasyMock.createMock(WorkflowInstance.class);
EasyMock.expect(workflowInstance.getId()).andReturn(workflowId).anyTimes();
EasyMock.expect(workflowInstance.getCurrentOperation()).andReturn(workflowOperationInstance).anyTimes();
EasyMock.expect(workflowInstance.getMediaPackage()).andReturn(mediaPackage).anyTimes();
EasyMock.expect(workflowInstance.getCreator()).andReturn(creator).anyTimes();
// Test no previous comments
EventCommentService eventCommentService = EasyMock.createMock(EventCommentService.class);
EasyMock.expect(eventCommentService.getComments(mediaPackageId)).andReturn(new ArrayList<EventComment>());
Capture<EventComment> comment = EasyMock.newCapture();
EasyMock.expect(eventCommentService.updateComment(EasyMock.capture(comment))).andReturn(EventComment.create(Option.option(15L), mediaPackageId, org.getId(), description, creator));
EasyMock.replay(creator, eventCommentService, mediaPackage, workflowInstance, workflowOperationInstance);
CommentWorkflowOperationHandler commentWorkflowOperationHandler = new CommentWorkflowOperationHandler();
commentWorkflowOperationHandler.setEventCommentService(eventCommentService);
commentWorkflowOperationHandler.setSecurityService(secSrv);
commentWorkflowOperationHandler.start(workflowInstance, null);
assertTrue(comment.hasCaptured());
assertEquals(creator, comment.getValue().getAuthor());
assertEquals(description, comment.getValue().getText());
assertEquals(reason, comment.getValue().getReason());
// Test previous comment with same reason and description
List<EventComment> comments = new ArrayList<EventComment>();
comments.add(EventComment.create(Option.option(13L), mediaPackageId, org.getId(), description, creator, reason, true));
eventCommentService = EasyMock.createMock(EventCommentService.class);
EasyMock.expect(eventCommentService.getComments(mediaPackageId)).andReturn(comments);
EasyMock.replay(eventCommentService);
commentWorkflowOperationHandler = new CommentWorkflowOperationHandler();
commentWorkflowOperationHandler.setEventCommentService(eventCommentService);
commentWorkflowOperationHandler.start(workflowInstance, null);
assertTrue(comment.hasCaptured());
assertEquals(creator, comment.getValue().getAuthor());
assertEquals(description, comment.getValue().getText());
assertEquals(reason, comment.getValue().getReason());
// Test previous comment with different reasons and descriptions
comments = new ArrayList<EventComment>();
comments.add(EventComment.create(Option.option(15L), mediaPackageId, org.getId(), "Different description", creator, reason, true));
comments.add(EventComment.create(Option.option(15L), mediaPackageId, org.getId(), description, creator, "Different reason", true));
eventCommentService = EasyMock.createMock(EventCommentService.class);
EasyMock.expect(eventCommentService.getComments(mediaPackageId)).andReturn(comments);
comment = EasyMock.newCapture();
EasyMock.expect(eventCommentService.updateComment(EasyMock.capture(comment))).andReturn(EventComment.create(Option.option(15L), mediaPackageId, org.getId(), description, creator));
EasyMock.replay(eventCommentService);
commentWorkflowOperationHandler = new CommentWorkflowOperationHandler();
commentWorkflowOperationHandler.setEventCommentService(eventCommentService);
commentWorkflowOperationHandler.setSecurityService(secSrv);
commentWorkflowOperationHandler.start(workflowInstance, null);
assertTrue(comment.hasCaptured());
assertEquals(creator, comment.getValue().getAuthor());
assertEquals(description, comment.getValue().getText());
assertEquals(reason, comment.getValue().getReason());
}
use of org.opencastproject.mediapackage.identifier.IdImpl in project opencast by opencast.
the class EmailSchedulerConflictNotifierTest method testEmailSchedulerConflict.
@Test
public void testEmailSchedulerConflict() throws Exception {
Set<String> userIds = new HashSet<>();
userIds.add("user1");
userIds.add("user2");
Map<String, String> caProperties = new HashMap<String, String>();
caProperties.put("test", "true");
caProperties.put("clear", "all");
Map<String, String> wfProperties = new HashMap<String, String>();
wfProperties.put("test", "false");
wfProperties.put("skip", "true");
final String mpId = "1234";
final TechnicalMetadata technicalMetadata = new TechnicalMetadataImpl(mpId, "demo", new Date(), new Date(new Date().getTime() + 10 * 60 * 1000), false, userIds, wfProperties, caProperties, null);
final MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
mp.setIdentifier(new IdImpl(mpId));
mp.add(DublinCores.mkOpencastEpisode().getCatalog());
DublinCoreCatalog extendedEvent = DublinCores.mkStandard();
extendedEvent.setFlavor(new MediaPackageElementFlavor("extended", "episode"));
mp.add(extendedEvent);
final SchedulerEvent schedulerEvent = EasyMock.createNiceMock(SchedulerEvent.class);
EasyMock.expect(schedulerEvent.getTechnicalMetadata()).andReturn(technicalMetadata).anyTimes();
EasyMock.expect(schedulerEvent.getMediaPackage()).andReturn(mp).anyTimes();
EasyMock.expect(schedulerEvent.getEventId()).andReturn(mpId).anyTimes();
EasyMock.expect(schedulerEvent.getVersion()).andReturn("2").anyTimes();
EasyMock.replay(schedulerEvent);
ConflictingEvent conflictingEvent = EasyMock.createNiceMock(ConflictingEvent.class);
EasyMock.expect(conflictingEvent.getOldEvent()).andReturn(schedulerEvent).anyTimes();
EasyMock.expect(conflictingEvent.getNewEvent()).andReturn(schedulerEvent).anyTimes();
EasyMock.expect(conflictingEvent.getConflictStrategy()).andReturn(Strategy.NEW).anyTimes();
EasyMock.replay(conflictingEvent);
List<ConflictingEvent> conflicts = new ArrayList<>();
conflicts.add(conflictingEvent);
final Integer[] counter = new Integer[1];
counter[0] = 0;
SmtpService smtpService = new SmtpService() {
@Override
public void send(MimeMessage message) throws MessagingException {
counter[0]++;
}
};
conflictNotifier.setSmtpService(smtpService);
conflictNotifier.notifyConflicts(conflicts);
Assert.assertEquals(1, counter[0].intValue());
}
Aggregations