@Test void resolveArgument_withValidMessagePayload_shouldReturnNotificationMessage() throws Exception { NotificationMessageArgumentResolver notificationMessageArgumentResolver = new NotificationMessageArgumentResolver( new StringMessageConverter()); Method methodWithNotificationMessageArgument = this.getClass() .getDeclaredMethod("methodWithNotificationMessageArgument", String.class); MethodParameter methodParameter = new MethodParameter( methodWithNotificationMessageArgument, 0); ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); jsonObject.put("Type", "Notification"); jsonObject.put("Message", "Hello World!"); String payload = jsonObject.toString(); Message<String> message = MessageBuilder.withPayload(payload).build(); Object result = notificationMessageArgumentResolver .resolveArgument(methodParameter, message); assertThat(String.class.isInstance(result)).isTrue(); assertThat(result).isEqualTo("Hello World!"); }
@Override public Object resolveArgument(MethodParameter par, Message<?> msg) throws Exception { Object object = this.converter.fromMessage(msg, par.getParameterType()); NotificationRequestConverter.NotificationRequest nr = (NotificationRequestConverter.NotificationRequest) object; return nr.getMessage(); }
NotificationMessageArgumentResolver implements HandlerMethodArgumentResolver { @Override public Object resolveArgument(MethodParameter par, Message<?> msg) throws Exception { Object object = this.converter.fromMessage(msg, par.getParameterType()); NotificationRequestConverter.NotificationRequest nr = (NotificationRequestConverter.NotificationRequest) object; return nr.getMessage(); } }
NotificationMessageArgumentResolver implements HandlerMethodArgumentResolver { @Override public Object resolveArgument(MethodParameter par, Message<?> msg) throws Exception { Object object = this.converter.fromMessage(msg, par.getParameterType()); NotificationRequestConverter.NotificationRequest nr = (NotificationRequestConverter.NotificationRequest) object; return nr.getMessage(); } NotificationMessageArgumentResolver(MessageConverter converter); }
NotificationMessageArgumentResolver implements HandlerMethodArgumentResolver { @Override public Object resolveArgument(MethodParameter par, Message<?> msg) throws Exception { Object object = this.converter.fromMessage(msg, par.getParameterType()); NotificationRequestConverter.NotificationRequest nr = (NotificationRequestConverter.NotificationRequest) object; return nr.getMessage(); } NotificationMessageArgumentResolver(MessageConverter converter); @Override boolean supportsParameter(MethodParameter parameter); @Override Object resolveArgument(MethodParameter par, Message<?> msg); }
NotificationMessageArgumentResolver implements HandlerMethodArgumentResolver { @Override public Object resolveArgument(MethodParameter par, Message<?> msg) throws Exception { Object object = this.converter.fromMessage(msg, par.getParameterType()); NotificationRequestConverter.NotificationRequest nr = (NotificationRequestConverter.NotificationRequest) object; return nr.getMessage(); } NotificationMessageArgumentResolver(MessageConverter converter); @Override boolean supportsParameter(MethodParameter parameter); @Override Object resolveArgument(MethodParameter par, Message<?> msg);  }