-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' of github.com:wordpress-mobile/WordPress-FluxC-A…
…ndroid into analysis/add-missing-nullability-annotations-to-theme-client-classes
- Loading branch information
Showing
12 changed files
with
364 additions
and
3 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
62 changes: 62 additions & 0 deletions
62
.../src/androidTest/java/org/wordpress/android/fluxc/release/ReleaseStack_WooPaymentsTest.kt
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,62 @@ | ||
package org.wordpress.android.fluxc.release | ||
|
||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.wordpress.android.fluxc.example.test.BuildConfig | ||
import org.wordpress.android.fluxc.network.rest.wpcom.wc.payments.woo.WooPaymentsDepositsOverviewApiResponse | ||
import org.wordpress.android.fluxc.store.AccountStore.AuthenticatePayload | ||
import org.wordpress.android.fluxc.store.WCWooPaymentsStore | ||
import javax.inject.Inject | ||
|
||
class ReleaseStack_WooPaymentsTest : ReleaseStack_WCBase() { | ||
@Inject internal lateinit var store: WCWooPaymentsStore | ||
|
||
override val testSite: TestSite = TestSite.Specified(siteId = BuildConfig.TEST_WPCOM_SITE_ID_WOO_JP_WCPAY.toLong()) | ||
|
||
override fun buildAuthenticatePayload() = AuthenticatePayload( | ||
BuildConfig.TEST_WPCOM_USERNAME_WOO_JP, | ||
BuildConfig.TEST_WPCOM_PASSWORD_WOO_JP | ||
) | ||
|
||
@Throws(Exception::class) | ||
override fun setUp() { | ||
super.setUp() | ||
mReleaseStackAppComponent.inject(this) | ||
// Register | ||
init() | ||
} | ||
|
||
@Test | ||
fun givenSiteHasWCPayWhenLoadAccountThenTestAccountReturned() = runBlocking { | ||
val result = store.fetchDepositsOverview(sSite) | ||
|
||
assertEquals("usd", result.result?.account?.defaultCurrency) | ||
assertEquals(false, result.result?.account?.depositsBlocked) | ||
assertEquals(true, result.result?.account?.depositsEnabled) | ||
assertEquals(2, result.result?.account?.depositsSchedule?.delayDays) | ||
assertEquals("daily", result.result?.account?.depositsSchedule?.interval) | ||
assertEquals(0, result.result?.balance?.available?.get(0)?.amount) | ||
assertEquals("usd", result.result?.balance?.available?.get(0)?.currency) | ||
assertEquals(0, result.result?.balance?.available?.get(0)?.sourceTypes?.card) | ||
assertEquals(0, result.result?.balance?.instant?.size) | ||
assertEquals(0, result.result?.balance?.pending?.get(0)?.amount) | ||
assertEquals("usd", result.result?.balance?.pending?.get(0)?.currency) | ||
assertEquals(0, result.result?.balance?.pending?.get(0)?.depositsCount) | ||
assertEquals(0, result.result?.balance?.pending?.get(0)?.sourceTypes?.card) | ||
assertEquals(0, result.result?.deposit?.lastManualDeposits?.size) | ||
assertEquals(1, result.result?.deposit?.lastPaid?.size) | ||
assertEquals(4373, result.result?.deposit?.lastPaid?.get(0)?.amount) | ||
assertEquals(true, result.result?.deposit?.lastPaid?.get(0)?.automatic) | ||
assertEquals("STRIPE TEST BANK •••• 6789 (USD)", result.result?.deposit?.lastPaid?.get(0)?.bankAccount) | ||
assertEquals(1644192000, result.result?.deposit?.lastPaid?.get(0)?.created) | ||
assertEquals("usd", result.result?.deposit?.lastPaid?.get(0)?.currency) | ||
assertEquals(1644192000000, result.result?.deposit?.lastPaid?.get(0)?.date) | ||
assertEquals(0, result.result?.deposit?.lastPaid?.get(0)?.fee) | ||
assertEquals(0, result.result?.deposit?.lastPaid?.get(0)?.feePercentage) | ||
assertEquals("po_1KQLho2HswaZkMX3M9Qhzf4W", result.result?.deposit?.lastPaid?.get(0)?.id) | ||
assertEquals("paid", result.result?.deposit?.lastPaid?.get(0)?.status) | ||
assertEquals("deposit", result.result?.deposit?.lastPaid?.get(0)?.type) | ||
assertEquals(0, result.result?.deposit?.nextScheduled?.size) | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
example/src/test/java/org/wordpress/android/fluxc/store/WCWooPaymentsStoreTest.kt
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,50 @@ | ||
package org.wordpress.android.fluxc.store | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
import org.mockito.kotlin.any | ||
import org.mockito.kotlin.mock | ||
import org.mockito.kotlin.whenever | ||
import org.wordpress.android.fluxc.network.rest.wpcom.wc.WooError | ||
import org.wordpress.android.fluxc.network.rest.wpcom.wc.WooPayload | ||
import org.wordpress.android.fluxc.network.rest.wpcom.wc.payments.woo.WooPaymentsDepositsOverviewApiResponse | ||
import org.wordpress.android.fluxc.network.rest.wpcom.wc.payments.woo.WooPaymentsRestClient | ||
import org.wordpress.android.fluxc.test | ||
import org.wordpress.android.fluxc.tools.initCoroutineEngine | ||
|
||
class WCWooPaymentsStoreTest { | ||
private val restClient = mock<WooPaymentsRestClient>() | ||
|
||
private val store = WCWooPaymentsStore( | ||
initCoroutineEngine(), | ||
restClient | ||
) | ||
|
||
@Test | ||
fun `given rest returns error, when fetchConnectionToken, then error returned`() = test { | ||
// GIVEN | ||
val error = mock<WooError>() | ||
val restResult = WooPayload<WooPaymentsDepositsOverviewApiResponse>(error) | ||
whenever(restClient.fetchDepositsOverview(any())).thenReturn(restResult) | ||
|
||
// WHEN | ||
val result = store.fetchDepositsOverview(mock()) | ||
|
||
// THEN | ||
assertThat(result).isEqualTo(restResult) | ||
} | ||
|
||
@Test | ||
fun `given rest returns success, when fetchConnectionToken, then success returned`() = test { | ||
// GIVEN | ||
val model = mock<WooPaymentsDepositsOverviewApiResponse>() | ||
val restResult = WooPayload(model) | ||
whenever(restClient.fetchDepositsOverview(any())).thenReturn(restResult) | ||
|
||
// WHEN | ||
val result = store.fetchDepositsOverview(mock()) | ||
|
||
// THEN | ||
assertThat(result).isEqualTo(restResult) | ||
} | ||
} |
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
150 changes: 150 additions & 0 deletions
150
...ndroid/fluxc/network/rest/wpcom/wc/payments/woo/WooPaymentsDepositsOverviewApiResponse.kt
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,150 @@ | ||
package org.wordpress.android.fluxc.network.rest.wpcom.wc.payments.woo | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class WooPaymentsDepositsOverviewApiResponse( | ||
@SerializedName("account") | ||
val account: Account?, | ||
@SerializedName("balance") | ||
val balance: Balance?, | ||
@SerializedName("deposit") | ||
val deposit: Deposit? | ||
) { | ||
data class Account( | ||
@SerializedName("default_currency") | ||
val defaultCurrency: String?, | ||
@SerializedName("deposits_blocked") | ||
val depositsBlocked: Boolean?, | ||
@SerializedName("deposits_enabled") | ||
val depositsEnabled: Boolean?, | ||
@SerializedName("deposits_schedule") | ||
val depositsSchedule: DepositsSchedule? | ||
) { | ||
data class DepositsSchedule( | ||
@SerializedName("delay_days") | ||
val delayDays: Int?, | ||
@SerializedName("interval") | ||
val interval: String? | ||
) | ||
} | ||
|
||
data class Balance( | ||
@SerializedName("available") | ||
val available: List<Available?>?, | ||
@SerializedName("instant") | ||
val instant: List<Instant?>?, | ||
@SerializedName("pending") | ||
val pending: List<Pending?>? | ||
) { | ||
data class Available( | ||
@SerializedName("amount") | ||
val amount: Int?, | ||
@SerializedName("currency") | ||
val currency: String?, | ||
@SerializedName("source_types") | ||
val sourceTypes: SourceTypes? | ||
) { | ||
data class SourceTypes( | ||
@SerializedName("card") | ||
val card: Int? | ||
) | ||
} | ||
|
||
data class Instant( | ||
@SerializedName("amount") | ||
val amount: Int?, | ||
@SerializedName("currency") | ||
val currency: String?, | ||
@SerializedName("fee") | ||
val fee: Int?, | ||
@SerializedName("fee_percentage") | ||
val feePercentage: Double?, | ||
@SerializedName("net") | ||
val net: Int?, | ||
@SerializedName("transaction_ids") | ||
val transactionIds: List<String?>? | ||
) | ||
|
||
data class Pending( | ||
@SerializedName("amount") | ||
val amount: Int?, | ||
@SerializedName("currency") | ||
val currency: String?, | ||
@SerializedName("deposits_count") | ||
val depositsCount: Int?, | ||
@SerializedName("source_types") | ||
val sourceTypes: SourceTypes? | ||
) { | ||
data class SourceTypes( | ||
@SerializedName("card") | ||
val card: Int? | ||
) | ||
} | ||
} | ||
|
||
data class Deposit( | ||
@SerializedName("last_manual_deposits") | ||
val lastManualDeposits: List<Any?>?, | ||
@SerializedName("last_paid") | ||
val lastPaid: List<LastPaid?>?, | ||
@SerializedName("next_scheduled") | ||
val nextScheduled: List<NextScheduled?>? | ||
) { | ||
data class LastPaid( | ||
@SerializedName("amount") | ||
val amount: Int?, | ||
@SerializedName("automatic") | ||
val automatic: Boolean?, | ||
@SerializedName("bankAccount") | ||
val bankAccount: String?, | ||
@SerializedName("created") | ||
val created: Int?, | ||
@SerializedName("currency") | ||
val currency: String?, | ||
@SerializedName("date") | ||
val date: Long?, | ||
@SerializedName("fee") | ||
val fee: Int?, | ||
@SerializedName("fee_percentage") | ||
val feePercentage: Int?, | ||
@SerializedName("id") | ||
val id: String?, | ||
@SerializedName("status") | ||
val status: String?, | ||
@SerializedName("type") | ||
val type: String? | ||
) | ||
|
||
data class NextScheduled( | ||
@SerializedName("amount") | ||
val amount: Int?, | ||
@SerializedName("automatic") | ||
val automatic: Boolean?, | ||
@SerializedName("bankAccount") | ||
val bankAccount: String?, | ||
@SerializedName("created") | ||
val created: Int?, | ||
@SerializedName("currency") | ||
val currency: String?, | ||
@SerializedName("date") | ||
val date: Long?, | ||
@SerializedName("fee") | ||
val fee: Int?, | ||
@SerializedName("fee_percentage") | ||
val feePercentage: Int?, | ||
@SerializedName("id") | ||
val id: String?, | ||
@SerializedName("status") | ||
val status: String?, | ||
@SerializedName("type") | ||
val type: String? | ||
) | ||
|
||
data class ManualDeposit( | ||
@SerializedName("currency") | ||
val currency: String?, | ||
@SerializedName("date") | ||
val date: String? | ||
) | ||
} | ||
} |
Oops, something went wrong.