@Test void resolveArgument_withValidRequestPayload_shouldReturnNotificationSubject() throws Exception { NotificationSubjectArgumentResolver notificationSubjectArgumentResolver = new NotificationSubjectArgumentResolver(); Method methodWithNotificationSubjectArgument = this.getClass() .getDeclaredMethod("methodWithNotificationSubjectArgument", String.class); MethodParameter methodParameter = new MethodParameter( methodWithNotificationSubjectArgument, 0); ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); jsonObject.put("Type", "Notification"); jsonObject.put("Subject", "My subject!"); jsonObject.put("Message", "message"); String payload = jsonObject.toString(); Message<String> message = MessageBuilder.withPayload(payload).build(); Object result = notificationSubjectArgumentResolver .resolveArgument(methodParameter, message); assertThat(String.class.isInstance(result)).isTrue(); assertThat(result).isEqualTo("My subject!"); }
@Override public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception { return ((NotificationRequestConverter.NotificationRequest) this.converter .fromMessage(message, String.class)).getSubject(); }
NotificationSubjectArgumentResolver implements HandlerMethodArgumentResolver { @Override public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception { return ((NotificationRequestConverter.NotificationRequest) this.converter .fromMessage(message, String.class)).getSubject(); } }
NotificationSubjectArgumentResolver implements HandlerMethodArgumentResolver { @Override public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception { return ((NotificationRequestConverter.NotificationRequest) this.converter .fromMessage(message, String.class)).getSubject(); } NotificationSubjectArgumentResolver(); }
NotificationSubjectArgumentResolver implements HandlerMethodArgumentResolver { @Override public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception { return ((NotificationRequestConverter.NotificationRequest) this.converter .fromMessage(message, String.class)).getSubject(); } NotificationSubjectArgumentResolver(); @Override boolean supportsParameter(MethodParameter parameter); @Override Object resolveArgument(MethodParameter parameter, Message<?> message); }
NotificationSubjectArgumentResolver implements HandlerMethodArgumentResolver { @Override public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception { return ((NotificationRequestConverter.NotificationRequest) this.converter .fromMessage(message, String.class)).getSubject(); } NotificationSubjectArgumentResolver(); @Override boolean supportsParameter(MethodParameter parameter); @Override Object resolveArgument(MethodParameter parameter, Message<?> message);  }