Skip to content

Commit 9cf2a40

Browse files
committed
Improve assertions for missing field tests
1 parent a51c830 commit 9cf2a40

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

spring-cloud-open-service-broker-autoconfigure/src/test/java/org/springframework/cloud/servicebroker/autoconfigure/web/reactive/ServiceInstanceBindingControllerIntegrationTests.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
package org.springframework.cloud.servicebroker.autoconfigure.web.reactive;
1818

19+
import java.nio.charset.StandardCharsets;
20+
import java.util.Objects;
21+
22+
import com.jayway.jsonpath.JsonPath;
1923
import org.junit.jupiter.api.BeforeEach;
2024
import org.junit.jupiter.api.Test;
2125
import org.junit.jupiter.api.extension.ExtendWith;
@@ -382,8 +386,12 @@ void createBindingWithMissingFieldsFails() {
382386
.expectBody()
383387
.jsonPath("$.description")
384388
.isNotEmpty()
385-
.consumeWith((result) -> assertDescriptionContains(result, "serviceDefinitionId"))
386-
.consumeWith((result) -> assertDescriptionContains(result, "planId"));
389+
.consumeWith((result) -> {
390+
String responseBody = new String(Objects.requireNonNull(result.getResponseBody()),
391+
StandardCharsets.UTF_8);
392+
String description = JsonPath.read(responseBody, "$.description");
393+
assertThat(description).contains("Missing required fields:", "planId", "serviceDefinitionId");
394+
});
387395
}
388396

389397
@Test

spring-cloud-open-service-broker-autoconfigure/src/test/java/org/springframework/cloud/servicebroker/autoconfigure/web/reactive/ServiceInstanceControllerIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ void createServiceInstanceWithMissingFieldsFails() throws Exception {
466466
String responseBody = new String(Objects.requireNonNull(result.getResponseBody()),
467467
StandardCharsets.UTF_8);
468468
String description = JsonPath.read(responseBody, "$.description");
469-
assertThat(description).contains("planId", "serviceDefinitionId");
469+
assertThat(description).contains("Missing required fields:", "planId", "serviceDefinitionId");
470470
});
471471
}
472472

0 commit comments

Comments
 (0)