@Test public void testService() throws URISyntaxException { String declaringClassCanonicalName = Foo.class.getCanonicalName(); String methodName = "sayHello"; Object[] arguments = new String[] {"Hello from " + getClass().getName()}; String rootPath = Paths.get(getClass().getResource("/").toURI()).toString() + File.separator; boolean useRootRelativePath = true; try { String msg = (String) simulatorAdapter.service(declaringClassCanonicalName, methodName, arguments, rootPath, useRootRelativePath); assertEquals("Hello " + getClass().getName() + " from SimulatorAdapter", msg); } catch (Exception e) { fail(e.getMessage()); } }
public Object service(String declaringClassCanonicalName, String methodName, Object[] arguments, String rootPath, boolean useRootRelativePath) throws Exception { log.debug("declaringClassCanonicalName: {}, methodName: {}, arguments: {}, rootPath: {}, useRootRelativePath: {}", new Object[]{declaringClassCanonicalName, methodName, arguments, rootPath, useRootRelativePath}); String rootRelativePath = useRootRelativePath ? getRootRelativePath(declaringClassCanonicalName, methodName) : ""; String simulatorRequest = createRequest(arguments); Optional<SimulatorResponse> simulatorResponseOptional = simulator.service(rootPath, rootRelativePath, simulatorRequest, CONTENT_TYPE); SimulatorResponse simulatorResponse = simulatorResponseOptional.get(); Object response = createResponse(simulatorResponse.getResponse()); if (response instanceof Throwable) { throw (Exception) response; } return response; }
SimulatorAdapter { public Object service(String declaringClassCanonicalName, String methodName, Object[] arguments, String rootPath, boolean useRootRelativePath) throws Exception { log.debug("declaringClassCanonicalName: {}, methodName: {}, arguments: {}, rootPath: {}, useRootRelativePath: {}", new Object[]{declaringClassCanonicalName, methodName, arguments, rootPath, useRootRelativePath}); String rootRelativePath = useRootRelativePath ? getRootRelativePath(declaringClassCanonicalName, methodName) : ""; String simulatorRequest = createRequest(arguments); Optional<SimulatorResponse> simulatorResponseOptional = simulator.service(rootPath, rootRelativePath, simulatorRequest, CONTENT_TYPE); SimulatorResponse simulatorResponse = simulatorResponseOptional.get(); Object response = createResponse(simulatorResponse.getResponse()); if (response instanceof Throwable) { throw (Exception) response; } return response; } }
SimulatorAdapter { public Object service(String declaringClassCanonicalName, String methodName, Object[] arguments, String rootPath, boolean useRootRelativePath) throws Exception { log.debug("declaringClassCanonicalName: {}, methodName: {}, arguments: {}, rootPath: {}, useRootRelativePath: {}", new Object[]{declaringClassCanonicalName, methodName, arguments, rootPath, useRootRelativePath}); String rootRelativePath = useRootRelativePath ? getRootRelativePath(declaringClassCanonicalName, methodName) : ""; String simulatorRequest = createRequest(arguments); Optional<SimulatorResponse> simulatorResponseOptional = simulator.service(rootPath, rootRelativePath, simulatorRequest, CONTENT_TYPE); SimulatorResponse simulatorResponse = simulatorResponseOptional.get(); Object response = createResponse(simulatorResponse.getResponse()); if (response instanceof Throwable) { throw (Exception) response; } return response; }  }
SimulatorAdapter { public Object service(String declaringClassCanonicalName, String methodName, Object[] arguments, String rootPath, boolean useRootRelativePath) throws Exception { log.debug("declaringClassCanonicalName: {}, methodName: {}, arguments: {}, rootPath: {}, useRootRelativePath: {}", new Object[]{declaringClassCanonicalName, methodName, arguments, rootPath, useRootRelativePath}); String rootRelativePath = useRootRelativePath ? getRootRelativePath(declaringClassCanonicalName, methodName) : ""; String simulatorRequest = createRequest(arguments); Optional<SimulatorResponse> simulatorResponseOptional = simulator.service(rootPath, rootRelativePath, simulatorRequest, CONTENT_TYPE); SimulatorResponse simulatorResponse = simulatorResponseOptional.get(); Object response = createResponse(simulatorResponse.getResponse()); if (response instanceof Throwable) { throw (Exception) response; } return response; }  Object service(String declaringClassCanonicalName, String methodName, Object[] arguments, String rootPath, boolean useRootRelativePath); }
SimulatorAdapter { public Object service(String declaringClassCanonicalName, String methodName, Object[] arguments, String rootPath, boolean useRootRelativePath) throws Exception { log.debug("declaringClassCanonicalName: {}, methodName: {}, arguments: {}, rootPath: {}, useRootRelativePath: {}", new Object[]{declaringClassCanonicalName, methodName, arguments, rootPath, useRootRelativePath}); String rootRelativePath = useRootRelativePath ? getRootRelativePath(declaringClassCanonicalName, methodName) : ""; String simulatorRequest = createRequest(arguments); Optional<SimulatorResponse> simulatorResponseOptional = simulator.service(rootPath, rootRelativePath, simulatorRequest, CONTENT_TYPE); SimulatorResponse simulatorResponse = simulatorResponseOptional.get(); Object response = createResponse(simulatorResponse.getResponse()); if (response instanceof Throwable) { throw (Exception) response; } return response; }  Object service(String declaringClassCanonicalName, String methodName, Object[] arguments, String rootPath, boolean useRootRelativePath);  }