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