@Test public void testSupportAndResolve() throws NoSuchMethodException { Method method = MappingsController.class.getMethod("handleSlotValues", new Class[]{Map.class}); MethodParameter methodParameter = new MethodParameter( method, 0, Map.class, method.getParameterAnnotations()[0] ); RequestEnvelope envelope = Utils.buildSimpleEnvelope("intent"); ArgumentResolverContext input = new ArgumentResolverContext(mockSkillContext, methodParameter, HandlerInput.builder().withRequestEnvelope(envelope).build()); assertEquals(Collections.singletonMap("GREETING", "hola"), resolver.resolve(input).get()); }
@Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.requestTypeEquals(IntentRequest.class) && input.parameterTypeEquals(Map.class) && input.getMethodParameter().findAnnotation(SlotValues.class).isPresent()) { IntentRequest request = (IntentRequest) input.unwrapRequest(); return Optional.of(request.getIntent() .getSlots().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getValue()))); } else { return Optional.empty(); } }
SlotValuesArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.requestTypeEquals(IntentRequest.class) && input.parameterTypeEquals(Map.class) && input.getMethodParameter().findAnnotation(SlotValues.class).isPresent()) { IntentRequest request = (IntentRequest) input.unwrapRequest(); return Optional.of(request.getIntent() .getSlots().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getValue()))); } else { return Optional.empty(); } } }
SlotValuesArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.requestTypeEquals(IntentRequest.class) && input.parameterTypeEquals(Map.class) && input.getMethodParameter().findAnnotation(SlotValues.class).isPresent()) { IntentRequest request = (IntentRequest) input.unwrapRequest(); return Optional.of(request.getIntent() .getSlots().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getValue()))); } else { return Optional.empty(); } }  }
SlotValuesArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.requestTypeEquals(IntentRequest.class) && input.parameterTypeEquals(Map.class) && input.getMethodParameter().findAnnotation(SlotValues.class).isPresent()) { IntentRequest request = (IntentRequest) input.unwrapRequest(); return Optional.of(request.getIntent() .getSlots().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getValue()))); } else { return Optional.empty(); } }  @Override Optional<Object> resolve(ArgumentResolverContext input); }
SlotValuesArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.requestTypeEquals(IntentRequest.class) && input.parameterTypeEquals(Map.class) && input.getMethodParameter().findAnnotation(SlotValues.class).isPresent()) { IntentRequest request = (IntentRequest) input.unwrapRequest(); return Optional.of(request.getIntent() .getSlots().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getValue()))); } else { return Optional.empty(); } }  @Override Optional<Object> resolve(ArgumentResolverContext input);  }