From aebe732a8187f372e67c256d61e3ae4a7d747956 Mon Sep 17 00:00:00 2001 From: Austin Nicholas Date: Tue, 7 Oct 2025 00:57:25 +0000 Subject: [PATCH] feat: add constructor to set clientId on Client creation Add new constructor Client(String name, String clientId) to allow setting the immutable clientId field during object construction. The existing Client(String name) constructor remains unchanged to maintain backward compatibility. This allows users to optionally set the clientId at construction time when needed, while the field remains immutable (no setter exists). - Add Client(String name, String clientId) constructor with JavaDoc - Add test for backward compatibility (existing constructor) - Add test for new constructor functionality - All existing tests continue to pass --- .../java/com/auth0/json/mgmt/client/Client.java | 11 +++++++++++ .../com/auth0/json/mgmt/client/ClientTest.java | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/main/java/com/auth0/json/mgmt/client/Client.java b/src/main/java/com/auth0/json/mgmt/client/Client.java index 35be65d26..fdac12210 100644 --- a/src/main/java/com/auth0/json/mgmt/client/Client.java +++ b/src/main/java/com/auth0/json/mgmt/client/Client.java @@ -154,6 +154,17 @@ public Client(@JsonProperty("name") String name) { this.name = name; } + /** + * Creates a new Application instance setting the name and client id properties. + * + * @param name of the application. + * @param clientId the client id of the application. + */ + public Client(String name, String clientId) { + this.name = name; + this.clientId = clientId; + } + /** * Getter for the name of the application. * diff --git a/src/test/java/com/auth0/json/mgmt/client/ClientTest.java b/src/test/java/com/auth0/json/mgmt/client/ClientTest.java index 301976258..e9ac5233b 100644 --- a/src/test/java/com/auth0/json/mgmt/client/ClientTest.java +++ b/src/test/java/com/auth0/json/mgmt/client/ClientTest.java @@ -377,4 +377,18 @@ public void shouldIncludeReadOnlyValuesOnDeserialize() throws Exception { assertThat(client.isHerokuApp(), is(true)); assertThat(client.getSigningKeys(), is(notNullValue())); } + + @Test + public void shouldCreateClientWithNameOnly() { + Client client = new Client("My App"); + assertThat(client.getName(), is("My App")); + assertThat(client.getClientId(), is(nullValue())); + } + + @Test + public void shouldCreateClientWithNameAndClientId() { + Client client = new Client("My App", "client123"); + assertThat(client.getName(), is("My App")); + assertThat(client.getClientId(), is("client123")); + } }