use of org.cometd.common.HashMapMessage in project ddf by codice.
the class NotificationControllerTest method verifyGetPersistedNotificationsWithMessageData.
private void verifyGetPersistedNotificationsWithMessageData(Map<String, Object> messageData, boolean notificationPublished) {
Message message = new HashMapMessage();
message.put(Message.DATA_FIELD, messageData);
List<Map<String, Object>> notifications = new ArrayList<>();
notifications.add(testEventProperties);
NotificationController spyNotificationController = spy(notificationController);
doReturn(notifications).when(spyNotificationController).getNotificationsForUser(anyString());
// Don't want queuePersistedMessages to start up a new thread.
doNothing().when(spyNotificationController).queuePersistedMessages(any(ServerSession.class), Matchers.<List<Map<String, Object>>>any(), anyString());
spyNotificationController.getPersistedNotifications(mockServerSession, message);
if (notificationPublished) {
ArgumentCaptor<Event> eventArgumentCaptor = ArgumentCaptor.forClass(Event.class);
verify(spyNotificationController.eventAdmin, times(1)).postEvent(eventArgumentCaptor.capture());
Event event = eventArgumentCaptor.getValue();
assertThat(event.getProperty(Notification.NOTIFICATION_KEY_APPLICATION), is(MOCK_APPLICATION));
assertThat(event.getProperty(Notification.NOTIFICATION_KEY_MESSAGE), is(MOCK_MESSAGE));
assertThat(event.getProperty(Notification.NOTIFICATION_KEY_TIMESTAMP), is(ISODateTimeFormat.dateTime().print(MOCK_TIMESTAMP)));
assertThat(event.getProperty(Notification.NOTIFICATION_KEY_TITLE), is(MOCK_TITLE));
assertThat(event.getProperty(Notification.NOTIFICATION_KEY_SESSION_ID), is(MOCK_SESSION_ID));
assertThat(event.getProperty(Notification.NOTIFICATION_KEY_USER_ID), is(MOCK_SESSION_ID));
} else {
verify(spyNotificationController, times(1)).queuePersistedMessages(eq(mockServerSession), eq(notifications), startsWith(EXPECTED_COMETD_NOTIFICATIONS_CHANNEL_PREFIX));
}
}
use of org.cometd.common.HashMapMessage in project ddf by codice.
the class ActivityControllerTest method verifyGetPersistedActivitiesWithMessageData.
private void verifyGetPersistedActivitiesWithMessageData(Map<String, Object> messageData, boolean expectPublish) {
Message message = new HashMapMessage();
message.put(Message.DATA_FIELD, messageData);
List<Map<String, Object>> activities = new ArrayList<>();
activities.add(testEventProperties);
ActivityController spyActivityController = spy(activityController);
doReturn(activities).when(spyActivityController).getActivitiesForUser(anyString());
// Don't want queuePersistedMessages to start up a new thread.
doNothing().when(spyActivityController).queuePersistedMessages(any(ServerSession.class), Matchers.<List<Map<String, Object>>>any(), anyString());
spyActivityController.getPersistedActivities(mockServerSession, message);
if (expectPublish) {
verify(spyActivityController, times(1)).queuePersistedMessages(eq(mockServerSession), eq(activities), startsWith(EXPECTED_COMETD_ACTIVITIES_CHANNEL_PREFIX));
} else {
verify(spyActivityController, never()).queuePersistedMessages(any(ServerSession.class), Matchers.<List<Map<String, Object>>>any(), anyString());
}
}
Aggregations