@Test public void testResponse_whenNoHandlerForResponse_thenShouldReplyWithDefaultError() throws Exception { RootRequest rootRequest = new RootRequest(); RootResponse expectedResponse = ResponseBuilder.tellResponse(ActionsConfig.ERROR_MESSAGE); assistantActions.handleRequest(rootRequest); verify(responseHandlerMock).onResponse(expectedResponse); }
public void handleRequest(RootRequest rootRequest) { responseHandler.onPrepareContentType(ActionsConfig.HTTP_CONTENT_TYPE_JSON); responseHandler.onPrepareResponseHeaders(ActionsConfig.RESPONSE_HEADERS); String actionIntent = AssistantUtils.getActionIntent(rootRequest); if (actionIntent != null && requestHandlersFactories.containsKey(actionIntent)) { RequestHandler requestHandler = requestHandlersFactories.get(actionIntent).create(rootRequest); responseHandler.onResponse(requestHandler.getResponse()); } else { responseHandler.onResponse(ResponseBuilder.tellResponse(ActionsConfig.ERROR_MESSAGE)); } }
AssistantActions { public void handleRequest(RootRequest rootRequest) { responseHandler.onPrepareContentType(ActionsConfig.HTTP_CONTENT_TYPE_JSON); responseHandler.onPrepareResponseHeaders(ActionsConfig.RESPONSE_HEADERS); String actionIntent = AssistantUtils.getActionIntent(rootRequest); if (actionIntent != null && requestHandlersFactories.containsKey(actionIntent)) { RequestHandler requestHandler = requestHandlersFactories.get(actionIntent).create(rootRequest); responseHandler.onResponse(requestHandler.getResponse()); } else { responseHandler.onResponse(ResponseBuilder.tellResponse(ActionsConfig.ERROR_MESSAGE)); } } }
AssistantActions { public void handleRequest(RootRequest rootRequest) { responseHandler.onPrepareContentType(ActionsConfig.HTTP_CONTENT_TYPE_JSON); responseHandler.onPrepareResponseHeaders(ActionsConfig.RESPONSE_HEADERS); String actionIntent = AssistantUtils.getActionIntent(rootRequest); if (actionIntent != null && requestHandlersFactories.containsKey(actionIntent)) { RequestHandler requestHandler = requestHandlersFactories.get(actionIntent).create(rootRequest); responseHandler.onResponse(requestHandler.getResponse()); } else { responseHandler.onResponse(ResponseBuilder.tellResponse(ActionsConfig.ERROR_MESSAGE)); } } AssistantActions(ResponseHandler responseHandler,
                     Map<String, RequestHandler.Factory> requestHandlersFactories); }
AssistantActions { public void handleRequest(RootRequest rootRequest) { responseHandler.onPrepareContentType(ActionsConfig.HTTP_CONTENT_TYPE_JSON); responseHandler.onPrepareResponseHeaders(ActionsConfig.RESPONSE_HEADERS); String actionIntent = AssistantUtils.getActionIntent(rootRequest); if (actionIntent != null && requestHandlersFactories.containsKey(actionIntent)) { RequestHandler requestHandler = requestHandlersFactories.get(actionIntent).create(rootRequest); responseHandler.onResponse(requestHandler.getResponse()); } else { responseHandler.onResponse(ResponseBuilder.tellResponse(ActionsConfig.ERROR_MESSAGE)); } } AssistantActions(ResponseHandler responseHandler,
                     Map<String, RequestHandler.Factory> requestHandlersFactories); void handleRequest(RootRequest rootRequest); }
AssistantActions { public void handleRequest(RootRequest rootRequest) { responseHandler.onPrepareContentType(ActionsConfig.HTTP_CONTENT_TYPE_JSON); responseHandler.onPrepareResponseHeaders(ActionsConfig.RESPONSE_HEADERS); String actionIntent = AssistantUtils.getActionIntent(rootRequest); if (actionIntent != null && requestHandlersFactories.containsKey(actionIntent)) { RequestHandler requestHandler = requestHandlersFactories.get(actionIntent).create(rootRequest); responseHandler.onResponse(requestHandler.getResponse()); } else { responseHandler.onResponse(ResponseBuilder.tellResponse(ActionsConfig.ERROR_MESSAGE)); } } AssistantActions(ResponseHandler responseHandler,
                     Map<String, RequestHandler.Factory> requestHandlersFactories); void handleRequest(RootRequest rootRequest);  }