Fix tests
This commit is contained in:
parent
682869a2ee
commit
c5e3a5080a
2 changed files with 61 additions and 64 deletions
|
@ -7,9 +7,11 @@ import java.io.RandomAccessFile;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
@ -33,20 +35,11 @@ import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public class RouteTestingTestIgnore {
|
public class RouteTestingTestIgnore {
|
||||||
|
private TestEntry te;
|
||||||
|
|
||||||
|
|
||||||
private LatLon startPoint;
|
public RouteTestingTestIgnore(String name, TestEntry te) {
|
||||||
private LatLon endPoint;
|
this.te = te;
|
||||||
private Map<Long, String> expectedResults;
|
|
||||||
private Map<String, String> params;
|
|
||||||
|
|
||||||
|
|
||||||
public RouteTestingTestIgnore(String testName, LatLon startPoint, LatLon endPoint, Map<Long, String> expectedResults,
|
|
||||||
Map<String, String> params) {
|
|
||||||
this.startPoint = startPoint;
|
|
||||||
this.endPoint = endPoint;
|
|
||||||
this.expectedResults = expectedResults;
|
|
||||||
this.params = params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
|
@ -55,62 +48,65 @@ public class RouteTestingTestIgnore {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameters(name = "{index}: {0}")
|
@Parameterized.Parameters(name = "{index}: {0}")
|
||||||
public static Collection<Object[]> data() throws IOException {
|
public static Iterable<Object[]> data() throws IOException {
|
||||||
String fileName = "/test_routing.json";
|
String fileName = "/test_routing.json";
|
||||||
Reader reader = new InputStreamReader(RouteTestingTestIgnore.class.getResourceAsStream(fileName));
|
Reader reader = new InputStreamReader(RouteTestingTestIgnore.class.getResourceAsStream(fileName));
|
||||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
TestEntry[] testEntries = gson.fromJson(reader, TestEntry[].class);
|
TestEntry[] testEntries = gson.fromJson(reader, TestEntry[].class);
|
||||||
ArrayList<Object[]> twoDArray = new ArrayList<Object[]>();
|
ArrayList<Object[]> arrayList = new ArrayList<>();
|
||||||
for (int i = 0; i < testEntries.length; ++i) {
|
for(TestEntry te : testEntries) {
|
||||||
if (!testEntries[i].isIgnore()) {
|
arrayList.add(new Object[] {te.getTestName(), te});
|
||||||
Object[] arr = new Object[] { testEntries[i].getTestName(), testEntries[i].getStartPoint(),
|
|
||||||
testEntries[i].getEndPoint(), testEntries[i].getExpectedResults(),
|
|
||||||
testEntries[i].getParams()};
|
|
||||||
twoDArray.add(arr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
return twoDArray;
|
return arrayList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRouting() throws Exception {
|
public void testRouting() throws Exception {
|
||||||
String fl = "../../resources/test-resources/Routing_test.obf";
|
String fl = "../../resources/test-resources/Routing_test.obf";
|
||||||
RandomAccessFile raf = new RandomAccessFile(fl, "r");
|
RandomAccessFile raf = new RandomAccessFile(fl, "r");
|
||||||
RoutePlannerFrontEnd fe = new RoutePlannerFrontEnd(false);
|
RoutePlannerFrontEnd fe = new RoutePlannerFrontEnd(false);
|
||||||
|
|
||||||
BinaryMapIndexReader[] binaryMapIndexReaders = { new BinaryMapIndexReader(raf, new File(fl)) };
|
BinaryMapIndexReader[] binaryMapIndexReaders = { new BinaryMapIndexReader(raf, new File(fl)) };
|
||||||
RoutingConfiguration.Builder builder = RoutingConfiguration.getDefault();
|
RoutingConfiguration.Builder builder = RoutingConfiguration.getDefault();
|
||||||
RoutingConfiguration config = builder.build(params.containsKey("vehicle") ?
|
Map<String, String> params = te.getParams();
|
||||||
params.get("vehicle") : "car", RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3, params);
|
RoutingConfiguration config = builder.build(params.containsKey("vehicle") ? params.get("vehicle") : "car",
|
||||||
RoutingContext ctx = fe.buildRoutingContext(config, null, binaryMapIndexReaders,
|
RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3, params);
|
||||||
RoutePlannerFrontEnd.RouteCalculationMode.NORMAL);
|
RoutingContext ctx = fe.buildRoutingContext(config, null, binaryMapIndexReaders,
|
||||||
ctx.leftSideNavigation = false;
|
RoutePlannerFrontEnd.RouteCalculationMode.NORMAL);
|
||||||
List<RouteSegmentResult> routeSegments = fe.searchRoute(ctx, startPoint, endPoint, null);
|
ctx.leftSideNavigation = false;
|
||||||
Set<Long> reachedSegments = new TreeSet<Long>();
|
List<RouteSegmentResult> routeSegments = fe.searchRoute(ctx, te.getStartPoint(), te.getEndPoint(), null);
|
||||||
Assert.assertNotNull(routeSegments);
|
Set<Long> reachedSegments = new TreeSet<Long>();
|
||||||
int prevSegment = -1;
|
Assert.assertNotNull(routeSegments);
|
||||||
for (int i = 0; i <= routeSegments.size(); i++) {
|
int prevSegment = -1;
|
||||||
if (i == routeSegments.size() || routeSegments.get(i).getTurnType() != null) {
|
for (int i = 0; i <= routeSegments.size(); i++) {
|
||||||
if (prevSegment >= 0) {
|
if (i == routeSegments.size() || routeSegments.get(i).getTurnType() != null) {
|
||||||
String name = routeSegments.get(prevSegment).getDescription();
|
if (prevSegment >= 0) {
|
||||||
long segmentId = routeSegments.get(prevSegment).getObject().getId() >> (BinaryInspector.SHIFT_ID );
|
String name = routeSegments.get(prevSegment).getDescription();
|
||||||
System.out.println("segmentId: " + segmentId + " description: " + name);
|
long segmentId = routeSegments.get(prevSegment).getObject().getId() >> (BinaryInspector.SHIFT_ID);
|
||||||
}
|
System.out.println("segmentId: " + segmentId + " description: " + name);
|
||||||
prevSegment = i;
|
}
|
||||||
}
|
prevSegment = i;
|
||||||
if (i < routeSegments.size()) {
|
}
|
||||||
reachedSegments.add(routeSegments.get(i).getObject().getId() >> (BinaryInspector.SHIFT_ID ));
|
if (i < routeSegments.size()) {
|
||||||
}
|
reachedSegments.add(routeSegments.get(i).getObject().getId() >> (BinaryInspector.SHIFT_ID));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Map<Long, String> expectedResults = te.getExpectedResults();
|
||||||
|
Iterator<Entry<Long, String>> it = expectedResults.entrySet().iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Entry<Long, String> es = it.next();
|
||||||
|
if (es.getValue().equals("false")) {
|
||||||
|
Assert.assertTrue("Expected segment " + (es.getKey()) + " was wrongly reached in route segments "
|
||||||
|
+ reachedSegments.toString(), !reachedSegments.contains(es.getKey()));
|
||||||
|
} else {
|
||||||
|
Assert.assertTrue("Expected segment " + (es.getKey()) + " weren't reached in route segments "
|
||||||
|
+ reachedSegments.toString(), reachedSegments.contains(es.getKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Set<Long> expectedSegments = expectedResults.keySet();
|
}
|
||||||
for (Long expSegId : expectedSegments){
|
|
||||||
Assert.assertTrue("Expected segment " + (expSegId ) +
|
|
||||||
" weren't reached in route segments " + reachedSegments.toString(), reachedSegments.contains(expSegId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
"description": "При planRoadDirection='-1' маршрут неверный, при 0 - верный",
|
"description": "При planRoadDirection='-1' маршрут неверный, при 0 - верный",
|
||||||
"params": {
|
"params": {
|
||||||
"vehicle": "car",
|
"vehicle": "car",
|
||||||
"shortWay": "true",
|
"short_way": "true",
|
||||||
"planRoadDirection": "0"
|
"planRoadDirection": "0"
|
||||||
},
|
},
|
||||||
|
"ignore":true,
|
||||||
"startPoint": {
|
"startPoint": {
|
||||||
"latitude": 45.90810929390909,
|
"latitude": 45.90810929390909,
|
||||||
"longitude": 35.25023227930072
|
"longitude": 35.25023227930072
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
"description": "Подтверждается только неверный маршрут. От дистанции не зависит, но зависит от planRoadDirection. При -1 маршрут верный, при 0 - нет",
|
"description": "Подтверждается только неверный маршрут. От дистанции не зависит, но зависит от planRoadDirection. При -1 маршрут верный, при 0 - нет",
|
||||||
"params": {
|
"params": {
|
||||||
"vehicle": "car",
|
"vehicle": "car",
|
||||||
"shortWay": "true",
|
"short_way": "true",
|
||||||
"planRoadDirection": "0"
|
"planRoadDirection": "0"
|
||||||
},
|
},
|
||||||
"startPoint": {
|
"startPoint": {
|
||||||
|
@ -45,7 +46,7 @@
|
||||||
"description": "Не воспроизводится",
|
"description": "Не воспроизводится",
|
||||||
"params": {
|
"params": {
|
||||||
"vehicle": "car",
|
"vehicle": "car",
|
||||||
"shortWay": "true",
|
"short_way": "true",
|
||||||
"planRoadDirection": "-1"
|
"planRoadDirection": "-1"
|
||||||
},
|
},
|
||||||
"startPoint": {
|
"startPoint": {
|
||||||
|
@ -65,7 +66,7 @@
|
||||||
"description": "Не воспроизводится",
|
"description": "Не воспроизводится",
|
||||||
"params": {
|
"params": {
|
||||||
"vehicle": "car",
|
"vehicle": "car",
|
||||||
"shortWay": "true",
|
"short_way": "true",
|
||||||
"planRoadDirection": "-1"
|
"planRoadDirection": "-1"
|
||||||
},
|
},
|
||||||
"startPoint": {
|
"startPoint": {
|
||||||
|
@ -86,10 +87,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"testName": "10.Longer route preferred? https://github.com/osmandapp/Osmand/issues/1941",
|
"testName": "10.Longer route preferred? https://github.com/osmandapp/Osmand/issues/1941",
|
||||||
"description": "shortWay строит не самый короткий путь. Транзит через MEX 261 короче.",
|
"description": "short_way строит не самый короткий путь. Транзит через MEX 261 короче.",
|
||||||
"params": {
|
"params": {
|
||||||
"vehicle": "car",
|
"vehicle": "car",
|
||||||
"shortWay": "true",
|
"short_way": "true",
|
||||||
"planRoadDirection": "-1"
|
"planRoadDirection": "-1"
|
||||||
},
|
},
|
||||||
"startPoint": {
|
"startPoint": {
|
||||||
|
@ -108,7 +109,7 @@
|
||||||
"testName": "12.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA https://github.com/osmandapp/Osmand/issues/1743",
|
"testName": "12.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA https://github.com/osmandapp/Osmand/issues/1743",
|
||||||
"params": {
|
"params": {
|
||||||
"vehicle": "car",
|
"vehicle": "car",
|
||||||
"shortWay": "true",
|
"short_way": "true",
|
||||||
"planRoadDirection": "-1"
|
"planRoadDirection": "-1"
|
||||||
},
|
},
|
||||||
"startPoint": {
|
"startPoint": {
|
||||||
|
@ -128,7 +129,7 @@
|
||||||
"testName": "12.1.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA (transit2 point) https://github.com/osmandapp/Osmand/issues/1743",
|
"testName": "12.1.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA (transit2 point) https://github.com/osmandapp/Osmand/issues/1743",
|
||||||
"params": {
|
"params": {
|
||||||
"vehicle": "car",
|
"vehicle": "car",
|
||||||
"shortWay": "true",
|
"short_way": "true",
|
||||||
"planRoadDirection": "-1"
|
"planRoadDirection": "-1"
|
||||||
},
|
},
|
||||||
"startPoint": {
|
"startPoint": {
|
||||||
|
@ -151,7 +152,7 @@
|
||||||
"testName": "12.2.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA (reverse) https://github.com/osmandapp/Osmand/issues/1743",
|
"testName": "12.2.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA (reverse) https://github.com/osmandapp/Osmand/issues/1743",
|
||||||
"params": {
|
"params": {
|
||||||
"vehicle": "car",
|
"vehicle": "car",
|
||||||
"shortWay": "true",
|
"short_way": "true",
|
||||||
"planRoadDirection": "-1"
|
"planRoadDirection": "-1"
|
||||||
},
|
},
|
||||||
"startPoint": {
|
"startPoint": {
|
||||||
|
|
Loading…
Reference in a new issue