@Test public void mailFeedback_delivery() throws Exception { request.addHeader("x-amz-sns-message-type", "Notification"); String message = q("{" + " 'notificationType':'Delivery'," + " 'mail':{" + " 'timestamp':'2014-10-26T12:20:16.071Z'," + " 'source':'noreply@kaif.io'," + " 'messageId':'000001494c665847-0a24c891-a43a-4b7a-99c0-60968e638bc4-000000'," + " 'destination':[" + " 'success@simulator.amazonses.com'" + " ]" + " }," + " 'delivery':{" + " 'timestamp':'2014-10-26T12:20:16.689Z'," + " 'processingTimeMillis':618," + " 'recipients':[" + " 'success@simulator.amazonses.com'" + " ]," + " 'smtpResponse':'250 2.6.0 Message received'," + " 'reportingMTA':'a8-52.smtp-out.amazonses.com'" + " }" + "}"); request.setContent(toJsonBytes(ImmutableMap.of("Type", "Notification", "MessageId", "21b2766f-a4c2-5e4f-8eaa-3aa9775ce46f", "Message", message))); controller.mailFeedback(request); q(""); }
@RequestMapping(value = "/mail-feedback", method = RequestMethod.POST) public void mailFeedback(HttpServletRequest request) throws IOException { String messageType = Optional.ofNullable(request.getHeader("x-amz-sns-message-type")) .map(Strings::emptyToNull) .orElse(NO_SUCH_FIELD); switch (messageType) { case "SubscriptionConfirmation": handleSubscriptionConfirmation(request); break; case "Notification": handleNotification(request); break; default: logger.warn("receive unknown sns, headers:\n" + dumpHeaders(request) + "\nbody:\n" + inputToString(request.getInputStream())); break; } }
AwsSnsRestController { @RequestMapping(value = "/mail-feedback", method = RequestMethod.POST) public void mailFeedback(HttpServletRequest request) throws IOException { String messageType = Optional.ofNullable(request.getHeader("x-amz-sns-message-type")) .map(Strings::emptyToNull) .orElse(NO_SUCH_FIELD); switch (messageType) { case "SubscriptionConfirmation": handleSubscriptionConfirmation(request); break; case "Notification": handleNotification(request); break; default: logger.warn("receive unknown sns, headers:\n" + dumpHeaders(request) + "\nbody:\n" + inputToString(request.getInputStream())); break; } } }
AwsSnsRestController { @RequestMapping(value = "/mail-feedback", method = RequestMethod.POST) public void mailFeedback(HttpServletRequest request) throws IOException { String messageType = Optional.ofNullable(request.getHeader("x-amz-sns-message-type")) .map(Strings::emptyToNull) .orElse(NO_SUCH_FIELD); switch (messageType) { case "SubscriptionConfirmation": handleSubscriptionConfirmation(request); break; case "Notification": handleNotification(request); break; default: logger.warn("receive unknown sns, headers:\n" + dumpHeaders(request) + "\nbody:\n" + inputToString(request.getInputStream())); break; } } AwsSnsRestController(); @VisibleForTesting  AwsSnsRestController(AccountService accountService); }
AwsSnsRestController { @RequestMapping(value = "/mail-feedback", method = RequestMethod.POST) public void mailFeedback(HttpServletRequest request) throws IOException { String messageType = Optional.ofNullable(request.getHeader("x-amz-sns-message-type")) .map(Strings::emptyToNull) .orElse(NO_SUCH_FIELD); switch (messageType) { case "SubscriptionConfirmation": handleSubscriptionConfirmation(request); break; case "Notification": handleNotification(request); break; default: logger.warn("receive unknown sns, headers:\n" + dumpHeaders(request) + "\nbody:\n" + inputToString(request.getInputStream())); break; } } AwsSnsRestController(); @VisibleForTesting  AwsSnsRestController(AccountService accountService); @RequestMapping(value = "/mail-feedback", method = RequestMethod.POST) void mailFeedback(HttpServletRequest request); }
AwsSnsRestController { @RequestMapping(value = "/mail-feedback", method = RequestMethod.POST) public void mailFeedback(HttpServletRequest request) throws IOException { String messageType = Optional.ofNullable(request.getHeader("x-amz-sns-message-type")) .map(Strings::emptyToNull) .orElse(NO_SUCH_FIELD); switch (messageType) { case "SubscriptionConfirmation": handleSubscriptionConfirmation(request); break; case "Notification": handleNotification(request); break; default: logger.warn("receive unknown sns, headers:\n" + dumpHeaders(request) + "\nbody:\n" + inputToString(request.getInputStream())); break; } } AwsSnsRestController(); @VisibleForTesting  AwsSnsRestController(AccountService accountService); @RequestMapping(value = "/mail-feedback", method = RequestMethod.POST) void mailFeedback(HttpServletRequest request);  }