Skip to content

Commit a51c830

Browse files
committed
Resolve an issue where certain tests were quietly failing due to a blocking call
1 parent fa9056b commit a51c830

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.junit.jupiter.api.Test;
2121
import org.junit.jupiter.api.extension.ExtendWith;
2222
import org.mockito.junit.jupiter.MockitoExtension;
23+
import reactor.core.publisher.Mono;
2324

2425
import org.springframework.boot.test.system.CapturedOutput;
2526
import org.springframework.boot.test.system.OutputCaptureExtension;
@@ -48,6 +49,7 @@
4849

4950
import static org.assertj.core.api.Assertions.assertThat;
5051
import static org.mockito.ArgumentMatchers.any;
52+
import static org.mockito.ArgumentMatchers.eq;
5153
import static org.mockito.BDDMockito.given;
5254
import static org.mockito.BDDMockito.then;
5355
import static org.springframework.cloud.servicebroker.model.ServiceBrokerRequest.API_INFO_LOCATION_HEADER;
@@ -347,7 +349,9 @@ void createBindingWithDuplicateIdFails() {
347349

348350
@Test
349351
void createBindingWithInvalidFieldsFails() {
350-
String body = createRequestBody.replace("service_id", "service-1");
352+
given(this.catalogService.getServiceDefinition(eq("service-1"))).willReturn(Mono.empty());
353+
354+
String body = "{\"plan_id\":\"plan-one-id\",\"service_id\":\"service-1\"}";
351355

352356
this.client.put()
353357
.uri(buildCreateUrl())
@@ -359,7 +363,8 @@ void createBindingWithInvalidFieldsFails() {
359363
.expectBody()
360364
.jsonPath("$.description")
361365
.isNotEmpty()
362-
.consumeWith((result) -> assertDescriptionContains(result, "serviceDefinitionId"));
366+
.consumeWith(
367+
(result) -> assertDescriptionContains(result, "Service definition does not exist: id=service-1"));
363368
}
364369

365370
@Test

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.junit.jupiter.api.Test;
2525
import org.junit.jupiter.api.extension.ExtendWith;
2626
import org.mockito.junit.jupiter.MockitoExtension;
27+
import reactor.core.publisher.Mono;
2728

2829
import org.springframework.boot.test.system.CapturedOutput;
2930
import org.springframework.boot.test.system.OutputCaptureExtension;
@@ -56,6 +57,8 @@
5657

5758
import static org.assertj.core.api.Assertions.assertThat;
5859
import static org.hamcrest.core.StringContains.containsString;
60+
import static org.mockito.ArgumentMatchers.eq;
61+
import static org.mockito.BDDMockito.given;
5962
import static org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException.ASYNC_REQUIRED_ERROR;
6063
import static org.springframework.cloud.servicebroker.exception.ServiceBrokerMaintenanceInfoConflictException.MAINTENANCE_INFO_CONFLICT_ERROR;
6164
import static org.springframework.cloud.servicebroker.exception.ServiceBrokerMaintenanceInfoConflictException.MAINTENANCE_INFO_CONFLICT_MESSAGE;
@@ -421,7 +424,9 @@ void createServiceInstanceWithInvalidParametersFails() {
421424

422425
@Test
423426
void createServiceInstanceWithInvalidFieldsFails() throws Exception {
424-
String body = this.createRequestBody.replace("service_id", "service-1");
427+
given(this.catalogService.getServiceDefinition(eq("service-1"))).willReturn(Mono.empty());
428+
429+
String body = "{\"plan_id\":\"plan-one-id\",\"service_id\":\"service-1\"}";
425430

426431
this.client.put()
427432
.uri(buildCreateUpdateUrl())
@@ -436,7 +441,8 @@ void createServiceInstanceWithInvalidFieldsFails() throws Exception {
436441
.expectBody()
437442
.jsonPath("$.description")
438443
.isNotEmpty()
439-
.consumeWith((result) -> assertDescriptionContains(result, "serviceDefinitionId"));
444+
.consumeWith(
445+
(result) -> assertDescriptionContains(result, "Service definition does not exist: id=service-1"));
440446
}
441447

442448
@Test

0 commit comments

Comments
 (0)