-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Added kotlin decode test & removed unsupported date-time
Showing
11 changed files
with
2,097 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,7 @@ publishing { | |
|
||
groupId = "com.osrm" | ||
artifactId = "api" | ||
version = "0.0.8" | ||
version = "0.0.9" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class TestFixture { | ||
companion object { | ||
fun loadAsset(fileName: String): String { | ||
val stream = | ||
this.javaClass.classLoader.getResource(fileName)?.openStream() | ||
?: throw IllegalArgumentException("Asset not found: $fileName") | ||
return stream.bufferedReader().use { it.readText() } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
import com.osrm.api.models.RouteResponse | ||
import kotlin.test.Test | ||
import com.osrm.api.models.Waypoint | ||
import com.squareup.moshi.Moshi | ||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNotNull | ||
import kotlin.test.fail | ||
|
||
class ModelTest { | ||
|
||
private val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build() | ||
|
||
@Test | ||
fun testWaypoint() { | ||
val waypoint = Waypoint("name", listOf(1.0, 2.0)) | ||
assertEquals("name", waypoint.name) | ||
assertEquals(listOf(1.0, 2.0), waypoint.location) | ||
} | ||
|
||
@Test | ||
fun testDecode() { | ||
val jsonData = TestFixture.loadAsset("route.json") | ||
val response = moshi.adapter(RouteResponse::class.java).fromJson(jsonData) | ||
|
||
assertNotNull(response?.routes) | ||
assertEquals(RouteResponse.Code.Ok, response?.code) | ||
|
||
val route = response?.routes?.first() ?: fail("response must have at least one route") | ||
|
||
assertEquals(1, route.legs?.size) | ||
assertEquals(4, route.legs?.first()?.steps?.size) | ||
|
||
val step = route.legs?.first()?.steps?.first() ?: fail("route leg must have at least one step") | ||
|
||
assertEquals("State Highway 65", step.name) | ||
assertEquals("tezuoAezllgIfhAdStpAzV`hAxQlxA|X|i@vIdQpCnxClh@laCjd@dRdDr}@zOxgApR`pBf^jk@hKvmAnUfJ|AdDj@tCR", step.geometry) | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters