diff options
author | Torsten Grote <t@grobox.de> | 2020-08-11 09:41:40 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2020-08-11 09:41:40 -0300 |
commit | f0670e2f3936f0223c02e9ec0d0de52f31a3539f (patch) | |
tree | f50cfc07029a024f06b79ee6b5031f5ba668a0f5 /merchant-lib/src/test/java/net/taler | |
parent | a20adabb2cfbaa2a78acac6560d81c27ca721731 (diff) | |
download | taler-android-f0670e2f3936f0223c02e9ec0d0de52f31a3539f.tar.gz taler-android-f0670e2f3936f0223c02e9ec0d0de52f31a3539f.tar.bz2 taler-android-f0670e2f3936f0223c02e9ec0d0de52f31a3539f.zip |
[pos] Improve coroutine-based merchant library access
Diffstat (limited to 'merchant-lib/src/test/java/net/taler')
-rw-r--r-- | merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt b/merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt index f9f5e87..992af6f 100644 --- a/merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt +++ b/merchant-lib/src/test/java/net/taler/merchantlib/MerchantApiTest.kt @@ -17,7 +17,9 @@ package net.taler.merchantlib import io.ktor.http.HttpStatusCode.Companion.NotFound -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.TestCoroutineDispatcher +import kotlinx.coroutines.test.runBlockingTest import net.taler.common.Amount import net.taler.common.ContractProduct import net.taler.common.ContractTerms @@ -28,9 +30,10 @@ import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test +@ExperimentalCoroutinesApi class MerchantApiTest { - private val api = MerchantApi(httpClient) + private val api = MerchantApi(httpClient, TestCoroutineDispatcher()) private val merchantConfig = MerchantConfig( baseUrl = "http://example.net/", instance = "testInstance", @@ -39,7 +42,7 @@ class MerchantApiTest { private val orderId = "orderIdFoo" @Test - fun testGetConfig() = runBlocking { + fun testGetConfig() = runBlockingTest { httpClient.giveJsonResponse("https://backend.int.taler.net/config") { """ { @@ -54,7 +57,7 @@ class MerchantApiTest { } @Test - fun testPostOrder() = runBlocking { + fun testPostOrder() = runBlockingTest { val product = ContractProduct( productId = "foo", description = "bar", @@ -111,7 +114,7 @@ class MerchantApiTest { } @Test - fun testCheckOrder() = runBlocking { + fun testCheckOrder() = runBlockingTest { val unpaidResponse = CheckPaymentResponse.Unpaid(false, "http://taler.net/foo") httpClient.giveJsonResponse("http://example.net/instances/testInstance/private/orders/$orderId") { """{ @@ -140,7 +143,7 @@ class MerchantApiTest { } @Test - fun testDeleteOrder() = runBlocking { + fun testDeleteOrder() = runBlockingTest { httpClient.giveJsonResponse("http://example.net/instances/testInstance/private/orders/$orderId") { "{}" } @@ -163,7 +166,7 @@ class MerchantApiTest { } @Test - fun testGetOrderHistory() = runBlocking { + fun testGetOrderHistory() = runBlockingTest { httpClient.giveJsonResponse("http://example.net/instances/testInstance/private/orders") { """{ "orders": [ { @@ -213,7 +216,7 @@ class MerchantApiTest { } @Test - fun testGiveRefund() = runBlocking { + fun testGiveRefund() = runBlockingTest { httpClient.giveJsonResponse("http://example.net/instances/testInstance/private/orders/$orderId/refund") { """{ "taler_refund_uri": "taler://refund/foo/bar" @@ -227,5 +230,4 @@ class MerchantApiTest { assertEquals("taler://refund/foo/bar", it.talerRefundUri) } } - } |