Source:
public void testVia() { final String vehicle = "car"; final String weighting = "fastest"; instance = new GraphHopperOSM().setStoreOnFlush(true). init(new GraphHopperConfig(). putObject("datareader.file", testOsm3). putObject("prepare.min_network_size", "1"). putObject("graph.flag_encoders", vehicle) .setProfiles(Collections.singletonList(new ProfileConfig("profile").setVehicle(vehicle).setWeighting(weighting))) .setCHProfiles(Collections.singletonList(new CHProfileConfig("profile"))) ). setGraphHopperLocation(ghLoc); instance.importOrLoad(); GHPoint first = new GHPoint(11.1, 50); GHPoint second = new GHPoint(12, 51); GHPoint third = new GHPoint(11.2, 51.9); GHResponse rsp12 = instance.route(new GHRequest().addPoint(first).addPoint(second).setVehicle(vehicle).setWeighting(weighting)); assertFalse("should find 1->2", rsp12.hasErrors()); assertEquals(147930.5, rsp12.getBest().getDistance(), .1); GHResponse rsp23 = instance.route(new GHRequest().addPoint(second).addPoint(third).setVehicle(vehicle).setWeighting(weighting)); assertFalse("should find 2->3", rsp23.hasErrors()); assertEquals(176608.9, rsp23.getBest().getDistance(), .1); GHResponse grsp = instance.route(new GHRequest().addPoint(first).addPoint(second).addPoint(third).setVehicle(vehicle).setWeighting(weighting)); assertFalse("should find 1->2->3", grsp.hasErrors()); PathWrapper rsp = grsp.getBest(); assertEquals(rsp12.getBest().getDistance() + rsp23.getBest().getDistance(), rsp.getDistance(), 1e-6); assertEquals(4, rsp.getPoints().getSize()); assertEquals(5, rsp.getInstructions().size()); assertEquals(Instruction.REACHED_VIA, rsp.getInstructions().get(1).getSign()); }

Target:
public void testVia() { final String vehicle = "car"; final String weighting = "fastest"; instance = new GraphHopperOSM().setStoreOnFlush(true). init(new GraphHopperConfig(). putObject("datareader.file", testOsm3). putObject("prepare.min_network_size", 1). putObject("graph.flag_encoders", vehicle) .setProfiles(Collections.singletonList(new ProfileConfig("profile").setVehicle(vehicle).setWeighting(weighting))) .setCHProfiles(Collections.singletonList(new CHProfileConfig("profile"))) ). setGraphHopperLocation(ghLoc); instance.importOrLoad(); GHPoint first = new GHPoint(11.1, 50); GHPoint second = new GHPoint(12, 51); GHPoint third = new GHPoint(11.2, 51.9); GHResponse rsp12 = instance.route(new GHRequest().addPoint(first).addPoint(second).setVehicle(vehicle).setWeighting(weighting)); assertFalse("should find 1->2", rsp12.hasErrors()); assertEquals(147930.5, rsp12.getBest().getDistance(), .1); GHResponse rsp23 = instance.route(new GHRequest().addPoint(second).addPoint(third).setVehicle(vehicle).setWeighting(weighting)); assertFalse("should find 2->3", rsp23.hasErrors()); assertEquals(176608.9, rsp23.getBest().getDistance(), .1); GHResponse grsp = instance.route(new GHRequest().addPoint(first).addPoint(second).addPoint(third).setVehicle(vehicle).setWeighting(weighting)); assertFalse("should find 1->2->3", grsp.hasErrors()); PathWrapper rsp = grsp.getBest(); assertEquals(rsp12.getBest().getDistance() + rsp23.getBest().getDistance(), rsp.getDistance(), 1e-6); assertEquals(4, rsp.getPoints().getSize()); assertEquals(5, rsp.getInstructions().size()); assertEquals(Instruction.REACHED_VIA, rsp.getInstructions().get(1).getSign()); }