@Test public void testSupportAndResolve() throws NoSuchMethodException { Method method = MappingsController.class.getMethod("handleSlotArg", new Class[]{Slot.class}); MethodParameter methodParameter = new MethodParameter( method, 0, Slot.class, method.getParameterAnnotations()[0] ); RequestEnvelope envelope = Utils.buildSimpleEnvelope("intent"); ArgumentResolverContext input = new ArgumentResolverContext(mockSkillContext, methodParameter, HandlerInput.builder().withRequestEnvelope(envelope).build()); assertSame(((IntentRequest) envelope.getRequest()).getIntent().getSlots().get("GREETING"), resolver.resolve(input).get()); }
@Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.requestTypeEquals(IntentRequest.class) && input.parameterTypeEquals(Slot.class) && input.getMethodParameter().findAnnotation(com.amazon.ask.mvc.annotation.argument.Slot.class).isPresent()) { String slotName = input.getMethodParameter().findAnnotation(com.amazon.ask.mvc.annotation.argument.Slot.class).get().value(); IntentRequest request = (IntentRequest) input.unwrapRequest(); return Optional.of(request.getIntent().getSlots().get(slotName)); } return Optional.empty(); }
SlotArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.requestTypeEquals(IntentRequest.class) && input.parameterTypeEquals(Slot.class) && input.getMethodParameter().findAnnotation(com.amazon.ask.mvc.annotation.argument.Slot.class).isPresent()) { String slotName = input.getMethodParameter().findAnnotation(com.amazon.ask.mvc.annotation.argument.Slot.class).get().value(); IntentRequest request = (IntentRequest) input.unwrapRequest(); return Optional.of(request.getIntent().getSlots().get(slotName)); } return Optional.empty(); } }
SlotArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.requestTypeEquals(IntentRequest.class) && input.parameterTypeEquals(Slot.class) && input.getMethodParameter().findAnnotation(com.amazon.ask.mvc.annotation.argument.Slot.class).isPresent()) { String slotName = input.getMethodParameter().findAnnotation(com.amazon.ask.mvc.annotation.argument.Slot.class).get().value(); IntentRequest request = (IntentRequest) input.unwrapRequest(); return Optional.of(request.getIntent().getSlots().get(slotName)); } return Optional.empty(); }  }
SlotArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.requestTypeEquals(IntentRequest.class) && input.parameterTypeEquals(Slot.class) && input.getMethodParameter().findAnnotation(com.amazon.ask.mvc.annotation.argument.Slot.class).isPresent()) { String slotName = input.getMethodParameter().findAnnotation(com.amazon.ask.mvc.annotation.argument.Slot.class).get().value(); IntentRequest request = (IntentRequest) input.unwrapRequest(); return Optional.of(request.getIntent().getSlots().get(slotName)); } return Optional.empty(); }  @Override Optional<Object> resolve(ArgumentResolverContext input); }
SlotArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.requestTypeEquals(IntentRequest.class) && input.parameterTypeEquals(Slot.class) && input.getMethodParameter().findAnnotation(com.amazon.ask.mvc.annotation.argument.Slot.class).isPresent()) { String slotName = input.getMethodParameter().findAnnotation(com.amazon.ask.mvc.annotation.argument.Slot.class).get().value(); IntentRequest request = (IntentRequest) input.unwrapRequest(); return Optional.of(request.getIntent().getSlots().get(slotName)); } return Optional.empty(); }  @Override Optional<Object> resolve(ArgumentResolverContext input);  }