@Test public void mailFeedback_complaint() throws Exception { request.addHeader("x-amz-sns-message-type", "Notification"); String message = q("{" + " 'notificationType':'Complaint'," + " 'complaint':{" + " 'complaintFeedbackType':'abuse'," + " 'complainedRecipients':[" + " {" + " 'emailAddress':'complaint@simulator.amazonses.com'" + " }" + " ]," + " 'userAgent':'Amazon SES Mailbox Simulator'," + " 'timestamp':'2014-10-26T14:24:39.000Z'," + " 'feedbackId':'000001494cd839bf-d1d08066-5d1b-11e4-8869-1119a4f60aa4-000000'" + " }," + " 'mail':{" + " 'timestamp':'2014-10-26T14:24:38.000Z'," + " 'source':'noreply@kaif.io'," + " 'messageId':'000001494cd8372a-d52bda52-c14b-46fa-a624-b6a85d22d289-000000'," + " 'destination':[" + " 'complaint@simulator.amazonses.com'" + " ]" + " }" + "}"); request.setContent(toJsonBytes(ImmutableMap.of("Type", "Notification", "MessageId", "7eac2174-75c1-5c0a-9a5d-6db373a6be23", "Message", message))); controller.mailFeedback(request); verify(accountService).complaintEmail(asList("complaint@simulator.amazonses.com")); }
@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);  }