IntentRequestHandler implements RequestHandler { @Override public Optional<Response> handle(HandlerInput input) { try { return handle(input, intentReader.read((IntentRequest) input.getRequestEnvelope().getRequest())); } catch (IntentParseException ex) { String msg = String.format("Failed to read a '%s' from intent request", intentClass.getName()); logger.error(msg); throw new RuntimeException(msg, ex); } } IntentRequestHandler(Class<T> intentClass, IntentMapper intentMapper);  IntentRequestHandler(Class<T> intentClass, IntentReader<T> intentReader); @Override boolean canHandle(HandlerInput input); @Override Optional<Response> handle(HandlerInput input);  }
@Test public void testParseInHandle() { TestIntentHandler underTest = new TestIntentHandler(mapper); when(mockInput.getRequestEnvelope()).thenReturn(RequestEnvelope.builder() .withRequest(IntentRequest.builder() .withIntent(com.amazon.ask.model.Intent.builder() .withName("TestIntent") .withSlots(Collections.singletonMap( "amazonDate", Slot.builder() .withName("amazonDate") .withValue("2018-12-01") .build() )) .build()) .build()) .build()); underTest.handle(mockInput); TestIntent expected = new TestIntent(); expected.setAmazonDate(new SpecificDate(Slot.builder() .withName("amazonDate") .withValue("2018-12-01") .build(), LocalDate.of(2018, 12, 1))); verify(spy).handle(mockInput, expected); }