src_fm_fc_ms_ff
stringlengths 43
86.8k
| target
stringlengths 20
276k
|
---|---|
Contour { public void calculateContour() { handleBaseCells(); cellStorage.flush(); IntObjectMap<IntHashSet> superCells = handleSuperCells(); cellStorage.storeContourPointerMap(); if (isSupercellsEnabled()) cellStorage.storeSuperCells(superCells); cellStorage.setContourPrepared(true); cellStorage.flush(); } Contour(GraphHopperStorage ghStorage, NodeAccess nodeAccess, IsochroneNodeStorage isochroneNodeStorage, CellStorage cellStorage); static double distance(double lat1, double lat2, double lon1,
double lon2); void calculateContour(); Contour setGhStorage(GraphHopperStorage ghStorage); } | @Test public void testCalculateContour() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createSimpleGraph(encodingManager); createMockStorages(graphHopperStorage); Contour contour = new Contour(graphHopperStorage, graphHopperStorage.getBaseGraph().getNodeAccess(), ins, cs); contour.calculateContour(); List<Double> coordinatesCell2 = cs.getCellContourOrder(2); assertEquals(2686, coordinatesCell2.size()); assertEquals(3.0, coordinatesCell2.get(0), 1e-10); assertEquals(1.0, coordinatesCell2.get(1), 1e-10); assertEquals(3.0, coordinatesCell2.get(2), 1e-10); assertEquals(1.003596954128078, coordinatesCell2.get(3), 1e-10); assertEquals(3.0, coordinatesCell2.get(2684), 1e-10); assertEquals(1.0, coordinatesCell2.get(2685), 1e-10); } |
Contour { public static double distance(double lat1, double lat2, double lon1, double lon2) { final int R = 6371; double latDistance = Math.toRadians(lat2 - lat1); double lonDistance = Math.toRadians(lon2 - lon1); double a = Math.sin(latDistance / 2) * Math.sin(latDistance / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); double distance = R * c * 1000; distance = Math.pow(distance, 2); return Math.sqrt(distance); } Contour(GraphHopperStorage ghStorage, NodeAccess nodeAccess, IsochroneNodeStorage isochroneNodeStorage, CellStorage cellStorage); static double distance(double lat1, double lat2, double lon1,
double lon2); void calculateContour(); Contour setGhStorage(GraphHopperStorage ghStorage); } | @Test public void testDistance() { double distance = Contour.distance(1, 1, 1, 2); assertEquals(111177.99068882648, distance, 1e-10); double distance2 = Contour.distance(1, 1, 0.5, -0.5); assertEquals(111177.99068882648, distance2, 1e-10); } |
FastIsochroneAlgorithm extends AbstractIsochroneAlgorithm { public Map<Integer, IntObjectMap<SPTEntry>> getActiveCellMaps() { return activeCellMaps; } FastIsochroneAlgorithm(Graph graph,
Weighting weighting,
TraversalMode tMode,
CellStorage cellStorage,
IsochroneNodeStorage isochroneNodeStorage,
EccentricityStorage eccentricityStorage,
BorderNodeDistanceStorage borderNodeDistanceStorage,
EdgeFilter additionalEdgeFilter); @Override void init(int from, double isochroneLimit); @Override boolean finishedStartCellPhase(); @Override boolean finishedBorderNodePhase(); @Override boolean finishedActiveCellPhase(); Set<Integer> getFullyReachableCells(); IntObjectMap<SPTEntry> getStartCellMap(); String getName(); Map<Integer, IntObjectMap<SPTEntry>> getActiveCellMaps(); } | @Test public void testExactWeightActiveCell() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createMediumGraphWithAdditionalEdge(encodingManager); Weighting shortestWeighting = new ShortestWeighting(carEncoder); createMockStorages(graphHopperStorage); Eccentricity ecc = new Eccentricity(graphHopperStorage, null, ins, cs); ecc.loadExisting(shortestWeighting); ecc.calcEccentricities(shortestWeighting, carEncoder); ecc.calcBorderNodeDistances(shortestWeighting, carEncoder); FastIsochroneAlgorithm fastIsochroneAlgorithm = new FastIsochroneAlgorithm( graphHopperStorage.getBaseGraph(), shortestWeighting, TraversalMode.NODE_BASED, cs, ins, ecc.getEccentricityStorage(shortestWeighting), ecc.getBorderNodeDistanceStorage(shortestWeighting), null); fastIsochroneAlgorithm.calcIsochroneNodes(1, 5.0); Set<Integer> nodeIds = new HashSet<>(); Set<Integer> expectedNodeIds = new HashSet<>(); expectedNodeIds.add(4); expectedNodeIds.add(7); for (IntObjectCursor<SPTEntry> entry : fastIsochroneAlgorithm.getActiveCellMaps().get(3)) { nodeIds.add(entry.value.adjNode); } assertEquals(expectedNodeIds, nodeIds); assertEquals(5.0, fastIsochroneAlgorithm.getActiveCellMaps().get(3).get(4).weight, 1e-10); assertEquals(5.0, fastIsochroneAlgorithm.getActiveCellMaps().get(3).get(7).weight, 1e-10); }
@Test public void testLimitInBetweenNodesActiveCell() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createMediumGraphWithAdditionalEdge(encodingManager); Weighting shortestWeighting = new ShortestWeighting(carEncoder); createMockStorages(graphHopperStorage); Eccentricity ecc = new Eccentricity(graphHopperStorage, null, ins, cs); ecc.loadExisting(shortestWeighting); ecc.calcEccentricities(shortestWeighting, carEncoder); ecc.calcBorderNodeDistances(shortestWeighting, carEncoder); FastIsochroneAlgorithm fastIsochroneAlgorithm = new FastIsochroneAlgorithm( graphHopperStorage.getBaseGraph(), shortestWeighting, TraversalMode.NODE_BASED, cs, ins, ecc.getEccentricityStorage(shortestWeighting), ecc.getBorderNodeDistanceStorage(shortestWeighting), null); fastIsochroneAlgorithm.calcIsochroneNodes(1, 5.5); Set<Integer> nodeIds = new HashSet<>(); Set<Integer> expectedNodeIds = new HashSet<>(); expectedNodeIds.add(4); expectedNodeIds.add(5); expectedNodeIds.add(6); expectedNodeIds.add(7); for (IntObjectCursor<SPTEntry> entry : fastIsochroneAlgorithm.getActiveCellMaps().get(3)) { nodeIds.add(entry.value.adjNode); } assertEquals(expectedNodeIds, nodeIds); assertEquals(5.0, fastIsochroneAlgorithm.getActiveCellMaps().get(3).get(4).weight, 1e-10); assertEquals(6.0, fastIsochroneAlgorithm.getActiveCellMaps().get(3).get(5).weight, 1e-10); assertEquals(6.0, fastIsochroneAlgorithm.getActiveCellMaps().get(3).get(6).weight, 1e-10); assertEquals(5.0, fastIsochroneAlgorithm.getActiveCellMaps().get(3).get(7).weight, 1e-10); } |
FastIsochroneAlgorithm extends AbstractIsochroneAlgorithm { public IntObjectMap<SPTEntry> getStartCellMap() { return startCellMap; } FastIsochroneAlgorithm(Graph graph,
Weighting weighting,
TraversalMode tMode,
CellStorage cellStorage,
IsochroneNodeStorage isochroneNodeStorage,
EccentricityStorage eccentricityStorage,
BorderNodeDistanceStorage borderNodeDistanceStorage,
EdgeFilter additionalEdgeFilter); @Override void init(int from, double isochroneLimit); @Override boolean finishedStartCellPhase(); @Override boolean finishedBorderNodePhase(); @Override boolean finishedActiveCellPhase(); Set<Integer> getFullyReachableCells(); IntObjectMap<SPTEntry> getStartCellMap(); String getName(); Map<Integer, IntObjectMap<SPTEntry>> getActiveCellMaps(); } | @Test public void testStartCell() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createMediumGraphWithAdditionalEdge(encodingManager); Weighting shortestWeighting = new ShortestWeighting(carEncoder); createMockStorages(graphHopperStorage); Eccentricity ecc = new Eccentricity(graphHopperStorage, null, ins, cs); ecc.loadExisting(shortestWeighting); ecc.calcEccentricities(shortestWeighting, carEncoder); ecc.calcBorderNodeDistances(shortestWeighting, carEncoder); FastIsochroneAlgorithm fastIsochroneAlgorithm = new FastIsochroneAlgorithm( graphHopperStorage.getBaseGraph(), shortestWeighting, TraversalMode.NODE_BASED, cs, ins, ecc.getEccentricityStorage(shortestWeighting), ecc.getBorderNodeDistanceStorage(shortestWeighting), null); fastIsochroneAlgorithm.calcIsochroneNodes(1, 5.5); Set<Integer> nodeIds = new HashSet<>(); Set<Integer> expectedNodeIds = new HashSet<>(); expectedNodeIds.add(0); expectedNodeIds.add(1); expectedNodeIds.add(2); expectedNodeIds.add(3); expectedNodeIds.add(8); for (IntObjectCursor<SPTEntry> entry : fastIsochroneAlgorithm.getStartCellMap()) { nodeIds.add(entry.value.adjNode); } assertEquals(expectedNodeIds, nodeIds); assertEquals(1.0, fastIsochroneAlgorithm.getStartCellMap().get(0).weight, 1e-10); assertEquals(0.0, fastIsochroneAlgorithm.getStartCellMap().get(1).weight, 1e-10); assertEquals(1.0, fastIsochroneAlgorithm.getStartCellMap().get(2).weight, 1e-10); assertEquals(3.0, fastIsochroneAlgorithm.getStartCellMap().get(3).weight, 1e-10); assertEquals(2.0, fastIsochroneAlgorithm.getStartCellMap().get(8).weight, 1e-10); } |
FastIsochroneAlgorithm extends AbstractIsochroneAlgorithm { public Set<Integer> getFullyReachableCells() { return fullyReachableCells; } FastIsochroneAlgorithm(Graph graph,
Weighting weighting,
TraversalMode tMode,
CellStorage cellStorage,
IsochroneNodeStorage isochroneNodeStorage,
EccentricityStorage eccentricityStorage,
BorderNodeDistanceStorage borderNodeDistanceStorage,
EdgeFilter additionalEdgeFilter); @Override void init(int from, double isochroneLimit); @Override boolean finishedStartCellPhase(); @Override boolean finishedBorderNodePhase(); @Override boolean finishedActiveCellPhase(); Set<Integer> getFullyReachableCells(); IntObjectMap<SPTEntry> getStartCellMap(); String getName(); Map<Integer, IntObjectMap<SPTEntry>> getActiveCellMaps(); } | @Test public void testFullyReachableCells() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createMediumGraphWithAdditionalEdge(encodingManager); Weighting shortestWeighting = new ShortestWeighting(carEncoder); createMockStorages(graphHopperStorage); Eccentricity ecc = new Eccentricity(graphHopperStorage, null, ins, cs); ecc.loadExisting(shortestWeighting); ecc.calcEccentricities(shortestWeighting, carEncoder); ecc.calcBorderNodeDistances(shortestWeighting, carEncoder); FastIsochroneAlgorithm fastIsochroneAlgorithm = new FastIsochroneAlgorithm( graphHopperStorage.getBaseGraph(), shortestWeighting, TraversalMode.NODE_BASED, cs, ins, ecc.getEccentricityStorage(shortestWeighting), ecc.getBorderNodeDistanceStorage(shortestWeighting), null); fastIsochroneAlgorithm.calcIsochroneNodes(1, 5.5); Set<Integer> cellIds = fastIsochroneAlgorithm.getFullyReachableCells(); Set<Integer> expectedCellIds = new HashSet<>(); assertEquals(expectedCellIds, cellIds); fastIsochroneAlgorithm = new FastIsochroneAlgorithm( graphHopperStorage.getBaseGraph(), shortestWeighting, TraversalMode.NODE_BASED, cs, ins, ecc.getEccentricityStorage(shortestWeighting), ecc.getBorderNodeDistanceStorage(shortestWeighting), null); fastIsochroneAlgorithm.calcIsochroneNodes(1, 6); cellIds = fastIsochroneAlgorithm.getFullyReachableCells(); expectedCellIds = new HashSet<>(); expectedCellIds.add(2); assertEquals(expectedCellIds, cellIds); fastIsochroneAlgorithm = new FastIsochroneAlgorithm( graphHopperStorage.getBaseGraph(), shortestWeighting, TraversalMode.NODE_BASED, cs, ins, ecc.getEccentricityStorage(shortestWeighting), ecc.getBorderNodeDistanceStorage(shortestWeighting), null); fastIsochroneAlgorithm.calcIsochroneNodes(8, 6); cellIds = fastIsochroneAlgorithm.getFullyReachableCells(); expectedCellIds = new HashSet<>(); expectedCellIds.add(2); expectedCellIds.add(3); assertEquals(expectedCellIds, cellIds); } |
ActiveCellDijkstra extends AbstractIsochroneDijkstra { protected void addInitialBordernode(int nodeId, double weight) { SPTEntry entry = new SPTEntry(nodeId, weight); fromHeap.add(entry); fromMap.put(nodeId, entry); } ActiveCellDijkstra(Graph graph, Weighting weighting, IsochroneNodeStorage isochroneNodeStorage, int cellId); void setIsochroneLimit(double limit); @Override String getName(); } | @Test public void testAddInitialBorderNode() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createMediumGraph(encodingManager); createMockStorages(graphHopperStorage); Weighting shortestWeighting = new ShortestWeighting(carEncoder); ActiveCellDijkstra activeCellDijkstra = new ActiveCellDijkstra(graphHopperStorage.getBaseGraph(), shortestWeighting, ins, 2); activeCellDijkstra.setIsochroneLimit(5000); for (int nodeId : new int[]{3, 8}) { activeCellDijkstra.addInitialBordernode(nodeId, 0); } SPTEntry entry = activeCellDijkstra.fromHeap.poll(); assertEquals(3, entry.adjNode); assertEquals(0.0, entry.getWeightOfVisitedPath(), 1e-10); entry = activeCellDijkstra.fromHeap.poll(); assertEquals(8, entry.adjNode); assertEquals(0.0, entry.getWeightOfVisitedPath(), 1e-10); assertEquals(2, activeCellDijkstra.getFromMap().size()); } |
RangeDijkstra extends AbstractIsochroneDijkstra { private void getMaxWeight() { for (IntObjectCursor<SPTEntry> entry : fromMap) { if (USERELEVANTONLY && !relevantNodes.contains(entry.key)) continue; if (maximumWeight < entry.value.weight) maximumWeight = entry.value.weight; } } RangeDijkstra(Graph graph, Weighting weighting); double calcMaxWeight(int from, IntHashSet relevantNodes); void setCellNodes(IntHashSet cellNodes); int getFoundCellNodeSize(); @Override String getName(); } | @Test public void testGetMaxWeight() { GraphHopperStorage graphHopperStorage = createSimpleGraph(); RangeDijkstra rangeDijkstra = new RangeDijkstra(graphHopperStorage.getBaseGraph(), new ShortestWeighting(carEncoder)); rangeDijkstra.setMaxVisitedNodes(getMaxCellNodesNumber() * 10); IntHashSet cellNodes = new IntHashSet(); IntHashSet relevantNodes = new IntHashSet(); cellNodes.addAll(0, 1, 2, 5); relevantNodes.addAll(0, 1, 2); rangeDijkstra.setCellNodes(cellNodes); assertEquals(3.0, rangeDijkstra.calcMaxWeight(0, cellNodes), 1e-10); rangeDijkstra = new RangeDijkstra(graphHopperStorage.getBaseGraph(), new ShortestWeighting(carEncoder)); rangeDijkstra.setMaxVisitedNodes(getMaxCellNodesNumber() * 10); rangeDijkstra.setCellNodes(cellNodes); assertEquals(1.0, rangeDijkstra.calcMaxWeight(0, relevantNodes), 1e-10); } |
PartitioningDataBuilder { PartitioningDataBuilder(Graph graph, PartitioningData pData) { this.graph = graph; this.pData = pData; } PartitioningDataBuilder(Graph graph, PartitioningData pData); void run(); } | @Test public void testPartitioningDataBuilder() { GraphHopperStorage ghStorage = ToyGraphCreationUtil.createMediumGraph(encodingManager); PartitioningData pData = new PartitioningData(); EdgeFilter edgeFilter = new EdgeFilterSequence(); PartitioningDataBuilder partitioningDataBuilder = new PartitioningDataBuilder(ghStorage.getBaseGraph(), pData); partitioningDataBuilder.run(); assertEquals(28, pData.flowEdgeBaseNode.length); assertEquals(28, pData.flow.length); assertEquals(0, pData.flowEdgeBaseNode[0]); assertEquals(1, pData.flowEdgeBaseNode[1]); assertEquals(0, pData.flowEdgeBaseNode[2]); assertEquals(2, pData.flowEdgeBaseNode[3]); assertEquals(10, pData.visited.length); assertEquals(0, pData.visited[0]); } |
OSMAttachedSidewalkProcessor { public ReaderWay attachSidewalkTag(ReaderWay way, Side side) { switch(side) { case LEFT: way.setTag(KEY_ORS_SIDEWALK_SIDE, VAL_LEFT); break; case RIGHT: way.setTag(KEY_ORS_SIDEWALK_SIDE, VAL_RIGHT); break; case BOTH: if(way.hasTag(KEY_ORS_SIDEWALK_SIDE) && way.getTag(KEY_ORS_SIDEWALK_SIDE).equalsIgnoreCase(VAL_LEFT)) { way.setTag(KEY_ORS_SIDEWALK_SIDE, VAL_RIGHT); } else { way.setTag(KEY_ORS_SIDEWALK_SIDE, VAL_LEFT); } break; case NONE: if(way.hasTag(KEY_ORS_SIDEWALK_SIDE)) { way.removeTag(KEY_ORS_SIDEWALK_SIDE); } } return way; } ReaderWay attachSidewalkTag(ReaderWay way, Side side); Side getPreparedSide(ReaderWay way); static final String KEY_ORS_SIDEWALK_SIDE; static final String VAL_RIGHT; static final String VAL_LEFT; } | @Test public void TestAttachingORSSidewalkSideTagForWayWithSingleSide() { ReaderWay way = new ReaderWay(1); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.LEFT); assertTrue(way.hasTag("ors-sidewalk-side")); String side = way.getTag("ors-sidewalk-side"); assertEquals("left", side); way = new ReaderWay(1); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.RIGHT); assertTrue(way.hasTag("ors-sidewalk-side")); side = way.getTag("ors-sidewalk-side"); assertEquals("right", side); }
@Test public void TestAttchingNoSidewalkRemovesAnyAlreadyAttachedORSSidewalkTags() { ReaderWay way = new ReaderWay(1); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.NONE); assertFalse(way.hasTag("ors-sidewalk-side")); way = new ReaderWay(1); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.LEFT); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.NONE); assertFalse(way.hasTag("ors-sidewalk-side")); }
@Test public void TestAttachingORSSidealkTagsWhenBothSidesHaveValues() { ReaderWay way = new ReaderWay(1); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.BOTH); assertTrue(way.hasTag("ors-sidewalk-side")); String side = way.getTag("ors-sidewalk-side"); assertEquals("left", side); way = processor.attachSidewalkTag(way, OSMAttachedSidewalkProcessor.Side.BOTH); assertTrue(way.hasTag("ors-sidewalk-side")); side = way.getTag("ors-sidewalk-side"); assertEquals("right", side); } |
Projector { protected Map<Projection, IntArrayList> calculateProjections() { EnumMap<Projection, IntArrayList> nodeListProjMap = new EnumMap<>(Projection.class); Integer[] ids = IntStream.rangeClosed(0, ghStorage.getNodes() - 1).boxed().toArray(Integer[]::new); Double[] values = new Double[ids.length]; Sort sort = new Sort(); for (Projection proj : Projection.values()) { for (int i = 0; i < ids.length; i++) { values[i] = proj.sortValue(ghStorage.getNodeAccess().getLatitude(ids[i]), ghStorage.getNodeAccess().getLongitude(ids[i])); } nodeListProjMap.put(proj, sort.sortByValueReturnList(ids, values)); } boolean valid = false; for (Projection proj : Projection.values()) { if (!nodeListProjMap.get(proj).equals(nodeListProjMap.get(LINE_M00))) valid = true; } if (!valid) throw new IllegalStateException("All projections of the graph are the same. Maybe NodeAccess is faulty or not initialized?"); return nodeListProjMap; } Projector(); void setGHStorage(GraphHopperStorage ghStorage); } | @Test public void testCalculateProjections() { Projector projector = new Projector(); projector.setGHStorage(ToyGraphCreationUtil.createMediumGraph2(encodingManager)); Map<Projector.Projection, IntArrayList> projections = projector.calculateProjections(); IntArrayList expected_m00 = new IntArrayList(); expected_m00.add(1, 2, 3, 0, 8, 4, 6, 5, 7); assertEquals(expected_m00, projections.get(Projector.Projection.LINE_M00)); IntArrayList expected_p90 = new IntArrayList(); expected_p90.add(1, 8, 0, 2, 6, 7, 3, 4, 5); assertEquals(expected_p90, projections.get(Projector.Projection.LINE_P90)); IntArrayList expected_p45 = new IntArrayList(); expected_p45.add(1, 2, 8, 0, 3, 6, 4, 7, 5); assertEquals(expected_p45, projections.get(Projector.Projection.LINE_P45)); } |
Projector { protected List<Projection> calculateProjectionOrder(Map<Projection, IntArrayList> projections) { List<Projection> order; EnumMap<Projection, Double> squareRangeProjMap = new EnumMap<>(Projection.class); EnumMap<Projection, Double> orthogonalDiffProjMap = new EnumMap<>(Projection.class); for (Map.Entry<Projection, IntArrayList> proj : projections.entrySet()) { int idx = (int) (proj.getValue().size() * getSplitValue()); squareRangeProjMap.put(proj.getKey(), projIndividualValue(projections, proj.getKey(), idx)); } for (Projection proj : projections.keySet()) { orthogonalDiffProjMap.put(proj, projCombinedValue(squareRangeProjMap, proj)); } Sort sort = new Sort(); order = sort.sortByValueReturnList(orthogonalDiffProjMap, false); return order; } Projector(); void setGHStorage(GraphHopperStorage ghStorage); } | @Test public void testCalculateProjectionOrder() { double originalSplitValue = getSplitValue(); setSplitValue(0); Projector projector = new Projector(); projector.setGHStorage(ToyGraphCreationUtil.createMediumGraph2(encodingManager)); Map<Projector.Projection, IntArrayList> projections = projector.calculateProjections(); List<Projector.Projection> projectionOrder = projector.calculateProjectionOrder(projections); assertEquals(Projector.Projection.LINE_P675, projectionOrder.get(0)); assertEquals(Projector.Projection.LINE_P45, projectionOrder.get(1)); assertEquals(Projector.Projection.LINE_M225, projectionOrder.get(7)); setSplitValue(originalSplitValue); } |
MaxFlowMinCut { protected void reset() { resetAlgorithm(); resetData(); } MaxFlowMinCut(Graph graph, PartitioningData pData, EdgeFilter edgeFilter); void setVisited(int node); boolean isVisited(int visited); void setUnvisitedAll(); abstract int getMaxFlow(); BiPartition calcNodePartition(); void setNodeOrder(); void setOrderedNodes(IntArrayList orderedNodes); void setAdditionalEdgeFilter(EdgeFilter edgeFilter); } | @Test public void testReset() { GraphHopperStorage graphHopperStorage = ToyGraphCreationUtil.createMediumGraph(encodingManager); Graph graph = graphHopperStorage.getBaseGraph(); int[] flowEdgeBaseNode = new int[]{ 0, 1, 0, 2, 0, 3, 0, 8, 1, 2, 1, 8, 2, 3, 3, 4, 4, 5, 4, 6, 5, 7, 6, 7, 7, 8, -1, -1 }; boolean[] flow = new boolean[]{ false, true, false, true, false, true, false, false, true, false, true, false, true, false, false, true, false, true, false, true, false, false, true, false, true, false, false, false }; int[] visited = new int[]{ 0, 1, 0, 1, 0, 1, 0, 1, 0, 0 }; PartitioningData pData = new PartitioningData(flowEdgeBaseNode, flow, visited); IntArrayList projection_m00 = new IntArrayList(); projection_m00.add(1, 2, 3, 0, 4, 6, 8, 5, 7); MaxFlowMinCut maxFlowMinCut = new EdmondsKarpAStar(graph, pData, null); maxFlowMinCut.setOrderedNodes(projection_m00); maxFlowMinCut.setNodeOrder(); maxFlowMinCut.reset(); for (boolean f : pData.flow) assertEquals(false, f); for (int v : pData.visited) assertEquals(0, v); } |
FastIsochroneFactory { public void init(CmdArgs args) { setMaxThreadCount(args.getInt(FastIsochrone.PREPARE + "threads", getMaxThreadCount())); setMaxCellNodesNumber(args.getInt(FastIsochrone.PREPARE + "maxcellnodes", getMaxCellNodesNumber())); String weightingsStr = args.get(FastIsochrone.PREPARE + "weightings", ""); if ("no".equals(weightingsStr)) { fastisochroneProfileStrings.clear(); } else if (!weightingsStr.isEmpty()) { setFastIsochroneProfilesAsStrings(Arrays.asList(weightingsStr.split(","))); } boolean enableThis = !fastisochroneProfileStrings.isEmpty(); setEnabled(enableThis); if (enableThis) { setDisablingAllowed(args.getBool(FastIsochrone.INIT_DISABLING_ALLOWED, isDisablingAllowed())); IsochronesServiceSettings.setFastIsochronesActive(args.get(FastIsochrone.PROFILE, "")); } } void init(CmdArgs args); FastIsochroneFactory setFastIsochroneProfilesAsStrings(List<String> profileStrings); Set<String> getFastisochroneProfileStrings(); FastIsochroneFactory addFastIsochroneProfileAsString(String profileString); final boolean isEnabled(); final FastIsochroneFactory setEnabled(boolean enabled); final boolean isDisablingAllowed(); final FastIsochroneFactory setDisablingAllowed(boolean disablingAllowed); FastIsochroneFactory setPartition(PreparePartition pp); PreparePartition getPartition(); void prepare(final StorableProperties properties); void createPreparation(GraphHopperStorage ghStorage, EdgeFilterSequence edgeFilters); void setExistingStorages(); IsochroneNodeStorage getIsochroneNodeStorage(); void setIsochroneNodeStorage(IsochroneNodeStorage isochroneNodeStorage); CellStorage getCellStorage(); void setCellStorage(CellStorage cellStorage); } | @Test public void testInit() { FastIsochroneFactory fastIsochroneFactory = intitFastIsochroneFactory(); assertTrue(fastIsochroneFactory.isEnabled()); assertTrue(fastIsochroneFactory.isDisablingAllowed()); assertEquals("fastest", fastIsochroneFactory.getFastisochroneProfileStrings().iterator().next()); } |
FastIsochroneFactory { public void prepare(final StorableProperties properties) { ExecutorService threadPool = Executors.newFixedThreadPool(1); ExecutorCompletionService<String> completionService = new ExecutorCompletionService<>(threadPool); final String name = "PreparePartition"; completionService.submit(() -> { Thread.currentThread().setName(name); getPartition().prepare(); setIsochroneNodeStorage(getPartition().getIsochroneNodeStorage()); setCellStorage(getPartition().getCellStorage()); properties.put(FastIsochrone.PREPARE + "date." + name, Helper.createFormatter().format(new Date())); }, name); threadPool.shutdown(); try { completionService.take().get(); } catch (Exception e) { threadPool.shutdownNow(); throw new IllegalStateException(e); } } void init(CmdArgs args); FastIsochroneFactory setFastIsochroneProfilesAsStrings(List<String> profileStrings); Set<String> getFastisochroneProfileStrings(); FastIsochroneFactory addFastIsochroneProfileAsString(String profileString); final boolean isEnabled(); final FastIsochroneFactory setEnabled(boolean enabled); final boolean isDisablingAllowed(); final FastIsochroneFactory setDisablingAllowed(boolean disablingAllowed); FastIsochroneFactory setPartition(PreparePartition pp); PreparePartition getPartition(); void prepare(final StorableProperties properties); void createPreparation(GraphHopperStorage ghStorage, EdgeFilterSequence edgeFilters); void setExistingStorages(); IsochroneNodeStorage getIsochroneNodeStorage(); void setIsochroneNodeStorage(IsochroneNodeStorage isochroneNodeStorage); CellStorage getCellStorage(); void setCellStorage(CellStorage cellStorage); } | @Test public void testPrepare() { GraphHopperStorage gs = ToyGraphCreationUtil.createMediumGraph(encodingManager); FastIsochroneFactory fastIsochroneFactory = intitFastIsochroneFactory(); fastIsochroneFactory.createPreparation(gs, null); fastIsochroneFactory.prepare(gs.getProperties()); assertNotNull(fastIsochroneFactory.getCellStorage()); assertNotNull(fastIsochroneFactory.getIsochroneNodeStorage()); } |
XMLBuilder { public String build(Gpx gpx) throws JAXBException { JAXBContext context = JAXBContext.newInstance(Gpx.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter sw = new StringWriter(); m.marshal(gpx, sw); return sw.toString(); } String build(Gpx gpx); } | @Test public void testBuild() throws JAXBException { XMLBuilder xMLBuilder = new XMLBuilder(); String result = xMLBuilder.build(gpx); Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<gpx version=\"1.0\" xmlns=\"https: " <metadata>\n" + " <name></name>\n" + " <desc></desc>\n" + " <author>\n" + " <name></name>\n" + " <email id=\"id\" domain=\"@domain\"/>\n" + " <link href=\"\">\n" + " <text></text>\n" + " <type></type>\n" + " </link>\n" + " </author>\n" + " <copyright author=\"\">\n" + " <year></year>\n" + " <license></license>\n" + " </copyright>\n" + " <time></time>\n" + " <keywords></keywords>\n" + " <bounds/>\n" + " <extensions>\n" + " <system-message>System message string</system-message>\n" + " </extensions>\n" + " </metadata>\n" + " <wpt lat=\"0.0\" lon=\"0.0\">\n" + " <ele>0.0</ele>\n" + " <extensions>\n" + " <distance>0.0</distance>\n" + " <duration>0.0</duration>\n" + " <type>0</type>\n" + " <step>0</step>\n" + " </extensions>\n" + " </wpt>\n" + " <rte>\n" + " <rtept lat=\"0.0\" lon=\"0.0\">\n" + " <ele>0.0</ele>\n" + " <extensions>\n" + " <distance>0.0</distance>\n" + " <duration>0.0</duration>\n" + " <type>0</type>\n" + " <step>0</step>\n" + " </extensions>\n" + " </rtept>\n" + " <extensions>\n" + " <distance>0.0</distance>\n" + " <duration>0.0</duration>\n" + " <distanceActual>0.0</distanceActual>\n" + " <ascent>0.0</ascent>\n" + " <descent>0.0</descent>\n" + " <avgspeed>0.0</avgspeed>\n" + " <bounds minLat=\"0.0\" minLon=\"0.0\" maxLat=\"0.0\" maxLon=\"0.0\"/>\n" + " </extensions>\n" + " </rte>\n" + " <trk>\n" + " <extensions>\n" + " <example1>0.0</example1>\n" + " </extensions>\n" + " <trkseg>\n" + " <trkpt lat=\"0.0\" lon=\"0.0\">\n" + " <ele>0.0</ele>\n" + " <extensions>\n" + " <distance>0.0</distance>\n" + " <duration>0.0</duration>\n" + " <type>0</type>\n" + " <step>0</step>\n" + " </extensions>\n" + " </trkpt>\n" + " <extensions>\n" + " <example1>0.0</example1>\n" + " </extensions>\n" + " </trkseg>\n" + " </trk>\n" + " <extensions>\n" + " <attribution></attribution>\n" + " <engine></engine>\n" + " <build_date></build_date>\n" + " <profile></profile>\n" + " <preference></preference>\n" + " <language></language>\n" + " <distance-units></distance-units>\n" + " <duration-units></duration-units>\n" + " <instructions></instructions>\n" + " <elevation></elevation>\n" + " </extensions>\n" + "</gpx>\n", result); } |
GeoJsonResponseWriter { public static JSONObject addProperties(SimpleFeature simpleFeature, Map<String, Map<String, Object>> featurePropertiesMap) throws IOException { StringWriter stringWriter = new StringWriter(); fjson.writeFeature(simpleFeature, stringWriter); JSONObject featureAsJSON = new JSONObject(stringWriter.toString()); stringWriter.close(); return featureProperties(featureAsJSON, featurePropertiesMap); } static JSONObject toGeoJson(RoutingRequest rreq, RouteResult[] routeResult); JSONObject toGeoJson(IsochroneRequest rreq, RouteResult[] routeResults); static JSONObject addProperties(SimpleFeature simpleFeature, Map<String, Map<String, Object>> featurePropertiesMap); static JSONObject addProperties(DefaultFeatureCollection defaultFeatureCollection, Map<String, Map<String, Object>> featurePropertiesMap, Map<String, Object> defaultFeatureCollectionProperties); static final String KEY_ROUTES; static final String KEY_FEATURES; static final String KEY_PROPERTIES; } | @Test public void testAddProperties() throws Exception { JSONObject expectedJSON = new JSONObject("{\"geometry\":{\"coordinates\":[[1,1],[1,1],[1,1]],\"type\":\"LineString\"},\"id\":\"" + routingFeatureID + "\",\"type\":\"Feature\",\"properties\":{\"bbox\":[1,1,1,1],\"way_points\":[1,1],\"segments\":[1]}}"); JSONObject resultJSON = GeoJsonResponseWriter.addProperties(routingFeature, featurePropertiesMap); JSONAssert.assertEquals(expectedJSON, resultJSON, JSONCompareMode.NON_EXTENSIBLE); }
@Test public void testAddProperties1() throws Exception { JSONObject expectedJSON = new JSONObject("{\"features\":[{\"geometry\":{\"coordinates\":[[1,1],[1,1],[1,1]],\"type\":\"LineString\"},\"id\":\"" + routingFeatureID + "\",\"type\":\"Feature\",\"properties\":{\"bbox\":[1,1,1,1],\"way_points\":[1,1],\"segments\":[1]}}],\"bbox\":[1,1,1,1],\"type\":\"FeatureCollection\",\"info\":[1]}"); JSONObject resultJSON = GeoJsonResponseWriter.addProperties(defaultFeatureCollection, featurePropertiesMap, defaultFeatureCollectionProperties); JSONAssert.assertEquals(expectedJSON, resultJSON, JSONCompareMode.NON_EXTENSIBLE); } |
CountryBordersPolygon { public String getName() { return this.name; } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); } | @Test public void TestName() { assertEquals("name", cbp.getName()); } |
CountryBordersPolygon { public MultiPolygon getBoundary() { return this.boundary; } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); } | @Test public void TestBoundaryGeometry() { MultiPolygon boundary = cbp.getBoundary(); Coordinate[] cbpCoords = boundary.getCoordinates(); assertEquals(country1Geom.length, cbpCoords.length); assertEquals(country1Geom[0].x, cbpCoords[0].x, 0.0); assertEquals(country1Geom[3].y, cbpCoords[3].y,0.0); } |
CountryBordersPolygon { public double[] getBBox() { return new double[] {minLon, maxLon, minLat, maxLat}; } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); } | @Test public void TestBBox() { double[] bbox = cbp.getBBox(); assertEquals(-1.0, bbox[0], 0.0); assertEquals(1.0, bbox[1], 0.0); assertEquals(-1.0, bbox[2], 0.0); assertEquals(2.0, bbox[3], 0.0); } |
CountryBordersPolygon { public boolean crossesBoundary(LineString line) { return this.boundaryLine.intersects(line); } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); } | @Test public void TestIntersection() { LineString ls = gf.createLineString(new Coordinate[] { new Coordinate(0.5, 0.5), new Coordinate(-10.5, -10.5) }); assertTrue(cbp.crossesBoundary(ls)); ls = gf.createLineString(new Coordinate[] { new Coordinate(0.5, 0.5), new Coordinate(0.25, 0.25) }); assertFalse(cbp.crossesBoundary(ls)); } |
CountryBordersPolygon { public boolean inBbox(Coordinate c) { return !(c.x < minLon || c.x > maxLon || c.y < minLat || c.y > maxLat); } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); } | @Test public void TestBBoxContains() { assertTrue(cbp.inBbox(new Coordinate(0.5, 0.5))); assertFalse(cbp.inBbox(new Coordinate(10.0, 0.5))); } |
BordersExtractor { public boolean isOpenBorder(int edgeId) { return storage.getEdgeValue(edgeId, BordersGraphStorage.Property.TYPE) == BordersGraphStorage.OPEN_BORDER; } BordersExtractor(BordersGraphStorage storage, int[] avoidCountries); int getValue(int edgeId); boolean isBorder(int edgeId); boolean isControlledBorder(int edgeId); boolean isOpenBorder(int edgeId); boolean restrictedCountry(int edgeId); boolean isSameCountry(List<Integer> edgeIds); } | @Test public void TestDetectOpenBorder() { VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); BordersExtractor be = new BordersExtractor(_graphstorage, new int[0]); assertEquals(false, be.isOpenBorder(1)); assertEquals(true, be.isOpenBorder(2)); assertEquals(false, be.isOpenBorder(3)); } |
CountryBordersPolygon { public boolean inArea(Coordinate c) { if(!Double.isNaN(c.x) && !Double.isNaN(c.y) && inBbox(c)) { GeometryFactory gf = new GeometryFactory(); return boundary.contains(gf.createPoint(c)); } return false; } CountryBordersPolygon(String name, Geometry boundary); double[] getBBox(); boolean shares(MultiPolygon other); boolean crossesBoundary(LineString line); String getName(); MultiPolygon getBoundary(); boolean inBbox(Coordinate c); boolean inArea(Coordinate c); double getArea(); } | @Test public void TestPolygonContains() { assertTrue(cbp.inArea(new Coordinate(0.5, 0.5))); assertFalse(cbp.inArea(new Coordinate(-0.5, -0.5))); } |
CountryBordersReader { public CountryBordersPolygon[] getCountry(Coordinate c) { ArrayList<CountryBordersPolygon> countries = new ArrayList<>(); Iterator it = hierarchies.entrySet().iterator(); while(it.hasNext()) { Map.Entry<Long, CountryBordersHierarchy> pair = (Map.Entry)it.next(); CountryBordersHierarchy h = pair.getValue(); if(h.inBbox(c)) { List<CountryBordersPolygon> ps = h.getPolygons(); for(CountryBordersPolygon cp : ps) { if(cp.inBbox(c) && cp.inArea(c)) { countries.add(cp); } } } } return countries.toArray(new CountryBordersPolygon[countries.size()]); } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; } | @Test public void TestGetCountry() { Coordinate c = new Coordinate(0.5, 0.5); CountryBordersPolygon[] polys = _reader.getCountry(c); assertEquals(1, polys.length); assertEquals("country1", polys[0].getName()); } |
CountryBordersReader { public CountryBordersPolygon[] getCandidateCountry(Coordinate c) { ArrayList<CountryBordersPolygon> countries = new ArrayList<>(); Iterator it = hierarchies.entrySet().iterator(); while(it.hasNext()) { Map.Entry<Long, CountryBordersHierarchy> pair = (Map.Entry)it.next(); CountryBordersHierarchy h = pair.getValue(); if(h.inBbox(c)) { List<CountryBordersPolygon> ps = h.getPolygons(); for(CountryBordersPolygon cp : ps) { if(cp.inBbox(c)) { countries.add(cp); } } } } return countries.toArray(new CountryBordersPolygon[countries.size()]); } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; } | @Test public void TestGetCandidateCountry() { Coordinate c = new Coordinate(-0.25, -0.25); CountryBordersPolygon[] polys = _reader.getCandidateCountry(c); assertEquals(1, polys.length); assertEquals("country3", polys[0].getName()); } |
CountryBordersReader { public String getId(String name) { if(name.equals(INTERNATIONAL_NAME)) return INTERNATIONAL_ID; if(ids.containsKey(name)) return ids.get(name).id; else return ""; } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; } | @Test public void TestGetCountryId() { assertEquals("1", _reader.getId("country1")); } |
CountryBordersReader { public String getEngName(String name) { if(name.equals(INTERNATIONAL_NAME)) return INTERNATIONAL_NAME; if(ids.containsKey(name)) return ids.get(name).nameEng; else return ""; } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; } | @Test public void TestGetCountryEnglishName() { assertEquals("country1 English", _reader.getEngName("country1")); } |
CountryBordersReader { public boolean isOpen(String c1, String c2) { if(openBorders.containsKey(c1)) { return openBorders.get(c1).contains(c2); } else if(openBorders.containsKey(c2)) return openBorders.get(c2).contains(c1); return false; } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; } | @Test public void TestGetOpenBorder() { assertTrue(_reader.isOpen("country1", "country2")); assertFalse(_reader.isOpen("country1", "country3")); } |
CountryBordersReader { public static int getCountryIdByISOCode(String code) { return currentInstance != null ? currentInstance.isoCodes.getOrDefault(code.toUpperCase(), 0) : 0; } CountryBordersReader(); CountryBordersReader(String filepath, String idsPath, String openPath); void addHierarchy(Long id, CountryBordersHierarchy hierarchy); void addId(String id, String localName, String englishName, String cca2, String cca3); void addOpenBorder(String country1, String country2); CountryBordersPolygon[] getCountry(Coordinate c); CountryBordersPolygon[] getCandidateCountry(Coordinate c); String getId(String name); String getEngName(String name); boolean isOpen(String c1, String c2); static int getCountryIdByISOCode(String code); static final String INTERNATIONAL_NAME; static final String INTERNATIONAL_ID; static final String KEY_PROPERTIES; } | @Test public void TestGetCountryIdByISOCode() { assertEquals(1, CountryBordersReader.getCountryIdByISOCode("CT")); assertEquals(1, CountryBordersReader.getCountryIdByISOCode("CTR")); assertEquals(0, CountryBordersReader.getCountryIdByISOCode("FOO")); } |
CountryBordersHierarchy { public double[] getBBox() { return new double[] {minLon, maxLon, minLat, maxLat}; } void add(CountryBordersPolygon cp); boolean inBbox(Coordinate c); double[] getBBox(); List<CountryBordersPolygon> getPolygons(); List<CountryBordersPolygon> getContainingPolygons(Coordinate c); } | @Test public void GetBBoxTest() { double[] bbox = cbh1.getBBox(); assertEquals(-1.0, bbox[0], 0.0); assertEquals(1.0, bbox[1], 0.0); assertEquals(-1.0, bbox[2], 0.0); assertEquals(1.0, bbox[3], 0.0); bbox = cbh2.getBBox(); assertEquals(5.0, bbox[0], 0.0); assertEquals(10.0, bbox[1], 0.0); assertEquals(5.0, bbox[2], 0.0); assertEquals(10.0, bbox[3], 0.0); } |
CountryBordersHierarchy { public boolean inBbox(Coordinate c) { return !(c.x <= minLon || c.x >= maxLon || c.y <= minLat || c.y >= maxLat); } void add(CountryBordersPolygon cp); boolean inBbox(Coordinate c); double[] getBBox(); List<CountryBordersPolygon> getPolygons(); List<CountryBordersPolygon> getContainingPolygons(Coordinate c); } | @Test public void InBBoxTest() { assertTrue(cbh1.inBbox(new Coordinate(0.5, 0.5))); assertTrue(cbh1.inBbox(new Coordinate(-0.5, 0.5))); assertFalse(cbh1.inBbox(new Coordinate(7.5, 7.5))); assertFalse(cbh1.inBbox(new Coordinate(100, 100))); } |
CountryBordersHierarchy { public List<CountryBordersPolygon> getContainingPolygons(Coordinate c) { ArrayList<CountryBordersPolygon> containing = new ArrayList<>(); if(!Double.isNaN(c.x) && !Double.isNaN(c.y) && inBbox(c)) { for (CountryBordersPolygon cbp : polygons) { if (cbp.inBbox(c)) { containing.add(cbp); } } } return containing; } void add(CountryBordersPolygon cp); boolean inBbox(Coordinate c); double[] getBBox(); List<CountryBordersPolygon> getPolygons(); List<CountryBordersPolygon> getContainingPolygons(Coordinate c); } | @Test public void GetCountryTest() { List<CountryBordersPolygon> containing = cbh1.getContainingPolygons(new Coordinate(0.9, 0.9)); assertEquals(1, containing.size()); assertEquals("name1", containing.get(0).getName()); containing = cbh1.getContainingPolygons(new Coordinate(0.0, 0.0)); assertEquals(2, containing.size()); containing = cbh1.getContainingPolygons(new Coordinate(10, 10)); assertEquals(0, containing.size()); } |
BordersExtractor { public boolean restrictedCountry(int edgeId) { int startCountry = storage.getEdgeValue(edgeId, BordersGraphStorage.Property.START); int endCountry = storage.getEdgeValue(edgeId, BordersGraphStorage.Property.END); for(int i = 0; i< avoidCountries.length; i++) { if(startCountry == avoidCountries[i] || endCountry == avoidCountries[i] ) { return true; } } return false; } BordersExtractor(BordersGraphStorage storage, int[] avoidCountries); int getValue(int edgeId); boolean isBorder(int edgeId); boolean isControlledBorder(int edgeId); boolean isOpenBorder(int edgeId); boolean restrictedCountry(int edgeId); boolean isSameCountry(List<Integer> edgeIds); } | @Test public void TestAvoidCountry() { VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); BordersExtractor be = new BordersExtractor(_graphstorage, new int[] {2, 4}); assertEquals(true, be.restrictedCountry(1)); assertEquals(true, be.restrictedCountry(2)); assertEquals(false, be.restrictedCountry(3)); } |
RouteResultBuilder { RouteResult createMergedRouteResultFromBestPaths(List<GHResponse> responses, RoutingRequest request, List<RouteExtraInfo>[] extras) throws Exception { RouteResult result = createInitialRouteResult(request, extras[0]); for (int ri = 0; ri < responses.size(); ++ri) { GHResponse response = responses.get(ri); if (response.hasErrors()) throw new InternalServerException(RoutingErrorCodes.UNKNOWN, String.format("Unable to find a route between points %d (%s) and %d (%s)", ri, FormatUtility.formatCoordinate(request.getCoordinates()[ri]), ri + 1, FormatUtility.formatCoordinate(request.getCoordinates()[ri + 1]))); handleResponseWarnings(result, response); PathWrapper path = response.getBest(); result.addPointlist(path.getPoints()); if (request.getIncludeGeometry()) { result.addPointsToGeometry(path.getPoints(), ri > 0, request.getIncludeElevation()); result.addWayPointIndex(result.getGeometry().length - 1); } result.addSegment(createRouteSegment(path, request, getNextResponseFirstStepPoints(responses, ri))); result.setGraphDate(response.getHints().get("data.date", "0000-00-00T00:00:00Z")); } result.calculateRouteSummary(request); if (!request.getIncludeInstructions()) { result.resetSegments(); } return result; } RouteResultBuilder(); } | @Test public void TestCreateMergedRouteResultFromBestPaths() throws Exception { List<GHResponse> responseList = new ArrayList<>(); RoutingRequest routingRequest = new RouteRequestHandler().convertRouteRequest(request1); List<RouteExtraInfo> extrasList = new ArrayList<>(); RouteResultBuilder builder = new RouteResultBuilder(); RouteResult result = builder.createMergedRouteResultFromBestPaths(responseList, routingRequest, new List[]{extrasList}); Assert.assertEquals("Empty response list should return empty RouteResult (summary.distance = 0.0)", 0.0, result.getSummary().getDistance(), 0.0); Assert.assertEquals("Empty response list should return empty RouteResult (no segments)", 0, result.getSegments().size()); Assert.assertEquals("Empty response list should return empty RouteResult (no extra info)", 0, result.getExtraInfo().size()); Assert.assertNull("Empty response list should return empty RouteResult (no geometry)", result.getGeometry()); extrasList.add(new RouteExtraInfo(APIEnums.ExtraInfo.OSM_ID.toString())); responseList.add(constructResponse(request1)); result = builder.createMergedRouteResultFromBestPaths(responseList, routingRequest, new List[]{extrasList}); Assert.assertEquals("Single response should return valid RouteResult (summary.duration = 1452977.2)", 1452977.2, result.getSummary().getDistance(), 0.0); Assert.assertEquals("Single response should return valid RouteResult (summary.bbox = 45.6,56.7,12.3,23.4)", "45.6,56.7,12.3,23.4", result.getSummary().getBBox().toString()); Assert.assertEquals("Single response should return valid RouteResult (geometry.length = 2)", 2, result.getGeometry().length); Assert.assertEquals("Single response should return valid RouteResult (geometry[0] = 45.6,12.3,NaN)", "(45.6, 12.3, NaN)", result.getGeometry()[0].toString()); Assert.assertEquals("Single response should return valid RouteResult (geometry[1] = 56.7,23.4,NaN)", "(56.7, 23.4, NaN)", result.getGeometry()[1].toString()); Assert.assertEquals("Single response should return valid RouteResult (segments.size = 1)", 1, result.getSegments().size()); Assert.assertEquals("Single response should return valid RouteResult (segments[0].distance = 1452977.2)", 1452977.2, result.getSegments().get(0).getDistance(), 0.0); Assert.assertEquals("Single response should return valid RouteResult (segments[0].detourFactor = 2)", 0.85, result.getSegments().get(0).getDetourFactor(), 0.0); Assert.assertEquals("Single response should return valid RouteResult (segments[0].steps.size = 2)", 2, result.getSegments().get(0).getSteps().size()); Assert.assertEquals("Single response should return valid RouteResult (segments[0].steps[0].name = 'Instruction 1')", "Instruction 1", result.getSegments().get(0).getSteps().get(0).getName()); Assert.assertEquals("Single response should return valid RouteResult (segments[0].steps[0].type = 11)", 11, result.getSegments().get(0).getSteps().get(0).getType()); Assert.assertEquals("Single response should return valid RouteResult (segments[0].steps[0].maneuver.bearingAfter = 44)", 44, result.getSegments().get(0).getSteps().get(0).getManeuver().getBearingAfter()); Assert.assertEquals("Single response should return valid RouteResult (segments[0].steps[1].name = 'Instruction 2')", "Instruction 2", result.getSegments().get(0).getSteps().get(1).getName()); Assert.assertEquals("Single response should return valid RouteResult (segments[0].steps[1].type = 10)", 10, result.getSegments().get(0).getSteps().get(1).getType()); Assert.assertEquals("Single response should return valid RouteResult (segments[0].steps[1].maneuver.bearingAfter = 0)", 0, result.getSegments().get(0).getSteps().get(1).getManeuver().getBearingAfter()); Assert.assertEquals("Single response should return valid RouteResult (extrainfo.size = 1)", 1, result.getExtraInfo().size()); Assert.assertEquals("Single response should return valid RouteResult (extrainfo[0].name = 'osmid)", APIEnums.ExtraInfo.OSM_ID.toString(), result.getExtraInfo().get(0).getName()); Assert.assertEquals("Single response should return valid RouteResult (waypointindices.size = 2)", 2, result.getWayPointsIndices().size()); responseList.add(constructResponse(request2)); result = builder.createMergedRouteResultFromBestPaths(responseList, routingRequest, new List[]{extrasList}); Assert.assertEquals("Two responses should return merged RouteResult (summary.duration = 2809674.1)", 2809674.1, result.getSummary().getDistance(), 0.0); Assert.assertEquals("Two responses should return merged RouteResult (summary.bbox = 45.6,67.8,12.3,34.5)", "45.6,67.8,12.3,34.5", result.getSummary().getBBox().toString()); Assert.assertEquals("Two responses should return merged RouteResult (geometry.length = 3)", 3, result.getGeometry().length); Assert.assertEquals("Two responses should return merged RouteResult (geometry[0] = 45.6,12.3,NaN)", "(45.6, 12.3, NaN)", result.getGeometry()[0].toString()); Assert.assertEquals("Two responses should return merged RouteResult (geometry[1] = 56.7,23.4,NaN)", "(56.7, 23.4, NaN)", result.getGeometry()[1].toString()); Assert.assertEquals("Two responses should return merged RouteResult (geometry[2] = 67.8,34.5,NaN)", "(67.8, 34.5, NaN)", result.getGeometry()[2].toString()); Assert.assertEquals("Two responses should return merged RouteResult (segments.size = 2)", 2, result.getSegments().size()); Assert.assertEquals("Two responses should return merged RouteResult (segments[0].distance = 1452977.2)", 1452977.2, result.getSegments().get(0).getDistance(), 0.0); Assert.assertEquals("Two responses should return merged RouteResult (segments[0].detourFactor = 0.85)", 0.85, result.getSegments().get(0).getDetourFactor(), 0.0); Assert.assertEquals("Two responses should return merged RouteResult (segments[0].steps.size = 2)", 2, result.getSegments().get(0).getSteps().size()); Assert.assertEquals("Two responses should return merged RouteResult (segments[0].steps[0].name = 'Instruction 1')", "Instruction 1", result.getSegments().get(0).getSteps().get(0).getName()); Assert.assertEquals("Two responses should return merged RouteResult (segments[0].steps[0].type = 11)", 11, result.getSegments().get(0).getSteps().get(0).getType()); Assert.assertEquals("Two responses should return merged RouteResult (segments[0].steps[0].maneuver.bearingAfter = 44)", 44, result.getSegments().get(0).getSteps().get(0).getManeuver().getBearingAfter()); Assert.assertEquals("Two responses should return merged RouteResult (segments[0].steps[1].name = 'Instruction 2')", "Instruction 2", result.getSegments().get(0).getSteps().get(1).getName()); Assert.assertEquals("Two responses should return merged RouteResult (segments[0].steps[1].type = 10)", 10, result.getSegments().get(0).getSteps().get(1).getType()); Assert.assertEquals("Two responses should return merged RouteResult (segments[0].steps[1].maneuver.bearingAfter = 0)", 0, result.getSegments().get(0).getSteps().get(1).getManeuver().getBearingAfter()); Assert.assertEquals("Two responses should return merged RouteResult (segments[1].distance = 1356696.9)", 1356696.9, result.getSegments().get(1).getDistance(), 0.0); Assert.assertEquals("Two responses should return merged RouteResult (segments[1].detourFactor = 0.83)", 0.83, result.getSegments().get(1).getDetourFactor(), 0.0); Assert.assertEquals("Two responses should return merged RouteResult (segments[1].steps.size = 2)", 2, result.getSegments().get(1).getSteps().size()); Assert.assertEquals("Two responses should return merged RouteResult (segments[1].steps[0].name = 'Instruction 1')", "Instruction 1", result.getSegments().get(1).getSteps().get(0).getName()); Assert.assertEquals("Two responses should return merged RouteResult (segments[1].steps[0].type = 11)", 11, result.getSegments().get(1).getSteps().get(0).getType()); Assert.assertEquals("Two responses should return merged RouteResult (segments[1].steps[0].maneuver.bearingAfter = 41)", 41, result.getSegments().get(1).getSteps().get(0).getManeuver().getBearingAfter()); Assert.assertEquals("Two responses should return merged RouteResult (segments[1].steps[1].name = 'Instruction 2')", "Instruction 2", result.getSegments().get(1).getSteps().get(1).getName()); Assert.assertEquals("Two responses should return merged RouteResult (segments[1].steps[1].type = 10)", 10, result.getSegments().get(1).getSteps().get(1).getType()); Assert.assertEquals("Two responses should return merged RouteResult (segments[1].steps[1].maneuver.bearingAfter = 0)", 0, result.getSegments().get(1).getSteps().get(1).getManeuver().getBearingAfter()); Assert.assertEquals("Two responses should return merged RouteResult (extrainfo.size = 1)", 1, result.getExtraInfo().size()); Assert.assertEquals("Two responses should return merged RouteResult (extrainfo[0].name = 'osmid)", APIEnums.ExtraInfo.OSM_ID.toString(), result.getExtraInfo().get(0).getName()); Assert.assertEquals("Two responses should return merged RouteResult (waypointindices.size = 3)", 3, result.getWayPointsIndices().size()); RouteRequest modRequest = request1; List<Integer> skipSegments = new ArrayList<>(); skipSegments.add(1); modRequest.setSkipSegments(skipSegments); routingRequest = new RouteRequestHandler().convertRouteRequest(modRequest); responseList = new ArrayList<>(); responseList.add(constructResponse(modRequest)); result = builder.createMergedRouteResultFromBestPaths(responseList, routingRequest, new List[]{extrasList}); Assert.assertEquals("Response with SkipSegments should return RouteResult with warning", 1, result.getWarnings().size()); Assert.assertEquals("Response with SkipSegments should return RouteResult with warning (code 3)", 3, result.getWarnings().get(0).getWarningCode()); } |
RouteSearchParameters { public int getProfileType() { return profileType; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getProfileType() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertEquals(0, routeSearchParameters.getProfileType()); } |
RouteSearchParameters { public void setProfileType(int profileType) throws Exception { if (profileType == RoutingProfileType.UNKNOWN) throw new Exception("Routing profile is unknown."); this.profileType = profileType; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setProfileType() throws Exception { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setProfileType(2); Assert.assertEquals(2, routeSearchParameters.getProfileType()); } |
RouteSearchParameters { public int getWeightingMethod() { return weightingMethod; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getWeightingMethod() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertEquals(WeightingMethod.FASTEST, routeSearchParameters.getWeightingMethod(), 0.0); } |
RouteSearchParameters { public void setWeightingMethod(int weightingMethod) { this.weightingMethod = weightingMethod; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setWeightingMethod() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setWeightingMethod(WeightingMethod.RECOMMENDED); Assert.assertEquals(WeightingMethod.RECOMMENDED, routeSearchParameters.getWeightingMethod(), 0.0); } |
RouteSearchParameters { public Polygon[] getAvoidAreas() { return avoidAreas; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getAvoidAreas() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertArrayEquals(null, routeSearchParameters.getAvoidAreas()); } |
RouteSearchParameters { public void setAvoidAreas(Polygon[] avoidAreas) { this.avoidAreas = avoidAreas; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setAvoidAreas() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidAreas(new Polygon[0]); Assert.assertArrayEquals(new Polygon[0], routeSearchParameters.getAvoidAreas()); } |
RouteSearchParameters { public boolean hasAvoidAreas() { return avoidAreas != null && avoidAreas.length > 0; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void hasAvoidAreas() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.hasAvoidAreas()); routeSearchParameters.setAvoidAreas(new Polygon[1]); Assert.assertTrue(routeSearchParameters.hasAvoidAreas()); } |
RouteSearchParameters { public int getAvoidFeatureTypes() { return avoidFeaturesTypes; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getAvoidFeatureTypes() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertEquals(0, routeSearchParameters.getAvoidFeatureTypes()); } |
RouteSearchParameters { public void setAvoidFeatureTypes(int avoidFeatures) { avoidFeaturesTypes = avoidFeatures; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setAvoidFeatureTypes() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidFeatureTypes(1); Assert.assertEquals(1, routeSearchParameters.getAvoidFeatureTypes()); } |
BordersExtractor { public boolean isSameCountry(List<Integer> edgeIds){ if(edgeIds.isEmpty()) return true; short country0 = storage.getEdgeValue(edgeIds.get(0), BordersGraphStorage.Property.START); short country1 = storage.getEdgeValue(edgeIds.get(0), BordersGraphStorage.Property.END); for(int edgeId : edgeIds) { short country2 = storage.getEdgeValue(edgeId, BordersGraphStorage.Property.START); short country3 = storage.getEdgeValue(edgeId, BordersGraphStorage.Property.END); if(country0 != country2 && country0 != country3 && country1 != country2 && country1 != country3) return false; } return true; } BordersExtractor(BordersGraphStorage storage, int[] avoidCountries); int getValue(int edgeId); boolean isBorder(int edgeId); boolean isControlledBorder(int edgeId); boolean isOpenBorder(int edgeId); boolean restrictedCountry(int edgeId); boolean isSameCountry(List<Integer> edgeIds); } | @Test public void TestIsSameCountry() { VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); BordersExtractor be = new BordersExtractor(_graphstorage, new int[] {2, 4}); List<Integer> countries = new ArrayList<>(); countries.add(1); countries.add(2); assertFalse(be.isSameCountry(countries)); countries = new ArrayList<>(); countries.add(3); countries.add(4); assertTrue(be.isSameCountry(countries)); countries = new ArrayList<>(); countries.add(4); countries.add(5); assertFalse(be.isSameCountry(countries)); countries = new ArrayList<>(); countries.add(5); countries.add(6); assertTrue(be.isSameCountry(countries)); } |
RouteSearchParameters { public boolean hasAvoidFeatures() { return avoidFeaturesTypes > 0; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void hasAvoidFeatures() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.hasAvoidFeatures()); routeSearchParameters.setAvoidFeatureTypes(1); Assert.assertTrue(routeSearchParameters.hasAvoidFeatures()); } |
RouteSearchParameters { public int[] getAvoidCountries() { return avoidCountries; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getAvoidCountries() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertNull(routeSearchParameters.getAvoidCountries()); } |
RouteSearchParameters { public void setAvoidCountries(int[] avoidCountries) { this.avoidCountries = avoidCountries; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setAvoidCountries() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidCountries(new int[1]); Assert.assertArrayEquals(new int[1], routeSearchParameters.getAvoidCountries()); } |
RouteSearchParameters { public boolean hasAvoidCountries() { return avoidCountries != null && avoidCountries.length > 0; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void hasAvoidCountries() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.hasAvoidCountries()); routeSearchParameters.setAvoidCountries(new int[1]); Assert.assertTrue(routeSearchParameters.hasAvoidCountries()); } |
RouteSearchParameters { public boolean hasAvoidBorders() { return avoidBorders != BordersExtractor.Avoid.NONE; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void hasAvoidBorders() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.hasAvoidBorders()); routeSearchParameters.setAvoidBorders(BordersExtractor.Avoid.CONTROLLED); Assert.assertTrue(routeSearchParameters.hasAvoidBorders()); } |
RouteSearchParameters { public void setAvoidBorders(BordersExtractor.Avoid avoidBorders) { this.avoidBorders = avoidBorders; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setAvoidBorders() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidBorders(BordersExtractor.Avoid.CONTROLLED); Assert.assertEquals(BordersExtractor.Avoid.CONTROLLED, routeSearchParameters.getAvoidBorders()); } |
RouteSearchParameters { public BordersExtractor.Avoid getAvoidBorders() { return avoidBorders; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getAvoidBorders() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertEquals(BordersExtractor.Avoid.NONE, routeSearchParameters.getAvoidBorders()); } |
RouteSearchParameters { public Boolean getConsiderTurnRestrictions() { return considerTurnRestrictions; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getConsiderTurnRestrictions() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.getConsiderTurnRestrictions()); } |
RouteSearchParameters { public void setConsiderTurnRestrictions(Boolean considerTurnRestrictions) { this.considerTurnRestrictions = considerTurnRestrictions; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setConsiderTurnRestrictions() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setConsiderTurnRestrictions(true); Assert.assertTrue(routeSearchParameters.getConsiderTurnRestrictions()); } |
RouteSearchParameters { public int getVehicleType() { return vehicleType; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getVehicleType() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertEquals(HeavyVehicleAttributes.UNKNOWN, routeSearchParameters.getVehicleType()); } |
EncodeUtils { public static byte[] longToByteArray(long longValue) { ByteBuffer longToByteBuffer = ByteBuffer.allocate(Long.BYTES); longToByteBuffer.putLong(longValue); return longToByteBuffer.array(); } private EncodeUtils(); static byte[] longToByteArray(long longValue); static long byteArrayToLong(byte[] byteArray); } | @Test public void longToByteArrayTest() { long value = 1234L; byte[] byteValue = EncodeUtils.longToByteArray(value); assertEquals(8, byteValue.length); assertEquals(-46, byteValue[7]); assertEquals(4, byteValue[6]); } |
RouteSearchParameters { public void setVehicleType(int vehicleType) { this.vehicleType = vehicleType; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setVehicleType() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setVehicleType(HeavyVehicleAttributes.AGRICULTURE); Assert.assertEquals(HeavyVehicleAttributes.AGRICULTURE, routeSearchParameters.getVehicleType()); } |
RouteSearchParameters { public String getOptions() { return options; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getOptions() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertNull(routeSearchParameters.getOptions()); } |
RouteSearchParameters { public boolean hasParameters(Class<?> value) { if (profileParams == null) return false; return profileParams.getClass() == value; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void hasParameters() throws Exception { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.hasParameters(routeSearchParameters.getClass())); routeSearchParameters.setProfileType(2); routeSearchParameters.setOptions("{\"profile_params\":{\"weightings\":{\"green\":{\"factor\":0.8}}}}"); Assert.assertTrue(routeSearchParameters.hasParameters(VehicleParameters.class)); } |
RouteSearchParameters { public ProfileParameters getProfileParameters() { return profileParams; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getProfileParameters() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertNull(routeSearchParameters.getProfileParameters()); } |
RouteSearchParameters { public boolean getFlexibleMode() { return flexibleMode; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getFlexibleMode() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.getFlexibleMode()); } |
RouteSearchParameters { public void setFlexibleMode(boolean flexibleMode) { this.flexibleMode = flexibleMode; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setFlexibleMode() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setFlexibleMode(true); Assert.assertTrue(routeSearchParameters.getFlexibleMode()); } |
RouteSearchParameters { public double[] getMaximumRadiuses() { return maxRadiuses; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getMaximumRadiuses() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertNull(routeSearchParameters.getMaximumRadiuses()); } |
RouteSearchParameters { public void setMaximumRadiuses(double[] maxRadiuses) { this.maxRadiuses = maxRadiuses; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setMaximumRadiuses() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setMaximumRadiuses(new double[0]); Assert.assertNotNull(routeSearchParameters.getMaximumRadiuses()); Assert.assertSame(routeSearchParameters.getMaximumRadiuses().getClass(), double[].class); Assert.assertEquals(0, routeSearchParameters.getMaximumRadiuses().length); } |
RouteSearchParameters { public WayPointBearing[] getBearings() { return bearings; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void getBearings() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertNull(routeSearchParameters.getBearings()); } |
RouteSearchParameters { public void setBearings(WayPointBearing[] bearings) { this.bearings = bearings; } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void setBearings() { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setBearings(new WayPointBearing[]{}); Assert.assertArrayEquals(new WayPointBearing[]{}, routeSearchParameters.getBearings()); } |
EncodeUtils { public static long byteArrayToLong(byte[] byteArray) { ByteBuffer byteToLongBuffer = ByteBuffer.allocate(Long.BYTES); byte[] storageBytes = {0,0,0,0,0,0,0,0}; int differenceInSize = storageBytes.length - byteArray.length; for(int i = byteArray.length-1; i >= 0; i--) { if(differenceInSize + i >= 0) storageBytes[differenceInSize + i] = byteArray[i]; } byteToLongBuffer.put(storageBytes); byteToLongBuffer.flip(); return byteToLongBuffer.getLong(); } private EncodeUtils(); static byte[] longToByteArray(long longValue); static long byteArrayToLong(byte[] byteArray); } | @Test public void byteArrayToLongTest() { byte[] byteArr = {0,0,0,0,73,-106,2,-46}; long value = EncodeUtils.byteArrayToLong(byteArr); assertEquals(1234567890, value); byte[] byteArr2 = {-24,106,4,-97}; long value2 = EncodeUtils.byteArrayToLong(byteArr2); assertEquals(3899262111L, value2); byte[] byteArr3 = {124,0,0,12,-45,76,-8,-96,1}; long value3 = EncodeUtils.byteArrayToLong(byteArr3); assertEquals(14101668995073L, value3); } |
RouteSearchParameters { public boolean requiresDynamicPreprocessedWeights() { return hasAvoidAreas() || hasAvoidFeatures() || hasAvoidBorders() || hasAvoidCountries() || getConsiderTurnRestrictions() || isProfileTypeHeavyVehicle() && getVehicleType() > 0 || isProfileTypeDriving() && hasParameters(VehicleParameters.class) || hasMaximumSpeed(); } int getProfileType(); void setProfileType(int profileType); int getWeightingMethod(); void setWeightingMethod(int weightingMethod); Polygon[] getAvoidAreas(); void setAvoidAreas(Polygon[] avoidAreas); boolean hasAvoidAreas(); int getAvoidFeatureTypes(); void setAvoidFeatureTypes(int avoidFeatures); boolean hasAvoidFeatures(); int[] getAvoidCountries(); void setAvoidCountries(int[] avoidCountries); boolean hasAvoidCountries(); boolean hasAvoidBorders(); void setAvoidBorders(BordersExtractor.Avoid avoidBorders); BordersExtractor.Avoid getAvoidBorders(); Boolean getConsiderTurnRestrictions(); void setConsiderTurnRestrictions(Boolean considerTurnRestrictions); int getVehicleType(); void setVehicleType(int vehicleType); int getAlternativeRoutesCount(); void setAlternativeRoutesCount(int alternativeRoutesCount); double getAlternativeRoutesWeightFactor(); void setAlternativeRoutesWeightFactor(double alternativeRoutesWeightFactor); double getAlternativeRoutesShareFactor(); void setAlternativeRoutesShareFactor(double alternativeRoutesShareFactor); int getExtraInfo(); void setExtraInfo(int extraInfo); boolean getSuppressWarnings(); void setSuppressWarnings(boolean suppressWarnings); String getOptions(); void setOptions(String options); boolean hasParameters(Class<?> value); ProfileParameters getProfileParameters(); void setProfileParams(ProfileParameters profileParams); boolean getFlexibleMode(); void setFlexibleMode(boolean flexibleMode); boolean getOptimized(); void setOptimized(boolean optimized); double[] getMaximumRadiuses(); void setMaximumRadiuses(double[] maxRadiuses); WayPointBearing[] getBearings(); void setBearings(WayPointBearing[] bearings); boolean hasBearings(); void setRoundTripLength(float length); float getRoundTripLength(); void setRoundTripPoints(int points); int getRoundTripPoints(); void setRoundTripSeed(long seed); long getRoundTripSeed(); double getMaximumSpeed(); void setMaximumSpeed(double maximumSpeed); boolean hasMaximumSpeed(); boolean isProfileTypeDriving(); boolean isProfileTypeHeavyVehicle(); boolean requiresDynamicPreprocessedWeights(); boolean requiresFullyDynamicWeights(); static final String KEY_AVOID_COUNTRIES; static final String KEY_AVOID_BORDERS; static final String KEY_PROFILE_PARAMS; static final String KEY_AVOID_FEATURES; static final String KEY_AVOID_POLYGONS; static final String KEY_ALTERNATIVE_ROUTES_WEIGHT_FACTOR; static final String KEY_ALTERNATIVE_ROUTES_SHARE_FACTOR; } | @Test public void requiresDynamicPreprocessedWeights() throws Exception { RouteSearchParameters routeSearchParameters = new RouteSearchParameters(); Assert.assertFalse(routeSearchParameters.requiresDynamicPreprocessedWeights()); routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidAreas(new Polygon[1]); Assert.assertTrue("avoid areas", routeSearchParameters.requiresDynamicPreprocessedWeights()); routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidFeatureTypes(1); Assert.assertTrue("avoid features", routeSearchParameters.requiresDynamicPreprocessedWeights()); routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidBorders(BordersExtractor.Avoid.CONTROLLED); Assert.assertTrue("avoid borders", routeSearchParameters.requiresDynamicPreprocessedWeights()); routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setAvoidCountries(new int[1]); Assert.assertTrue("avoid countries", routeSearchParameters.requiresDynamicPreprocessedWeights()); routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setConsiderTurnRestrictions(true); Assert.assertTrue("turn restrictions", routeSearchParameters.requiresDynamicPreprocessedWeights()); routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setProfileType(RoutingProfileType.DRIVING_HGV); routeSearchParameters.setVehicleType(HeavyVehicleAttributes.HGV); Assert.assertTrue("heavy vehicle", routeSearchParameters.requiresDynamicPreprocessedWeights()); routeSearchParameters = new RouteSearchParameters(); routeSearchParameters.setProfileType(RoutingProfileType.DRIVING_HGV); routeSearchParameters.setOptions("{\"profile_params\":{\"weightings\":{\"green\":{\"factor\":0.8}}}}"); Assert.assertTrue("profile param", routeSearchParameters.requiresDynamicPreprocessedWeights()); } |
GeomUtility { public static BBox calculateBoundingBox(PointList pointList) { if (pointList == null || pointList.getSize() <= 0) { return new BBox(0, 0, 0, 0); } else { double minLon = Double.MAX_VALUE; double maxLon = -Double.MAX_VALUE; double minLat = Double.MAX_VALUE; double maxLat = -Double.MAX_VALUE; double minEle = Double.MAX_VALUE; double maxEle = -Double.MAX_VALUE; for (int i = 0; i < pointList.getSize(); ++i) { minLon = Math.min(minLon, pointList.getLon(i)); maxLon = Math.max(maxLon, pointList.getLon(i)); minLat = Math.min(minLat, pointList.getLat(i)); maxLat = Math.max(maxLat, pointList.getLat(i)); if (pointList.is3D()) { minEle = Math.min(minEle, pointList.getEle(i)); maxEle = Math.max(maxEle, pointList.getEle(i)); } } if (pointList.is3D()) { return new BBox(minLon, maxLon, minLat, maxLat, minEle, maxEle); } else { return new BBox(minLon, maxLon, minLat, maxLat); } } } private GeomUtility(); static LineString createLinestring(Coordinate[] coords); static BBox calculateBoundingBox(PointList pointList); static BBox generateBoundingFromMultiple(BBox[] boundingBoxes); static double getLength(Geometry geom, boolean inMeters); static double metresToDegrees(double metres); static double getArea(Geometry geom, boolean inMeters); static double calculateMaxExtent(Geometry geom); } | @Test public void calculateBoundingBox() { BBox bbox3D = GeomUtility.calculateBoundingBox(pointList3D); BBox bbox2D = GeomUtility.calculateBoundingBox(pointList2D); BBox bbox_fallback = GeomUtility.calculateBoundingBox(emptyPointList); Assert.assertEquals(-35.507813,bbox3D.minLon, 0.000009); Assert.assertEquals(38.408203,bbox3D.maxLon, 0.0000009); Assert.assertEquals(-12.897489,bbox3D.minLat, 0.000009); Assert.assertEquals(50.958427,bbox3D.maxLat, 0.0000009); Assert.assertEquals(113.0,bbox3D.minEle, 0.09); Assert.assertEquals(409.0,bbox3D.maxEle, 0.09); Assert.assertEquals(-35.507813,bbox2D.minLon, 0.000009); Assert.assertEquals(38.408203,bbox2D.maxLon, 0.000009); Assert.assertEquals(-12.897489,bbox2D.minLat, 0.000009); Assert.assertEquals(50.958427,bbox2D.maxLat, 0.000009); Assert.assertEquals(0f,bbox_fallback.minLon, 0.000009); Assert.assertEquals(0f,bbox_fallback.maxLon, 0.000009); Assert.assertEquals(0f,bbox_fallback.minLat, 0.000009); Assert.assertEquals(0f,bbox_fallback.maxLat, 0.000009); } |
GeomUtility { public static BBox generateBoundingFromMultiple(BBox[] boundingBoxes) { double minLon = Double.MAX_VALUE; double maxLon = -Double.MAX_VALUE; double minLat = Double.MAX_VALUE; double maxLat = -Double.MAX_VALUE; double minEle = Double.MAX_VALUE; double maxEle = -Double.MAX_VALUE; for(BBox bbox : boundingBoxes) { minLon = Math.min(minLon, bbox.minLon); maxLon = Math.max(maxLon, bbox.maxLon); minLat = Math.min(minLat, bbox.minLat); maxLat = Math.max(maxLat, bbox.maxLat); if(!Double.isNaN(bbox.minEle)) minEle = Math.min(minEle, bbox.minEle); if(!Double.isNaN(bbox.maxEle)) maxEle = Math.max(maxEle, bbox.maxEle); } if(minEle != Double.MAX_VALUE && maxEle != Double.MAX_VALUE) return new BBox(minLon, maxLon, minLat, maxLat, minEle, maxEle); else return new BBox(minLon, maxLon, minLat, maxLat); } private GeomUtility(); static LineString createLinestring(Coordinate[] coords); static BBox calculateBoundingBox(PointList pointList); static BBox generateBoundingFromMultiple(BBox[] boundingBoxes); static double getLength(Geometry geom, boolean inMeters); static double metresToDegrees(double metres); static double getArea(Geometry geom, boolean inMeters); static double calculateMaxExtent(Geometry geom); } | @Test public void generateBBoxFromMultiple() { BBox[] bboxes = { new BBox(1.5, 2.5, -1.5, 1.5, 10, 20), new BBox(2.6, 8.5, -0.5, 1.7, 5, 25) }; BBox bbox = GeomUtility.generateBoundingFromMultiple(bboxes); Assert.assertEquals(-1.5, bbox.minLat, 0); Assert.assertEquals(1.7, bbox.maxLat, 0); Assert.assertEquals(1.5, bbox.minLon, 0); Assert.assertEquals(8.5, bbox.maxLon, 0); Assert.assertEquals(5, bbox.minEle, 0); Assert.assertEquals(25, bbox.maxEle, 0); } |
JsonIsochronesRequestProcessor extends AbstractHttpRequestProcessor { public static BBox constructIsochroneBBox(Envelope env){ BBox bbox = new BBox(0,0,0,0); if (Double.isFinite(env.getMinX())) bbox.minLon = env.getMinX(); if (Double.isFinite(env.getMinY())) bbox.minLat = env.getMinY(); if (Double.isFinite(env.getMaxX())) bbox.maxLon = env.getMaxX(); if (Double.isFinite(env.getMaxY())) bbox.maxLat = env.getMaxY(); if (!bbox.isValid()) bbox = new BBox(0, 0, 0, 0); return bbox; } JsonIsochronesRequestProcessor(HttpServletRequest request); @Override void process(HttpServletResponse response); static BBox constructIsochroneBBox(Envelope env); } | @Test public void constructNegativeIsochroneBBoxTest() { BBox bbox = JsonIsochronesRequestProcessor.constructIsochroneBBox(negativeEnv); BBox expectedBBox = new BBox(-77.033874, -77.025082, -12.127332, -12.120505); Assert.assertTrue(bbox.isValid()); Assert.assertEquals(expectedBBox.maxLat, bbox.maxLat, 0.0); Assert.assertEquals(expectedBBox.maxLon, bbox.maxLon, 0.0); Assert.assertEquals(expectedBBox.minLat, bbox.minLat, 0.0); Assert.assertEquals(expectedBBox.minLon, bbox.minLon, 0.0); Assert.assertEquals(Double.NaN, bbox.minEle, 0.0); Assert.assertEquals(Double.NaN, bbox.maxEle, 0.0); }
@Test public void constructPositiveIsochroneBBoxTest() { BBox bbox = JsonIsochronesRequestProcessor.constructIsochroneBBox(positiveEnv); BBox expectedBBox = new BBox(2.288033, 2.304801, 48.854886, 48.864247); Assert.assertTrue(bbox.isValid()); Assert.assertEquals(expectedBBox.maxLat, bbox.maxLat, 0.0); Assert.assertEquals(expectedBBox.maxLon, bbox.maxLon, 0.0); Assert.assertEquals(expectedBBox.minLat, bbox.minLat, 0.0); Assert.assertEquals(expectedBBox.minLon, bbox.minLon, 0.0); Assert.assertEquals(Double.NaN, bbox.minEle, 0.0); Assert.assertEquals(Double.NaN, bbox.maxEle, 0.0); }
@Test public void constructMixedIsochroneBBoxTest() { BBox bbox = JsonIsochronesRequestProcessor.constructIsochroneBBox(mixedEnv); BBox expectedBBox = new BBox(18.395489, 18.409940, -33.909040, -33.897771); Assert.assertTrue(bbox.isValid()); Assert.assertEquals(expectedBBox.maxLat, bbox.maxLat, 0.0); Assert.assertEquals(expectedBBox.maxLon, bbox.maxLon, 0.0); Assert.assertEquals(expectedBBox.minLat, bbox.minLat, 0.0); Assert.assertEquals(expectedBBox.minLon, bbox.minLon, 0.0); Assert.assertEquals(Double.NaN, bbox.minEle, 0.0); Assert.assertEquals(Double.NaN, bbox.maxEle, 0.0); } |
SystemMessage { public static String getSystemMessage(Object requestObj) { if (messages == null) { loadMessages(); } if (messages.isEmpty()) { return ""; } if (requestObj == null) { requestObj = ""; } RequestParams params = new RequestParams(); if (requestObj.getClass() == RoutingRequest.class) { extractParams((RoutingRequest)requestObj, params); } else if (requestObj.getClass() == org.heigit.ors.matrix.MatrixRequest.class) { extractParams((org.heigit.ors.matrix.MatrixRequest)requestObj, params); } else if (requestObj.getClass() == org.heigit.ors.isochrones.IsochroneRequest.class) { extractParams((org.heigit.ors.isochrones.IsochroneRequest)requestObj, params); } else if (requestObj.getClass() == RouteRequest.class) { extractParams((RouteRequest)requestObj, params); } else if (requestObj.getClass() == MatrixRequest.class) { extractParams((MatrixRequest)requestObj, params); } else if (requestObj.getClass() == IsochronesRequest.class) { extractParams((IsochronesRequest)requestObj, params); } return selectMessage(params); } private SystemMessage(); static String getSystemMessage(Object requestObj); } | @Test public void testGetSystemMessage() throws ParameterValueException { System.setProperty("ors_app_config", "target/test-classes/app.config.test"); RoutingRequest v1RouteRequest = new RoutingRequest(); Assert.assertEquals("This message would be sent with every request on API v1 from January 2020 until June 2050", SystemMessage.getSystemMessage(v1RouteRequest)); RouteRequest routeRequest = new RouteRequest(new Double[][] {new Double[] {1.0,1.0}, new Double[] {2.0,2.0}}); routeRequest.setProfile(APIEnums.Profile.CYCLING_REGULAR); routeRequest.setRoutePreference(APIEnums.RoutePreference.FASTEST); Assert.assertEquals("This message would be sent with every routing bike fastest request", SystemMessage.getSystemMessage(routeRequest)); IsochronesRequest isochronesRequest = new IsochronesRequest(); Assert.assertEquals("This message would be sent with every request for geojson response", SystemMessage.getSystemMessage(isochronesRequest)); MatrixRequest matrixRequest = new MatrixRequest(new ArrayList<>()); Assert.assertEquals("This message would be sent with every request", SystemMessage.getSystemMessage(matrixRequest)); Assert.assertEquals("This message would be sent with every request", SystemMessage.getSystemMessage(null)); Assert.assertEquals("This message would be sent with every request", SystemMessage.getSystemMessage("not a valid request parameter object")); } |
MatrixResponse { public MatrixResponseInfo getResponseInformation() { return responseInformation; } MatrixResponse(MatrixResult result, MatrixRequest request); MatrixResponseInfo getResponseInformation(); MatrixResult getMatrixResult(); MatrixRequest getMatrixRequest(); } | @Test public void getResponseInformation() { Assert.assertEquals(MatrixResponseInfo.class, bareMatrixResponse.responseInformation.getClass()); Assert.assertNotNull(bareMatrixResponse.responseInformation); } |
JSONBasedIndividualMatrixResponse { List<JSON2DDestinations> constructDestinations(MatrixResult matrixResult) { List<JSON2DDestinations> destinations = new ArrayList<>(); for (ResolvedLocation location : matrixResult.getDestinations()) { if (location != null) destinations.add(new JSON2DDestinations(location, includeResolveLocations)); else destinations.add(null); } return destinations; } JSONBasedIndividualMatrixResponse(MatrixRequest request); } | @Test public void constructDestinations() { List<JSON2DDestinations> json2DDestinations = jsonBasedIndividualMatrixResponse.constructDestinations(matrixResult); Assert.assertEquals(1, json2DDestinations.size()); Assert.assertEquals("foo", json2DDestinations.get(0).name); Assert.assertEquals(new Coordinate(8.681495, 49.41461, Double.NaN), json2DDestinations.get(0).location); Double[] location = json2DDestinations.get(0).getLocation(); Assert.assertEquals(2, location.length); Assert.assertEquals(0, location[0].compareTo(8.681495)); Assert.assertEquals(0, location[1].compareTo(49.41461)); } |
JSONBasedIndividualMatrixResponse { List<JSON2DSources> constructSources(MatrixResult matrixResult) { List<JSON2DSources> sources = new ArrayList<>(); for (ResolvedLocation location : matrixResult.getSources()) { if (location != null) sources.add(new JSON2DSources(location, includeResolveLocations)); else sources.add(null); } return sources; } JSONBasedIndividualMatrixResponse(MatrixRequest request); } | @Test public void constructSources() { List<JSON2DSources> json2DSources = jsonBasedIndividualMatrixResponse.constructSources(matrixResult); Assert.assertEquals(1, json2DSources.size()); Assert.assertEquals("foo", json2DSources.get(0).name); Assert.assertEquals(new Coordinate(8.681495, 49.41461, Double.NaN), json2DSources.get(0).location); Double[] location = json2DSources.get(0).getLocation(); Assert.assertEquals(2, location.length); Assert.assertEquals(0, location[0].compareTo(8.681495)); Assert.assertEquals(0, location[1].compareTo(49.41461)); } |
JSONMatrixResponse extends MatrixResponse { @JsonProperty("matrix") @JsonUnwrapped public JSONIndividualMatrixResponse getMatrix() { return new JSONIndividualMatrixResponse(matrixResult, matrixRequest); } JSONMatrixResponse(MatrixResult result, MatrixRequest request); @JsonProperty("matrix") @JsonUnwrapped JSONIndividualMatrixResponse getMatrix(); @JsonProperty("metadata") @ApiModelProperty("Information about the service and request") MatrixResponseInfo getInfo(); } | @Test public void getMatrix() { JSONIndividualMatrixResponse durationMatrix = jsonMatrixDurationsResponse.getMatrix(); Assert.assertNotNull(durationMatrix.getDurations()); Assert.assertNull(durationMatrix.getDistances()); Assert.assertEquals(3, durationMatrix.getDestinations().size()); Assert.assertEquals(3, durationMatrix.getSources().size()); Assert.assertEquals(8.681495, durationMatrix.getSources().get(0).location.x, 0); Assert.assertEquals(49.41461, durationMatrix.getSources().get(0).location.y, 0); Assert.assertEquals(Double.NaN, durationMatrix.getSources().get(0).location.z, 0); Assert.assertNotNull(durationMatrix.getSources().get(0).name); Assert.assertEquals(0.0, durationMatrix.getSources().get(0).getSnappedDistance(), 0); JSONIndividualMatrixResponse distanceMatrix = jsonMatrixDistancesResponse.getMatrix(); Assert.assertNotNull(distanceMatrix.getDistances()); Assert.assertNull(distanceMatrix.getDurations()); Assert.assertEquals(3, distanceMatrix.getDestinations().size()); Assert.assertEquals(3, distanceMatrix.getSources().size()); Assert.assertEquals(8.681495, distanceMatrix.getSources().get(0).location.x, 0); Assert.assertEquals(49.41461, distanceMatrix.getSources().get(0).location.y, 0); Assert.assertEquals(Double.NaN, distanceMatrix.getSources().get(0).location.z, 0); Assert.assertNull(distanceMatrix.getSources().get(0).name); Assert.assertEquals(0.0, distanceMatrix.getSources().get(0).getSnappedDistance(), 0); JSONIndividualMatrixResponse combinedMatrix = jsonMatrixCombinedResponse.getMatrix(); Assert.assertNotNull(combinedMatrix.getDistances()); Assert.assertNotNull(combinedMatrix.getDurations()); Assert.assertEquals(3, combinedMatrix.getDestinations().size()); Assert.assertEquals(3, combinedMatrix.getSources().size()); Assert.assertEquals(8.681495, combinedMatrix.getSources().get(0).location.x, 0); Assert.assertEquals(49.41461, combinedMatrix.getSources().get(0).location.y, 0); Assert.assertEquals(Double.NaN, combinedMatrix.getSources().get(0).location.z, 0); Assert.assertNotNull(combinedMatrix.getSources().get(0).name); Assert.assertEquals(0.0, combinedMatrix.getSources().get(0).getSnappedDistance(), 0); } |
JSONMatrixResponse extends MatrixResponse { @JsonProperty("metadata") @ApiModelProperty("Information about the service and request") public MatrixResponseInfo getInfo() { return responseInformation; } JSONMatrixResponse(MatrixResult result, MatrixRequest request); @JsonProperty("matrix") @JsonUnwrapped JSONIndividualMatrixResponse getMatrix(); @JsonProperty("metadata") @ApiModelProperty("Information about the service and request") MatrixResponseInfo getInfo(); } | @Test public void getInfo() { Assert.assertEquals(MatrixResponseInfo.class, jsonMatrixDurationsResponse.getInfo().getClass()); Assert.assertNotNull(jsonMatrixDurationsResponse.getInfo().getEngineInfo()); Assert.assertNotNull(jsonMatrixDurationsResponse.getInfo().getAttribution()); Assert.assertNotNull(jsonMatrixDurationsResponse.getInfo().getRequest()); Assert.assertNotNull(jsonMatrixDurationsResponse.getInfo().getService()); Assert.assertTrue(jsonMatrixDurationsResponse.getInfo().getTimeStamp() > 0); } |
JSONLocation { public Double getSnappedDistance() { return FormatUtility.roundToDecimals(snappedDistance, SNAPPED_DISTANCE_DECIMAL_PLACES); } JSONLocation(ResolvedLocation location, boolean includeResolveLocations); Double getSnappedDistance(); Double[] getLocation(); } | @Test public void getSnapped_distance() { Assert.assertEquals("foo", jsonLocationWithLocation.name); Assert.assertEquals(new Double(0.0), jsonLocationWithLocation.getSnappedDistance()); } |
JSONLocation { public Double[] getLocation() { return new Double[0]; } JSONLocation(ResolvedLocation location, boolean includeResolveLocations); Double getSnappedDistance(); Double[] getLocation(); } | @Test public void getLocation() { Assert.assertEquals(new Coordinate(8.681495, 49.41461, Double.NaN), jsonLocationWithLocation.location); Assert.assertArrayEquals(new Double[0], jsonLocationWithLocation.getLocation()); } |
JSONIndividualMatrixResponse extends JSONBasedIndividualMatrixResponse { public Double[][] getDistances() { return distances; } JSONIndividualMatrixResponse(MatrixResult result, MatrixRequest request); Double[][] getDurations(); List<JSON2DDestinations> getDestinations(); List<JSON2DSources> getSources(); Double[][] getDistances(); void setDistances(Double[][] distances); void setDurations(Double[][] durations); void setDestinations(List<JSON2DDestinations> destinations); void setSources(List<JSON2DSources> sources); } | @Test public void getDistances() { Assert.assertNull(durationsMatrixResponse.getDistances()); Assert.assertArrayEquals(new Double[]{0.0, 1.0, 2.0}, distancesMatrixResponse.getDistances()[0]); Assert.assertArrayEquals(new Double[]{3.0,4.0,5.0}, combinedMatrixResponse.getDistances()[1]); } |
JSONIndividualMatrixResponse extends JSONBasedIndividualMatrixResponse { public void setDistances(Double[][] distances) { this.distances = distances; } JSONIndividualMatrixResponse(MatrixResult result, MatrixRequest request); Double[][] getDurations(); List<JSON2DDestinations> getDestinations(); List<JSON2DSources> getSources(); Double[][] getDistances(); void setDistances(Double[][] distances); void setDurations(Double[][] durations); void setDestinations(List<JSON2DDestinations> destinations); void setSources(List<JSON2DSources> sources); } | @Test public void setDistances() { distancesMatrixResponse.setDistances(new Double[][]{{1.0, 2.0, 3.0},{1.0, 2.0, 3.0},{1.0, 2.0, 3.0}}); Assert.assertEquals(3, distancesMatrixResponse.getDistances().length); Assert.assertArrayEquals(new Double[]{1.0, 2.0, 3.0}, distancesMatrixResponse.getDistances()[0]); Assert.assertNull(durationsMatrixResponse.getDistances()); } |
JSONIndividualMatrixResponse extends JSONBasedIndividualMatrixResponse { public Double[][] getDurations() { return durations; } JSONIndividualMatrixResponse(MatrixResult result, MatrixRequest request); Double[][] getDurations(); List<JSON2DDestinations> getDestinations(); List<JSON2DSources> getSources(); Double[][] getDistances(); void setDistances(Double[][] distances); void setDurations(Double[][] durations); void setDestinations(List<JSON2DDestinations> destinations); void setSources(List<JSON2DSources> sources); } | @Test public void getDurations() { Assert.assertEquals(3, durationsMatrixResponse.getDurations().length); Assert.assertArrayEquals(new Double[]{0.0, 1.0, 2.0}, durationsMatrixResponse.getDurations()[0]); Assert.assertNull(distancesMatrixResponse.getDurations()); Assert.assertArrayEquals(new Double[]{3.0,4.0,5.0}, combinedMatrixResponse.getDurations()[1]); } |
JSONIndividualMatrixResponse extends JSONBasedIndividualMatrixResponse { public void setDurations(Double[][] durations) { this.durations = durations; } JSONIndividualMatrixResponse(MatrixResult result, MatrixRequest request); Double[][] getDurations(); List<JSON2DDestinations> getDestinations(); List<JSON2DSources> getSources(); Double[][] getDistances(); void setDistances(Double[][] distances); void setDurations(Double[][] durations); void setDestinations(List<JSON2DDestinations> destinations); void setSources(List<JSON2DSources> sources); } | @Test public void setDurations() { durationsMatrixResponse.setDurations(new Double[][]{{1.0, 2.0, 3.0},{1.0, 2.0, 3.0},{1.0, 2.0, 3.0}}); Assert.assertEquals(3, durationsMatrixResponse.getDurations().length); Assert.assertArrayEquals(new Double[]{1.0, 2.0, 3.0}, durationsMatrixResponse.getDurations()[0]); Assert.assertNull(distancesMatrixResponse.getDurations()); } |
JSONIndividualMatrixResponse extends JSONBasedIndividualMatrixResponse { public List<JSON2DDestinations> getDestinations() { return destinations; } JSONIndividualMatrixResponse(MatrixResult result, MatrixRequest request); Double[][] getDurations(); List<JSON2DDestinations> getDestinations(); List<JSON2DSources> getSources(); Double[][] getDistances(); void setDistances(Double[][] distances); void setDurations(Double[][] durations); void setDestinations(List<JSON2DDestinations> destinations); void setSources(List<JSON2DSources> sources); } | @Test public void getDestinations() { Assert.assertEquals(3, distancesMatrixResponse.getDestinations().size()); Assert.assertArrayEquals(new Double[]{8.681495, 49.41461}, distancesMatrixResponse.getDestinations().get(0).getLocation()); } |
JSONIndividualMatrixResponse extends JSONBasedIndividualMatrixResponse { public void setDestinations(List<JSON2DDestinations> destinations) { this.destinations = destinations; } JSONIndividualMatrixResponse(MatrixResult result, MatrixRequest request); Double[][] getDurations(); List<JSON2DDestinations> getDestinations(); List<JSON2DSources> getSources(); Double[][] getDistances(); void setDistances(Double[][] distances); void setDurations(Double[][] durations); void setDestinations(List<JSON2DDestinations> destinations); void setSources(List<JSON2DSources> sources); } | @Test public void setDestinations() { Coordinate coordinate = new Coordinate(9.681495, 50.41461); ResolvedLocation resolvedLocation = new ResolvedLocation(coordinate, "foo", 0.0); List<JSON2DDestinations> json2DDestinations = new ArrayList<>(); JSON2DDestinations json2DDestination = new JSON2DDestinations(resolvedLocation, false); json2DDestinations.add(json2DDestination); durationsMatrixResponse.setDestinations(json2DDestinations); distancesMatrixResponse.setDestinations(json2DDestinations); Assert.assertEquals(1, durationsMatrixResponse.getDestinations().size()); Assert.assertArrayEquals(new Double[]{9.681495, 50.41461}, durationsMatrixResponse.getDestinations().get(0).getLocation()); Assert.assertEquals(1, distancesMatrixResponse.getDestinations().size()); Assert.assertArrayEquals(new Double[]{9.681495, 50.41461}, distancesMatrixResponse.getDestinations().get(0).getLocation()); } |
JSONIndividualMatrixResponse extends JSONBasedIndividualMatrixResponse { public List<JSON2DSources> getSources() { return sources; } JSONIndividualMatrixResponse(MatrixResult result, MatrixRequest request); Double[][] getDurations(); List<JSON2DDestinations> getDestinations(); List<JSON2DSources> getSources(); Double[][] getDistances(); void setDistances(Double[][] distances); void setDurations(Double[][] durations); void setDestinations(List<JSON2DDestinations> destinations); void setSources(List<JSON2DSources> sources); } | @Test public void getSources() { Assert.assertEquals(3, durationsMatrixResponse.getSources().size()); Assert.assertArrayEquals(new Double[]{8.681495, 49.41461}, durationsMatrixResponse.getSources().get(0).getLocation()); } |
JSONIndividualMatrixResponse extends JSONBasedIndividualMatrixResponse { public void setSources(List<JSON2DSources> sources) { this.sources = sources; } JSONIndividualMatrixResponse(MatrixResult result, MatrixRequest request); Double[][] getDurations(); List<JSON2DDestinations> getDestinations(); List<JSON2DSources> getSources(); Double[][] getDistances(); void setDistances(Double[][] distances); void setDurations(Double[][] durations); void setDestinations(List<JSON2DDestinations> destinations); void setSources(List<JSON2DSources> sources); } | @Test public void setSources() { Coordinate coordinate = new Coordinate(9.681495, 50.41461); ResolvedLocation resolvedLocation = new ResolvedLocation(coordinate, "foo", 0.0); List<JSON2DSources> json2DSources = new ArrayList<>(); JSON2DSources json2DSource = new JSON2DSources(resolvedLocation, false); json2DSources.add(json2DSource); durationsMatrixResponse.setSources(json2DSources); distancesMatrixResponse.setSources(json2DSources); Assert.assertEquals(1, durationsMatrixResponse.getSources().size()); Assert.assertArrayEquals(new Double[]{9.681495, 50.41461}, durationsMatrixResponse.getSources().get(0).getLocation()); Assert.assertEquals(1, distancesMatrixResponse.getSources().size()); Assert.assertArrayEquals(new Double[]{9.681495, 50.41461}, distancesMatrixResponse.getSources().get(0).getLocation()); } |
JSON2DDestinations extends JSONLocation { @Override public Double[] getLocation() { Double[] location2D = new Double[2]; location2D[0] = FormatUtility.roundToDecimals(location.x, COORDINATE_DECIMAL_PLACES); location2D[1] = FormatUtility.roundToDecimals(location.y, COORDINATE_DECIMAL_PLACES); return location2D; } JSON2DDestinations(ResolvedLocation destination, boolean includeResolveLocations); @Override Double[] getLocation(); } | @Test public void getLocation() { JSON2DDestinations json2DDestinationsWithLocation = new JSON2DDestinations(resolvedLocation, true); JSON2DDestinations json2DDestinationsWoLocation = new JSON2DDestinations(resolvedLocation, false); Assert.assertArrayEquals(new Double[]{8.681495, 49.41461}, json2DDestinationsWithLocation.getLocation()); Assert.assertArrayEquals(new Double[]{8.681495, 49.41461}, json2DDestinationsWoLocation.getLocation()); } |
JSON2DSources extends JSONLocation { @Override public Double[] getLocation() { Double[] location2D = new Double[2]; location2D[0] = FormatUtility.roundToDecimals(location.x, COORDINATE_DECIMAL_PLACES); location2D[1] = FormatUtility.roundToDecimals(location.y, COORDINATE_DECIMAL_PLACES); return location2D; } JSON2DSources(ResolvedLocation source, boolean includeResolveLocations); @Override Double[] getLocation(); } | @Test public void getLocation() { JSON2DSources json2DSourcesWithLocation = new JSON2DSources(resolvedLocation, true); JSON2DSources json2DSourcesWoLocation = new JSON2DSources(resolvedLocation, false); Assert.assertArrayEquals(new Double[]{8.681495, 49.41461}, json2DSourcesWithLocation.getLocation()); Assert.assertArrayEquals(new Double[]{8.681495, 49.41461}, json2DSourcesWoLocation.getLocation()); } |
MatrixResponseInfo { public String getAttribution() { return attribution; } MatrixResponseInfo(MatrixRequest request); void setGraphDate(String graphDate); String getAttribution(); String getOsmFileMD5Hash(); String getService(); long getTimeStamp(); MatrixRequest getRequest(); EngineInfo getEngineInfo(); } | @Test public void getAttributionTest() { Assert.assertEquals(MatrixResponseInfo.class, responseInformation.getClass()); Assert.assertEquals(String.class, responseInformation.getAttribution().getClass()); } |
MatrixResponseInfo { public String getService() { return service; } MatrixResponseInfo(MatrixRequest request); void setGraphDate(String graphDate); String getAttribution(); String getOsmFileMD5Hash(); String getService(); long getTimeStamp(); MatrixRequest getRequest(); EngineInfo getEngineInfo(); } | @Test public void getServiceTest() { Assert.assertEquals("matrix", responseInformation.getService()); } |
MatrixResponseInfo { public long getTimeStamp() { return timeStamp; } MatrixResponseInfo(MatrixRequest request); void setGraphDate(String graphDate); String getAttribution(); String getOsmFileMD5Hash(); String getService(); long getTimeStamp(); MatrixRequest getRequest(); EngineInfo getEngineInfo(); } | @Test public void getTimeStampTest() { Assert.assertTrue(Long.toString(responseInformation.getTimeStamp()).length() > 0); } |
MatrixResponseInfo { public MatrixRequest getRequest() { return request; } MatrixResponseInfo(MatrixRequest request); void setGraphDate(String graphDate); String getAttribution(); String getOsmFileMD5Hash(); String getService(); long getTimeStamp(); MatrixRequest getRequest(); EngineInfo getEngineInfo(); } | @Test public void getRequestTest() { Assert.assertEquals(bareMatrixRequest, responseInformation.getRequest()); } |
MatrixResponseInfo { public EngineInfo getEngineInfo() { return engineInfo; } MatrixResponseInfo(MatrixRequest request); void setGraphDate(String graphDate); String getAttribution(); String getOsmFileMD5Hash(); String getService(); long getTimeStamp(); MatrixRequest getRequest(); EngineInfo getEngineInfo(); } | @Test public void getEngineInfoTest() { Assert.assertNotNull(responseInformation.getEngineInfo()); } |
IsochronesResponse { public IsochronesResponseInfo getResponseInformation() { return responseInformation; } IsochronesResponse(IsochronesRequest request); IsochronesResponseInfo getResponseInformation(); BoundingBox getBbox(); } | @Test public void getResponseInformation() { } |
ResolverQueryOrderBy implements OrderByResolver<Query, Query> { @Override public Query resolve(OrderByClause orderByClause, Query target) { switch (orderByClause.getOrderByMode()) { case ORDER_BY_CHILD: if (orderByClause.getArgument() == null) { throw new IllegalArgumentException(MISSING_ARGUMENT); } return target.orderByChild(orderByClause.getArgument()); case ORDER_BY_KEY: return target.orderByKey(); case ORDER_BY_VALUE: return target.orderByValue(); default: throw new IllegalStateException(); } } @Override Query resolve(OrderByClause orderByClause, Query target); } | @Test public void resolve_orderByChild() { OrderByClause orderByClause = new OrderByClause(); orderByClause.setOrderByMode(OrderByMode.ORDER_BY_CHILD); orderByClause.setArgument("test_argument"); Query query = PowerMockito.mock(Query.class); ResolverQueryOrderBy resolver = new ResolverQueryOrderBy(); resolver.resolve(orderByClause, query); Mockito.verify(query, VerificationModeFactory.times(1)).orderByChild(Mockito.eq("test_argument")); }
@Test(expected = IllegalArgumentException.class) public void resolve_orderByChild_withoutArgument() { OrderByClause orderByClause = new OrderByClause(); orderByClause.setOrderByMode(OrderByMode.ORDER_BY_CHILD); Query query = PowerMockito.mock(Query.class); ResolverQueryOrderBy resolver = new ResolverQueryOrderBy(); resolver.resolve(orderByClause, query); Mockito.verify(query, VerificationModeFactory.times(1)).orderByChild(Mockito.eq("test_argument")); }
@Test public void resolve_orderByKey() { OrderByClause orderByClause = new OrderByClause(); orderByClause.setOrderByMode(OrderByMode.ORDER_BY_KEY); Query query = PowerMockito.mock(Query.class); ResolverQueryOrderBy resolver = new ResolverQueryOrderBy(); resolver.resolve(orderByClause, query); Mockito.verify(query, VerificationModeFactory.times(1)).orderByKey(); }
@Test public void resolve_orderByValue() { OrderByClause orderByClause = new OrderByClause(); orderByClause.setOrderByMode(OrderByMode.ORDER_BY_VALUE); Query query = PowerMockito.mock(Query.class); ResolverQueryOrderBy resolver = new ResolverQueryOrderBy(); resolver.resolve(orderByClause, query); Mockito.verify(query, VerificationModeFactory.times(1)).orderByValue(); } |
Auth implements AuthDistribution { @Override public Promise<GdxFirebaseUser> signInWithToken(String token) { return FuturePromise.when(new AuthPromiseConsumer<>(FirebaseAuth.getInstance().signInWithCustomToken(token))); } @Override GdxFirebaseUser getCurrentUser(); @Override Promise<GdxFirebaseUser> createUserWithEmailAndPassword(String email, char[] password); @Override Promise<GdxFirebaseUser> signInWithEmailAndPassword(String email, char[] password); @Override Promise<GdxFirebaseUser> signInWithToken(String token); @Override Promise<GdxFirebaseUser> signInAnonymously(); @Override Promise<Void> signOut(); @Override Promise<Void> sendPasswordResetEmail(final String email); } | @Test public void signInWithToken() { Auth auth = new Auth(); Consumer consumer = Mockito.mock(Consumer.class); Mockito.when(task.isSuccessful()).thenReturn(true); Mockito.doReturn(task).when(firebaseAuth).signInWithCustomToken(Mockito.anyString()); auth.signInWithToken("token") .then(consumer); PowerMockito.verifyStatic(FirebaseAuth.class, VerificationModeFactory.times(2)); FirebaseAuth.getInstance(); Mockito.verify(firebaseAuth, VerificationModeFactory.times(1)).signInWithCustomToken(Mockito.eq("token")); Mockito.verify(firebaseAuth, VerificationModeFactory.times(1)).getCurrentUser(); Mockito.verify(task, VerificationModeFactory.times(1)).addOnCompleteListener(Mockito.any(OnCompleteListener.class)); Mockito.verify(consumer, VerificationModeFactory.times(1)).accept(Mockito.any(GdxFirebaseUser.class)); }
@Test public void signInWithToken_fail() { Auth auth = new Auth(); BiConsumer biConsumer = Mockito.mock(BiConsumer.class); Mockito.when(task.isSuccessful()).thenReturn(false); Mockito.when(task.getException()).thenReturn(new Exception()); Mockito.doReturn(task).when(firebaseAuth).signInWithCustomToken(Mockito.anyString()); auth.signInWithToken("token") .fail(biConsumer); PowerMockito.verifyStatic(FirebaseAuth.class, VerificationModeFactory.times(1)); FirebaseAuth.getInstance(); Mockito.verify(firebaseAuth, VerificationModeFactory.times(1)).signInWithCustomToken(Mockito.eq("token")); Mockito.verify(task, VerificationModeFactory.times(1)).addOnCompleteListener(Mockito.any(OnCompleteListener.class)); Mockito.verify(biConsumer, VerificationModeFactory.times(1)).accept(Mockito.nullable(String.class), Mockito.any(Exception.class)); } |
Auth implements AuthDistribution { @Override public Promise<GdxFirebaseUser> signInAnonymously() { return FuturePromise.when(new AuthPromiseConsumer<>(FirebaseAuth.getInstance().signInAnonymously())); } @Override GdxFirebaseUser getCurrentUser(); @Override Promise<GdxFirebaseUser> createUserWithEmailAndPassword(String email, char[] password); @Override Promise<GdxFirebaseUser> signInWithEmailAndPassword(String email, char[] password); @Override Promise<GdxFirebaseUser> signInWithToken(String token); @Override Promise<GdxFirebaseUser> signInAnonymously(); @Override Promise<Void> signOut(); @Override Promise<Void> sendPasswordResetEmail(final String email); } | @Test public void signInAnonymously() { Auth auth = new Auth(); Consumer consumer = Mockito.mock(Consumer.class); Mockito.when(task.isSuccessful()).thenReturn(true); Mockito.doReturn(task).when(firebaseAuth).signInAnonymously(); auth.signInAnonymously() .then(consumer); PowerMockito.verifyStatic(FirebaseAuth.class, VerificationModeFactory.times(2)); FirebaseAuth.getInstance(); Mockito.verify(firebaseAuth, VerificationModeFactory.times(1)).signInAnonymously(); Mockito.verify(task, VerificationModeFactory.times(1)).addOnCompleteListener(Mockito.any(OnCompleteListener.class)); Mockito.verify(consumer, VerificationModeFactory.times(1)).accept(Mockito.any(GdxFirebaseUser.class)); Mockito.verify(firebaseAuth, VerificationModeFactory.times(1)).getCurrentUser(); }
@Test public void signInAnonymously_fail() { Auth auth = new Auth(); BiConsumer biConsumer = Mockito.mock(BiConsumer.class); Mockito.when(task.isSuccessful()).thenReturn(false); Mockito.when(task.getException()).thenReturn(new Exception()); Mockito.doReturn(task).when(firebaseAuth).signInAnonymously(); auth.signInAnonymously() .fail(biConsumer); PowerMockito.verifyStatic(FirebaseAuth.class, VerificationModeFactory.times(1)); FirebaseAuth.getInstance(); Mockito.verify(firebaseAuth, VerificationModeFactory.times(1)).signInAnonymously(); Mockito.verify(task, VerificationModeFactory.times(1)).addOnCompleteListener(Mockito.any(OnCompleteListener.class)); Mockito.verify(biConsumer, VerificationModeFactory.times(1)).accept(Mockito.nullable(String.class), Mockito.any(Exception.class)); } |
Auth implements AuthDistribution { @Override public Promise<Void> signOut() { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(FuturePromise<Void> promise) { try { FirebaseAuth.getInstance().signOut(); promise.doComplete(null); } catch (Exception e) { promise.doFail(e); } } }); } @Override GdxFirebaseUser getCurrentUser(); @Override Promise<GdxFirebaseUser> createUserWithEmailAndPassword(String email, char[] password); @Override Promise<GdxFirebaseUser> signInWithEmailAndPassword(String email, char[] password); @Override Promise<GdxFirebaseUser> signInWithToken(String token); @Override Promise<GdxFirebaseUser> signInAnonymously(); @Override Promise<Void> signOut(); @Override Promise<Void> sendPasswordResetEmail(final String email); } | @Test public void signOut() { Auth auth = new Auth(); Consumer consumer = Mockito.mock(Consumer.class); auth.signOut().then(consumer); PowerMockito.verifyStatic(FirebaseAuth.class, VerificationModeFactory.times(1)); FirebaseAuth.getInstance(); Mockito.verify(firebaseAuth, VerificationModeFactory.times(1)).signOut(); Mockito.verify(consumer, VerificationModeFactory.times(1)).accept(Mockito.any()); }
@Test public void signOut_fail() { Auth auth = new Auth(); BiConsumer biConsumer = Mockito.mock(BiConsumer.class); Mockito.doThrow(new RuntimeException()).when(firebaseAuth).signOut(); auth.signOut().fail(biConsumer); PowerMockito.verifyStatic(FirebaseAuth.class, VerificationModeFactory.times(1)); FirebaseAuth.getInstance(); Mockito.verify(firebaseAuth, VerificationModeFactory.times(1)).signOut(); Mockito.verify(biConsumer, VerificationModeFactory.times(1)).accept(Mockito.nullable(String.class), Mockito.any(Exception.class)); } |
Auth implements AuthDistribution { @Override public Promise<Void> sendPasswordResetEmail(final String email) { return FuturePromise.when(new Consumer<FuturePromise<Void>>() { @Override public void accept(final FuturePromise<Void> promise) { FirebaseAuth.getInstance().sendPasswordResetEmail(email) .addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { promise.doComplete(null); } else { promise.doFail(task.getException()); } } }); } }); } @Override GdxFirebaseUser getCurrentUser(); @Override Promise<GdxFirebaseUser> createUserWithEmailAndPassword(String email, char[] password); @Override Promise<GdxFirebaseUser> signInWithEmailAndPassword(String email, char[] password); @Override Promise<GdxFirebaseUser> signInWithToken(String token); @Override Promise<GdxFirebaseUser> signInAnonymously(); @Override Promise<Void> signOut(); @Override Promise<Void> sendPasswordResetEmail(final String email); } | @Test public void sendPasswordResetEmail() { Auth auth = new Auth(); Consumer consumer = Mockito.mock(Consumer.class); Mockito.when(task.isSuccessful()).thenReturn(true); Mockito.doReturn(task).when(firebaseAuth).sendPasswordResetEmail(Mockito.anyString()); String arg1 = "email"; auth.sendPasswordResetEmail(arg1).then(consumer); PowerMockito.verifyStatic(FirebaseAuth.class, VerificationModeFactory.times(1)); FirebaseAuth.getInstance(); Mockito.verify(firebaseAuth, VerificationModeFactory.times(1)).sendPasswordResetEmail(Mockito.eq(arg1)); Mockito.verify(consumer, VerificationModeFactory.times(1)).accept(Mockito.any()); }
@Test public void sendPasswordResetEmail_fail() { Auth auth = new Auth(); BiConsumer biConsumer = Mockito.mock(BiConsumer.class); Mockito.when(task.isSuccessful()).thenReturn(false); Mockito.when(task.getException()).thenReturn(new Exception()); Mockito.doReturn(task).when(firebaseAuth).sendPasswordResetEmail(Mockito.anyString()); String arg1 = "email"; auth.sendPasswordResetEmail(arg1).fail(biConsumer); PowerMockito.verifyStatic(FirebaseAuth.class, VerificationModeFactory.times(1)); FirebaseAuth.getInstance(); Mockito.verify(firebaseAuth, VerificationModeFactory.times(1)).sendPasswordResetEmail(Mockito.eq(arg1)); Mockito.verify(biConsumer, VerificationModeFactory.times(1)).accept(Mockito.nullable(String.class), Mockito.any(Exception.class)); } |
ResolverQueryFilter implements FilterResolver<Query, Query> { @Override public <V> Query resolve(FilterType filterType, Query target, V... filterArguments) { if (filterArguments.length == 0) throw new IllegalArgumentException(MISSING_FILTER_ARGUMENTS); switch (filterType) { case LIMIT_FIRST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToFirst((Integer) filterArguments[0]); case LIMIT_LAST: if (!(filterArguments[0] instanceof Integer)) throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE); return target.limitToLast((Integer) filterArguments[0]); case START_AT: if (filterArguments[0] instanceof Double) { return target.startAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.startAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.startAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case END_AT: if (filterArguments[0] instanceof Double) { return target.endAt((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.endAt((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.endAt((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } case EQUAL_TO: if (filterArguments[0] instanceof Double) { return target.equalTo((Double) filterArguments[0]); } else if (filterArguments[0] instanceof Boolean) { return target.equalTo((Boolean) filterArguments[0]); } else if (filterArguments[0] instanceof String) { return target.equalTo((String) filterArguments[0]); } else { throw new IllegalArgumentException(WRONG_ARGUMENT_TYPE2); } default: throw new IllegalStateException(); } } @Override Query resolve(FilterType filterType, Query target, V... filterArguments); } | @Test public void resolve_endAt() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.END_AT, query, "test"); Mockito.verify(query, VerificationModeFactory.times(1)).endAt(Mockito.eq("test")); }
@Test public void resolve_endAt2() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.END_AT, query, 2.0); Mockito.verify(query, VerificationModeFactory.times(1)).endAt(Mockito.any(Double.class)); }
@Test public void resolve_endAt3() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.END_AT, query, true); Mockito.verify(query, VerificationModeFactory.times(1)).endAt(Mockito.anyBoolean()); }
@Test(expected = IllegalArgumentException.class) public void resolve_endAtWrongArgument() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.END_AT, query, 2); Assert.fail(); }
@Test public void resolve_equalTo() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.EQUAL_TO, query, "test"); Mockito.verify(query, VerificationModeFactory.times(1)).equalTo(Mockito.eq("test")); }
@Test public void resolve_equalTo2() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.EQUAL_TO, query, 10.0); Mockito.verify(query, VerificationModeFactory.times(1)).equalTo(Mockito.anyDouble()); }
@Test public void resolve_equalTo3() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.EQUAL_TO, query, true); Mockito.verify(query, VerificationModeFactory.times(1)).equalTo(Mockito.anyBoolean()); }
@Test(expected = IllegalArgumentException.class) public void resolve_equalToWrongArgument() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.EQUAL_TO, query, 10f); Assert.fail(); }
@Test public void resolve_limitLast() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.LIMIT_LAST, query, 2); Mockito.verify(query, VerificationModeFactory.times(1)).limitToLast(Mockito.anyInt()); }
@Test(expected = IllegalArgumentException.class) public void resolve_limitLastWrongArgument() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.LIMIT_LAST, query, "test"); Assert.fail(); }
@Test public void resolve_startAt() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.START_AT, query, "test"); Mockito.verify(query, VerificationModeFactory.times(1)).startAt(Mockito.eq("test")); }
@Test public void resolve_startAt2() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.START_AT, query, 10.0); Mockito.verify(query, VerificationModeFactory.times(1)).startAt(Mockito.anyDouble()); }
@Test public void resolve_startAt3() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.START_AT, query, true); Mockito.verify(query, VerificationModeFactory.times(1)).startAt(Mockito.anyBoolean()); }
@Test(expected = IllegalArgumentException.class) public void resolve_startAtWrongArgument() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.START_AT, query, 10f); Assert.fail(); }
@Test public void resolve_limitFirst() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.LIMIT_FIRST, query, 2); Mockito.verify(query, VerificationModeFactory.times(1)).limitToFirst(Mockito.anyInt()); }
@Test(expected = IllegalArgumentException.class) public void resolve_limitFirstWrongArgument() { ResolverQueryFilter resolver = new ResolverQueryFilter(); resolver.resolve(FilterType.LIMIT_FIRST, query, "test"); Assert.fail(); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.