use of org.opencastproject.scheduler.api.SchedulerEvent in project opencast by opencast.
the class CommentSchedulerConflictNotifierTest method testCommentSchedulerConflict.
@Test
public void testCommentSchedulerConflict() 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);
EventCommentService eventCommentService = EasyMock.createNiceMock(EventCommentService.class);
EasyMock.expect(eventCommentService.updateComment(EasyMock.anyObject(EventComment.class))).andReturn(null).once();
EasyMock.replay(eventCommentService);
conflictNotifier.setEventCommentService(eventCommentService);
conflictNotifier.notifyConflicts(conflicts);
EasyMock.verify(eventCommentService);
}
use of org.opencastproject.scheduler.api.SchedulerEvent 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