From 91171521cd554dcfe3b788e26f0a75961e58ed94 Mon Sep 17 00:00:00 2001 From: Alison Tong Date: Thu, 9 May 2019 16:08:57 -0400 Subject: [PATCH] Add metadata field to Connection object --- .../java/com/auth0/json/mgmt/Connection.java | 21 +++++++++++++++++++ .../com/auth0/json/mgmt/ConnectionTest.java | 6 +++++- src/test/resources/mgmt/connection.json | 5 ++++- src/test/resources/mgmt/connections_list.json | 5 ++++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/auth0/json/mgmt/Connection.java b/src/main/java/com/auth0/json/mgmt/Connection.java index 7a56a27a..7630ec69 100644 --- a/src/main/java/com/auth0/json/mgmt/Connection.java +++ b/src/main/java/com/auth0/json/mgmt/Connection.java @@ -28,6 +28,8 @@ public class Connection { private List enabledClients = null; @JsonProperty("provisioning_ticket_url") private String provisioningTicketUrl; + @JsonProperty("metadata") + private Map metadata; public Connection() { } @@ -118,4 +120,23 @@ public String getProvisioningTicketUrl() { return provisioningTicketUrl; } + /** + * Getter for the metadata of this connection. + * + * @return the map of metadata key-values. + */ + @JsonProperty("metadata") + public Map getMetadata() { + return metadata; + } + + /** + * Setter for the metadata of this connection. + * + * @param metadata the map of metadata key-values. + */ + @JsonProperty("metadata") + public void setMetadata(Map metadata) { + this.metadata = metadata; + } } diff --git a/src/test/java/com/auth0/json/mgmt/ConnectionTest.java b/src/test/java/com/auth0/json/mgmt/ConnectionTest.java index 04206894..118c1e0a 100644 --- a/src/test/java/com/auth0/json/mgmt/ConnectionTest.java +++ b/src/test/java/com/auth0/json/mgmt/ConnectionTest.java @@ -12,7 +12,7 @@ public class ConnectionTest extends JsonTest { - private static final String json = "{\"name\":\"my-connection\",\"strategy\":\"auth0\",\"options\":{},\"enabled_clients\":[\"client1\",\"client2\"]}"; + private static final String json = "{\"name\": \"my-connection\",\"strategy\": \"auth0\",\"options\": {},\"enabled_clients\": [\"client1\",\"client2\"],\"metadata\": {\"key\": \"value\"}}"; private static final String readOnlyJson = "{\"id\":\"connectionId\"}"; private static final String jsonAd = "{\"name\":\"my-ad-connection\",\"strategy\":\"ad\",\"provisioning_ticket_url\":\"https://demo.auth0.com/p/ad/ddQTRlVt\",\"options\":{},\"enabled_clients\":[\"client1\",\"client2\"]}"; @@ -22,6 +22,7 @@ public void shouldSerialize() throws Exception { Connection connection = new Connection("my-connection", "auth0"); connection.setOptions(new HashMap()); connection.setEnabledClients(Arrays.asList("client1", "client2")); + connection.setMetadata(new HashMap()); String serialized = toJSON(connection); assertThat(serialized, is(notNullValue())); @@ -30,6 +31,7 @@ public void shouldSerialize() throws Exception { assertThat(serialized, JsonMatcher.hasEntry("options", notNullValue())); assertThat(serialized, JsonMatcher.hasEntry("enabled_clients", Arrays.asList("client1", "client2"))); assertThat(serialized, JsonMatcher.hasEntry("provisioning_ticket_url", null)); + assertThat(serialized, JsonMatcher.hasEntry("metadata", notNullValue())); } @Test @@ -42,6 +44,7 @@ public void shouldDeserialize() throws Exception { assertThat(connection.getStrategy(), is("auth0")); assertThat(connection.getEnabledClients(), contains("client1", "client2")); assertThat(connection.getProvisioningTicketUrl(), is(nullValue())); + assertThat(connection.getMetadata(), is(notNullValue())); } @Test @@ -54,6 +57,7 @@ public void shouldDeserializeAd() throws Exception { assertThat(connection.getStrategy(), is("ad")); assertThat(connection.getEnabledClients(), contains("client1", "client2")); assertThat(connection.getProvisioningTicketUrl(), is("https://demo.auth0.com/p/ad/ddQTRlVt")); + assertThat(connection.getMetadata(), is(nullValue())); } @Test diff --git a/src/test/resources/mgmt/connection.json b/src/test/resources/mgmt/connection.json index 3d3be34d..b9430624 100644 --- a/src/test/resources/mgmt/connection.json +++ b/src/test/resources/mgmt/connection.json @@ -6,5 +6,8 @@ "enabled_clients": [ "avUAvH1pgnZGgAGlv8guZLPoaOnjVJsM", "ScKKdrpyUwfkhOQP6KXItH32INgZf7Rb" - ] + ], + "metadata": { + "key": "value" + } } \ No newline at end of file diff --git a/src/test/resources/mgmt/connections_list.json b/src/test/resources/mgmt/connections_list.json index 9f621c4d..88c471cc 100644 --- a/src/test/resources/mgmt/connections_list.json +++ b/src/test/resources/mgmt/connections_list.json @@ -7,7 +7,10 @@ "enabled_clients": [ "avUAvH1pgnZGgAGlv8guZLPoaOnjVJsM", "ScKKdrpyUwfkhOQP6KXItH32INgZf7Rb" - ] + ], + "metadata": { + "key": "value" + } }, { "name": "My connection2",