@Test public void testIfEmailSenderServiceIsCalledWithEventValues() throws EmailSendException { String from = "testfromaddress"; String to = "testtoaddress"; String message = "test message"; String subject = "test subject"; Map<String, Object> values = new HashMap<>(); values.put(FROM_ADDRESS, from); values.put(TO_ADDRESS, to); values.put(MESSAGE, message); values.put(SUBJECT, subject); emailEventHandler.handle(new MotechEvent(SEND_EMAIL_SUBJECT, values)); verify(emailSenderService).send(from, to, subject, message); }
@MotechListener (subjects = { SendEmailConstants.SEND_EMAIL_SUBJECT }) public void handle(MotechEvent event) throws EmailSendException { String fromAddress = (String) event.getParameters().get(SendEmailConstants.FROM_ADDRESS); String toAddress = (String) event.getParameters().get(SendEmailConstants.TO_ADDRESS); String subject = (String) event.getParameters().get(SendEmailConstants.SUBJECT); String message = (String) event.getParameters().get(SendEmailConstants.MESSAGE); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Send email event received: from - {}, to - {}, subject - {}, message - {}", fromAddress, toAddress, subject, message); } emailSenderService.send(fromAddress, toAddress, subject, message); }
SendEmailEventHandlerImpl { @MotechListener (subjects = { SendEmailConstants.SEND_EMAIL_SUBJECT }) public void handle(MotechEvent event) throws EmailSendException { String fromAddress = (String) event.getParameters().get(SendEmailConstants.FROM_ADDRESS); String toAddress = (String) event.getParameters().get(SendEmailConstants.TO_ADDRESS); String subject = (String) event.getParameters().get(SendEmailConstants.SUBJECT); String message = (String) event.getParameters().get(SendEmailConstants.MESSAGE); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Send email event received: from - {}, to - {}, subject - {}, message - {}", fromAddress, toAddress, subject, message); } emailSenderService.send(fromAddress, toAddress, subject, message); } }
SendEmailEventHandlerImpl { @MotechListener (subjects = { SendEmailConstants.SEND_EMAIL_SUBJECT }) public void handle(MotechEvent event) throws EmailSendException { String fromAddress = (String) event.getParameters().get(SendEmailConstants.FROM_ADDRESS); String toAddress = (String) event.getParameters().get(SendEmailConstants.TO_ADDRESS); String subject = (String) event.getParameters().get(SendEmailConstants.SUBJECT); String message = (String) event.getParameters().get(SendEmailConstants.MESSAGE); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Send email event received: from - {}, to - {}, subject - {}, message - {}", fromAddress, toAddress, subject, message); } emailSenderService.send(fromAddress, toAddress, subject, message); }  }
SendEmailEventHandlerImpl { @MotechListener (subjects = { SendEmailConstants.SEND_EMAIL_SUBJECT }) public void handle(MotechEvent event) throws EmailSendException { String fromAddress = (String) event.getParameters().get(SendEmailConstants.FROM_ADDRESS); String toAddress = (String) event.getParameters().get(SendEmailConstants.TO_ADDRESS); String subject = (String) event.getParameters().get(SendEmailConstants.SUBJECT); String message = (String) event.getParameters().get(SendEmailConstants.MESSAGE); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Send email event received: from - {}, to - {}, subject - {}, message - {}", fromAddress, toAddress, subject, message); } emailSenderService.send(fromAddress, toAddress, subject, message); }  @MotechListener (subjects = { SendEmailConstants.SEND_EMAIL_SUBJECT }) void handle(MotechEvent event); }
SendEmailEventHandlerImpl { @MotechListener (subjects = { SendEmailConstants.SEND_EMAIL_SUBJECT }) public void handle(MotechEvent event) throws EmailSendException { String fromAddress = (String) event.getParameters().get(SendEmailConstants.FROM_ADDRESS); String toAddress = (String) event.getParameters().get(SendEmailConstants.TO_ADDRESS); String subject = (String) event.getParameters().get(SendEmailConstants.SUBJECT); String message = (String) event.getParameters().get(SendEmailConstants.MESSAGE); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Send email event received: from - {}, to - {}, subject - {}, message - {}", fromAddress, toAddress, subject, message); } emailSenderService.send(fromAddress, toAddress, subject, message); }  @MotechListener (subjects = { SendEmailConstants.SEND_EMAIL_SUBJECT }) void handle(MotechEvent event);  }