### Question:
GoogleMatrixSyncRequester extends GHMatrixAbstractRequester { @Override public MatrixResponse route(GHMRequest ghRequest) { String pointsStr; pointsStr = createGoogleQuery(ghRequest.getFromPoints(), "origins"); pointsStr += "&" + createGoogleQuery(ghRequest.getToPoints(), "destinations"); List<String> outArraysList = new ArrayList<>(ghRequest.getOutArrays()); if (outArraysList.isEmpty()) { outArraysList.add("distances"); outArraysList.add("times"); } String url = buildURL("", ghRequest); url += "&" + pointsStr + "&mode=" + ghRequest.getVehicle(); boolean withTimes = outArraysList.contains("times"); boolean withDistances = outArraysList.contains("distances"); boolean withWeights = outArraysList.contains("weights"); if (withWeights) { throw new UnsupportedOperationException("Google Matrix API does not include weights"); } MatrixResponse matrixResponse = new MatrixResponse( ghRequest.getFromPoints().size(), ghRequest.getToPoints().size(), withTimes, withDistances, false); try { String str = getJson(url); JsonNode getResponseJson = objectMapper.reader().readTree(str); fillResponseFromJson(matrixResponse, getResponseJson); } catch (IOException ex) { throw new RuntimeException(ex); } return matrixResponse; } GoogleMatrixSyncRequester();  GoogleMatrixSyncRequester(String serviceUrl); @Override MatrixResponse route(GHMRequest ghRequest); @Override void fillResponseFromJson(MatrixResponse matrixResponse, String responseAsString);  }### Answer:
@Test public void testMatrix() throws IOException { GHMRequest req = new GHMRequest(); req.addFromPoint(new GHPoint(51.534377, -0.087891)); req.addFromPoint(new GHPoint(51.467697, -0.090637)); req.addToPoint(new GHPoint(51.521241, -0.171833)); req.addToPoint(new GHPoint(51.467697, -0.090637)); req.addToPoint(new GHPoint(51.534377, -0.087891)); GraphHopperMatrixWeb matrix = createMatrixClient(AbstractGHMatrixWebTester.readFile( new InputStreamReader(getClass().getResourceAsStream("google-matrix1.json")))); MatrixResponse rsp = matrix.route(req); assertEquals(712692, rsp.getDistance(0, 1), .1); assertEquals(25995, rsp.getTime(0, 1) / 1000); assertEquals(806813, rsp.getDistance(1, 2), .1); assertEquals(28737, rsp.getTime(1, 2) / 1000); }
@Test public void testMatrixWithError() throws IOException { GHMRequest req = createRequest(); GraphHopperMatrixWeb matrix = createMatrixClient(AbstractGHMatrixWebTester.readFile( new InputStreamReader(getClass().getResourceAsStream("google-error1.json")))); MatrixResponse rsp = matrix.route(req); assertTrue(rsp.hasErrors()); }