Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directions api validator cli #1189

Closed
wants to merge 2 commits into from
Closed

Directions api validator cli #1189

wants to merge 2 commits into from

Conversation

kmadsen
Copy link
Contributor

@kmadsen kmadsen commented Sep 23, 2020

Addressing https://github.com/mapbox/navigation-sdks/issues/542

This project can be pretty big, and I have been mostly hacking to just get it to work. But this is what it does. You can download any version of the directions api from mapbox-java, and then validate json is parsed with the release.

➜  validator git:(km-validator-cli) validator
validator <command>

Commands:
  validator list-services            Request info on all available services
  validator list-releases [service]  Request releases for a specific service
  validator download <release>       Download specific release
  validator download-all             Download all the releases
  validator json <release> <file>    Validate the contents of a json file
  validator json-all <file>          Validate the contents of a json file

Options:
  --version  Show version number                                       [boolean]
  --help     Show help                                                 [boolean]

Moved some of the completed issues into comments.

cc: @LukasPaczos @Guardiola31337 @1ec5

@kmadsen
Copy link
Contributor Author

kmadsen commented Sep 23, 2020

With this approach, there will be issues maintaining the validation tool.

Screen Shot 2020-09-22 at 7 51 21 PM

Notice, it was parsing the issues fine until release 5.1.0 when modules were separated. I've since fixed this by including mapbox-sdk-directions-models.jar in the builds.

Foreseeing SEMVER issues. If in some version the package name is changed (com.mapbox.api.directions.v5.models.DirectionsResponse). It's not an issue today, but not sure 🤔 how to deal with it in the future.

@kmadsen
Copy link
Contributor Author

kmadsen commented Sep 23, 2020

Running into another case where valid json is giving an error. But good news is it's all linking and working.

Ok this is expected. mapbox-java is not able to interpret geometry as a LineString

➜  validator git:(km-validator-cli) ✗ validator json 4.9.0 json/tokyo-2020-09-22.json
Completed 4.9.0 with a CRASH Error: Error running static method
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 881 path $.routes[0].legs[0].steps[0].geometry
	at com.google.gson.Gson.fromJson(Gson.java:944)
pick 9e276fd4 wip
	at com.google.gson.Gson.fromJson(Gson.java:897)
	at com.google.gson.Gson.fromJson(Gson.java:846)
	at com.google.gson.Gson.fromJson(Gson.java:817)
	at com.mapbox.api.directions.v5.models.DirectionsResponse.fromJson(DirectionsResponse.java:133)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 881 path $.routes[0].legs[0].steps[0].geometry
	at com.google.gson.stream.JsonReader.nextString(JsonReader.java:826)
	at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:402)
	at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:390)

@kmadsen
Copy link
Contributor Author

kmadsen commented Sep 25, 2020

Ok it's all working. Give it some json, it tells you if mapbox-java can handle it. @danpaz

5.4.0 fails because it is missing libraries #1191
There is a 5.4.1. We can remove 5.4.0 from the validator.

Also, can see that the tool is working because mapbox-java cannot interpret geometry as a LineString, it must be a Polyline String

➜  validator git:(km-validator-cli) sh scripts/all-releases.sh json/test-from-examples.json
3.0.0 success
3.0.0-beta.1 failure TypeError: directionStatic.fromJsonSync is not a function
3.0.0-beta.2 success
3.0.0-beta.3 success
3.0.0-beta.4 success
3.0.1 success
3.1.0 success
3.2.0 success
3.3.0 success
3.4.0 success
3.4.1 success
4.0.0 success
4.1.0 success
4.1.1 success
4.2.0 success
4.3.0 success
4.5.0 success
4.6.0 success
4.7.0 success
4.7.0-alpha.1 success
4.8.0 success
4.8.0-alpha.2 success
4.9.0 success
4.9.0-alpha.1 success
4.9.1 success
5.0.0 success
5.1.0 success
5.1.0-beta.1 success
5.1.0-beta.2 success
5.2.0 success
5.2.1 success
5.3.0 success
5.4.0 failure Error: Could not create class com.mapbox.api.directions.v5.models.DirectionsResponse
java.lang.NoClassDefFoundError: com/mapbox/api/directions/v5/models/DirectionsResponse
Caused by: java.lang.ClassNotFoundException: com.mapbox.api.directions.v5.models.DirectionsResponse
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)

5.4.1 success
5.5.0 success
5.6.0 success
5.7.0-beta success

@@ -0,0 +1,3 @@

npm link
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe don't do this. i think this messed up my mbxcli and i had to relink it

@kmadsen kmadsen force-pushed the km-validator-cli branch 2 times, most recently from 8c249ba to a737d96 Compare September 26, 2020 03:43
@kmadsen
Copy link
Contributor Author

kmadsen commented Sep 28, 2020

Considering that I'm new to NodeJs development and that is what is wiring these integration tests together. I'm also looking for a nice way to add unit tests to this command line interface.

This post looks well received https://medium.com/@me_37286/yoni-goldberg-javascript-nodejs-testing-best-practices-2b98924c9347

@kmadsen
Copy link
Contributor Author

kmadsen commented Sep 29, 2020

@kmadsen kmadsen closed this Sep 29, 2020
@kmadsen kmadsen deleted the km-validator-cli branch March 11, 2021 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant