Skip to content

Commit f063b0b

Browse files
committed
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
1 parent cda78f9 commit f063b0b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/main/java/com/auth0/json/mgmt/client/Client.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ public Client(@JsonProperty("name") String name) {
154154
this.name = name;
155155
}
156156

157+
/**
158+
* Creates a new Application instance setting the name and client id properties.
159+
*
160+
* @param name of the application.
161+
* @param clientId the client id of the application.
162+
*/
163+
public Client(String name, String clientId) {
164+
this.name = name;
165+
this.clientId = clientId;
166+
}
167+
157168
/**
158169
* Getter for the name of the application.
159170
*

src/test/java/com/auth0/json/mgmt/client/ClientTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,4 +377,18 @@ public void shouldIncludeReadOnlyValuesOnDeserialize() throws Exception {
377377
assertThat(client.isHerokuApp(), is(true));
378378
assertThat(client.getSigningKeys(), is(notNullValue()));
379379
}
380+
381+
@Test
382+
public void shouldCreateClientWithNameOnly() {
383+
Client client = new Client("My App");
384+
assertThat(client.getName(), is("My App"));
385+
assertThat(client.getClientId(), is(nullValue()));
386+
}
387+
388+
@Test
389+
public void shouldCreateClientWithNameAndClientId() {
390+
Client client = new Client("My App", "client123");
391+
assertThat(client.getName(), is("My App"));
392+
assertThat(client.getClientId(), is("client123"));
393+
}
380394
}

0 commit comments

Comments
 (0)