Skip to content

Commit 1fffc4c

Browse files
Merge pull request #1233 from kvmw/kvmw/fix-1231
Makes guid optional in Relationship
2 parents 97574d5 + bc8996f commit 1fffc4c

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

Diff for: cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_Relationship.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.fasterxml.jackson.annotation.JsonProperty;
2020
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
21+
import org.cloudfoundry.Nullable;
2122
import org.immutables.value.Value;
2223

2324
/**
@@ -31,6 +32,7 @@ abstract class _Relationship {
3132
* The id
3233
*/
3334
@JsonProperty("guid")
35+
@Nullable
3436
abstract String getId();
3537

3638
}

Diff for: cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/RelationshipTest.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,24 @@
1616

1717
package org.cloudfoundry.client.v3;
1818

19-
import static org.junit.jupiter.api.Assertions.assertThrows;
19+
import static org.assertj.core.api.Assertions.assertThat;
2020

2121
import org.junit.jupiter.api.Test;
2222

2323
final class RelationshipTest {
2424

2525
@Test
2626
void noId() {
27-
assertThrows(
28-
IllegalStateException.class,
29-
() -> {
30-
Relationship.builder().build();
31-
});
27+
assertThat(Relationship.builder().build().getId()).isNull();
3228
}
3329

3430
@Test
35-
void valid() {
36-
Relationship.builder().id("test-id").build();
31+
void nullId() {
32+
assertThat(Relationship.builder().id(null).build().getId()).isNull();
33+
}
34+
35+
@Test
36+
void nonNullId() {
37+
assertThat(Relationship.builder().id("test-id").build().getId()).isEqualTo("test-id");
3738
}
3839
}

Diff for: cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/domains/ShareDomainRequestTest.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ final class ShareDomainRequestTest {
2525

2626
@Test
2727
void emptyRelationship() {
28-
assertThrows(
29-
IllegalStateException.class,
30-
() -> {
31-
ShareDomainRequest.builder()
32-
.domainId("test-domain-id")
33-
.data(Relationship.builder().build())
34-
.build();
35-
});
28+
ShareDomainRequest.builder()
29+
.domainId("test-domain-id")
30+
.data(Relationship.builder().build())
31+
.build();
3632
}
3733

3834
@Test

0 commit comments

Comments
 (0)