diff --git a/src/test/java/com/vonage/client/subaccounts/CreateSubaccountRequestTest.java b/src/test/java/com/vonage/client/subaccounts/CreateSubaccountRequestTest.java index 409adaee5..c33d82800 100644 --- a/src/test/java/com/vonage/client/subaccounts/CreateSubaccountRequestTest.java +++ b/src/test/java/com/vonage/client/subaccounts/CreateSubaccountRequestTest.java @@ -54,9 +54,13 @@ public void testConstructNoName() { } @Test - public void testConstructShortSecret() { + public void testConstructSecretLength() { CreateSubaccountRequest.Builder builder = CreateSubaccountRequest.builder().name("Department C"); - assertThrows(IllegalArgumentException.class, () -> builder.secret("A1b23c5").build()); + String min = "*A1b23c5", max = "A1b2*".repeat(5); + assertEquals(min, builder.secret(min).build().getSecret()); + assertEquals(max, builder.secret(max).build().getSecret()); + assertThrows(IllegalArgumentException.class, () -> builder.secret(min.substring(1)).build()); + assertThrows(IllegalArgumentException.class, () -> builder.secret(max + "T").build()); } @Test diff --git a/src/test/java/com/vonage/client/subaccounts/SubaccountsClientTest.java b/src/test/java/com/vonage/client/subaccounts/SubaccountsClientTest.java index 5452c73c3..a7f9a3635 100644 --- a/src/test/java/com/vonage/client/subaccounts/SubaccountsClientTest.java +++ b/src/test/java/com/vonage/client/subaccounts/SubaccountsClientTest.java @@ -326,6 +326,7 @@ public void testListCreditTransfers() throws Exception { assertNotNull(response.get(2)); assertEqualsExpectedMoneyTransfer(response.get(1)); assertNotNull(stubResponseAndGet(responseJson, client::listCreditTransfers)); + assertNull(stubResponseAndGet("{}", client::listCreditTransfers)); stubResponseAndAssertThrows(200, () -> client.listCreditTransfers(null), NullPointerException.class); stubResponseAndAssertThrows(401, () -> client.listCreditTransfers(request), SubaccountsResponseException.class); assert403ResponseException(client::listCreditTransfers); @@ -370,6 +371,7 @@ public void testListBalanceTransfers() throws Exception { assertNotNull(response.get(2)); assertEqualsExpectedMoneyTransfer(response.get(1)); assertNotNull(stubResponseAndGet(responseJson, client::listBalanceTransfers)); + assertNull(stubResponseAndGet("{}", client::listBalanceTransfers)); stubResponseAndAssertThrows(200, () -> client.listBalanceTransfers(null), NullPointerException.class); stubResponseAndAssertThrows(401, () -> client.listBalanceTransfers(request), SubaccountsResponseException.class); assert403ResponseException(client::listBalanceTransfers); @@ -513,6 +515,9 @@ public void testTransferNumber() throws Exception { .from(request.getFrom()).to(request.getTo()).number(request.getNumber()) .country("United Kingdom").build() ); + assertThrows(IllegalArgumentException.class, () -> NumberTransfer.builder() + .from(request.getFrom()).to(request.getTo()).number(request.getNumber()).build() + ); new SubaccountsEndpointTestSpec() { diff --git a/src/test/java/com/vonage/client/subaccounts/UpdateSubaccountRequestTest.java b/src/test/java/com/vonage/client/subaccounts/UpdateSubaccountRequestTest.java index 01886bfe4..3b00c24ef 100644 --- a/src/test/java/com/vonage/client/subaccounts/UpdateSubaccountRequestTest.java +++ b/src/test/java/com/vonage/client/subaccounts/UpdateSubaccountRequestTest.java @@ -38,9 +38,11 @@ public void testSerializeAllParameters() { @Test public void testSerializeRequiredParameters() { - UpdateSubaccountRequest.Builder builder = UpdateSubaccountRequest.builder("abc6123f"); + var builder = UpdateSubaccountRequest.builder("abc6123f"); assertThrows(IllegalStateException.class, builder::build); assertEquals("{\"suspended\":false}", builder.suspended(false).build().toJson()); + builder.usePrimaryAccountBalance(true); + assertEquals("{\"use_primary_account_balance\":true,\"suspended\":false}", builder.build().toJson()); } @Test