diff --git a/spring-boot-example/spring-crypto/spring-crypto-webflux/src/test/java/com/livk/crypto/webflux/controller/InfoWebFluxControllerTest.java b/spring-boot-example/spring-crypto/spring-crypto-webflux/src/test/java/com/livk/crypto/webflux/controller/InfoWebFluxControllerTest.java index 37d783ee4..0ad4de0fd 100644 --- a/spring-boot-example/spring-crypto/spring-crypto-webflux/src/test/java/com/livk/crypto/webflux/controller/InfoWebFluxControllerTest.java +++ b/spring-boot-example/spring-crypto/spring-crypto-webflux/src/test/java/com/livk/crypto/webflux/controller/InfoWebFluxControllerTest.java @@ -16,11 +16,8 @@ package com.livk.crypto.webflux.controller; -import com.fasterxml.jackson.databind.JsonNode; -import com.livk.commons.jackson.util.JsonNodeUtils; import com.livk.crypto.CryptoType; import com.livk.crypto.support.PbeSecurity; -import org.hamcrest.core.Is; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; @@ -56,9 +53,11 @@ void infoGet() { .isOk() .expectHeader() .contentType(MediaType.APPLICATION_JSON) - .expectBody(JsonNode.class) - .value(jsonNode -> JsonNodeUtils.findNode(jsonNode, "id.paramId").asText(), Is.is(encoding)) - .value(jsonNode -> JsonNodeUtils.findNode(jsonNode, "id.headerId").asText(), Is.is(encoding)); + .expectBody() + .jsonPath("id.paramId", encoding) + .exists() + .jsonPath("id.headerId", encoding) + .exists(); } @Test @@ -75,9 +74,11 @@ void infoPost() { .isOk() .expectHeader() .contentType(MediaType.APPLICATION_JSON) - .expectBody(JsonNode.class) - .value(jsonNode -> JsonNodeUtils.findNode(jsonNode, "body.paramId").asText(), Is.is(encoding)) - .value(jsonNode -> JsonNodeUtils.findNode(jsonNode, "body.headerId").asText(), Is.is(encoding)); + .expectBody() + .jsonPath("body.paramId", encoding) + .exists() + .jsonPath("body.headerId", encoding) + .exists(); } } diff --git a/spring-boot-example/spring-doc/spring-doc-webflux/src/test/java/com/livk/doc/webflux/controller/DocControllerTest.java b/spring-boot-example/spring-doc/spring-doc-webflux/src/test/java/com/livk/doc/webflux/controller/DocControllerTest.java index 91389de31..deb35bfca 100644 --- a/spring-boot-example/spring-doc/spring-doc-webflux/src/test/java/com/livk/doc/webflux/controller/DocControllerTest.java +++ b/spring-boot-example/spring-doc/spring-doc-webflux/src/test/java/com/livk/doc/webflux/controller/DocControllerTest.java @@ -16,8 +16,6 @@ package com.livk.doc.webflux.controller; -import com.fasterxml.jackson.databind.JsonNode; -import org.hamcrest.core.Is; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; @@ -44,8 +42,9 @@ void test() { .isOk() .expectHeader() .contentType(MediaType.APPLICATION_JSON) - .expectBody(JsonNode.class) - .value(jsonNode -> jsonNode.get("openapi").asText(), Is.is("3.0.1")); + .expectBody() + .jsonPath("openapi", "3.0.1") + .exists(); } } diff --git a/spring-boot-example/spring-hateoas/src/test/java/com/livk/spring/controller/GreetingControllerTest.java b/spring-boot-example/spring-hateoas/src/test/java/com/livk/spring/controller/GreetingControllerTest.java index d4f615ea2..1ef0c15d8 100644 --- a/spring-boot-example/spring-hateoas/src/test/java/com/livk/spring/controller/GreetingControllerTest.java +++ b/spring-boot-example/spring-hateoas/src/test/java/com/livk/spring/controller/GreetingControllerTest.java @@ -16,8 +16,6 @@ package com.livk.spring.controller; -import com.fasterxml.jackson.databind.JsonNode; -import org.hamcrest.core.Is; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebFlux; @@ -46,8 +44,9 @@ void greeting() { .isOk() .expectHeader() .contentType(MediaType.APPLICATION_JSON) - .expectBody(JsonNode.class) - .value(jsonNode -> jsonNode.get("content").asText(), Is.is("hello,World!")); + .expectBody() + .jsonPath("content", "hello,World!") + .exists(); } }