@Test public void testSupportAndResolve() throws NoSuchMethodException { MethodParameter methodParameter = new MethodParameter( this.getClass().getMethod("testSupportAndResolve"), 0, MappingsController.PetTypeIntent.class, MethodParameter.EMPTY_ANNOTATIONS ); RequestEnvelope envelope = Utils.buildSimpleEnvelope("PetTypeIntent", "pet", "DRAGON"); ArgumentResolverContext input = new ArgumentResolverContext(mockSkillContext, methodParameter, HandlerInput.builder().withRequestEnvelope(envelope).build()); Object resolved = resolver.resolve(input).get(); assertTrue(resolved instanceof MappingsController.PetTypeIntent); }
@Override public Optional<Object> resolve(ArgumentResolverContext input) { try { if (input.requestTypeEquals(IntentRequest.class)) { Object model = intentMapper.parseIntent((IntentRequest) input.unwrapRequest()); if (input.getMethodParameter().getType().isInstance(model)) { return Optional.of(model); } } } catch (IntentParseException e) { } return Optional.empty(); }
IntentModelArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { try { if (input.requestTypeEquals(IntentRequest.class)) { Object model = intentMapper.parseIntent((IntentRequest) input.unwrapRequest()); if (input.getMethodParameter().getType().isInstance(model)) { return Optional.of(model); } } } catch (IntentParseException e) { } return Optional.empty(); } }
IntentModelArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { try { if (input.requestTypeEquals(IntentRequest.class)) { Object model = intentMapper.parseIntent((IntentRequest) input.unwrapRequest()); if (input.getMethodParameter().getType().isInstance(model)) { return Optional.of(model); } } } catch (IntentParseException e) { } return Optional.empty(); } IntentModelArgumentResolver(IntentMapper intentMapper); }
IntentModelArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { try { if (input.requestTypeEquals(IntentRequest.class)) { Object model = intentMapper.parseIntent((IntentRequest) input.unwrapRequest()); if (input.getMethodParameter().getType().isInstance(model)) { return Optional.of(model); } } } catch (IntentParseException e) { } return Optional.empty(); } IntentModelArgumentResolver(IntentMapper intentMapper); @Override Optional<Object> resolve(ArgumentResolverContext input); }
IntentModelArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { try { if (input.requestTypeEquals(IntentRequest.class)) { Object model = intentMapper.parseIntent((IntentRequest) input.unwrapRequest()); if (input.getMethodParameter().getType().isInstance(model)) { return Optional.of(model); } } } catch (IntentParseException e) { } return Optional.empty(); } IntentModelArgumentResolver(IntentMapper intentMapper); @Override Optional<Object> resolve(ArgumentResolverContext input);  }