use of org.motechproject.event.MotechEvent in project motech by motech.
the class AnnotationBasedHandlerIT method testRelay.
@Test
public void testRelay() {
MotechEvent e = new MotechEvent("sub_b", null);
clear();
eventRelay.relayQueueEvent(e);
assertTrue(test);
e = new MotechEvent("sub_c", null);
clear();
eventRelay.relayQueueEvent(e);
assertTrue(test);
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class AnnotationBasedHandlerIT method testNamedParamsHappy.
@Test
public void testNamedParamsHappy() {
clear();
MotechEvent event = new MotechEvent("named");
event.getParameters().put("id", "id0012");
event.getParameters().put("key", "2354");
eventRelay.relayQueueEvent(event);
assertTrue(test);
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class PasswordReminderEventHandlerTest method prepareEvent.
private void prepareEvent() {
Map<String, Object> params = new HashMap<>();
params.put(TEMPLATE_PARAM_USERNAME, user.getUserName());
params.put(EMAIL_PARAM_TO_ADDRESS, user.getEmail());
params.put(TEMPLATE_PARAM_EXPIRATION_DATE, user.getSafeLastPasswordChange().plusDays(DAYS_TO_CHANGE_PASSWORD));
params.put(TEMPLATE_PARAM_LOCALE, user.getLocale());
params.put(TEMPLATE_PARAM_LAST_PASSWORD_CHANGE, user.getSafeLastPasswordChange());
params.put(TEMPLATE_PARAM_EXTERNAL_ID, user.getExternalId());
params.put(TEMPLATE_PARAM_DAYS_TILL_EXPIRE, DAYS_FOR_REMINDER);
event = new MotechEvent(PASSWORD_CHANGE_REMINDER_EVENT, params);
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class EmailSenderImpl method sendEmail.
private void sendEmail(String userEmail, String messageText, String messageSubject) {
Map<String, Object> params = new HashMap<>();
params.put(EMAIL_PARAM_FROM_ADDRESS, getSenderAddress());
params.put(EMAIL_PARAM_TO_ADDRESS, userEmail);
params.put(EMAIL_PARAM_MESSAGE, messageText);
params.put(EMAIL_PARAM_SUBJECT, messageSubject);
MotechEvent emailEvent = new MotechEvent("SendEMail", params);
eventRelay.sendEventMessage(emailEvent);
LOGGER.info("Sent email event: {}", emailEvent.getSubject());
}
use of org.motechproject.event.MotechEvent in project motech by motech.
the class ChannelServiceImplTest method shouldSendEventWhenChannelWasUpdated.
@Test
public void shouldSendEventWhenChannelWasUpdated() {
Channel channel = new Channel("displayName", BUNDLE_SYMBOLIC_NAME, VERSION);
EventParameter eventParameter = new EventParameter("displayName", "eventKey");
TriggerEvent triggerEvent = new TriggerEvent("displayName", "subject", null, Arrays.asList(eventParameter), "");
channel.getTriggerTaskEvents().add(triggerEvent);
when(channelsDataService.findByModuleName(channel.getModuleName())).thenReturn(channel);
when(bundleContext.getBundles()).thenReturn(new Bundle[] { bundle });
when(bundle.getSymbolicName()).thenReturn(BUNDLE_SYMBOLIC_NAME);
ArgumentCaptor<MotechEvent> captor = ArgumentCaptor.forClass(MotechEvent.class);
Channel updatedChannel = new Channel("displayName2", BUNDLE_SYMBOLIC_NAME, VERSION);
updatedChannel.getTriggerTaskEvents().add(triggerEvent);
channelService.addOrUpdate(updatedChannel);
verify(channelsDataService).update(channel);
verify(eventRelay).sendEventMessage(captor.capture());
MotechEvent event = captor.getValue();
assertEquals(CHANNEL_UPDATE_SUBJECT, event.getSubject());
assertEquals(BUNDLE_SYMBOLIC_NAME, event.getParameters().get(CHANNEL_MODULE_NAME));
}
Aggregations