Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/test/java/com/dgf/shopcart/rest/handler/BaseHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.dgf.shopcart.model.Item;
import com.dgf.shopcart.rest.handler.req.CartItemAddRequest;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
Expand Down Expand Up @@ -61,7 +62,16 @@ void assertExchange(MockServerWebExchange exchange, String expectedBody) {
.consumeNextWith(System.out::println)
.expectComplete().verify();
assertThat(mockResponse.getHeaders().getContentType()).isEqualTo(APPLICATION_JSON);
assertThat(mockResponse.getBodyAsString().block()).isEqualTo(expectedBody);
String bodyAsString = mockResponse.getBodyAsString().block();
JsonNode expectedJson = null;
JsonNode bodyAsStringJson = null;
try {
expectedJson = mapper.readTree(expectedBody);
bodyAsStringJson = mapper.readTree(bodyAsString);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
assertThat(bodyAsStringJson).isEqualTo(expectedJson);
}


Expand Down