From 47dc8477ae7875936f438ad345743410ed1f170e Mon Sep 17 00:00:00 2001
From: Haroon Khan <haroonkhan79@gmail.com>
Date: Thu, 26 May 2022 15:06:05 +0100
Subject: [PATCH] [JAVA-12361] Code clean up and migrate to JUnit 5 tests

---
 .../ConsumerFooServiceIntegrationTest.java    |  6 ++--
 .../consumer/ConsumerFooServiceLiveTest.java  |  8 ++---
 .../ErrorHandlingIntegrationTest.java         | 27 +++++++--------
 .../introduction/ReactorIntegrationTest.java  | 16 ++++-----
 .../security/SecurityIntegrationTest.java     | 15 ++++-----
 .../reactive/webclient/SpringContextTest.java |  4 +--
 .../webclient/WebClientIntegrationTest.java   | 16 ++++-----
 .../WebControllerIntegrationTest.java         |  2 +-
 .../WebTestClientIntegrationTest.java         | 12 +++----
 ...bClientRequestsWithParametersUnitTest.java | 33 +++++++++----------
 .../EmployeeControllerIntegrationTest.java    | 15 ++++-----
 ...ployeeSpringFunctionalIntegrationTest.java | 13 +++-----
 12 files changed, 76 insertions(+), 91 deletions(-)

diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceIntegrationTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceIntegrationTest.java
index 3635844056..b03bfeb82d 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceIntegrationTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceIntegrationTest.java
@@ -19,18 +19,18 @@ import ch.qos.logback.classic.spi.IThrowableProxy;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Hooks;
 
-public class ConsumerFooServiceIntegrationTest {
+class ConsumerFooServiceIntegrationTest {
 
     FooService service = new FooService();
 
     @BeforeEach
-    public void clearLogList() {
+    void clearLogList() {
         Hooks.onOperatorDebug();
         ListAppender.clearEventList();
     }
 
     @Test
-    public void givenFooWithNullId_whenProcessFoo_thenLogsWithDebugTrace() {
+    void givenFooWithNullId_whenProcessFoo_thenLogsWithDebugTrace() {
         Foo one = new Foo(1, "nameverylong", 8);
         Foo two = new Foo(null, "nameverylong", 4);
         Flux<Foo> flux = Flux.just(one, two);
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceLiveTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceLiveTest.java
index 89e92f2818..84aee83c98 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceLiveTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceLiveTest.java
@@ -10,7 +10,7 @@ import org.springframework.test.web.reactive.server.WebTestClient.ResponseSpec;
  * - com.baeldung.reactive.debugging.server.ServerDebuggingApplication
  * - com.baeldung.reactive.debugging.consumer.ConsumerDebuggingApplication
  */
-public class ConsumerFooServiceLiveTest {
+class ConsumerFooServiceLiveTest {
 
     private static final String BASE_URL = "http://localhost:8082";
     private static final String DEBUG_HOOK_ON = BASE_URL + "/debug-hook-on";
@@ -19,14 +19,14 @@ public class ConsumerFooServiceLiveTest {
     private static WebTestClient client;
 
     @BeforeAll
-    public static void setup() {
+    static void setup() {
         client = WebTestClient.bindToServer()
             .baseUrl(BASE_URL)
             .build();
     }
 
     @Test
-    public void whenRequestingDebugHookOn_thenObtainExpectedMessage() {
+    void whenRequestingDebugHookOn_thenObtainExpectedMessage() {
         ResponseSpec response = client.get()
             .uri(DEBUG_HOOK_ON)
             .exchange();
@@ -37,7 +37,7 @@ public class ConsumerFooServiceLiveTest {
     }
 
     @Test
-    public void whenRequestingDebugHookOff_thenObtainExpectedMessage() {
+    void whenRequestingDebugHookOff_thenObtainExpectedMessage() {
         ResponseSpec response = client.get()
             .uri(DEBUG_HOOK_OFF)
             .exchange();
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java
index bbcab179eb..0068379d61 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java
@@ -1,27 +1,24 @@
 package com.baeldung.reactive.errorhandling;
 
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
 import org.springframework.http.MediaType;
 import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.reactive.server.WebTestClient;
 
-@RunWith(SpringRunner.class)
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
 @DirtiesContext
 @AutoConfigureWebTestClient(timeout = "10000")
-public class ErrorHandlingIntegrationTest {
+class ErrorHandlingIntegrationTest {
 
     @Autowired
     private WebTestClient webTestClient;
 
     @Test
-    public void givenErrorReturn_whenUsernamePresent_thenOk() {
+    void givenErrorReturn_whenUsernamePresent_thenOk() {
 
         webTestClient.get()
           .uri("/api/endpoint1?name={username}", "Tony")
@@ -31,7 +28,7 @@ public class ErrorHandlingIntegrationTest {
     }
 
     @Test
-    public void givenErrorReturn_whenNoUsername_thenOk() {
+    void givenErrorReturn_whenNoUsername_thenOk() {
 
         webTestClient.get()
           .uri("/api/endpoint1")
@@ -41,7 +38,7 @@ public class ErrorHandlingIntegrationTest {
     }
 
     @Test
-    public void givenResumeFallback_whenUsernamePresent_thenOk() {
+    void givenResumeFallback_whenUsernamePresent_thenOk() {
 
         webTestClient.get()
           .uri("/api/endpoint2?name={username}", "Tony")
@@ -51,7 +48,7 @@ public class ErrorHandlingIntegrationTest {
     }
 
     @Test
-    public void givenResumeFallback_whenNoUsername_thenOk() {
+    void givenResumeFallback_whenNoUsername_thenOk() {
 
         webTestClient.get()
           .uri("/api/endpoint2")
@@ -61,7 +58,7 @@ public class ErrorHandlingIntegrationTest {
     }
 
     @Test
-    public void givenResumeDynamicValue_whenUsernamePresent_thenOk() {
+    void givenResumeDynamicValue_whenUsernamePresent_thenOk() {
 
         webTestClient.get()
           .uri("/api/endpoint3?name={username}", "Tony")
@@ -71,7 +68,7 @@ public class ErrorHandlingIntegrationTest {
     }
 
     @Test
-    public void givenResumeDynamicValue_whenNoUsername_thenOk() {
+    void givenResumeDynamicValue_whenNoUsername_thenOk() {
 
         webTestClient.get()
           .uri("/api/endpoint3")
@@ -81,7 +78,7 @@ public class ErrorHandlingIntegrationTest {
     }
 
     @Test
-    public void givenResumeRethrow_whenUsernamePresent_thenOk() {
+    void givenResumeRethrow_whenUsernamePresent_thenOk() {
 
         webTestClient.get()
           .uri("/api/endpoint4?name={username}", "Tony")
@@ -91,7 +88,7 @@ public class ErrorHandlingIntegrationTest {
     }
 
     @Test
-    public void givenResumeRethrow_whenNoUsername_thenOk() {
+    void givenResumeRethrow_whenNoUsername_thenOk() {
 
         webTestClient.get()
           .uri("/api/endpoint4")
@@ -103,7 +100,7 @@ public class ErrorHandlingIntegrationTest {
     }
 
     @Test
-    public void givenGlobalErrorHandling_whenUsernamePresent_thenOk() {
+    void givenGlobalErrorHandling_whenUsernamePresent_thenOk() {
 
         webTestClient.get()
           .uri("/api/endpoint5?name={username}", "Tony")
@@ -113,7 +110,7 @@ public class ErrorHandlingIntegrationTest {
     }
 
     @Test
-    public void givenGlobalErrorHandling_whenNoUsername_thenOk() {
+    void givenGlobalErrorHandling_whenNoUsername_thenOk() {
 
         webTestClient.get()
           .uri("/api/endpoint5")
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/introduction/ReactorIntegrationTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/introduction/ReactorIntegrationTest.java
index 307cc2cfeb..63e49419ba 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/introduction/ReactorIntegrationTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/introduction/ReactorIntegrationTest.java
@@ -1,6 +1,6 @@
 package com.baeldung.reactive.introduction;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.reactivestreams.Subscriber;
 import org.reactivestreams.Subscription;
 import org.slf4j.Logger;
@@ -14,12 +14,12 @@ import java.util.List;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-public class ReactorIntegrationTest {
+class ReactorIntegrationTest {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(ReactorIntegrationTest.class);
-    
+
     @Test
-    public void givenFlux_whenSubscribing_thenStream() {
+    void givenFlux_whenSubscribing_thenStream() {
 
         List<Integer> elements = new ArrayList<>();
 
@@ -35,7 +35,7 @@ public class ReactorIntegrationTest {
     }
 
     @Test
-    public void givenFlux_whenZipping_thenCombine() {
+    void givenFlux_whenZipping_thenCombine() {
         List<String> elements = new ArrayList<>();
 
         Flux.just(1, 2, 3, 4)
@@ -52,7 +52,7 @@ public class ReactorIntegrationTest {
     }
 
     @Test
-    public void givenFlux_whenApplyingBackPressure_thenPushElementsInBatches() {
+    void givenFlux_whenApplyingBackPressure_thenPushElementsInBatches() {
 
         List<Integer> elements = new ArrayList<>();
 
@@ -90,7 +90,7 @@ public class ReactorIntegrationTest {
     }
 
     @Test
-    public void givenFlux_whenInParallel_thenSubscribeInDifferentThreads() throws InterruptedException {
+    void givenFlux_whenInParallel_thenSubscribeInDifferentThreads() throws InterruptedException {
         List<String> threadNames = new ArrayList<>();
 
         Flux.just(1, 2, 3, 4)
@@ -106,7 +106,7 @@ public class ReactorIntegrationTest {
     }
 
     @Test
-    public void givenConnectableFlux_whenConnected_thenShouldStream() {
+    void givenConnectableFlux_whenConnected_thenShouldStream() {
 
         List<Integer> elements = new ArrayList<>();
 
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/security/SecurityIntegrationTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/security/SecurityIntegrationTest.java
index 0ef828df5a..6bf39e4791 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/security/SecurityIntegrationTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/security/SecurityIntegrationTest.java
@@ -2,17 +2,14 @@ package com.baeldung.reactive.security;
 
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.context.ApplicationContext;
 import org.springframework.security.test.context.support.WithMockUser;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.test.web.reactive.server.WebTestClient;
 
-@ExtendWith(SpringExtension.class)
-@ContextConfiguration(classes = SpringSecurity5Application.class)
-public class SecurityIntegrationTest {
+@SpringBootTest(classes = SpringSecurity5Application.class)
+class SecurityIntegrationTest {
 
     @Autowired
     private ApplicationContext context;
@@ -20,14 +17,14 @@ public class SecurityIntegrationTest {
     private WebTestClient webTestClient;
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         webTestClient = WebTestClient.bindToApplicationContext(context)
           .configureClient()
           .build();
     }
 
     @Test
-    public void whenNoCredentials_thenRedirectToLogin() {
+    void whenNoCredentials_thenRedirectToLogin() {
         webTestClient.get()
           .uri("/")
           .exchange()
@@ -36,7 +33,7 @@ public class SecurityIntegrationTest {
 
     @Test
     @WithMockUser
-    public void whenHasCredentials_thenSeesGreeting() {
+    void whenHasCredentials_thenSeesGreeting() {
         webTestClient.get()
           .uri("/")
           .exchange()
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/webclient/SpringContextTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/webclient/SpringContextTest.java
index 4a1fc4390a..7cef90472c 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/webclient/SpringContextTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/webclient/SpringContextTest.java
@@ -4,9 +4,9 @@ import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 
 @SpringBootTest(classes = WebClientApplication.class)
-public class SpringContextTest {
+class SpringContextTest {
 
     @Test
-    public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+    void whenSpringContextIsBootstrapped_thenNoExceptions() {
     }
 }
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebClientIntegrationTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebClientIntegrationTest.java
index 22c545c362..f52a20b149 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebClientIntegrationTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebClientIntegrationTest.java
@@ -43,7 +43,7 @@ import java.util.concurrent.TimeUnit;
 import static org.assertj.core.api.Assertions.assertThat;
 
 @SpringBootTest(classes = WebClientApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
-public class WebClientIntegrationTest {
+class WebClientIntegrationTest {
 
     private static final String BODY_VALUE = "bodyValue";
     private static final ParameterizedTypeReference<Map<String, String>> MAP_RESPONSE_REF = new ParameterizedTypeReference<Map<String, String>>() {
@@ -53,7 +53,7 @@ public class WebClientIntegrationTest {
     private int port;
 
     @Test
-    public void givenDifferentWebClientCreationMethods_whenUsed_thenObtainExpectedResponse() {
+    void givenDifferentWebClientCreationMethods_whenUsed_thenObtainExpectedResponse() {
         // WebClient creation
         WebClient client1 = WebClient.create();
         WebClient client2 = WebClient.create("http://localhost:" + port);
@@ -83,7 +83,7 @@ public class WebClientIntegrationTest {
     }
 
     @Test
-    public void givenDifferentMethodSpecifications_whenUsed_thenObtainExpectedResponse() {
+    void givenDifferentMethodSpecifications_whenUsed_thenObtainExpectedResponse() {
         // request specification
         RequestBodyUriSpec uriSpecPost1 = createDefaultClient().method(HttpMethod.POST);
         RequestBodyUriSpec uriSpecPost2 = createDefaultClient().post();
@@ -103,7 +103,7 @@ public class WebClientIntegrationTest {
     }
 
     @Test
-    public void givenDifferentUriSpecifications_whenUsed_thenObtainExpectedResponse() {
+    void givenDifferentUriSpecifications_whenUsed_thenObtainExpectedResponse() {
         // uri specification
         RequestBodySpec bodySpecUsingString = createDefaultPostRequest().uri("/resource");
         RequestBodySpec bodySpecUsingUriBuilder = createDefaultPostRequest().uri(
@@ -140,7 +140,7 @@ public class WebClientIntegrationTest {
     }
 
     @Test
-    public void givenDifferentBodySpecifications_whenUsed_thenObtainExpectedResponse() {
+    void givenDifferentBodySpecifications_whenUsed_thenObtainExpectedResponse() {
         // request body specifications
         RequestHeadersSpec<?> headersSpecPost1 = createDefaultPostResourceRequest().body(
           BodyInserters.fromPublisher(Mono.just(BODY_VALUE), String.class));
@@ -194,7 +194,7 @@ public class WebClientIntegrationTest {
     }
 
     @Test
-    public void givenPostSpecifications_whenHeadersAdded_thenObtainExpectedResponse() {
+    void givenPostSpecifications_whenHeadersAdded_thenObtainExpectedResponse() {
         // request header specification
         RequestHeadersSpec<?> headersSpecInserterStringWithHeaders = createDefaultPostResourceRequestResponse().header(
             HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
@@ -210,7 +210,7 @@ public class WebClientIntegrationTest {
     }
 
     @Test
-    public void givenDifferentResponseSpecifications_whenUsed_thenObtainExpectedResponse() {
+    void givenDifferentResponseSpecifications_whenUsed_thenObtainExpectedResponse() {
         ResponseSpec responseSpecPostString = createDefaultPostResourceRequestResponse().retrieve();
         Mono<String> responsePostString = responseSpecPostString.bodyToMono(String.class);
         Mono<String> responsePostString2 = createDefaultPostResourceRequestResponse().exchangeToMono(response -> {
@@ -255,7 +255,7 @@ public class WebClientIntegrationTest {
     }
 
     @Test
-    public void givenWebClientWithTimeoutConfigurations_whenRequestUsingWronglyConfiguredPublisher_thenObtainTimeout() {
+    void givenWebClientWithTimeoutConfigurations_whenRequestUsingWronglyConfiguredPublisher_thenObtainTimeout() {
         HttpClient httpClient = HttpClient.create()
           .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000)
           .responseTimeout(Duration.ofMillis(1000))
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebControllerIntegrationTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebControllerIntegrationTest.java
index 22bd2829d3..f4d2f4384f 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebControllerIntegrationTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebControllerIntegrationTest.java
@@ -13,7 +13,7 @@ import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFOR
 
 @DirtiesContext(classMode = BEFORE_CLASS)
 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = WebClientApplication.class)
-public class WebControllerIntegrationTest {
+class WebControllerIntegrationTest {
 
     @LocalServerPort
     private int randomServerPort;
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebTestClientIntegrationTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebTestClientIntegrationTest.java
index dc2a2a30b9..6c7433dfe3 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebTestClientIntegrationTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebTestClientIntegrationTest.java
@@ -16,7 +16,7 @@ import org.springframework.web.server.WebHandler;
 import reactor.core.publisher.Mono;
 
 @SpringBootTest(classes = WebClientApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
-public class WebTestClientIntegrationTest {
+class WebTestClientIntegrationTest {
 
     @LocalServerPort
     private int port;
@@ -28,7 +28,7 @@ public class WebTestClientIntegrationTest {
     private WebClientController controller;
 
     @Test
-    public void whenBindToWebHandler_thenRequestProcessed() {
+    void whenBindToWebHandler_thenRequestProcessed() {
         WebHandler webHandler = exchange -> Mono.empty();
 
         WebTestClient.bindToWebHandler(webHandler)
@@ -39,7 +39,7 @@ public class WebTestClientIntegrationTest {
     }
 
     @Test
-    public void whenBindToRouter_thenRequestProcessed() {
+    void whenBindToRouter_thenRequestProcessed() {
         RouterFunction<ServerResponse> routerFunction = RouterFunctions.route(
           RequestPredicates.GET("/resource"),
           request -> ServerResponse.ok().build()
@@ -55,7 +55,7 @@ public class WebTestClientIntegrationTest {
 
     @Test
     @WithMockUser
-    public void whenBindToServer_thenRequestProcessed() {
+    void whenBindToServer_thenRequestProcessed() {
         WebTestClient.bindToServer()
           .baseUrl("http://localhost:" + port).build()
           .get().uri("/resource")
@@ -66,7 +66,7 @@ public class WebTestClientIntegrationTest {
 
     @Test
     @WithMockUser
-    public void whenBindToApplicationContext_thenRequestProcessed() {
+    void whenBindToApplicationContext_thenRequestProcessed() {
         WebTestClient.bindToApplicationContext(context)
           .build()
           .get().uri("/resource")
@@ -76,7 +76,7 @@ public class WebTestClientIntegrationTest {
     }
 
     @Test
-    public void whenBindToController_thenRequestProcessed() {
+    void whenBindToController_thenRequestProcessed() {
         WebTestClient.bindToController(controller)
           .build()
           .get().uri("/resource")
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/webclientrequests/WebClientRequestsWithParametersUnitTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/webclientrequests/WebClientRequestsWithParametersUnitTest.java
index eefde078e1..3e09521e04 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/webclientrequests/WebClientRequestsWithParametersUnitTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/webclientrequests/WebClientRequestsWithParametersUnitTest.java
@@ -1,13 +1,11 @@
 package com.baeldung.reactive.webclientrequests;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mock;
 import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
-import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.web.reactive.function.client.ClientRequest;
 import org.springframework.web.reactive.function.client.ClientResponse;
 import org.springframework.web.reactive.function.client.ExchangeFunction;
@@ -15,15 +13,14 @@ import org.springframework.web.reactive.function.client.WebClient;
 import org.springframework.web.util.DefaultUriBuilderFactory;
 import reactor.core.publisher.Mono;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
-@RunWith(SpringRunner.class)
 @WebFluxTest
-public class WebClientRequestsWithParametersUnitTest {
+class WebClientRequestsWithParametersUnitTest {
 
     private static final String BASE_URL = "https://example.com";
 
@@ -35,8 +32,8 @@ public class WebClientRequestsWithParametersUnitTest {
     @Mock
     private ExchangeFunction exchangeFunction;
 
-    @Before
-    public void init() {
+    @BeforeEach
+    void init() {
         ClientResponse mockResponse = mock(ClientResponse.class);
         when(mockResponse.bodyToMono(String.class)).thenReturn(Mono.just("test"));
         when(exchangeFunction.exchange(argumentCaptor.capture())).thenReturn(Mono.just(mockResponse));
@@ -49,7 +46,7 @@ public class WebClientRequestsWithParametersUnitTest {
     }
 
     @Test
-    public void whenCallSimpleURI_thenURIMatched() {
+    void whenCallSimpleURI_thenURIMatched() {
         webClient.get()
           .uri("/products")
           .retrieve()
@@ -60,7 +57,7 @@ public class WebClientRequestsWithParametersUnitTest {
     }
 
     @Test
-    public void whenCallSinglePathSegmentUri_thenURIMatched() {
+    void whenCallSinglePathSegmentUri_thenURIMatched() {
         webClient.get()
           .uri(uriBuilder -> uriBuilder
             .path("/products/{id}")
@@ -73,7 +70,7 @@ public class WebClientRequestsWithParametersUnitTest {
     }
 
     @Test
-    public void whenCallMultiplePathSegmentsUri_thenURIMatched() {
+    void whenCallMultiplePathSegmentsUri_thenURIMatched() {
         webClient.get()
           .uri(uriBuilder -> uriBuilder
             .path("/products/{id}/attributes/{attributeId}")
@@ -86,7 +83,7 @@ public class WebClientRequestsWithParametersUnitTest {
     }
 
     @Test
-    public void whenCallSingleQueryParams_thenURIMatched() {
+    void whenCallSingleQueryParams_thenURIMatched() {
         webClient.get()
           .uri(uriBuilder -> uriBuilder
             .path("/products/")
@@ -102,7 +99,7 @@ public class WebClientRequestsWithParametersUnitTest {
     }
 
     @Test
-    public void whenCallSingleQueryParamsPlaceholders_thenURIMatched() {
+    void whenCallSingleQueryParamsPlaceholders_thenURIMatched() {
         webClient.get()
           .uri(uriBuilder -> uriBuilder
             .path("/products/")
@@ -118,7 +115,7 @@ public class WebClientRequestsWithParametersUnitTest {
     }
 
     @Test
-    public void whenCallArrayQueryParamsBrackets_thenURIMatched() {
+    void whenCallArrayQueryParamsBrackets_thenURIMatched() {
         webClient.get()
           .uri(uriBuilder -> uriBuilder
             .path("/products/")
@@ -132,7 +129,7 @@ public class WebClientRequestsWithParametersUnitTest {
     }
 
     @Test
-    public void whenCallArrayQueryParams_thenURIMatched() {
+    void whenCallArrayQueryParams_thenURIMatched() {
         webClient.get()
           .uri(uriBuilder -> uriBuilder
             .path("/products/")
@@ -146,7 +143,7 @@ public class WebClientRequestsWithParametersUnitTest {
     }
 
     @Test
-    public void whenCallArrayQueryParamsComma_thenURIMatched() {
+    void whenCallArrayQueryParamsComma_thenURIMatched() {
         webClient.get()
           .uri(uriBuilder -> uriBuilder
             .path("/products/")
@@ -160,7 +157,7 @@ public class WebClientRequestsWithParametersUnitTest {
     }
 
     @Test
-    public void whenUriComponentEncoding_thenQueryParamsNotEscaped() {
+    void whenUriComponentEncoding_thenQueryParamsNotEscaped() {
         DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(BASE_URL);
         factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.URI_COMPONENT);
         webClient = WebClient
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/webflux/annotation/EmployeeControllerIntegrationTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/webflux/annotation/EmployeeControllerIntegrationTest.java
index 699bc9c154..5825b815c2 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/webflux/annotation/EmployeeControllerIntegrationTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/webflux/annotation/EmployeeControllerIntegrationTest.java
@@ -2,13 +2,11 @@ package com.baeldung.reactive.webflux.annotation;
 
 import com.baeldung.reactive.webflux.Employee;
 import com.baeldung.reactive.webflux.EmployeeRepository;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.mock.mockito.MockBean;
 import org.springframework.security.test.context.support.WithMockUser;
-import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.reactive.server.WebTestClient;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
@@ -21,9 +19,8 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoInteractions;
 import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
 
-@RunWith(SpringRunner.class)
 @SpringBootTest(webEnvironment = RANDOM_PORT, classes = EmployeeSpringApplication.class)
-public class EmployeeControllerIntegrationTest {
+class EmployeeControllerIntegrationTest {
 
     @Autowired
     private WebTestClient testClient;
@@ -32,7 +29,7 @@ public class EmployeeControllerIntegrationTest {
     private EmployeeRepository employeeRepository;
 
     @Test
-    public void givenEmployeeId_whenGetEmployeeById_thenCorrectEmployee() {
+    void givenEmployeeId_whenGetEmployeeById_thenCorrectEmployee() {
 
         Employee employee = new Employee("1", "Employee 1 Name");
 
@@ -46,7 +43,7 @@ public class EmployeeControllerIntegrationTest {
     }
 
     @Test
-    public void whenGetAllEmployees_thenCorrectEmployees() {
+    void whenGetAllEmployees_thenCorrectEmployees() {
         List<Employee> employeeList = Arrays.asList(
           new Employee("1", "Employee 1 Name"),
           new Employee("2", "Employee 2 Name"),
@@ -65,7 +62,7 @@ public class EmployeeControllerIntegrationTest {
 
     @Test
     @WithMockUser(username = "admin", roles = { "ADMIN" })
-    public void givenValidUser_whenUpdateEmployee_thenEmployeeUpdated() {
+    void givenValidUser_whenUpdateEmployee_thenEmployeeUpdated() {
         Employee employee = new Employee("10", "Employee 10 Updated");
 
         given(employeeRepository.updateEmployee(employee)).willReturn(Mono.just(employee));
@@ -82,7 +79,7 @@ public class EmployeeControllerIntegrationTest {
 
     @Test
     @WithMockUser
-    public void givenInvalidUser_whenUpdateEmployee_thenForbidden() {
+    void givenInvalidUser_whenUpdateEmployee_thenForbidden() {
         Employee employee = new Employee("10", "Employee 10 Updated");
 
         testClient.post()
diff --git a/spring-reactive/src/test/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalIntegrationTest.java b/spring-reactive/src/test/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalIntegrationTest.java
index 5a54820e23..be2b64ae30 100644
--- a/spring-reactive/src/test/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalIntegrationTest.java
+++ b/spring-reactive/src/test/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalIntegrationTest.java
@@ -2,12 +2,10 @@ package com.baeldung.reactive.webflux.functional;
 
 import com.baeldung.reactive.webflux.Employee;
 import com.baeldung.reactive.webflux.EmployeeRepository;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.web.reactive.server.WebTestClient;
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
@@ -19,9 +17,8 @@ import static org.mockito.BDDMockito.given;
 import static org.mockito.Mockito.verify;
 import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
 
-@RunWith(SpringRunner.class)
 @SpringBootTest(webEnvironment = RANDOM_PORT, classes = EmployeeSpringFunctionalApplication.class)
-public class EmployeeSpringFunctionalIntegrationTest {
+class EmployeeSpringFunctionalIntegrationTest {
 
     @Autowired
     private EmployeeFunctionalConfig config;
@@ -30,7 +27,7 @@ public class EmployeeSpringFunctionalIntegrationTest {
     private EmployeeRepository employeeRepository;
 
     @Test
-    public void givenEmployeeId_whenGetEmployeeById_thenCorrectEmployee() {
+    void givenEmployeeId_whenGetEmployeeById_thenCorrectEmployee() {
         WebTestClient client = WebTestClient.bindToRouterFunction(config.getEmployeeByIdRoute())
             .build();
 
@@ -48,7 +45,7 @@ public class EmployeeSpringFunctionalIntegrationTest {
     }
 
     @Test
-    public void whenGetAllEmployees_thenCorrectEmployees() {
+    void whenGetAllEmployees_thenCorrectEmployees() {
         WebTestClient client = WebTestClient.bindToRouterFunction(config.getAllEmployeesRoute())
             .build();
 
@@ -67,7 +64,7 @@ public class EmployeeSpringFunctionalIntegrationTest {
     }
 
     @Test
-    public void whenUpdateEmployee_thenEmployeeUpdated() {
+    void whenUpdateEmployee_thenEmployeeUpdated() {
         WebTestClient client = WebTestClient.bindToRouterFunction(config.updateEmployeeRoute())
             .build();