### Question:
ResponseBuilderArgumentResolver implements ArgumentResolver { @Override public Optional<Object> resolve(ArgumentResolverContext input) { if (input.parameterTypeEquals(ResponseBuilder.class)) { return Optional.of(input.getHandlerInput().getResponseBuilder()); } return Optional.empty(); }  @Override Optional<Object> resolve(ArgumentResolverContext input);  }### Answer:
@Test public void testSupportAndResolve() throws NoSuchMethodException { MethodParameter methodParameter = new MethodParameter( this.getClass().getMethod("testSupportAndResolve"), 0, ResponseBuilder.class, MethodParameter.EMPTY_ANNOTATIONS ); RequestEnvelope envelope = Utils.buildSimpleEnvelope("intent"); HandlerInput handlerInput = HandlerInput.builder().withRequestEnvelope(envelope).build(); ArgumentResolverContext input = new ArgumentResolverContext(mockSkillContext, methodParameter, handlerInput); assertTrue(resolver.resolve(input).get() instanceof ResponseBuilder); }
@Test public void testResolvesNewInstance() throws NoSuchMethodException { MethodParameter methodParameter = new MethodParameter( this.getClass().getMethod("testSupportAndResolve"), 0, ResponseBuilder.class, MethodParameter.EMPTY_ANNOTATIONS ); RequestEnvelope envelope = Utils.buildSimpleEnvelope("intent"); HandlerInput handlerInput = HandlerInput.builder().withRequestEnvelope(envelope).build(); ArgumentResolverContext input = new ArgumentResolverContext(mockSkillContext, methodParameter, handlerInput); Object resolved = resolver.resolve(input); Object secondResolved = resolver.resolve(input); assertNotSame(handlerInput.getResponseBuilder(), resolved); assertNotSame(secondResolved, resolved); }
@Test public void testDoesntSupport() throws NoSuchMethodException { MethodParameter methodParameter = new MethodParameter( this.getClass().getMethod("testSupportAndResolve"), 0, Object.class, MethodParameter.EMPTY_ANNOTATIONS ); RequestEnvelope envelope = Utils.buildSimpleEnvelope("intent"); ArgumentResolverContext input = new ArgumentResolverContext(mockSkillContext, methodParameter, HandlerInput.builder().withRequestEnvelope(envelope).build()); assertFalse(resolver.resolve(input).isPresent()); }