I used open openapi-generator-maven-plugin from org.openapitools in my Spring Boot project with the reactive configuration enabled. One of my endpoint returns a List body response that is auto-generated as Mono<ResponseEntity<Flux>>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator.version}</version>
<configuration>
...
<configOptions>
<interfaceOnly>true</interfaceOnly>
<reactive>true</reactive>
...
</configOptions>
</configuration>
</plugin>
How can I test the body of my endpoint Controller within an integration test using WebTestClient?
If I try this it doesn't work due to I'm receiving a flux instead of the expected dto object.
webTestApi.get()
.uri("my_uri")
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON)
.expectBody(MyDto.class)
.isEqualTo(myDto);
I finally resolved it by my own.
I nested the ResponseBody into a StepVerifier as we usually do for testing a standard Producer (Flux)