diff --git a/.editorconfig b/.editorconfig index a3d213742f7..f201379da1e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,3 +15,6 @@ indent_size = 2 [*.json] indent_style = space indent_size = 2 + +[CHANGELOG.md] +trim_trailing_whitespace = false diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 312540b61fe..4e1cbb2de01 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -9,3 +9,15 @@ List out the key changes made in this PR, e.g. ### See Also + +## Changelog + diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c90ea393e3..689cd726122 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 33.0.0 - 2026-06-05 + +This release **doesn't** change the pinned API version; it still uses `2026-05-27.dahlia`. + +We're doing an out-of-band-major to update a field type that changed. If you're not using `tax_details`, this is a no-op release when compared with the last one. If you _are_ using `tax_details` its type has changed slightly and you'll have to update your code when upgrading. + +* [#2234](https://github.com/stripe/stripe-java/pull/2234) ⚠️ Make `tax_rate.tax_details` expandable +* [#2230](https://github.com/stripe/stripe-java/pull/2230) Add "source" field to user-agent header + ## 32.3.0-beta.1 - 2026-05-27 This release changes the pinned API version to 2026-05-27.private. @@ -15,6 +24,53 @@ This release changes the pinned API version to 2026-05-27.private. * ⚠️ Change type of `v2.moneymanagement.ReceivedCredit.bank_transfer.gb_bank_account.network` from `literal('fps')` to `enum('chaps'|'fps')` * Add support for new value `chaps` on enum `v2.FinancialAddressCreditSimulationCreditParams.network` +## 32.2.0 - 2026-05-27 +This release changes the pinned API version to 2026-05-27.dahlia. + +* [#2220](https://github.com/stripe/stripe-java/pull/2220) Update generated code + * Add support for new resource `v2.commerce.ProductCatalogImport` + * Add support for `create` and `retrieve` methods on resource `v2.commerce.ProductCatalogImport` + * Add support for `bizumPayments` and `scalapayPayments` on `Account.capabilities`, `AccountCreateParams.capabilities`, and `AccountUpdateParams.capabilities` + * Add support for `automaticTransferRulesByCurrency` on `BalanceSettings.payments.payouts` and `BalanceSettingsUpdateParams.payments.payouts` + * Add support for `startOfDay` on `BalanceSettings.payments.settlement_timing` and `BalanceSettingsUpdateParams.payments.settlement_timing` + * Add support for `description` on `ChargeCreateParams.transfer_data`, `PaymentIntent.transfer_data`, `PaymentIntentCreateParams.transfer_data`, and `PaymentIntentUpdateParams.transfer_data` + * Add support for `bizum` on `Charge.payment_method_details`, `ConfirmationToken.payment_method_preview`, `ConfirmationTokenCreateParams.payment_method_data`, `PaymentAttemptRecord.payment_method_details`, `PaymentIntent.payment_method_options`, `PaymentIntentConfirmParams.payment_method_data`, `PaymentIntentConfirmParams.payment_method_options`, `PaymentIntentCreateParams.payment_method_data`, `PaymentIntentCreateParams.payment_method_options`, `PaymentIntentUpdateParams.payment_method_data`, `PaymentIntentUpdateParams.payment_method_options`, `PaymentMethodConfigurationCreateParams`, `PaymentMethodConfigurationUpdateParams`, `PaymentMethodConfiguration`, `PaymentMethodCreateParams`, `PaymentMethod`, `PaymentRecord.payment_method_details`, `SetupIntent.payment_method_options`, `SetupIntentConfirmParams.payment_method_data`, `SetupIntentConfirmParams.payment_method_options`, `SetupIntentCreateParams.payment_method_data`, `SetupIntentCreateParams.payment_method_options`, `SetupIntentUpdateParams.payment_method_data`, and `SetupIntentUpdateParams.payment_method_options` + * Add support for `scalapay` on `Charge.payment_method_details`, `ConfirmationToken.payment_method_preview`, `ConfirmationTokenCreateParams.payment_method_data`, `PaymentAttemptRecord.payment_method_details`, `PaymentIntent.payment_method_options`, `PaymentIntentConfirmParams.payment_method_data`, `PaymentIntentConfirmParams.payment_method_options`, `PaymentIntentCreateParams.payment_method_data`, `PaymentIntentCreateParams.payment_method_options`, `PaymentIntentUpdateParams.payment_method_data`, `PaymentIntentUpdateParams.payment_method_options`, `PaymentMethodConfigurationCreateParams`, `PaymentMethodConfigurationUpdateParams`, `PaymentMethodConfiguration`, `PaymentMethodCreateParams`, `PaymentMethod`, `PaymentRecord.payment_method_details`, `Refund.destination_details`, `SetupIntentConfirmParams.payment_method_data`, `SetupIntentCreateParams.payment_method_data`, `SetupIntentUpdateParams.payment_method_data`, `checkout.Session.payment_method_options`, and `checkout.SessionCreateParams.payment_method_options` + * Add support for `mandate` on `Charge.payment_method_details.twint`, `PaymentAttemptRecord.payment_method_details.twint`, and `PaymentRecord.payment_method_details.twint` + * Add support for new values `bizum` and `scalapay` on enums `PaymentIntentConfirmParams.excludedPaymentMethodTypes`, `PaymentIntentCreateParams.excludedPaymentMethodTypes`, `PaymentIntentUpdateParams.excludedPaymentMethodTypes`, `SetupIntentCreateParams.excludedPaymentMethodTypes`, `SetupIntentUpdateParams.excludedPaymentMethodTypes`, and `checkout.SessionCreateParams.excludedPaymentMethodTypes` + * Change type of `PaymentIntentConfirmParams.payment_method_options.twint.setupFutureUsage`, `PaymentIntentCreateParams.payment_method_options.twint.setupFutureUsage`, `PaymentIntentUpdateParams.payment_method_options.twint.setupFutureUsage`, and `checkout.SessionCreateParams.payment_method_options.twint.setupFutureUsage` from `literal('none')` to `enum('none'|'off_session')` + * Add support for new values `bizum` and `scalapay` on enum `checkout.SessionCreateParams.paymentMethodTypes` + * ⚠️ Change type of `PaymentIntent.payment_method_options.twint.setupFutureUsage` and `checkout.Session.payment_method_options.twint.setupFutureUsage` from `literal('none')` to `enum('none'|'off_session')` + * Add support for new values `bizum` and `scalapay` on enums `ConfirmationTokenCreateParams.payment_method_data.type`, `PaymentIntentConfirmParams.payment_method_data.type`, `PaymentIntentCreateParams.payment_method_data.type`, `PaymentIntentUpdateParams.payment_method_data.type`, `SetupIntentConfirmParams.payment_method_data.type`, `SetupIntentCreateParams.payment_method_data.type`, and `SetupIntentUpdateParams.payment_method_data.type` + * Add support for new values `bizum` and `scalapay` on enums `CustomerListPaymentMethodsParams.type`, `PaymentMethodCreateParams.type`, and `PaymentMethodListParams.type` + * Add support for `creditedItems` on `InvoiceItem.proration_details` + * Add support for new value `twint` on enums `InvoiceCreateParams.payment_settings.paymentMethodTypes`, `InvoiceUpdateParams.payment_settings.paymentMethodTypes`, `SubscriptionCreateParams.payment_settings.paymentMethodTypes`, and `SubscriptionUpdateParams.payment_settings.paymentMethodTypes` + * Add support for `discountable` on `InvoiceCreatePreviewParams.schedule_details.phases[].add_invoice_items[]`, `SubscriptionCreateParams.add_invoice_items[]`, `SubscriptionSchedule.phases[].add_invoice_items[]`, `SubscriptionScheduleCreateParams.phases[].add_invoice_items[]`, `SubscriptionScheduleUpdateParams.phases[].add_invoice_items[]`, and `SubscriptionUpdateParams.add_invoice_items[]` + * Add support for `billingSchedules` on `InvoiceCreatePreviewParams.subscription_details`, `SubscriptionCreateParams`, `SubscriptionUpdateParams`, and `Subscription` + * Add support for new value `max_billed_until` on enums `InvoiceCreatePreviewParams.subscription_details.cancelAt`, `SubscriptionCreateParams.cancelAt`, and `SubscriptionUpdateParams.cancelAt` + * Add support for `amountPaidOffStripe` on `Invoice` + * Add support for `twint` on `Mandate.payment_method_details` and `SetupAttempt.payment_method_details` + * Add support for `metadata` on `PaymentIntent.transfer_data`, `PaymentIntentCreateParams.transfer_data`, `PaymentIntentUpdateParams.transfer_data`, and `Subscription.pending_update` + * Add support for `paymentData` on `PaymentIntent.transfer_data`, `PaymentIntentCreateParams.transfer_data`, and `PaymentIntentUpdateParams.transfer_data` + * Add support for `blikAuthorize` on `PaymentIntent.next_action` and `SetupIntent.next_action` + * Add support for `paymentMethodOptions` on `PaymentLinkCreateParams`, `PaymentLinkUpdateParams`, and `PaymentLink` + * Add support for new value `bizum` on enums `PaymentLinkCreateParams.paymentMethodTypes` and `PaymentLinkUpdateParams.paymentMethodTypes` + * Add support for `active` on `PaymentMethodConfigurationListParams` + * Add support for `billedUntil` on `SubscriptionItem` + * Add support for `discount` and `discounts` on `Subscription.pending_update` + * Add support for `verifoneM425`, `verifoneP630`, `verifoneUx700`, and `verifoneV660p` on `terminal.ConfigurationCreateParams`, `terminal.ConfigurationUpdateParams`, and `terminal.Configuration` + * Add support for new values `simulated_verifone_m425`, `simulated_verifone_p630`, `simulated_verifone_ux700`, `simulated_verifone_v660p`, `verifone_m425`, `verifone_p630`, `verifone_ux700`, and `verifone_v660p` on enum `terminal.ReaderListParams.deviceType` + * Add support for `apiError` and `printContent` on `terminal.Reader.action` + * Add support for `customer` on `testhelpers.TestClockCreateParams` + * Add support for new value `2026-05-27.dahlia` on enum `WebhookEndpointCreateParams.apiVersion` + * Add support for `signer` on `v2.core.Account.identity.business_details.documents.proof_of_registration`, `v2.core.Account.identity.business_details.documents.proof_of_ultimate_beneficial_ownership`, `v2.core.AccountCreateParams.identity.business_details.documents.proof_of_registration`, `v2.core.AccountCreateParams.identity.business_details.documents.proof_of_ultimate_beneficial_ownership`, `v2.core.AccountTokenCreateParams.identity.business_details.documents.proof_of_registration`, `v2.core.AccountTokenCreateParams.identity.business_details.documents.proof_of_ultimate_beneficial_ownership`, `v2.core.AccountUpdateParams.identity.business_details.documents.proof_of_registration`, and `v2.core.AccountUpdateParams.identity.business_details.documents.proof_of_ultimate_beneficial_ownership` + * Add support for `azureEventGrid` on `v2.core.EventDestinationCreateParams` and `v2.core.EventDestination` + * Add support for new value `azure_event_grid` on enum `v2.core.EventDestinationCreateParams.type` + * Add support for new value `meter_event_value_too_many_digits` on enums `EventsV1BillingMeterErrorReportTriggeredEvent.reason.error_types[].code` and `EventsV1BillingMeterNoMeterFoundEvent.reason.error_types[].code` + * Add support for event notifications `V2CommerceProductCatalogImportsFailedEvent`, `V2CommerceProductCatalogImportsProcessingEvent`, `V2CommerceProductCatalogImportsSucceededEvent`, and `V2CommerceProductCatalogImportsSucceededWithErrorsEvent` with related object `v2.commerce.ProductCatalogImport` +* [#2219](https://github.com/stripe/stripe-java/pull/2219) Emit warning when `stripe-notify` header is present in response +* [#2218](https://github.com/stripe/stripe-java/pull/2218) Add better example for accessing non-documented properties in a list response + ## 32.2.0-beta.2 - 2026-04-24 * [#2210](https://github.com/stripe/stripe-java/pull/2210) Update generated code for beta * Add support for new resources `v2.commerce.ProductCatalogImport`, `v2.data.reporting.QueryRun`, `v2.extend.WorkflowRun`, `v2.extend.Workflow`, `v2.iam.ActivityLog`, `v2.network.BusinessProfile`, and `v2.orchestratedcommerce.Agreement` diff --git a/CODEGEN_VERSION b/CODEGEN_VERSION index 3e0fd8d3279..26b2775e450 100644 --- a/CODEGEN_VERSION +++ b/CODEGEN_VERSION @@ -1 +1 @@ -1af5aa444ea8141a2d2b8d86e76c73f788f65e09 \ No newline at end of file +d4c29f2350721870596931042bd8edf49187fe0c \ No newline at end of file diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 30723023b84..14a4abeb1cf 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v2277 \ No newline at end of file +v2314 \ No newline at end of file diff --git a/README.md b/README.md index eb00b56fc72..9c5815639c6 100644 --- a/README.md +++ b/README.md @@ -298,7 +298,7 @@ Stripe.addBetaVersion("feature_beta", "v3"); ### Private Preview SDKs -Stripe has features in the [private preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `-alpha.X` suffix like `25.2.0-alpha.2`. These are invite-only features. Once invited, you can install the private preview SDKs by following the same instructions as for the [public preview SDKs](https://github.com/stripe/stripe-java?tab=readme-ov-file#public-preview-sdks) above and replacing the term `beta` with `alpha`. +Stripe has features in the [private preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `-alpha.X` suffix like `25.2.0-alpha.2`. You can install the private preview SDKs by following the same instructions as for the [public preview SDKs](https://github.com/stripe/stripe-java?tab=readme-ov-file#public-preview-sdks) above and replacing the term `beta` with `alpha`. Note that access to specific private preview API features may require separate approval. ### Custom requests @@ -335,6 +335,9 @@ New features and bug fixes are released on the latest major version of the Strip ## Development +> [!WARNING] +> External contributions to this repo from first-time contributors are currently on hiatus. If you'd like to see a change made to the package, please open an issue. + [Contribution guidelines for this project](CONTRIBUTING.md) JDK 17 is required to build the Stripe Java library. By default, tests use the same Java runtime as the build. diff --git a/src/main/java/com/stripe/net/HttpClient.java b/src/main/java/com/stripe/net/HttpClient.java index 8aa3fcda5f1..9d21f438342 100644 --- a/src/main/java/com/stripe/net/HttpClient.java +++ b/src/main/java/com/stripe/net/HttpClient.java @@ -7,6 +7,7 @@ import java.io.InputStream; import java.net.ConnectException; import java.net.SocketTimeoutException; +import java.security.MessageDigest; import java.time.Duration; import java.util.HashMap; import java.util.Map; @@ -26,6 +27,53 @@ public abstract class HttpClient { /** A value indicating whether the client should sleep between automatic request retries. */ boolean networkRetriesSleep = true; + static String UNAME_HASH = computeUnameHash(); + + private static String computeUnameHash() { + String uname = ""; + try { + uname = + (System.getProperty("os.name", "") + + " " + + System.getProperty("os.version", "") + + " " + + System.getProperty("os.arch", "") + + " " + + System.getProperty("java.version", "") + + " " + + System.getProperty("java.vendor", "") + + " " + + System.getProperty("java.vm.name", "") + + " " + + getHostname()) + .trim(); + } catch (Exception e) { + // fall through with empty string + } + if (uname.isEmpty()) { + return ""; + } + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] hashBytes = md.digest(uname.getBytes(java.nio.charset.StandardCharsets.UTF_8)); + StringBuilder sb = new StringBuilder(); + for (byte b : hashBytes) { + sb.append(String.format("%02x", b)); + } + return sb.toString(); + } catch (Exception e) { + return ""; + } + } + + private static String getHostname() { + try { + return java.net.InetAddress.getLocalHost().getHostName(); + } catch (Exception e) { + return ""; + } + } + /** Initializes a new instance of the {@link HttpClient} class. */ protected HttpClient() {} @@ -228,6 +276,10 @@ static String buildXStripeClientUserAgentString(String aiAgent) { propertyMap.put("ai_agent", aiAgent); } + if (!UNAME_HASH.isEmpty()) { + propertyMap.put("source", UNAME_HASH); + } + return ApiResource.INTERNAL_GSON.toJson(propertyMap); } diff --git a/src/test/java/com/stripe/functional/AccountLinkTest.java b/src/test/java/com/stripe/functional/AccountLinkTest.java deleted file mode 100644 index f1d7c48798c..00000000000 --- a/src/test/java/com/stripe/functional/AccountLinkTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.AccountLink; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class AccountLinkTest extends BaseStripeTest { - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap(); - params.put("account", "acct_123"); - params.put("refresh_url", "https://stripe.com/refresh"); - params.put("return_url", "https://stripe.com/return"); - params.put("type", "account_onboarding"); - - final AccountLink accountLink = AccountLink.create(params); - - assertNotNull(accountLink); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/account_links"), params); - } -} diff --git a/src/test/java/com/stripe/functional/ApplePayDomainTest.java b/src/test/java/com/stripe/functional/ApplePayDomainTest.java deleted file mode 100644 index 08683a13285..00000000000 --- a/src/test/java/com/stripe/functional/ApplePayDomainTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.ApplePayDomain; -import com.stripe.model.ApplePayDomainCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ApplePayDomainTest extends BaseStripeTest { - public static final String DOMAIN_ID = "apftw_123"; - - private ApplePayDomain getDomainFixture() throws StripeException { - final ApplePayDomain domain = ApplePayDomain.retrieve(DOMAIN_ID); - resetNetworkSpy(); - return domain; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("domain_name", "stripe.com"); - - final ApplePayDomain domain = ApplePayDomain.create(params); - - assertNotNull(domain); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/apple_pay/domains"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final ApplePayDomain domain = ApplePayDomain.retrieve(DOMAIN_ID); - - assertNotNull(domain); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/apple_pay/domains/%s", DOMAIN_ID)); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final ApplePayDomainCollection domains = ApplePayDomain.list(params); - - assertNotNull(domains); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/apple_pay/domains"), params); - } - - @Test - public void testDelete() throws StripeException { - final ApplePayDomain domain = getDomainFixture(); - - final ApplePayDomain deletedDomain = domain.delete(); - - assertNotNull(deletedDomain); - assertTrue(deletedDomain.getDeleted()); - verifyRequest( - ApiResource.RequestMethod.DELETE, - String.format("/v1/apple_pay/domains/%s", domain.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/ApplicationFeeTest.java b/src/test/java/com/stripe/functional/ApplicationFeeTest.java deleted file mode 100644 index 8b2c6df4b86..00000000000 --- a/src/test/java/com/stripe/functional/ApplicationFeeTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.ApplicationFee; -import com.stripe.model.ApplicationFeeCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ApplicationFeeTest extends BaseStripeTest { - public static final String FEE_ID = "fee_123"; - - @Test - public void testRetrieve() throws StripeException { - final ApplicationFee fee = ApplicationFee.retrieve(FEE_ID); - - assertNotNull(fee); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/application_fees/%s", FEE_ID)); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final ApplicationFeeCollection fees = ApplicationFee.list(params); - - assertNotNull(fees); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/application_fees"), params); - } -} diff --git a/src/test/java/com/stripe/functional/BalanceTest.java b/src/test/java/com/stripe/functional/BalanceTest.java deleted file mode 100644 index 3fb2b54a203..00000000000 --- a/src/test/java/com/stripe/functional/BalanceTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Balance; -import com.stripe.net.ApiResource; -import org.junit.jupiter.api.Test; - -public class BalanceTest extends BaseStripeTest { - @Test - public void testRetrieve() throws StripeException { - final Balance balance = Balance.retrieve(); - - assertNotNull(balance); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/balance")); - } -} diff --git a/src/test/java/com/stripe/functional/BalanceTransactionTest.java b/src/test/java/com/stripe/functional/BalanceTransactionTest.java deleted file mode 100644 index e8bfe910699..00000000000 --- a/src/test/java/com/stripe/functional/BalanceTransactionTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.BalanceTransaction; -import com.stripe.model.BalanceTransactionCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class BalanceTransactionTest extends BaseStripeTest { - public static final String RESOURCE_ID = "bt_123"; - - @Test - public void testRetrieve() throws StripeException { - final BalanceTransaction balanceTransaction = BalanceTransaction.retrieve(RESOURCE_ID); - - assertNotNull(balanceTransaction); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/balance_transactions/%s", RESOURCE_ID)); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final BalanceTransactionCollection balanceTransactions = BalanceTransaction.list(params); - - assertNotNull(balanceTransactions); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/balance_transactions"), params); - } -} diff --git a/src/test/java/com/stripe/functional/CountrySpecTest.java b/src/test/java/com/stripe/functional/CountrySpecTest.java deleted file mode 100644 index 18a556f03fc..00000000000 --- a/src/test/java/com/stripe/functional/CountrySpecTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.CountrySpec; -import com.stripe.model.CountrySpecCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class CountrySpecTest extends BaseStripeTest { - public static final String COUNTRY_SPEC_ID = "US"; - - @Test - public void testRetrieve() throws StripeException { - final CountrySpec countrySpec = CountrySpec.retrieve(COUNTRY_SPEC_ID); - - assertNotNull(countrySpec); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/country_specs/%s", COUNTRY_SPEC_ID)); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - CountrySpecCollection countrySpecs = CountrySpec.list(params); - - assertNotNull(countrySpecs); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/country_specs"), params); - } -} diff --git a/src/test/java/com/stripe/functional/CouponTest.java b/src/test/java/com/stripe/functional/CouponTest.java deleted file mode 100644 index 2fd614b653f..00000000000 --- a/src/test/java/com/stripe/functional/CouponTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Coupon; -import com.stripe.model.CouponCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class CouponTest extends BaseStripeTest { - public static final String COUPON_ID = "COUPON_ID"; - - private Coupon getCouponFixture() throws StripeException { - final Coupon coupon = Coupon.retrieve(COUPON_ID); - resetNetworkSpy(); - return coupon; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("percent_off", 25); - params.put("duration", "forever"); - - final Coupon coupon = Coupon.create(params); - - assertNotNull(coupon); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/coupons"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final Coupon coupon = Coupon.retrieve(COUPON_ID); - - assertNotNull(coupon); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/coupons/%s", COUPON_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Coupon coupon = getCouponFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Coupon updatedCoupon = coupon.update(params); - - assertNotNull(updatedCoupon); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/coupons/%s", coupon.getId()), params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final CouponCollection coupons = Coupon.list(params); - - assertNotNull(coupons); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/coupons")); - } - - @Test - public void testDelete() throws StripeException { - final Coupon coupon = getCouponFixture(); - - final Coupon deletedCoupon = coupon.delete(); - - assertNotNull(deletedCoupon); - assertTrue(deletedCoupon.getDeleted()); - verifyRequest( - ApiResource.RequestMethod.DELETE, String.format("/v1/coupons/%s", coupon.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/CustomerTest.java b/src/test/java/com/stripe/functional/CustomerTest.java deleted file mode 100644 index b4642d82f3e..00000000000 --- a/src/test/java/com/stripe/functional/CustomerTest.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Customer; -import com.stripe.model.CustomerCollection; -import com.stripe.model.Discount; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class CustomerTest extends BaseStripeTest { - public static final String CUSTOMER_ID = "cus_123"; - - private Customer getCustomerFixture() throws StripeException { - final Customer customer = Customer.retrieve(CUSTOMER_ID); - resetNetworkSpy(); - return customer; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - - final Customer customer = Customer.create(params); - - assertNotNull(customer); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/customers"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final Customer customer = Customer.retrieve(CUSTOMER_ID); - - assertNotNull(customer); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/customers/%s", CUSTOMER_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Customer customer = getCustomerFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Customer updatedCustomer = customer.update(params); - - assertNotNull(updatedCustomer); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/customers/%s", customer.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final CustomerCollection customers = Customer.list(params); - - assertNotNull(customers); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/customers"), params); - } - - @Test - public void testDelete() throws StripeException { - final Customer customer = getCustomerFixture(); - - final Customer deletedCustomer = customer.delete(); - - assertNotNull(deletedCustomer); - assertTrue(deletedCustomer.getDeleted()); - verifyRequest( - ApiResource.RequestMethod.DELETE, String.format("/v1/customers/%s", customer.getId())); - } - - @Test - public void testDeleteDiscount() throws StripeException { - final Customer customer = getCustomerFixture(); - - // stripe-mock does not support /v1/customers/%s/discount endpoint, so we stub the request - stubRequest( - ApiResource.RequestMethod.DELETE, - String.format("/v1/customers/%s/discount", customer.getId()), - null, - Discount.class, - null); - - customer.deleteDiscount(); - - verifyRequest( - ApiResource.RequestMethod.DELETE, - String.format("/v1/customers/%s/discount", customer.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/DisputeTest.java b/src/test/java/com/stripe/functional/DisputeTest.java deleted file mode 100644 index f343369dbc5..00000000000 --- a/src/test/java/com/stripe/functional/DisputeTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Dispute; -import com.stripe.model.DisputeCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class DisputeTest extends BaseStripeTest { - public static final String DISPUTE_ID = "dp_123"; - - private Dispute getDisputeFixture() throws StripeException { - final Dispute dispute = Dispute.retrieve(DISPUTE_ID); - resetNetworkSpy(); - return dispute; - } - - @Test - public void testRetrieve() throws StripeException { - final Dispute dispute = Dispute.retrieve(DISPUTE_ID); - - assertNotNull(dispute); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/disputes/%s", DISPUTE_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Dispute dispute = getDisputeFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Dispute updatedDispute = dispute.update(params); - - assertNotNull(updatedDispute); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/disputes/%s", dispute.getId()), params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final DisputeCollection disputes = Dispute.list(params); - - assertNotNull(disputes); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/disputes"), params); - } - - @Test - public void testClose() throws StripeException { - final Dispute dispute = getDisputeFixture(); - - final Dispute closedDispute = dispute.close(); - - assertNotNull(closedDispute); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/disputes/%s/close", dispute.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/ExchangeRateTest.java b/src/test/java/com/stripe/functional/ExchangeRateTest.java deleted file mode 100644 index 74df34e9658..00000000000 --- a/src/test/java/com/stripe/functional/ExchangeRateTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.ExchangeRate; -import com.stripe.model.ExchangeRateCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ExchangeRateTest extends BaseStripeTest { - public static final String CURRENCY = "usd"; - - @Test - public void testRetrieve() throws StripeException { - final ExchangeRate rate = ExchangeRate.retrieve(CURRENCY); - - assertNotNull(rate); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/exchange_rates/usd")); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final ExchangeRateCollection rates = ExchangeRate.list(params); - - assertNotNull(rates); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/exchange_rates")); - } -} diff --git a/src/test/java/com/stripe/functional/FeeRefundTest.java b/src/test/java/com/stripe/functional/FeeRefundTest.java deleted file mode 100644 index 17fbb4d81ec..00000000000 --- a/src/test/java/com/stripe/functional/FeeRefundTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.ApplicationFee; -import com.stripe.model.FeeRefund; -import com.stripe.model.FeeRefundCollection; -import com.stripe.net.ApiResource; -import com.stripe.net.RequestOptions; -import com.stripe.param.FeeRefundCollectionCreateParams; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class FeeRefundTest extends BaseStripeTest { - public static final String FEE_ID = "fee_123"; - public static final String REFUND_ID = "fr_123"; - - private ApplicationFee getFeeFixture() throws StripeException { - final ApplicationFee fee = ApplicationFee.retrieve(FEE_ID); - resetNetworkSpy(); - return fee; - } - - private FeeRefund getRefundFixture(ApplicationFee fee) throws StripeException { - final FeeRefund refund = fee.getRefunds().retrieve(REFUND_ID); - resetNetworkSpy(); - return refund; - } - - @Test - public void testCreate() throws StripeException { - final ApplicationFee fee = getFeeFixture(); - - final Map params = new HashMap<>(); - params.put("amount", 100); - - final FeeRefund refund = fee.getRefunds().create(params); - - assertNotNull(refund); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/application_fees/%s/refunds", fee.getId()), - params); - } - - @Test - public void testCreateWithTypedParams() throws StripeException { - final ApplicationFee fee = getFeeFixture(); - - FeeRefundCollectionCreateParams typedParams = - FeeRefundCollectionCreateParams.builder().setAmount(100L).build(); - - final FeeRefund refund = fee.getRefunds().create(typedParams, RequestOptions.getDefault()); - - assertNotNull(refund); - Map param = new HashMap<>(); - param.put("amount", 100); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/application_fees/%s/refunds", fee.getId()), - param); - } - - @Test - public void testRetrieve() throws StripeException { - final ApplicationFee fee = getFeeFixture(); - - final FeeRefund refund = fee.getRefunds().retrieve(REFUND_ID); - - assertNotNull(refund); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/application_fees/%s/refunds/%s", fee.getId(), REFUND_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final ApplicationFee fee = getFeeFixture(); - final FeeRefund refund = getRefundFixture(fee); - - Map metadata = new HashMap<>(); - metadata.put("key", "value"); - Map params = new HashMap<>(); - params.put("metadata", metadata); - - final FeeRefund updatedRefund = refund.update(params); - - assertNotNull(updatedRefund); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/application_fees/%s/refunds/%s", fee.getId(), refund.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final ApplicationFee fee = getFeeFixture(); - - final Map params = new HashMap<>(); - params.put("limit", 1); - - final FeeRefundCollection refunds = fee.getRefunds().list(params); - - assertNotNull(refunds); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/application_fees/%s/refunds", fee.getId()), - params); - } -} diff --git a/src/test/java/com/stripe/functional/FileLinkTest.java b/src/test/java/com/stripe/functional/FileLinkTest.java deleted file mode 100644 index 06510ff4812..00000000000 --- a/src/test/java/com/stripe/functional/FileLinkTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.FileLink; -import com.stripe.model.FileLinkCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class FileLinkTest extends BaseStripeTest { - public static final String FILE_LINK_ID = "link_123"; - - private FileLink getFileLinkFixture() throws StripeException { - final FileLink fileLink = FileLink.retrieve(FILE_LINK_ID); - resetNetworkSpy(); - return fileLink; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("file", "file_123"); - - final FileLink fileLink = FileLink.create(params); - - assertNotNull(fileLink); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/file_links"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final FileLink fileLink = FileLink.retrieve(FILE_LINK_ID); - - assertNotNull(fileLink); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/file_links/%s", FILE_LINK_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final FileLink fileLink = getFileLinkFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final FileLink updatedFileLink = fileLink.update(params); - - assertNotNull(updatedFileLink); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/file_links/%s", fileLink.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("file", "file_123"); - params.put("limit", 1); - - final FileLinkCollection fileLinks = FileLink.list(params); - - assertNotNull(fileLinks); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/file_links")); - } -} diff --git a/src/test/java/com/stripe/functional/InvoiceItemTest.java b/src/test/java/com/stripe/functional/InvoiceItemTest.java deleted file mode 100644 index 723b6d99ced..00000000000 --- a/src/test/java/com/stripe/functional/InvoiceItemTest.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.InvoiceItem; -import com.stripe.model.InvoiceItemCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class InvoiceItemTest extends BaseStripeTest { - public static final String INVOICE_ITEM_ID = "ii_123"; - - private InvoiceItem getItemFixture() throws StripeException { - final InvoiceItem item = InvoiceItem.retrieve(INVOICE_ITEM_ID); - resetNetworkSpy(); - return item; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("amount", 100); - params.put("currency", "usd"); - params.put("customer", "cus_123"); - - final InvoiceItem item = InvoiceItem.create(params); - - assertNotNull(item); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/invoiceitems"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final InvoiceItem item = InvoiceItem.retrieve(INVOICE_ITEM_ID); - - assertNotNull(item); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/invoiceitems/%s", INVOICE_ITEM_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final InvoiceItem resource = getItemFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final InvoiceItem updatedItem = resource.update(params); - - assertNotNull(updatedItem); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/invoiceitems/%s", resource.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - InvoiceItemCollection items = InvoiceItem.list(params); - - assertNotNull(items); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/invoiceitems"), params); - } -} diff --git a/src/test/java/com/stripe/functional/LoginLinkTest.java b/src/test/java/com/stripe/functional/LoginLinkTest.java deleted file mode 100644 index 42229156978..00000000000 --- a/src/test/java/com/stripe/functional/LoginLinkTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Account; -import com.stripe.model.LoginLink; -import com.stripe.net.ApiResource; -import java.io.IOException; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class LoginLinkTest extends BaseStripeTest { - public static final String ACCOUNT_ID = "acct_123"; - - @Test - public void testCreate() throws IOException, StripeException { - final Account account = Account.retrieve(ACCOUNT_ID, null); - - final LoginLink link = LoginLink.createOnAccount(ACCOUNT_ID, (Map) null, null); - - stubRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/accounts/%s/login_links", account.getId()), - null, - LoginLink.class, - getResourceAsString("/api_fixtures/login_link.json")); - - assertNotNull(link); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/accounts/%s/login_links", account.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/MandateTest.java b/src/test/java/com/stripe/functional/MandateTest.java deleted file mode 100644 index 52d5d9f61b2..00000000000 --- a/src/test/java/com/stripe/functional/MandateTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Mandate; -import com.stripe.net.ApiResource; -import org.junit.jupiter.api.Test; - -public class MandateTest extends BaseStripeTest { - public static final String MANDATE_ID = "mandate_123"; - - @Test - public void testRetrieve() throws StripeException { - final Mandate schedule = Mandate.retrieve(MANDATE_ID); - - assertNotNull(schedule); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/mandates/%s", MANDATE_ID)); - } -} diff --git a/src/test/java/com/stripe/functional/PaymentMethodTest.java b/src/test/java/com/stripe/functional/PaymentMethodTest.java deleted file mode 100644 index 07ac03ff552..00000000000 --- a/src/test/java/com/stripe/functional/PaymentMethodTest.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.PaymentMethod; -import com.stripe.model.PaymentMethodCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class PaymentMethodTest extends BaseStripeTest { - public static final String PAYMENT_METHOD_ID = "pm_123"; - - private PaymentMethod getPaymentMethodFixture() throws StripeException { - final PaymentMethod payment_method = PaymentMethod.retrieve(PAYMENT_METHOD_ID); - resetNetworkSpy(); - return payment_method; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("type", "card"); - - final PaymentMethod payment_method = PaymentMethod.create(params); - - assertNotNull(payment_method); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/payment_methods"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final PaymentMethod payment_method = PaymentMethod.retrieve(PAYMENT_METHOD_ID); - - assertNotNull(payment_method); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/payment_methods/%s", PAYMENT_METHOD_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final PaymentMethod payment_method = getPaymentMethodFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final PaymentMethod updatedPaymentMethod = payment_method.update(params); - - assertNotNull(updatedPaymentMethod); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/payment_methods/%s", payment_method.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("customer", "cus_123"); - params.put("limit", 1); - params.put("type", "card"); - - final PaymentMethodCollection payment_methods = PaymentMethod.list(params); - - assertNotNull(payment_methods); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/payment_methods")); - } - - @Test - public void testAttach() throws StripeException { - final PaymentMethod payment_method = getPaymentMethodFixture(); - - final Map params = new HashMap<>(); - params.put("customer", "cus_123"); - - final PaymentMethod attachedPaymentMethod = payment_method.attach(params); - - assertNotNull(attachedPaymentMethod); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/payment_methods/%s/attach", payment_method.getId())); - } - - @Test - public void testDetach() throws StripeException { - final PaymentMethod payment_method = getPaymentMethodFixture(); - - final PaymentMethod detachedPaymentMethod = payment_method.detach(); - - assertNotNull(detachedPaymentMethod); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/payment_methods/%s/detach", payment_method.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/PayoutTest.java b/src/test/java/com/stripe/functional/PayoutTest.java deleted file mode 100644 index 3d73d576332..00000000000 --- a/src/test/java/com/stripe/functional/PayoutTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Payout; -import com.stripe.model.PayoutCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class PayoutTest extends BaseStripeTest { - public static final String PAYOUT_ID = "po_123"; - - private Payout getPayoutFixture() throws StripeException { - final Payout payout = Payout.retrieve(PAYOUT_ID); - resetNetworkSpy(); - return payout; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("amount", "10000"); - params.put("currency", "usd"); - - final Payout payout = Payout.create(params); - - assertNotNull(payout); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/payouts"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final Payout payout = Payout.retrieve(PAYOUT_ID); - - assertNotNull(payout); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/payouts/%s", PAYOUT_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Payout payout = getPayoutFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Payout updatedPayout = payout.update(params); - - assertNotNull(updatedPayout); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/payouts/%s", payout.getId()), params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final PayoutCollection payouts = Payout.list(params); - - assertNotNull(payouts); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/payouts"), params); - } - - @Test - public void testCancel() throws StripeException { - final Payout resource = getPayoutFixture(); - - final Payout cancelledPayout = resource.cancel(); - - assertNotNull(cancelledPayout); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/payouts/%s/cancel", resource.getId())); - } - - @Test - public void testReverse() throws StripeException { - final Payout resource = getPayoutFixture(); - - final Payout reversedPayout = resource.reverse(); - - assertNotNull(reversedPayout); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/payouts/%s/reverse", resource.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/PersonTest.java b/src/test/java/com/stripe/functional/PersonTest.java deleted file mode 100644 index 84d2ffaedfb..00000000000 --- a/src/test/java/com/stripe/functional/PersonTest.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Account; -import com.stripe.model.Person; -import com.stripe.model.PersonCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class PersonTest extends BaseStripeTest { - public static final String ACCOUNT_ID = "cus_123"; - public static final String PERSON_ID = "person_123"; - - private PersonCollection getPersonCollectionFixture(Account account) throws StripeException { - PersonCollection persons = account.persons(); - resetNetworkSpy(); - - return persons; - } - - @Test - public void testCreate() throws StripeException { - final Account account = Account.retrieve(ACCOUNT_ID, null); - final PersonCollection personsTmp = getPersonCollectionFixture(account); - - final Map params = new HashMap<>(); - params.put("first_name", "John"); - - final Person person = personsTmp.create(params); - - assertNotNull(person); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/accounts/%s/persons", account.getId()), - params); - } - - @Test - public void testRetrieve() throws StripeException { - final Account account = Account.retrieve(ACCOUNT_ID, null); - final PersonCollection personsTmp = getPersonCollectionFixture(account); - Person person = personsTmp.retrieve(PERSON_ID); - - assertNotNull(person); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/accounts/%s/persons/%s", account.getId(), PERSON_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Account account = Account.retrieve(ACCOUNT_ID, null); - final PersonCollection personsTmp = getPersonCollectionFixture(account); - Person person = personsTmp.retrieve(PERSON_ID); - - final Map params = new HashMap<>(); - params.put("first_name", "John"); - - final Person updatedPerson = person.update(params); - - assertNotNull(updatedPerson); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/accounts/%s/persons/%s", account.getId(), person.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Account account = Account.retrieve(ACCOUNT_ID, null); - final PersonCollection personsTmp = getPersonCollectionFixture(account); - - final Map params = new HashMap<>(); - params.put("limit", 1); - - final PersonCollection persons = personsTmp.list(params); - - assertNotNull(persons); - assertEquals(1, persons.getData().size()); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/accounts/%s/persons", account.getId())); - - final Person person = persons.getData().get(0); - assertNotNull(person); - } - - @Test - public void testDelete() throws StripeException { - final Account account = Account.retrieve(ACCOUNT_ID, null); - final PersonCollection personsTmp = getPersonCollectionFixture(account); - Person person = personsTmp.retrieve(PERSON_ID); - - final Person deletedPerson = person.delete(); - - assertNotNull(deletedPerson); - assertTrue(deletedPerson.getDeleted()); - verifyRequest( - ApiResource.RequestMethod.DELETE, - String.format("/v1/accounts/%s/persons/%s", account.getId(), person.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/PriceTest.java b/src/test/java/com/stripe/functional/PriceTest.java deleted file mode 100644 index a2e9a00ad7b..00000000000 --- a/src/test/java/com/stripe/functional/PriceTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Price; -import com.stripe.model.PriceCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class PriceTest extends BaseStripeTest { - public static final String PRICE_ID = "price_123"; - - private Price getPriceFixture() throws StripeException { - final Price price = Price.retrieve(PRICE_ID); - resetNetworkSpy(); - return price; - } - - @Test - public void testCreate() throws StripeException { - final Map recurringParams = new HashMap<>(); - recurringParams.put("interval", "month"); - - final Map productDataParams = new HashMap<>(); - productDataParams.put("name", "Product name"); - - final Map params = new HashMap<>(); - params.put("unit_amount", 1000); - params.put("currency", "usd"); - params.put("recurring", recurringParams); - params.put("product_data", productDataParams); - - final Price price = Price.create(params); - - assertNotNull(price); - verifyRequest(ApiResource.RequestMethod.POST, "/v1/prices", params); - } - - @Test - public void testRetrieve() throws StripeException { - final Price price = Price.retrieve(PRICE_ID); - - assertNotNull(price); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/prices/%s", PRICE_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Price price = getPriceFixture(); - - final Map params = new HashMap<>(); - params.put("nickname", "Updated Name"); - - final Price updatedPrice = price.update(params); - - assertNotNull(updatedPrice); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/prices/%s", price.getId()), params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - PriceCollection prices = Price.list(params); - - assertNotNull(prices); - verifyRequest(ApiResource.RequestMethod.GET, "/v1/prices", params); - } -} diff --git a/src/test/java/com/stripe/functional/ProductTest.java b/src/test/java/com/stripe/functional/ProductTest.java deleted file mode 100644 index da1894a0347..00000000000 --- a/src/test/java/com/stripe/functional/ProductTest.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Product; -import com.stripe.model.ProductCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ProductTest extends BaseStripeTest { - public static final String PRODUCT_ID = "prod_123"; - - private Product getProductFixture() throws StripeException { - final Product product = Product.retrieve(PRODUCT_ID); - resetNetworkSpy(); - return product; - } - - @Test - public void testCreate() throws StripeException { - final Map packageDimensions = new HashMap<>(); - packageDimensions.put("height", 2.234); - packageDimensions.put("length", 5.10); - packageDimensions.put("width", 6.50); - packageDimensions.put("weight", 10); - final Map params = new HashMap<>(); - params.put("active", true); - params.put("name", "Test Name"); - params.put("description", "This is a description"); - params.put("url", "http://example.com"); - params.put("shippable", true); - params.put("package_dimensions", packageDimensions); - - final Product product = Product.create(params); - - assertNotNull(product); - verifyRequest(ApiResource.RequestMethod.POST, "/v1/products", params); - } - - @Test - public void testRetrieve() throws StripeException { - final Product product = Product.retrieve(PRODUCT_ID); - - assertNotNull(product); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/products/%s", PRODUCT_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Product product = getProductFixture(); - - Map params = new HashMap<>(); - params.put("name", "Updated Name"); - - final Product updatedProduct = product.update(params); - - assertNotNull(updatedProduct); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/products/%s", product.getId()), params); - } - - @Test - public void testDelete() throws StripeException { - final Product product = getProductFixture(); - - final Product deletedProduct = product.delete(); - - assertNotNull(deletedProduct); - assertTrue(deletedProduct.getDeleted()); - verifyRequest( - ApiResource.RequestMethod.DELETE, String.format("/v1/products/%s", product.getId())); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final ProductCollection products = Product.list(params); - - assertNotNull(products); - verifyRequest(ApiResource.RequestMethod.GET, "/v1/products", params); - } -} diff --git a/src/test/java/com/stripe/functional/RefundTest.java b/src/test/java/com/stripe/functional/RefundTest.java deleted file mode 100644 index e8f266c5b75..00000000000 --- a/src/test/java/com/stripe/functional/RefundTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Refund; -import com.stripe.model.RefundCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class RefundTest extends BaseStripeTest { - public static final String REFUND_ID = "re_123"; - - private Refund getRefundFixture() throws StripeException { - final Refund refund = Refund.retrieve(REFUND_ID); - resetNetworkSpy(); - return refund; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("charge", "ch_123"); - - final Refund refund = Refund.create(params); - - assertNotNull(refund); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/refunds"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final Refund refund = Refund.retrieve(REFUND_ID); - - assertNotNull(refund); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/refunds/%s", REFUND_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Refund refund = getRefundFixture(); - - Map metadata = new HashMap<>(); - metadata.put("key", "value"); - Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Refund updatedRefund = refund.update(params); - - assertNotNull(updatedRefund); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/refunds/%s", refund.getId()), params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final RefundCollection refunds = Refund.list(params); - - assertNotNull(refunds); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/refunds"), params); - } -} diff --git a/src/test/java/com/stripe/functional/ReversalTest.java b/src/test/java/com/stripe/functional/ReversalTest.java deleted file mode 100644 index c6441cd5ef9..00000000000 --- a/src/test/java/com/stripe/functional/ReversalTest.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Transfer; -import com.stripe.model.TransferReversal; -import com.stripe.model.TransferReversalCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ReversalTest extends BaseStripeTest { - public static final String TRANSFER_ID = "tr_123"; - public static final String REVERSAL_ID = "trr_123"; - - private Transfer getTransferFixture() throws StripeException { - final Transfer transfer = Transfer.retrieve(TRANSFER_ID); - resetNetworkSpy(); - return transfer; - } - - private TransferReversal getTransferReversalFixture(Transfer transfer) throws StripeException { - final TransferReversal reversal = transfer.getReversals().retrieve(REVERSAL_ID); - resetNetworkSpy(); - return reversal; - } - - @Test - public void testCreate() throws StripeException { - final Transfer transfer = getTransferFixture(); - - Map params = new HashMap<>(); - params.put("amount", 100); - - final TransferReversal reversal = transfer.getReversals().create(params); - - assertNotNull(reversal); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/transfers/%s/reversals", transfer.getId()), - params); - } - - @Test - public void testRetrieve() throws StripeException { - final Transfer transfer = getTransferFixture(); - - final TransferReversal reversal = transfer.getReversals().retrieve(REVERSAL_ID); - - assertNotNull(reversal); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/transfers/%s/reversals/%s", transfer.getId(), REVERSAL_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Transfer transfer = getTransferFixture(); - final TransferReversal reversal = getTransferReversalFixture(transfer); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final TransferReversal updatedTransferReversal = reversal.update(params); - - assertNotNull(updatedTransferReversal); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/transfers/%s/reversals/%s", transfer.getId(), reversal.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Transfer transfer = getTransferFixture(); - - final Map params = new HashMap<>(); - params.put("limit", 1); - - final TransferReversalCollection reversals = transfer.getReversals().list(params); - - assertNotNull(reversals); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/transfers/%s/reversals", transfer.getId()), - params); - } -} diff --git a/src/test/java/com/stripe/functional/ReviewTest.java b/src/test/java/com/stripe/functional/ReviewTest.java deleted file mode 100644 index 7fed68a13d4..00000000000 --- a/src/test/java/com/stripe/functional/ReviewTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Review; -import com.stripe.model.ReviewCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ReviewTest extends BaseStripeTest { - public static final String REVIEW_ID = "prv_123"; - - private Review getReviewFixture() throws StripeException { - final Review review = Review.retrieve(REVIEW_ID); - resetNetworkSpy(); - return review; - } - - @Test - public void testApprove() throws StripeException { - final Review review = getReviewFixture(); - - review.approve(); - assertNotNull(review); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/reviews/%s/approve", review.getId())); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final ReviewCollection reviews = Review.list(params); - - assertNotNull(reviews); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/reviews")); - } - - @Test - public void testRetrieve() throws StripeException { - final Review review = Review.retrieve(REVIEW_ID); - - assertNotNull(review); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/reviews/%s", review.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/SetupAttemptTest.java b/src/test/java/com/stripe/functional/SetupAttemptTest.java deleted file mode 100644 index e21ab12f887..00000000000 --- a/src/test/java/com/stripe/functional/SetupAttemptTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.SetupAttempt; -import com.stripe.model.SetupAttemptCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class SetupAttemptTest extends BaseStripeTest { - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("setup_intent", "seti_123"); - - final SetupAttemptCollection setupAttempts = SetupAttempt.list(params); - - assertNotNull(setupAttempts); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/setup_attempts"), params); - } -} diff --git a/src/test/java/com/stripe/functional/SubscriptionItemTest.java b/src/test/java/com/stripe/functional/SubscriptionItemTest.java deleted file mode 100644 index 87e3959ed4e..00000000000 --- a/src/test/java/com/stripe/functional/SubscriptionItemTest.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.SubscriptionItem; -import com.stripe.model.SubscriptionItemCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class SubscriptionItemTest extends BaseStripeTest { - public static final String ITEM_ID = "si_123"; - - private SubscriptionItem getItemFixture() throws StripeException { - final SubscriptionItem item = SubscriptionItem.retrieve(ITEM_ID); - resetNetworkSpy(); - return item; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("price", "price_123"); - params.put("subscription", "cus_123"); - params.put("quantity", 99); - - final SubscriptionItem subscriptionItem = SubscriptionItem.create(params); - - assertNotNull(subscriptionItem); - verifyRequest(ApiResource.RequestMethod.POST, "/v1/subscription_items", params); - } - - @Test - public void testRetrieve() throws StripeException { - final SubscriptionItem subscriptionItem = SubscriptionItem.retrieve(ITEM_ID); - - assertNotNull(subscriptionItem); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/subscription_items/%s", ITEM_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final SubscriptionItem subscriptionItem = getItemFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final SubscriptionItem updatedSubscriptionItem = subscriptionItem.update(params); - - assertNotNull(updatedSubscriptionItem); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/subscription_items/%s", subscriptionItem.getId()), - params); - } - - @Test - public void testDelete() throws StripeException { - final SubscriptionItem subscriptionItem = getItemFixture(); - - final SubscriptionItem deletedSubscriptionItem = subscriptionItem.delete(); - - assertNotNull(deletedSubscriptionItem); - assertTrue(deletedSubscriptionItem.getDeleted()); - verifyRequest( - ApiResource.RequestMethod.DELETE, - String.format("/v1/subscription_items/%s", subscriptionItem.getId())); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - params.put("subscription", "sub_123"); - - final SubscriptionItemCollection subscriptionItems = SubscriptionItem.list(params); - - assertNotNull(subscriptionItems); - verifyRequest(ApiResource.RequestMethod.GET, "/v1/subscription_items", params); - } -} diff --git a/src/test/java/com/stripe/functional/SubscriptionScheduleTest.java b/src/test/java/com/stripe/functional/SubscriptionScheduleTest.java deleted file mode 100644 index 88054a6728c..00000000000 --- a/src/test/java/com/stripe/functional/SubscriptionScheduleTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.SubscriptionSchedule; -import com.stripe.model.SubscriptionScheduleCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class SubscriptionScheduleTest extends BaseStripeTest { - public static final String SCHEDULE_ID = "sub_sched_123"; - - private SubscriptionSchedule getSubscriptionScheduleFixture() throws StripeException { - final SubscriptionSchedule schedule = SubscriptionSchedule.retrieve(SCHEDULE_ID); - resetNetworkSpy(); - return schedule; - } - - @Test - public void testCancel() throws StripeException { - final SubscriptionSchedule schedule = getSubscriptionScheduleFixture(); - - final Map params = new HashMap<>(); - params.put("invoice_now", true); - - final SubscriptionSchedule canceledSchedule = schedule.cancel(params); - - assertNotNull(canceledSchedule); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/subscription_schedules/%s/cancel", schedule.getId()), - params); - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("customer", "cus_123"); - - final SubscriptionSchedule schedule = SubscriptionSchedule.create(params); - - assertNotNull(schedule); - verifyRequest(ApiResource.RequestMethod.POST, "/v1/subscription_schedules", params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final SubscriptionScheduleCollection schedules = SubscriptionSchedule.list(params); - - assertNotNull(schedules); - verifyRequest(ApiResource.RequestMethod.GET, "/v1/subscription_schedules", params); - } - - @Test - public void testRelease() throws StripeException { - final SubscriptionSchedule schedule = getSubscriptionScheduleFixture(); - - final Map params = new HashMap<>(); - params.put("preserve_cancel_date", true); - - final SubscriptionSchedule releasedSchedule = schedule.release(params); - - assertNotNull(releasedSchedule); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/subscription_schedules/%s/release", schedule.getId()), - params); - } - - @Test - public void testRetrieve() throws StripeException { - final SubscriptionSchedule schedule = SubscriptionSchedule.retrieve(SCHEDULE_ID); - - assertNotNull(schedule); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/subscription_schedules/%s", SCHEDULE_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final SubscriptionSchedule schedule = getSubscriptionScheduleFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("foo", "bar"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final SubscriptionSchedule updatedSubscriptionSchedule = schedule.update(params); - - assertNotNull(updatedSubscriptionSchedule); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/subscription_schedules/%s", schedule.getId()), - params); - } -} diff --git a/src/test/java/com/stripe/functional/SubscriptionTest.java b/src/test/java/com/stripe/functional/SubscriptionTest.java deleted file mode 100644 index 968e7726136..00000000000 --- a/src/test/java/com/stripe/functional/SubscriptionTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Subscription; -import com.stripe.model.SubscriptionCollection; -import com.stripe.net.ApiResource; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class SubscriptionTest extends BaseStripeTest { - public static final String SUBSCRIPTION_ID = "sub_123"; - - private Subscription getSubscriptionFixture() throws StripeException { - final Subscription subscription = Subscription.retrieve(SUBSCRIPTION_ID); - resetNetworkSpy(); - return subscription; - } - - @Test - public void testCreate() throws StripeException { - final Map item = new HashMap<>(); - item.put("plan", "silver-plan_123-898"); - final List items = new ArrayList<>(); - items.add(item); - final Map params = new HashMap<>(); - params.put("customer", "cus_123"); - params.put("items", items); - - final Subscription subscription = Subscription.create(params); - - assertNotNull(subscription); - verifyRequest(ApiResource.RequestMethod.POST, "/v1/subscriptions", params); - } - - @Test - public void testRetrieve() throws StripeException { - final Subscription subscription = Subscription.retrieve(SUBSCRIPTION_ID); - - assertNotNull(subscription); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/subscriptions/%s", SUBSCRIPTION_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Subscription subscription = getSubscriptionFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Subscription updatedSubscription = subscription.update(params); - - assertNotNull(updatedSubscription); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/subscriptions/%s", subscription.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final SubscriptionCollection subscriptions = Subscription.list(params); - - assertNotNull(subscriptions); - verifyRequest(ApiResource.RequestMethod.GET, "/v1/subscriptions", params); - } - - @Test - public void testCancel() throws StripeException { - final Subscription subscription = getSubscriptionFixture(); - - final Subscription canceledSubscription = subscription.cancel((Map) null); - - assertNotNull(canceledSubscription); - verifyRequest( - ApiResource.RequestMethod.DELETE, - String.format("/v1/subscriptions/%s", subscription.getId())); - } - - @Test - public void testDeleteDiscount() throws StripeException { - final Subscription subscription = getSubscriptionFixture(); - - subscription.deleteDiscount(); - - verifyRequest( - ApiResource.RequestMethod.DELETE, - String.format("/v1/subscriptions/%s/discount", subscription.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/TaxCodeTest.java b/src/test/java/com/stripe/functional/TaxCodeTest.java deleted file mode 100644 index c2ce2cb3ba2..00000000000 --- a/src/test/java/com/stripe/functional/TaxCodeTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.TaxCode; -import com.stripe.model.TaxCodeCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class TaxCodeTest extends BaseStripeTest { - public static final String TAX_CODE_ID = "txcd_123"; - - @Test - public void testRetrieve() throws StripeException { - final TaxCode taxCode = TaxCode.retrieve(TAX_CODE_ID); - - assertNotNull(taxCode); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/tax_codes/%s", TAX_CODE_ID)); - assertEquals("tax_code", taxCode.getObject()); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final TaxCodeCollection taxCodes = TaxCode.list(params); - - assertNotNull(taxCodes); - assertEquals(1, taxCodes.getData().size()); - assertEquals("tax_code", taxCodes.getData().get(0).getObject()); - verifyRequest(ApiResource.RequestMethod.GET, "/v1/tax_codes", params); - } -} diff --git a/src/test/java/com/stripe/functional/TopupTest.java b/src/test/java/com/stripe/functional/TopupTest.java deleted file mode 100644 index 65c4d8af9fe..00000000000 --- a/src/test/java/com/stripe/functional/TopupTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Topup; -import com.stripe.model.TopupCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class TopupTest extends BaseStripeTest { - public static final String TOPUP_ID = "tu_123"; - - private Topup getTopupFixture() throws StripeException { - final Topup topup = Topup.retrieve(TOPUP_ID); - resetNetworkSpy(); - return topup; - } - - @Test - public void testCancel() throws StripeException { - final Topup topup = getTopupFixture(); - - final Map params = new HashMap<>(); - - final Topup canceledTopup = topup.cancel(params); - - assertNotNull(canceledTopup); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/topups/%s/cancel", topup.getId()), - params); - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("amount", 100); - params.put("currency", "usd"); - params.put("source", "src_123"); - params.put("description", "creating a topup"); - params.put("statement_descriptor", "topup"); - - final Topup topup = Topup.create(params); - - assertNotNull(topup); - verifyRequest(ApiResource.RequestMethod.POST, "/v1/topups", params); - } - - @Test - public void testRetrieve() throws StripeException { - final Topup topup = Topup.retrieve(TOPUP_ID); - - assertNotNull(topup); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/topups/%s", TOPUP_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Topup topup = getTopupFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Topup updatedTopup = topup.update(params); - - assertNotNull(updatedTopup); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/topups/%s", topup.getId()), params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final TopupCollection topups = Topup.list(params); - - assertNotNull(topups); - verifyRequest(ApiResource.RequestMethod.GET, "/v1/topups", params); - } -} diff --git a/src/test/java/com/stripe/functional/TransferTest.java b/src/test/java/com/stripe/functional/TransferTest.java deleted file mode 100644 index 0079e7d0ae1..00000000000 --- a/src/test/java/com/stripe/functional/TransferTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.stripe.functional; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.Transfer; -import com.stripe.model.TransferCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class TransferTest extends BaseStripeTest { - public static final String TRANSFER_ID = "tr_123"; - - private Transfer getTransferFixture() throws StripeException { - final Transfer transfer = Transfer.retrieve(TRANSFER_ID); - resetNetworkSpy(); - return transfer; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("amount", 100); - params.put("currency", "usd"); - params.put("destination", "acct_123"); - - final Transfer transfer = Transfer.create(params); - - assertNotNull(transfer); - verifyRequest(ApiResource.RequestMethod.POST, "/v1/transfers", params); - } - - @Test - public void testRetrieve() throws StripeException { - final Transfer transfer = Transfer.retrieve(TRANSFER_ID); - - assertNotNull(transfer); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/transfers/%s", TRANSFER_ID)); - } - - @Test - public void testUpdate() throws StripeException { - Transfer transfer = getTransferFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Transfer updatedTransfer = transfer.update(params); - - assertNotNull(updatedTransfer); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/transfers/%s", transfer.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final TransferCollection transfers = Transfer.list(params); - - assertNotNull(transfers); - verifyRequest(ApiResource.RequestMethod.GET, "/v1/transfers", params); - } -} diff --git a/src/test/java/com/stripe/functional/billingportal/ConfigurationTest.java b/src/test/java/com/stripe/functional/billingportal/ConfigurationTest.java deleted file mode 100644 index 5742d5bcdb5..00000000000 --- a/src/test/java/com/stripe/functional/billingportal/ConfigurationTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.stripe.functional.billingportal; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.billingportal.Configuration; -import com.stripe.model.billingportal.ConfigurationCollection; -import com.stripe.net.ApiResource; -import com.stripe.param.billingportal.ConfigurationCreateParams; -import com.stripe.param.billingportal.ConfigurationUpdateParams; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ConfigurationTest extends BaseStripeTest { - public static final String SESSION_ID = "bpc_123"; - - private Configuration getConfigurationFixture() throws StripeException { - final Configuration configuration = Configuration.retrieve(SESSION_ID); - resetNetworkSpy(); - return configuration; - } - - @Test - public void testCreate() throws StripeException { - - List allowedUpdates = - new ArrayList<>(); - allowedUpdates.add(ConfigurationCreateParams.Features.CustomerUpdate.AllowedUpdate.ADDRESS); - ConfigurationCreateParams params = - ConfigurationCreateParams.builder() - .setBusinessProfile( - ConfigurationCreateParams.BusinessProfile.builder() - .setPrivacyPolicyUrl("https://example.com/privacy") - .setTermsOfServiceUrl("https://example.com/tos") - .build()) - .setFeatures( - ConfigurationCreateParams.Features.builder() - .setCustomerUpdate( - ConfigurationCreateParams.Features.CustomerUpdate.builder() - .setAllowedUpdates(allowedUpdates) - .setEnabled(true) - .build()) - .build()) - .build(); - - final Configuration configuration = Configuration.create(params); - - assertNotNull(configuration); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/billing_portal/configurations"), - params.toMap()); - } - - @Test - public void testRetrieve() throws StripeException { - final Configuration configuration = Configuration.retrieve(SESSION_ID); - - assertNotNull(configuration); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/billing_portal/configurations/%s", configuration.getId())); - } - - @Test - public void testUpdate() throws StripeException { - final Configuration configuration = getConfigurationFixture(); - - ConfigurationUpdateParams params = ConfigurationUpdateParams.builder().setActive(false).build(); - - final Configuration updatedConfiguration = configuration.update(params); - - assertNotNull(updatedConfiguration); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/billing_portal/configurations/%s", configuration.getId()), - params.toMap()); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final ConfigurationCollection coupons = Configuration.list(params); - - assertNotNull(coupons); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/billing_portal/configurations")); - } -} diff --git a/src/test/java/com/stripe/functional/billingportal/SessionTest.java b/src/test/java/com/stripe/functional/billingportal/SessionTest.java deleted file mode 100644 index 06390356ef2..00000000000 --- a/src/test/java/com/stripe/functional/billingportal/SessionTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.stripe.functional.billingportal; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.billingportal.Session; -import com.stripe.net.ApiResource; -import com.stripe.param.billingportal.SessionCreateParams; -import org.junit.jupiter.api.Test; - -public class SessionTest extends BaseStripeTest { - public static final String SESSION_ID = "bps_123"; - - @Test - public void testCreate() throws StripeException { - - SessionCreateParams params = - SessionCreateParams.builder() - .setCustomer("cus_123") - .setReturnUrl("https://stripe.com/return") - .build(); - - final Session session = Session.create(params); - - assertNotNull(session); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/billing_portal/sessions"), - params.toMap()); - } -} diff --git a/src/test/java/com/stripe/functional/checkout/SessionTest.java b/src/test/java/com/stripe/functional/checkout/SessionTest.java deleted file mode 100644 index 7781062e81d..00000000000 --- a/src/test/java/com/stripe/functional/checkout/SessionTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.stripe.functional.checkout; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.LineItemCollection; -import com.stripe.model.checkout.Session; -import com.stripe.net.ApiResource; -import com.stripe.param.checkout.SessionListLineItemsParams; -import org.junit.jupiter.api.Test; - -public class SessionTest extends BaseStripeTest { - public static final String SESSION_ID = "cs_123"; - - @Test - public void testListLineItems() throws StripeException { - - Session session = Session.retrieve(SESSION_ID); - - SessionListLineItemsParams params = SessionListLineItemsParams.builder().build(); - - final LineItemCollection lineItems = session.listLineItems(params); - - assertNotNull(lineItems); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/checkout/sessions/cs_123/line_items"), - params.toMap()); - } - - @Test - public void testSessionListLineItems() throws StripeException { - com.stripe.model.checkout.Session resource = - com.stripe.model.checkout.Session.retrieve("sess_xyz"); - com.stripe.param.checkout.SessionListLineItemsParams params = - com.stripe.param.checkout.SessionListLineItemsParams.builder().build(); - - com.stripe.model.LineItemCollection lineItems = resource.listLineItems(params); - assertNotNull(lineItems); - verifyRequest( - ApiResource.RequestMethod.GET, "/v1/checkout/sessions/sess_xyz/line_items", params.toMap()); - } -} diff --git a/src/test/java/com/stripe/functional/identity/VerificationReportTest.java b/src/test/java/com/stripe/functional/identity/VerificationReportTest.java deleted file mode 100644 index 93c9cb55be8..00000000000 --- a/src/test/java/com/stripe/functional/identity/VerificationReportTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.stripe.functional.identity; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.identity.VerificationReport; -import com.stripe.model.identity.VerificationReportCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class VerificationReportTest extends BaseStripeTest { - public static final String VERIFICATION_REPORT_ID = "vr_123"; - - @Test - public void testRetrieve() throws StripeException { - final VerificationReport verificationReport = - VerificationReport.retrieve(VERIFICATION_REPORT_ID); - - assertNotNull(verificationReport); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/identity/verification_reports/%s", VERIFICATION_REPORT_ID)); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - VerificationReportCollection verificationReports = VerificationReport.list(params); - - assertNotNull(verificationReports); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/identity/verification_reports"), params); - } -} diff --git a/src/test/java/com/stripe/functional/identity/VerificationSessionTest.java b/src/test/java/com/stripe/functional/identity/VerificationSessionTest.java deleted file mode 100644 index 4e8dc6ecfd7..00000000000 --- a/src/test/java/com/stripe/functional/identity/VerificationSessionTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.stripe.functional.identity; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.identity.VerificationSession; -import com.stripe.model.identity.VerificationSessionCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class VerificationSessionTest extends BaseStripeTest { - public static final String VERIFICATION_SESSION_ID = "vs_123"; - - @Test - public void testCancel() throws StripeException { - final VerificationSession verificationSession = - VerificationSession.retrieve(VERIFICATION_SESSION_ID); - - final VerificationSession cancelledVerificationSession = - verificationSession.cancel((Map) null); - - assertNotNull(cancelledVerificationSession); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/identity/verification_sessions/%s/cancel", verificationSession.getId()), - null); - } - - @Test - public void testRedact() throws StripeException { - final VerificationSession verificationSession = - VerificationSession.retrieve(VERIFICATION_SESSION_ID); - - final VerificationSession redactedVerificationSession = - verificationSession.redact((Map) null); - - assertNotNull(redactedVerificationSession); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/identity/verification_sessions/%s/redact", verificationSession.getId()), - null); - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("type", "id_number"); - - final VerificationSession verificationSession = VerificationSession.create(params); - - assertNotNull(verificationSession); - verifyRequest(ApiResource.RequestMethod.POST, "/v1/identity/verification_sessions", params); - } - - @Test - public void testRetrieve() throws StripeException { - final VerificationSession verificationSession = - VerificationSession.retrieve(VERIFICATION_SESSION_ID); - - assertNotNull(verificationSession); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/identity/verification_sessions/%s", VERIFICATION_SESSION_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final VerificationSession verificationSession = - VerificationSession.retrieve(VERIFICATION_SESSION_ID); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final VerificationSession updatedVerificationSession = verificationSession.update(params); - - assertNotNull(updatedVerificationSession); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/identity/verification_sessions/%s", verificationSession.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - VerificationSessionCollection verificationSessions = VerificationSession.list(params); - - assertNotNull(verificationSessions); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/identity/verification_sessions"), params); - } -} diff --git a/src/test/java/com/stripe/functional/issuing/AuthorizationTest.java b/src/test/java/com/stripe/functional/issuing/AuthorizationTest.java deleted file mode 100644 index aabcbf7ba40..00000000000 --- a/src/test/java/com/stripe/functional/issuing/AuthorizationTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.stripe.functional.issuing; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.issuing.Authorization; -import com.stripe.model.issuing.AuthorizationCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class AuthorizationTest extends BaseStripeTest { - public static final String AUTHORIZATION_ID = "iauth_123"; - - @Test - public void testApprove() throws StripeException { - final Authorization authorization = Authorization.retrieve(AUTHORIZATION_ID); - - final Authorization approvedAuthorization = authorization.approve((Map) null); - - assertNotNull(approvedAuthorization); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/issuing/authorizations/%s/approve", authorization.getId()), - null); - } - - @Test - public void testDecline() throws StripeException { - final Authorization authorization = Authorization.retrieve(AUTHORIZATION_ID); - - final Authorization approvedAuthorization = authorization.decline((Map) null); - - assertNotNull(approvedAuthorization); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/issuing/authorizations/%s/decline", authorization.getId()), - null); - } - - @Test - public void testRetrieve() throws StripeException { - final Authorization authorization = Authorization.retrieve(AUTHORIZATION_ID); - - assertNotNull(authorization); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/issuing/authorizations/%s", AUTHORIZATION_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Authorization authorization = Authorization.retrieve(AUTHORIZATION_ID); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Authorization updatedAuthorization = authorization.update(params); - - assertNotNull(updatedAuthorization); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/issuing/authorizations/%s", authorization.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - AuthorizationCollection authorizations = Authorization.list(params); - - assertNotNull(authorizations); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/issuing/authorizations"), params); - } -} diff --git a/src/test/java/com/stripe/functional/issuing/CardTest.java b/src/test/java/com/stripe/functional/issuing/CardTest.java deleted file mode 100644 index fb9412267eb..00000000000 --- a/src/test/java/com/stripe/functional/issuing/CardTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.stripe.functional.issuing; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.issuing.Card; -import com.stripe.model.issuing.CardCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class CardTest extends BaseStripeTest { - public static final String CARD_ID = "ic_123"; - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("currency", "usd"); - params.put("type", "physical"); - - final Card card = Card.create(params); - - assertNotNull(card); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/issuing/cards"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final Card card = Card.retrieve(CARD_ID); - - assertNotNull(card); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/issuing/cards/%s", CARD_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Card card = Card.retrieve(CARD_ID); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Card updatedCard = card.update(params); - - assertNotNull(updatedCard); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/issuing/cards/%s", card.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - CardCollection resources = Card.list(params); - - assertNotNull(resources); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/issuing/cards"), params); - } -} diff --git a/src/test/java/com/stripe/functional/issuing/CardholderTest.java b/src/test/java/com/stripe/functional/issuing/CardholderTest.java deleted file mode 100644 index 3866591484e..00000000000 --- a/src/test/java/com/stripe/functional/issuing/CardholderTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.stripe.functional.issuing; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.issuing.Cardholder; -import com.stripe.model.issuing.CardholderCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class CardholderTest extends BaseStripeTest { - public static final String CARDHOLDER_ID = "ich_123"; - - @Test - public void testCreate() throws StripeException { - final Map address = new HashMap<>(); - address.put("city", "city"); - address.put("country", "US"); - address.put("line1", "line1"); - address.put("postal_code", "90210"); - - final Map billing = new HashMap<>(); - billing.put("address", address); - - final Map params = new HashMap<>(); - params.put("billing", billing); - params.put("name", "Jenny Rosen"); - params.put("type", "individual"); - - final Cardholder cardholder = Cardholder.create(params); - - assertNotNull(cardholder); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/issuing/cardholders"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final Cardholder cardholder = Cardholder.retrieve(CARDHOLDER_ID); - - assertNotNull(cardholder); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/issuing/cardholders/%s", CARDHOLDER_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Cardholder cardholder = Cardholder.retrieve(CARDHOLDER_ID); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Cardholder updatedCardholder = cardholder.update(params); - - assertNotNull(updatedCardholder); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/issuing/cardholders/%s", cardholder.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - CardholderCollection cardholders = Cardholder.list(params); - - assertNotNull(cardholders); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/issuing/cardholders"), params); - } -} diff --git a/src/test/java/com/stripe/functional/issuing/DisputeTest.java b/src/test/java/com/stripe/functional/issuing/DisputeTest.java deleted file mode 100644 index 5bfe5003be4..00000000000 --- a/src/test/java/com/stripe/functional/issuing/DisputeTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.stripe.functional.issuing; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.issuing.Dispute; -import com.stripe.model.issuing.DisputeCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class DisputeTest extends BaseStripeTest { - public static final String DISPUTE_ID = "idp_123"; - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("transaction", "ipi_123"); - - final Dispute dispute = Dispute.create(params); - - assertNotNull(dispute); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/issuing/disputes"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final Dispute dispute = Dispute.retrieve(DISPUTE_ID); - - assertNotNull(dispute); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/issuing/disputes/%s", DISPUTE_ID)); - } - - @Test - public void testsubmit() throws StripeException { - final Dispute dispute = Dispute.retrieve(DISPUTE_ID); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Dispute submitdDispute = dispute.submit(params); - - assertNotNull(submitdDispute); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/issuing/disputes/%s/submit", dispute.getId()), - params); - } - - @Test - public void testUpdate() throws StripeException { - final Dispute dispute = Dispute.retrieve(DISPUTE_ID); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Dispute updatedDispute = dispute.update(params); - - assertNotNull(updatedDispute); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/issuing/disputes/%s", dispute.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - DisputeCollection disputes = Dispute.list(params); - - assertNotNull(disputes); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/issuing/disputes"), params); - } -} diff --git a/src/test/java/com/stripe/functional/issuing/TransactionTest.java b/src/test/java/com/stripe/functional/issuing/TransactionTest.java deleted file mode 100644 index 233f0716754..00000000000 --- a/src/test/java/com/stripe/functional/issuing/TransactionTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.stripe.functional.issuing; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.issuing.Transaction; -import com.stripe.model.issuing.TransactionCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class TransactionTest extends BaseStripeTest { - public static final String TRANSACTION_ID = "ipi_123"; - - @Test - public void testRetrieve() throws StripeException { - final Transaction transaction = Transaction.retrieve(TRANSACTION_ID); - - assertNotNull(transaction); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/issuing/transactions/%s", TRANSACTION_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Transaction transaction = Transaction.retrieve(TRANSACTION_ID); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final Transaction updatedTransaction = transaction.update(params); - - assertNotNull(updatedTransaction); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/issuing/transactions/%s", transaction.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - TransactionCollection transactions = Transaction.list(params); - - assertNotNull(transactions); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/issuing/transactions"), params); - } -} diff --git a/src/test/java/com/stripe/functional/radar/ValueListItemTest.java b/src/test/java/com/stripe/functional/radar/ValueListItemTest.java deleted file mode 100644 index 40075aaeb7c..00000000000 --- a/src/test/java/com/stripe/functional/radar/ValueListItemTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.stripe.functional.radar; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.radar.ValueListItem; -import com.stripe.model.radar.ValueListItemCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ValueListItemTest extends BaseStripeTest { - public static final String VALUE_LIST_ID = "rsli_123"; - - private ValueListItem getValueListItemFixture() throws StripeException { - final ValueListItem valueListItem = ValueListItem.retrieve(VALUE_LIST_ID); - resetNetworkSpy(); - return valueListItem; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("value", "value"); - params.put("value_list", "rsl_123"); - - final ValueListItem valueListItem = ValueListItem.create(params); - - assertNotNull(valueListItem); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/radar/value_list_items"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final ValueListItem valueListItem = ValueListItem.retrieve(VALUE_LIST_ID); - - assertNotNull(valueListItem); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/radar/value_list_items/%s", VALUE_LIST_ID)); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("value_list", "rsl_123"); - params.put("limit", 1); - - final ValueListItemCollection valueListItems = ValueListItem.list(params); - - assertNotNull(valueListItems); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/radar/value_list_items")); - } - - @Test - public void testDelete() throws StripeException { - final ValueListItem valueListItem = getValueListItemFixture(); - - final ValueListItem deletedValueListItem = valueListItem.delete(); - - assertNotNull(deletedValueListItem); - assertTrue(deletedValueListItem.getDeleted()); - verifyRequest( - ApiResource.RequestMethod.DELETE, - String.format("/v1/radar/value_list_items/%s", valueListItem.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/radar/ValueListTest.java b/src/test/java/com/stripe/functional/radar/ValueListTest.java deleted file mode 100644 index e5df1bd1304..00000000000 --- a/src/test/java/com/stripe/functional/radar/ValueListTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.stripe.functional.radar; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.radar.ValueList; -import com.stripe.model.radar.ValueListCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ValueListTest extends BaseStripeTest { - public static final String VALUE_LIST_ID = "rsl_123"; - - private ValueList getValueListFixture() throws StripeException { - final ValueList valueList = ValueList.retrieve(VALUE_LIST_ID); - resetNetworkSpy(); - return valueList; - } - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("alias", "alias"); - params.put("name", "name"); - - final ValueList valueList = ValueList.create(params); - - assertNotNull(valueList); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/radar/value_lists"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final ValueList valueList = ValueList.retrieve(VALUE_LIST_ID); - - assertNotNull(valueList); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/radar/value_lists/%s", VALUE_LIST_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final ValueList valueList = getValueListFixture(); - - final Map metadata = new HashMap<>(); - metadata.put("key", "value"); - final Map params = new HashMap<>(); - params.put("metadata", metadata); - - final ValueList updatedValueList = valueList.update(params); - - assertNotNull(updatedValueList); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/radar/value_lists/%s", valueList.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - final ValueListCollection valueLists = ValueList.list(params); - - assertNotNull(valueLists); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/radar/value_lists")); - } - - @Test - public void testDelete() throws StripeException { - final ValueList valueList = getValueListFixture(); - - final ValueList deletedValueList = valueList.delete(); - - assertNotNull(deletedValueList); - assertTrue(deletedValueList.getDeleted()); - verifyRequest( - ApiResource.RequestMethod.DELETE, - String.format("/v1/radar/value_lists/%s", valueList.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/reporting/ReportRunTest.java b/src/test/java/com/stripe/functional/reporting/ReportRunTest.java deleted file mode 100644 index f822ea554d0..00000000000 --- a/src/test/java/com/stripe/functional/reporting/ReportRunTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.stripe.functional.reporting; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.reporting.ReportRun; -import com.stripe.model.reporting.ReportRunCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ReportRunTest extends BaseStripeTest { - public static final String REPORT_RUN_ID = "frr_123"; - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("report_type", "activity.summary.1"); - - final ReportRun reportRun = ReportRun.create(params); - - assertNotNull(reportRun); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/reporting/report_runs"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final ReportRun reportRun = ReportRun.retrieve(REPORT_RUN_ID); - - assertNotNull(reportRun); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/reporting/report_runs/%s", REPORT_RUN_ID)); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - ReportRunCollection reportRuns = ReportRun.list(params); - - assertNotNull(reportRuns); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/reporting/report_runs"), params); - } -} diff --git a/src/test/java/com/stripe/functional/reporting/ReportTypeTest.java b/src/test/java/com/stripe/functional/reporting/ReportTypeTest.java deleted file mode 100644 index 02a33b3b920..00000000000 --- a/src/test/java/com/stripe/functional/reporting/ReportTypeTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.stripe.functional.reporting; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.reporting.ReportType; -import com.stripe.model.reporting.ReportTypeCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ReportTypeTest extends BaseStripeTest { - public static final String REPORT_TYPE_ID = "activity.summary.1"; - - @Test - public void testRetrieve() throws StripeException { - final ReportType reportType = ReportType.retrieve(REPORT_TYPE_ID); - - assertNotNull(reportType); - verifyRequest( - ApiResource.RequestMethod.GET, - String.format("/v1/reporting/report_types/%s", REPORT_TYPE_ID)); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - - ReportTypeCollection reportTypes = ReportType.list(params); - - assertNotNull(reportTypes); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/reporting/report_types"), params); - } -} diff --git a/src/test/java/com/stripe/functional/sigma/ScheduledQueryRunTest.java b/src/test/java/com/stripe/functional/sigma/ScheduledQueryRunTest.java deleted file mode 100644 index cdc8c44b902..00000000000 --- a/src/test/java/com/stripe/functional/sigma/ScheduledQueryRunTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.stripe.functional.sigma; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.sigma.ScheduledQueryRun; -import com.stripe.model.sigma.ScheduledQueryRunCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ScheduledQueryRunTest extends BaseStripeTest { - public static final String RUN_ID = "sqr_123"; - - @Test - public void testRetrieve() throws StripeException { - final ScheduledQueryRun run = ScheduledQueryRun.retrieve(RUN_ID); - - assertNotNull(run); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/sigma/scheduled_query_runs/%s", RUN_ID)); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - ScheduledQueryRunCollection runs = ScheduledQueryRun.list(params); - - assertNotNull(runs); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/sigma/scheduled_query_runs"), params); - } -} diff --git a/src/test/java/com/stripe/functional/terminal/ConnectionTokenTest.java b/src/test/java/com/stripe/functional/terminal/ConnectionTokenTest.java deleted file mode 100644 index 70060a0b40d..00000000000 --- a/src/test/java/com/stripe/functional/terminal/ConnectionTokenTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.stripe.functional.terminal; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.terminal.ConnectionToken; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ConnectionTokenTest extends BaseStripeTest { - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - - final ConnectionToken connectionToken = ConnectionToken.create(params); - - assertNotNull(connectionToken); - verifyRequest( - ApiResource.RequestMethod.POST, String.format("/v1/terminal/connection_tokens"), params); - } -} diff --git a/src/test/java/com/stripe/functional/terminal/LocationTest.java b/src/test/java/com/stripe/functional/terminal/LocationTest.java deleted file mode 100644 index cd5812cb5f8..00000000000 --- a/src/test/java/com/stripe/functional/terminal/LocationTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.stripe.functional.terminal; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.terminal.Location; -import com.stripe.model.terminal.LocationCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class LocationTest extends BaseStripeTest { - public static final String LOCATION_ID = "loc_123"; - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - final Map address = new HashMap<>(); - address.put("line1", "line1"); - address.put("country", "US"); - address.put("state", "CA"); - address.put("postal_code", "123"); - address.put("city", "San Francisco"); - params.put("address", address); - params.put("display_name", "name"); - - final Location location = Location.create(params); - - assertNotNull(location); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/terminal/locations"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final Location location = Location.retrieve(LOCATION_ID); - - assertNotNull(location); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/terminal/locations/%s", LOCATION_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Location location = Location.retrieve(LOCATION_ID); - - final Map params = new HashMap<>(); - params.put("display_name", "new_name"); - - final Location updatedLocation = location.update(params); - - assertNotNull(updatedLocation); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/terminal/locations/%s", location.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - LocationCollection resources = Location.list(params); - - assertNotNull(resources); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/terminal/locations"), params); - } - - @Test - public void testDelete() throws StripeException { - final Location location = Location.retrieve(LOCATION_ID); - - final Location deletedLocation = location.delete(); - - assertNotNull(deletedLocation); - assertTrue(deletedLocation.getDeleted()); - verifyRequest( - ApiResource.RequestMethod.DELETE, - String.format("/v1/terminal/locations/%s", location.getId())); - } -} diff --git a/src/test/java/com/stripe/functional/terminal/ReaderTest.java b/src/test/java/com/stripe/functional/terminal/ReaderTest.java deleted file mode 100644 index 49129f513cc..00000000000 --- a/src/test/java/com/stripe/functional/terminal/ReaderTest.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.stripe.functional.terminal; - -import static org.junit.jupiter.api.Assertions.*; - -import com.stripe.BaseStripeTest; -import com.stripe.exception.StripeException; -import com.stripe.model.terminal.Reader; -import com.stripe.model.terminal.ReaderCollection; -import com.stripe.net.ApiResource; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Test; - -public class ReaderTest extends BaseStripeTest { - public static final String READER_ID = "rdr_123"; - - @Test - public void testCreate() throws StripeException { - final Map params = new HashMap<>(); - params.put("registration_code", "rabbit-analyzed-pig"); - params.put("label", "device"); - - final Reader reader = Reader.create(params); - - assertNotNull(reader); - verifyRequest(ApiResource.RequestMethod.POST, String.format("/v1/terminal/readers"), params); - } - - @Test - public void testRetrieve() throws StripeException { - final Reader reader = Reader.retrieve(READER_ID); - - assertNotNull(reader); - verifyRequest( - ApiResource.RequestMethod.GET, String.format("/v1/terminal/readers/%s", READER_ID)); - } - - @Test - public void testUpdate() throws StripeException { - final Reader reader = Reader.retrieve(READER_ID); - - final Map params = new HashMap<>(); - params.put("label", "new_label"); - - final Reader updatedReader = reader.update(params); - - assertNotNull(updatedReader); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format("/v1/terminal/readers/%s", reader.getId()), - params); - } - - @Test - public void testList() throws StripeException { - final Map params = new HashMap<>(); - params.put("limit", 1); - - ReaderCollection resources = Reader.list(params); - - assertNotNull(resources); - verifyRequest(ApiResource.RequestMethod.GET, String.format("/v1/terminal/readers"), params); - } - - @Test - public void testDelete() throws StripeException { - final Reader reader = Reader.retrieve(READER_ID); - - final Reader deletedReader = reader.delete(); - - assertNotNull(deletedReader); - assertTrue(deletedReader.getDeleted()); - verifyRequest( - ApiResource.RequestMethod.DELETE, String.format("/v1/terminal/readers/%s", reader.getId())); - } - - @Test - public void testPresentPaymentMethod() throws StripeException { - final Reader reader = Reader.retrieve(READER_ID); - - final Reader processedReader = reader.getTestHelpers().presentPaymentMethod(); - - assertNotNull(processedReader); - verifyRequest( - ApiResource.RequestMethod.POST, - String.format( - "/v1/test_helpers/terminal/readers/%s/present_payment_method", reader.getId())); - } -} diff --git a/src/test/java/com/stripe/net/HttpClientTest.java b/src/test/java/com/stripe/net/HttpClientTest.java index aa0d1f0ebc9..14bfbfcdd40 100644 --- a/src/test/java/com/stripe/net/HttpClientTest.java +++ b/src/test/java/com/stripe/net/HttpClientTest.java @@ -1,6 +1,7 @@ package com.stripe.net; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -295,4 +296,31 @@ public void testBuildXStripeClientUserAgentStringNoPlatformWithoutTelemetry() { Stripe.enableTelemetry = originalTelemetry; } } + + @Test + public void testBuildXStripeClientUserAgentStringIncludesSource() { + String json = HttpClient.buildXStripeClientUserAgentString(""); + com.google.gson.JsonObject parsed = + com.google.gson.JsonParser.parseString(json).getAsJsonObject(); + // "source" should be present and be a 32-character lowercase MD5 hex digest + assertTrue(parsed.has("source"), "Expected 'source' field in X-Stripe-Client-User-Agent"); + String source = parsed.get("source").getAsString(); + assertTrue( + source.matches("[0-9a-f]{32}"), + "Expected 'source' to be a 32-character lowercase hex string, got: " + source); + } + + @Test + public void testBuildXStripeClientUserAgentStringOmitsSourceWhenEmpty() throws Exception { + String savedHash = HttpClient.UNAME_HASH; + try { + HttpClient.UNAME_HASH = ""; + String userAgentString = HttpClient.buildXStripeClientUserAgentString(""); + com.google.gson.JsonObject userAgent = + com.google.gson.JsonParser.parseString(userAgentString).getAsJsonObject(); + assertFalse(userAgent.has("source")); + } finally { + HttpClient.UNAME_HASH = savedHash; + } + } }