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.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
@ -33,20 +35,11 @@ import com.google.gson.GsonBuilder;
|
|||
|
||||
@RunWith(Parameterized.class)
|
||||
public class RouteTestingTestIgnore {
|
||||
private TestEntry te;
|
||||
|
||||
|
||||
private LatLon startPoint;
|
||||
private LatLon endPoint;
|
||||
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;
|
||||
public RouteTestingTestIgnore(String name, TestEntry te) {
|
||||
this.te = te;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
@ -55,22 +48,17 @@ public class RouteTestingTestIgnore {
|
|||
}
|
||||
|
||||
@Parameterized.Parameters(name = "{index}: {0}")
|
||||
public static Collection<Object[]> data() throws IOException {
|
||||
public static Iterable<Object[]> data() throws IOException {
|
||||
String fileName = "/test_routing.json";
|
||||
Reader reader = new InputStreamReader(RouteTestingTestIgnore.class.getResourceAsStream(fileName));
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
TestEntry[] testEntries = gson.fromJson(reader, TestEntry[].class);
|
||||
ArrayList<Object[]> twoDArray = new ArrayList<Object[]>();
|
||||
for (int i = 0; i < testEntries.length; ++i) {
|
||||
if (!testEntries[i].isIgnore()) {
|
||||
Object[] arr = new Object[] { testEntries[i].getTestName(), testEntries[i].getStartPoint(),
|
||||
testEntries[i].getEndPoint(), testEntries[i].getExpectedResults(),
|
||||
testEntries[i].getParams()};
|
||||
twoDArray.add(arr);
|
||||
}
|
||||
ArrayList<Object[]> arrayList = new ArrayList<>();
|
||||
for(TestEntry te : testEntries) {
|
||||
arrayList.add(new Object[] {te.getTestName(), te});
|
||||
}
|
||||
reader.close();
|
||||
return twoDArray;
|
||||
return arrayList;
|
||||
|
||||
}
|
||||
|
||||
|
@ -82,12 +70,13 @@ public class RouteTestingTestIgnore {
|
|||
|
||||
BinaryMapIndexReader[] binaryMapIndexReaders = { new BinaryMapIndexReader(raf, new File(fl)) };
|
||||
RoutingConfiguration.Builder builder = RoutingConfiguration.getDefault();
|
||||
RoutingConfiguration config = builder.build(params.containsKey("vehicle") ?
|
||||
params.get("vehicle") : "car", RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3, params);
|
||||
Map<String, String> params = te.getParams();
|
||||
RoutingConfiguration config = builder.build(params.containsKey("vehicle") ? params.get("vehicle") : "car",
|
||||
RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3, params);
|
||||
RoutingContext ctx = fe.buildRoutingContext(config, null, binaryMapIndexReaders,
|
||||
RoutePlannerFrontEnd.RouteCalculationMode.NORMAL);
|
||||
ctx.leftSideNavigation = false;
|
||||
List<RouteSegmentResult> routeSegments = fe.searchRoute(ctx, startPoint, endPoint, null);
|
||||
List<RouteSegmentResult> routeSegments = fe.searchRoute(ctx, te.getStartPoint(), te.getEndPoint(), null);
|
||||
Set<Long> reachedSegments = new TreeSet<Long>();
|
||||
Assert.assertNotNull(routeSegments);
|
||||
int prevSegment = -1;
|
||||
|
@ -95,21 +84,28 @@ public class RouteTestingTestIgnore {
|
|||
if (i == routeSegments.size() || routeSegments.get(i).getTurnType() != null) {
|
||||
if (prevSegment >= 0) {
|
||||
String name = routeSegments.get(prevSegment).getDescription();
|
||||
long segmentId = routeSegments.get(prevSegment).getObject().getId() >> (BinaryInspector.SHIFT_ID );
|
||||
long segmentId = routeSegments.get(prevSegment).getObject().getId() >> (BinaryInspector.SHIFT_ID);
|
||||
System.out.println("segmentId: " + segmentId + " description: " + name);
|
||||
}
|
||||
prevSegment = i;
|
||||
}
|
||||
if (i < routeSegments.size()) {
|
||||
reachedSegments.add(routeSegments.get(i).getObject().getId() >> (BinaryInspector.SHIFT_ID ));
|
||||
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 - верный",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"shortWay": "true",
|
||||
"short_way": "true",
|
||||
"planRoadDirection": "0"
|
||||
},
|
||||
"ignore":true,
|
||||
"startPoint": {
|
||||
"latitude": 45.90810929390909,
|
||||
"longitude": 35.25023227930072
|
||||
|
@ -25,7 +26,7 @@
|
|||
"description": "Подтверждается только неверный маршрут. От дистанции не зависит, но зависит от planRoadDirection. При -1 маршрут верный, при 0 - нет",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"shortWay": "true",
|
||||
"short_way": "true",
|
||||
"planRoadDirection": "0"
|
||||
},
|
||||
"startPoint": {
|
||||
|
@ -45,7 +46,7 @@
|
|||
"description": "Не воспроизводится",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"shortWay": "true",
|
||||
"short_way": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"startPoint": {
|
||||
|
@ -65,7 +66,7 @@
|
|||
"description": "Не воспроизводится",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"shortWay": "true",
|
||||
"short_way": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"startPoint": {
|
||||
|
@ -86,10 +87,10 @@
|
|||
},
|
||||
{
|
||||
"testName": "10.Longer route preferred? https://github.com/osmandapp/Osmand/issues/1941",
|
||||
"description": "shortWay строит не самый короткий путь. Транзит через MEX 261 короче.",
|
||||
"description": "short_way строит не самый короткий путь. Транзит через MEX 261 короче.",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"shortWay": "true",
|
||||
"short_way": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"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",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"shortWay": "true",
|
||||
"short_way": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"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",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"shortWay": "true",
|
||||
"short_way": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"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",
|
||||
"params": {
|
||||
"vehicle": "car",
|
||||
"shortWay": "true",
|
||||
"short_way": "true",
|
||||
"planRoadDirection": "-1"
|
||||
},
|
||||
"startPoint": {
|
||||
|
|
Loading…
Reference in a new issue