From 51e273ecdca2d2458bb1d06d933137ac226489a6 Mon Sep 17 00:00:00 2001 From: kvmw Date: Wed, 3 Jul 2024 11:09:26 +0200 Subject: [PATCH 1/3] Makes guid optional in Relationship Signed-off-by: kvmw --- .../cloudfoundry/client/v3/_Relationship.java | 2 ++ .../client/v3/RelationshipTest.java | 19 ++++++++++--------- .../v3/domains/ShareDomainRequestTest.java | 12 ++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_Relationship.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_Relationship.java index 0c48a0eda4..50ef5c951a 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_Relationship.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_Relationship.java @@ -18,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; import org.immutables.value.Value; /** @@ -31,6 +32,7 @@ abstract class _Relationship { * The id */ @JsonProperty("guid") + @Nullable abstract String getId(); } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java index 61d59c23d6..2eac15a0a8 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java @@ -16,23 +16,24 @@ package org.cloudfoundry.client.v3; -import static org.junit.jupiter.api.Assertions.assertThrows; - import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + final class RelationshipTest { @Test void noId() { - assertThrows( - IllegalStateException.class, - () -> { - Relationship.builder().build(); - }); + assertThat(Relationship.builder().build().getId()).isNull(); + } + + @Test + void nullId() { + assertThat(Relationship.builder().id(null).build().getId()).isNull(); } @Test - void valid() { - Relationship.builder().id("test-id").build(); + void nonNullId() { + assertThat(Relationship.builder().id("test-id").build().getId()).isEqualTo("test-id"); } } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/domains/ShareDomainRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/domains/ShareDomainRequestTest.java index 6ccf8b1c75..5f8e27bcd3 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/domains/ShareDomainRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/domains/ShareDomainRequestTest.java @@ -25,14 +25,10 @@ final class ShareDomainRequestTest { @Test void emptyRelationship() { - assertThrows( - IllegalStateException.class, - () -> { - ShareDomainRequest.builder() - .domainId("test-domain-id") - .data(Relationship.builder().build()) - .build(); - }); + ShareDomainRequest.builder() + .domainId("test-domain-id") + .data(Relationship.builder().build()) + .build(); } @Test From 3d2ec417a7a8fd906f69cd5fd64fef824af742b7 Mon Sep 17 00:00:00 2001 From: Anthony Dahanne Date: Tue, 9 Jul 2024 23:05:15 -0400 Subject: [PATCH 2/3] fixes #1231 - format test with mvn spotless:apply --- .../test/java/org/cloudfoundry/client/v3/RelationshipTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java index 2eac15a0a8..12325eeda7 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java @@ -18,8 +18,6 @@ import org.junit.jupiter.api.Test; -import static org.assertj.core.api.Assertions.assertThat; - final class RelationshipTest { @Test From bc8996fc2b8ff25e14e0ff771f69c00df3b72d1a Mon Sep 17 00:00:00 2001 From: Anthony Dahanne Date: Tue, 9 Jul 2024 23:05:25 -0400 Subject: [PATCH 3/3] fixes #1231 - format test with mvn spotless:apply --- .../test/java/org/cloudfoundry/client/v3/RelationshipTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java index 12325eeda7..b3c434118b 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java @@ -16,6 +16,8 @@ package org.cloudfoundry.client.v3; +import static org.assertj.core.api.Assertions.assertThat; + import org.junit.jupiter.api.Test; final class RelationshipTest {