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..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,7 +16,7 @@ package org.cloudfoundry.client.v3; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; @@ -24,15 +24,16 @@ final class RelationshipTest { @Test void noId() { - assertThrows( - IllegalStateException.class, - () -> { - Relationship.builder().build(); - }); + assertThat(Relationship.builder().build().getId()).isNull(); } @Test - void valid() { - Relationship.builder().id("test-id").build(); + void nullId() { + assertThat(Relationship.builder().id(null).build().getId()).isNull(); + } + + @Test + 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