From 4394e828c1425c55fc8af955d0c37d2aa2079379 Mon Sep 17 00:00:00 2001 From: Harry9656 Date: Thu, 11 Apr 2024 01:26:19 +0200 Subject: [PATCH] JAVA-32410: Update mockito-core to version 5.11.0 (#16199) * JAVA-32410: Update mockito-core to version 5.11.0 * Fix rollback mockito upgrade. * wip * WIP: Update jee-7 wildfly versions * WIP: Fix jersey tests * WIP: rollback powermock module * wip: fix test in spring-data-dynamodb * wip: fix test in spring-security-legacy-oidc * wip: rollback quarkus * wip: fix greeter-spring-boot-autoconfigure * JAVA-33535: Fix spring-core module integration test JAVA-33535: rollback junit-5 module mockito version. * Fix byte-buddy * Fix log4j dependency in apache-poi --- apache-poi/pom.xml | 11 +++++ .../todo-reminder-lambda/ToDoFunction/pom.xml | 3 +- core-java-modules/core-java-jar/pom.xml | 1 - graphql-modules/pom.xml | 7 ++- libraries-http-2/pom.xml | 3 +- messaging-modules/spring-jms/pom.xml | 3 +- .../design-patterns-creational-2/pom.xml | 6 ++- .../spring-boot-persistence/pom.xml | 1 - .../spring-data-dynamodb/pom.xml | 6 +++ .../java/com/baeldung/SpringContextTest.java | 2 - pom.xml | 2 +- .../quarkus-virtual-threads/pom.xml | 3 +- quarkus-modules/quarkus/pom.xml | 2 +- spring-aop-2/pom.xml | 1 + .../greeter-spring-boot-autoconfigure/pom.xml | 7 +++ spring-core/pom.xml | 4 +- spring-ejb-modules/ejb-beans/pom.xml | 1 - .../spring-security-legacy-oidc/pom.xml | 6 +++ .../accessing-session-attributes/pom.xml | 1 - testing-modules/junit-5-basics-2/pom.xml | 3 +- testing-modules/junit-5/pom.xml | 7 +-- testing-modules/mockito-2/pom.xml | 2 +- testing-modules/mockito-simple/pom.xml | 1 - testing-modules/powermock/pom.xml | 2 +- web-modules/jakarta-ee/pom.xml | 5 +- .../eclipse/krazo/UserControllerUnitTest.java | 28 ++++++----- web-modules/javax-servlets-2/pom.xml | 1 - web-modules/jee-7/pom.xml | 9 ++-- .../com/baeldung/jersey/server/Greetings.java | 2 + .../GreetingsResourceIntegrationTest.java | 14 +++--- .../rest/FruitResourceIntegrationTest.java | 46 +++++++++---------- 31 files changed, 106 insertions(+), 84 deletions(-) diff --git a/apache-poi/pom.xml b/apache-poi/pom.xml index 876fca0efe..027ee06968 100644 --- a/apache-poi/pom.xml +++ b/apache-poi/pom.xml @@ -40,6 +40,16 @@ fastexcel-reader ${fastexcel.version} + + org.apache.logging.log4j + log4j-api + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + @@ -64,6 +74,7 @@ 1.0.9 0.17.0 3.3.1 + 2.23.1 \ No newline at end of file diff --git a/aws-modules/aws-lambda-modules/todo-reminder-lambda/ToDoFunction/pom.xml b/aws-modules/aws-lambda-modules/todo-reminder-lambda/ToDoFunction/pom.xml index acc14b55ff..2aa48a2f92 100644 --- a/aws-modules/aws-lambda-modules/todo-reminder-lambda/ToDoFunction/pom.xml +++ b/aws-modules/aws-lambda-modules/todo-reminder-lambda/ToDoFunction/pom.xml @@ -71,7 +71,7 @@ org.mockito mockito-core - ${mockito-core.version} + ${mockito.version} test @@ -112,7 +112,6 @@ 11.2 5.1.0 2.0.2 - 4.1.0 3.19.0 5.8.1 diff --git a/core-java-modules/core-java-jar/pom.xml b/core-java-modules/core-java-jar/pom.xml index 460adf45e7..e87fba922e 100644 --- a/core-java-modules/core-java-jar/pom.xml +++ b/core-java-modules/core-java-jar/pom.xml @@ -260,7 +260,6 @@ 0.4 1.8.7 - 4.6.1 1.1 3.6.2 diff --git a/graphql-modules/pom.xml b/graphql-modules/pom.xml index 2525f75eff..ef05e3eea6 100644 --- a/graphql-modules/pom.xml +++ b/graphql-modules/pom.xml @@ -20,7 +20,7 @@ org.springframework.boot spring-boot-dependencies - 2.6.4 + 2.6.15 pom import @@ -34,4 +34,9 @@ graphql-spqr-boot-starter + + + 4.4.0 + + \ No newline at end of file diff --git a/libraries-http-2/pom.xml b/libraries-http-2/pom.xml index 934e0d2900..fa6b65f79f 100644 --- a/libraries-http-2/pom.xml +++ b/libraries-http-2/pom.xml @@ -85,7 +85,7 @@ org.mockito mockito-inline - ${mockito.version} + ${mockito-inline.version} test @@ -120,6 +120,7 @@ 1.0.3 3.6.0 1.49 + 5.2.0 \ No newline at end of file diff --git a/messaging-modules/spring-jms/pom.xml b/messaging-modules/spring-jms/pom.xml index aad416433d..0df1e9fff2 100644 --- a/messaging-modules/spring-jms/pom.xml +++ b/messaging-modules/spring-jms/pom.xml @@ -44,7 +44,7 @@ org.mockito mockito-core - ${mockito-core.version} + ${mockito.version} test @@ -83,7 +83,6 @@ 5.14.1 1.5.10.RELEASE 3.3.2 - 4.6.1 5.16.5 1.17.3 5.10.1 diff --git a/patterns-modules/design-patterns-creational-2/pom.xml b/patterns-modules/design-patterns-creational-2/pom.xml index 27c83c9eb7..30e052e6db 100644 --- a/patterns-modules/design-patterns-creational-2/pom.xml +++ b/patterns-modules/design-patterns-creational-2/pom.xml @@ -16,9 +16,13 @@ org.mockito mockito-inline - ${mockito.version} + ${mockito-inline.version} test + + 5.2.0 + + \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence/pom.xml b/persistence-modules/spring-boot-persistence/pom.xml index 39edc01170..a816732e52 100644 --- a/persistence-modules/spring-boot-persistence/pom.xml +++ b/persistence-modules/spring-boot-persistence/pom.xml @@ -70,7 +70,6 @@ - 2.23.0 2.0.1.Final 8.2.0 com.baeldung.boot.Application diff --git a/persistence-modules/spring-data-dynamodb/pom.xml b/persistence-modules/spring-data-dynamodb/pom.xml index 5252aa5481..5d31f13518 100644 --- a/persistence-modules/spring-data-dynamodb/pom.xml +++ b/persistence-modules/spring-data-dynamodb/pom.xml @@ -136,6 +136,12 @@ so test + + net.bytebuddy + byte-buddy + 1.14.13 + test + diff --git a/persistence-modules/spring-data-dynamodb/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/spring-data-dynamodb/src/test/java/com/baeldung/SpringContextTest.java index 3ad54e2267..13c1c162f1 100644 --- a/persistence-modules/spring-data-dynamodb/src/test/java/com/baeldung/SpringContextTest.java +++ b/persistence-modules/spring-data-dynamodb/src/test/java/com/baeldung/SpringContextTest.java @@ -5,8 +5,6 @@ import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import com.baeldung.Application; - @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class SpringContextTest { diff --git a/pom.xml b/pom.xml index 7496d4ca93..5e703b4bc1 100644 --- a/pom.xml +++ b/pom.xml @@ -1149,7 +1149,7 @@ 3.21.0 2.2 1.3 - 4.4.0 + 5.11.0 1.14.11 diff --git a/quarkus-modules/quarkus-virtual-threads/pom.xml b/quarkus-modules/quarkus-virtual-threads/pom.xml index f2da9390b5..0b8cf46c3e 100644 --- a/quarkus-modules/quarkus-virtual-threads/pom.xml +++ b/quarkus-modules/quarkus-virtual-threads/pom.xml @@ -37,7 +37,6 @@ 3.0.0 0.3.0 3.6.0 - 3.11.2 @@ -92,7 +91,7 @@ org.mockito mockito-core - ${mockito-core.version} + ${mockito.version} test diff --git a/quarkus-modules/quarkus/pom.xml b/quarkus-modules/quarkus/pom.xml index fc3d294beb..5ddd9826e9 100644 --- a/quarkus-modules/quarkus/pom.xml +++ b/quarkus-modules/quarkus/pom.xml @@ -180,7 +180,7 @@ 2.16.3.Final - 3.3.0 + 4.4.0 \ No newline at end of file diff --git a/spring-aop-2/pom.xml b/spring-aop-2/pom.xml index 3a60739315..7aea3b64de 100644 --- a/spring-aop-2/pom.xml +++ b/spring-aop-2/pom.xml @@ -45,6 +45,7 @@ org.mockito mockito-core + ${mockito.version} test diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml index d7f437633d..96cfd622db 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml @@ -42,6 +42,12 @@ ${spring-boot.version} test + + net.bytebuddy + byte-buddy + ${byte-buddy.version} + test + @@ -61,6 +67,7 @@ 2.2.6.RELEASE 0.0.1-SNAPSHOT + 1.14.13 \ No newline at end of file diff --git a/spring-core/pom.xml b/spring-core/pom.xml index 5134ad42f7..99b3291dcf 100644 --- a/spring-core/pom.xml +++ b/spring-core/pom.xml @@ -49,7 +49,7 @@ org.springframework.boot spring-boot-test - ${mockito.spring.boot.version} + ${spring-boot.version} test @@ -78,10 +78,8 @@ - 1.4.4.RELEASE 1 1.5.2.RELEASE - 1.10.19 1.3.2 diff --git a/spring-ejb-modules/ejb-beans/pom.xml b/spring-ejb-modules/ejb-beans/pom.xml index 6203db5f5a..52503922b6 100644 --- a/spring-ejb-modules/ejb-beans/pom.xml +++ b/spring-ejb-modules/ejb-beans/pom.xml @@ -189,7 +189,6 @@ 5.2.3.RELEASE 5.16.3 5.16.3 - 2.21.0 2.8 8.2.1.Final 2.12.5 diff --git a/spring-security-modules/spring-security-legacy-oidc/pom.xml b/spring-security-modules/spring-security-legacy-oidc/pom.xml index 10c6eb3389..0fb10c7e4f 100644 --- a/spring-security-modules/spring-security-legacy-oidc/pom.xml +++ b/spring-security-modules/spring-security-legacy-oidc/pom.xml @@ -42,6 +42,12 @@ jwks-rsa ${jwks-rsa.version} + + net.bytebuddy + byte-buddy + 1.14.13 + test + diff --git a/spring-web-modules/spring-thymeleaf-attributes/accessing-session-attributes/pom.xml b/spring-web-modules/spring-thymeleaf-attributes/accessing-session-attributes/pom.xml index d4fff21605..c1795b500c 100644 --- a/spring-web-modules/spring-thymeleaf-attributes/accessing-session-attributes/pom.xml +++ b/spring-web-modules/spring-thymeleaf-attributes/accessing-session-attributes/pom.xml @@ -77,7 +77,6 @@ true true 5.9.3 - 5.3.1 3.1.1.RELEASE 3.1.1 diff --git a/testing-modules/junit-5-basics-2/pom.xml b/testing-modules/junit-5-basics-2/pom.xml index d8bb2a6e79..27681d66eb 100644 --- a/testing-modules/junit-5-basics-2/pom.xml +++ b/testing-modules/junit-5-basics-2/pom.xml @@ -26,7 +26,7 @@ org.mockito mockito-core - ${mockito-core.version} + ${mockito.version} test @@ -42,7 +42,6 @@ 5.10.0 - 5.5.0 \ No newline at end of file diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index cdddf90855..63162e71e8 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -89,11 +89,6 @@ ${powermock.version} test - - org.mockito - mockito-core - test - @@ -135,7 +130,7 @@ 2.17.1 2.0.9 5.0.1.RELEASE - 3.3.0 + 3.3.0 \ No newline at end of file diff --git a/testing-modules/mockito-2/pom.xml b/testing-modules/mockito-2/pom.xml index 79b8c86221..f4ff2da682 100644 --- a/testing-modules/mockito-2/pom.xml +++ b/testing-modules/mockito-2/pom.xml @@ -34,8 +34,8 @@ 4.8.1 - 5.10.0 1.18.30 + \ No newline at end of file diff --git a/testing-modules/mockito-simple/pom.xml b/testing-modules/mockito-simple/pom.xml index 6f50136de6..7a07ea73ee 100644 --- a/testing-modules/mockito-simple/pom.xml +++ b/testing-modules/mockito-simple/pom.xml @@ -60,7 +60,6 @@ 6.0.8 - 5.3.1 \ No newline at end of file diff --git a/testing-modules/powermock/pom.xml b/testing-modules/powermock/pom.xml index 8eedc818af..0c3b1c367f 100644 --- a/testing-modules/powermock/pom.xml +++ b/testing-modules/powermock/pom.xml @@ -41,7 +41,7 @@ - 2.21.0 + 2.21.0 2.0.9 diff --git a/web-modules/jakarta-ee/pom.xml b/web-modules/jakarta-ee/pom.xml index faad33338b..4caa67bf6f 100644 --- a/web-modules/jakarta-ee/pom.xml +++ b/web-modules/jakarta-ee/pom.xml @@ -48,7 +48,7 @@ org.mockito - mockito-all + mockito-core ${mockito.version} test @@ -100,11 +100,10 @@ 9.0.0 2.0.0 2.0.0 - 5.8.2 + 5.10.2 C:/glassfish6 admin mvn-domain - 1.10.19 ${local.glassfish.home}\\domains\\${local.glassfish.domain}\\config\\domain-passwords diff --git a/web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/UserControllerUnitTest.java b/web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/UserControllerUnitTest.java index 5e79924ed7..a116db3c65 100644 --- a/web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/UserControllerUnitTest.java +++ b/web-modules/jakarta-ee/src/test/java/com/baeldung/eclipse/krazo/UserControllerUnitTest.java @@ -1,25 +1,23 @@ package com.baeldung.eclipse.krazo; -import com.baeldung.eclipse.krazo.User; -import com.baeldung.eclipse.krazo.UserController; -import jakarta.mvc.Models; -import jakarta.mvc.binding.BindingResult; -import org.eclipse.krazo.core.ModelsImpl; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; +import org.eclipse.krazo.core.ModelsImpl; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import jakarta.mvc.Models; +import jakarta.mvc.binding.BindingResult; + /** * The class contains unit tests. We do only unit tests. Most of the classes are mocked */ diff --git a/web-modules/javax-servlets-2/pom.xml b/web-modules/javax-servlets-2/pom.xml index a792f6eea2..8031786af4 100644 --- a/web-modules/javax-servlets-2/pom.xml +++ b/web-modules/javax-servlets-2/pom.xml @@ -112,7 +112,6 @@ 2.22.2 10.0.4 1.10.0 - 5.6.0 1.5.4 diff --git a/web-modules/jee-7/pom.xml b/web-modules/jee-7/pom.xml index 47d79f12ac..9bbfc33e62 100644 --- a/web-modules/jee-7/pom.xml +++ b/web-modules/jee-7/pom.xml @@ -312,7 +312,7 @@ test - org.wildfly + org.wildfly.arquillian wildfly-arquillian-container-managed ${wildfly.version} test @@ -345,7 +345,7 @@ org.wildfly wildfly-dist - ${wildfly.version} + ${wildfly-dist.version} zip false ${project.build.directory} @@ -395,7 +395,7 @@ test - org.wildfly + org.wildfly.arquillian wildfly-arquillian-container-remote ${wildfly.version} test @@ -520,7 +520,8 @@ 3.0.0 7.0 1.1.11.Final - 8.2.1.Final + 31.0.1.Final + 5.0.1.Final 1.7.0 1.4.6.Final 3.0.19.Final diff --git a/web-modules/jersey/src/main/java/com/baeldung/jersey/server/Greetings.java b/web-modules/jersey/src/main/java/com/baeldung/jersey/server/Greetings.java index e753d34901..e87bd100c8 100644 --- a/web-modules/jersey/src/main/java/com/baeldung/jersey/server/Greetings.java +++ b/web-modules/jersey/src/main/java/com/baeldung/jersey/server/Greetings.java @@ -5,6 +5,7 @@ import com.baeldung.jersey.server.config.HelloBinding; import jakarta.ws.rs.GET; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Response; @Path("/greetings") @@ -17,6 +18,7 @@ public class Greetings { } @GET + @Produces("text/html") @Path("/hi") public String getHiGreeting() { return "hi"; diff --git a/web-modules/jersey/src/test/java/com/baeldung/jersey/server/GreetingsResourceIntegrationTest.java b/web-modules/jersey/src/test/java/com/baeldung/jersey/server/GreetingsResourceIntegrationTest.java index 47736f90d7..e01415b50a 100644 --- a/web-modules/jersey/src/test/java/com/baeldung/jersey/server/GreetingsResourceIntegrationTest.java +++ b/web-modules/jersey/src/test/java/com/baeldung/jersey/server/GreetingsResourceIntegrationTest.java @@ -1,18 +1,18 @@ package com.baeldung.jersey.server; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import jakarta.ws.rs.core.Application; import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; -public class GreetingsResourceIntegrationTest extends JerseyTest { +class GreetingsResourceIntegrationTest extends JerseyTest { @Override protected Application configure() { @@ -21,14 +21,14 @@ public class GreetingsResourceIntegrationTest extends JerseyTest { } @Test - public void givenGetHiGreeting_whenCorrectRequest_thenResponseIsOkAndContainsHi() { + void givenGetHiGreeting_whenCorrectRequest_thenResponseIsOkAndContainsHi() { Response response = target("/greetings/hi").request() .get(); - assertEquals("Http Response should be 200: ", Response.Status.OK.getStatusCode(), response.getStatus()); - assertEquals("Http Content-Type should be: ", MediaType.TEXT_HTML, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + assertEquals(MediaType.TEXT_HTML, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); String content = response.readEntity(String.class); - assertEquals("Content of ressponse is: ", "hi", content); + assertEquals("hi", content); } } diff --git a/web-modules/jersey/src/test/java/com/baeldung/jersey/server/rest/FruitResourceIntegrationTest.java b/web-modules/jersey/src/test/java/com/baeldung/jersey/server/rest/FruitResourceIntegrationTest.java index 4f73c9df5b..2eaeb94a00 100644 --- a/web-modules/jersey/src/test/java/com/baeldung/jersey/server/rest/FruitResourceIntegrationTest.java +++ b/web-modules/jersey/src/test/java/com/baeldung/jersey/server/rest/FruitResourceIntegrationTest.java @@ -2,12 +2,12 @@ package com.baeldung.jersey.server.rest; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.baeldung.jersey.server.config.ViewApplicationConfig; import com.baeldung.jersey.server.model.Fruit; @@ -19,7 +19,7 @@ import jakarta.ws.rs.core.Form; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; -public class FruitResourceIntegrationTest extends JerseyTest { +class FruitResourceIntegrationTest extends JerseyTest { @Override protected Application configure() { @@ -33,80 +33,80 @@ public class FruitResourceIntegrationTest extends JerseyTest { } @Test - public void givenGetAllFruit_whenCorrectRequest_thenAllTemplateInvoked() { + void givenGetAllFruit_whenCorrectRequest_thenAllTemplateInvoked() { final String response = target("/fruit/all").request() .get(String.class); assertThat(response, allOf(containsString("banana"), containsString("apple"), containsString("kiwi"))); } @Test - public void givenGetFruit_whenCorrectRequest_thenIndexTemplateInvoked() { + void givenGetFruit_whenCorrectRequest_thenIndexTemplateInvoked() { final String response = target("/fruit").request() .get(String.class); assertThat(response, containsString("Welcome Fruit Index Page!")); } @Test - public void givenGetFruitByName_whenFruitUnknown_thenErrorTemplateInvoked() { + void givenGetFruitByName_whenFruitUnknown_thenErrorTemplateInvoked() { final String response = target("/fruit/orange").request() .get(String.class); assertThat(response, containsString("Error - Fruit not found: orange!")); } @Test - public void givenCreateFruit_whenFormContainsNullParam_thenResponseCodeIsBadRequest() { + void givenCreateFruit_whenFormContainsNullParam_thenResponseCodeIsBadRequest() { Form form = new Form(); form.param("name", "apple"); form.param("colour", null); Response response = target("fruit/create").request(MediaType.APPLICATION_FORM_URLENCODED) .post(Entity.form(form)); - assertEquals("Http Response should be 400 ", 400, response.getStatus()); + assertEquals(400, response.getStatus()); assertThat(response.readEntity(String.class), containsString("Fruit colour must not be null")); } @Test - public void givenCreateFruit_whenJsonIsCorrect_thenResponseCodeIsCreated() { + void givenCreateFruit_whenJsonIsCorrect_thenResponseCodeIsCreated() { Response response = target("fruit/created").request() .post(Entity.json("{\"name\":\"strawberry\",\"weight\":20}")); - assertEquals("Http Response should be 201 ", Response.Status.CREATED.getStatusCode(), response.getStatus()); + assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus()); assertThat(response.readEntity(String.class), containsString("Fruit saved : Fruit [name: strawberry colour: null]")); } @Test - public void givenUpdateFruit_whenFormContainsBadSerialParam_thenResponseCodeIsBadRequest() { + void givenUpdateFruit_whenFormContainsBadSerialParam_thenResponseCodeIsBadRequest() { Form form = new Form(); form.param("serial", "2345-2345"); Response response = target("fruit/update").request(MediaType.APPLICATION_FORM_URLENCODED) .put(Entity.form(form)); - assertEquals("Http Response should be 400 ", 400, response.getStatus()); + assertEquals(400, response.getStatus()); assertThat(response.readEntity(String.class), containsString("Fruit serial number is not valid")); } @Test - public void givenCreateFruit_whenFruitIsInvalid_thenResponseCodeIsBadRequest() { + void givenCreateFruit_whenFruitIsInvalid_thenResponseCodeIsBadRequest() { Fruit fruit = new Fruit("Blueberry", "purple"); fruit.setWeight(1); Response response = target("fruit/create").request(MediaType.APPLICATION_JSON_TYPE) .post(Entity.entity(fruit, MediaType.APPLICATION_JSON_TYPE)); - assertEquals("Http Response should be 400 ", 400, response.getStatus()); + assertEquals(400, response.getStatus()); assertThat(response.readEntity(String.class), containsString("Fruit weight must be 10 or greater")); } @Test - public void givenFruitExists_whenSearching_thenResponseContainsFruit() { + void givenFruitExists_whenSearching_thenResponseContainsFruit() { Fruit fruit = new Fruit(); fruit.setName("strawberry"); fruit.setWeight(20); Response response = target("fruit/create").request(MediaType.APPLICATION_JSON_TYPE) .post(Entity.entity(fruit, MediaType.APPLICATION_JSON_TYPE)); - assertEquals("Http Response should be 204 ", 204, response.getStatus()); + assertEquals(204, response.getStatus()); final String json = target("fruit/search/strawberry").request() .get(String.class); @@ -114,28 +114,28 @@ public class FruitResourceIntegrationTest extends JerseyTest { } @Test - public void givenFruitExists_whenSearching_thenResponseContainsFruitEntity() { + void givenFruitExists_whenSearching_thenResponseContainsFruitEntity() { Fruit fruit = new Fruit(); fruit.setName("strawberry"); fruit.setWeight(20); Response response = target("fruit/create").request(MediaType.APPLICATION_JSON_TYPE) .post(Entity.entity(fruit, MediaType.APPLICATION_JSON_TYPE)); - assertEquals("Http Response should be 204 ", 204, response.getStatus()); + assertEquals(204, response.getStatus()); final Fruit entity = target("fruit/search/strawberry").request() .get(Fruit.class); - assertEquals("Fruit name: ", "strawberry", entity.getName()); - assertEquals("Fruit weight: ", Integer.valueOf(20), entity.getWeight()); + assertEquals("strawberry", entity.getName()); + assertEquals(Integer.valueOf(20), entity.getWeight()); } @Test - public void givenFruit_whenFruitIsInvalid_thenReponseContainsCustomExceptions() { + void givenFruit_whenFruitIsInvalid_thenReponseContainsCustomExceptions() { final Response response = target("fruit/exception").request() .get(); - assertEquals("Http Response should be 400 ", 400, response.getStatus()); + assertEquals(400, response.getStatus()); String responseString = response.readEntity(String.class); assertThat(responseString, containsString("exception..colour size must be between 5 and 200")); assertThat(responseString, containsString("exception..name size must be between 5 and 200"));