From 942efdce8952f6af15b9ff140b89389a924bee03 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein <richardm@stripe.com> Date: Wed, 29 Nov 2023 16:31:02 -0800 Subject: [PATCH] Test for usage setting --- src/test/java/com/stripe/StripeClientTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/com/stripe/StripeClientTest.java b/src/test/java/com/stripe/StripeClientTest.java index ac01a96aa81..c9534fdc095 100644 --- a/src/test/java/com/stripe/StripeClientTest.java +++ b/src/test/java/com/stripe/StripeClientTest.java @@ -5,6 +5,7 @@ import com.stripe.model.terminal.Reader; import com.stripe.net.*; +import java.util.List; import java.util.Map; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -43,4 +44,14 @@ public void clientOptionsDefaults() { assertEquals(Stripe.UPLOAD_API_BASE, options.getFilesBase()); assertEquals(0, options.getMaxNetworkRetries()); } + + @Test + public void setsUsageOnResponseGetter() throws Exception { + StripeResponseGetter responseGetter = new LiveStripeResponseGetter(); + new StripeClient(responseGetter); + Object usage = responseGetter.getClass().getDeclaredField("usage").get(responseGetter); + assertTrue(usage instanceof List); + assertEquals(1, ((List<?>) usage).size()); + assertEquals("stripe_client", ((List<?>) usage).get(0)); + } }