Skip to content

Commit 5403336

Browse files
Replace @MockBean with @MockitoBean and keep Java 21
Co-Authored-By: Philip Riecks <mail@philipriecks.de>
1 parent e89b2e8 commit 5403336

7 files changed

+14
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Masterclass](https://rieckpil.de/wp-content/uploads/2020/09/testing-spring-boot-applications-masterclass-course-logo.png)](https://rieckpil.de/testing-spring-boot-applications-masterclass/)
44

55
[![](https://img.shields.io/badge/Spring%20Boot%20Version-3.4.5-orange)](/pom.xml)
6-
[![](https://img.shields.io/badge/Java%20Version-17-orange)](/pom.xml)
6+
[![](https://img.shields.io/badge/Java%20Version-21-orange)](/pom.xml)
77
[![](https://img.shields.io/badge/Enroll-Now-orange)](https://rieckpil.de/testing-spring-boot-applications-masterclass/)
88

99
## 😓 Tired of the Friday Afternoon Dread?

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<description>Testing Spring Boot Applications Masterclass</description>
1818

1919
<properties>
20-
<java.version>17</java.version>
20+
<java.version>21</java.version>
2121
<node.version>v18.16.0</node.version>
2222
<spring-cloud-aws.version>3.3.0</spring-cloud-aws.version>
2323
<testcontainers.version>1.20.6</testcontainers.version>

src/test/java/de/rieckpil/courses/book/management/BookSynchronizationListenerSliceNewTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.slf4j.Logger;
1212
import org.slf4j.LoggerFactory;
1313
import org.springframework.beans.factory.annotation.Autowired;
14-
import org.springframework.boot.test.mock.mockito.MockBean;
14+
import org.springframework.boot.test.mock.mockito.MockitoBean;
1515
import org.springframework.test.context.DynamicPropertyRegistry;
1616
import org.springframework.test.context.DynamicPropertySource;
1717
import org.testcontainers.containers.localstack.LocalStackContainer;
@@ -59,9 +59,9 @@ static void configureProperties(DynamicPropertyRegistry registry) {
5959

6060
@Autowired private SqsTemplate sqsTemplate;
6161

62-
@MockBean private BookRepository bookRepository;
62+
@MockitoBean private BookRepository bookRepository;
6363

64-
@MockBean private OpenLibraryApiClient openLibraryApiClient;
64+
@MockitoBean private OpenLibraryApiClient openLibraryApiClient;
6565

6666
@Test
6767
void shouldConsumeMessageWhenPayloadIsCorrect() {

src/test/java/de/rieckpil/courses/book/management/BookSynchronizationListenerSliceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.springframework.beans.factory.annotation.Autowired;
1818
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
1919
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
20-
import org.springframework.boot.test.mock.mockito.MockBean;
20+
import org.springframework.boot.test.mock.mockito.MockitoBean;
2121
import org.springframework.context.annotation.Import;
2222
import org.springframework.test.context.DynamicPropertyRegistry;
2323
import org.springframework.test.context.DynamicPropertySource;
@@ -79,9 +79,9 @@ static void configureProperties(DynamicPropertyRegistry registry) {
7979

8080
@Autowired private SqsTemplate sqsTemplate;
8181

82-
@MockBean private BookRepository bookRepository;
82+
@MockitoBean private BookRepository bookRepository;
8383

84-
@MockBean private OpenLibraryApiClient openLibraryApiClient;
84+
@MockitoBean private OpenLibraryApiClient openLibraryApiClient;
8585

8686
@Test
8787
void shouldStartSQS() {

src/test/java/de/rieckpil/courses/book/review/ReviewControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.junit.jupiter.api.Test;
1010
import org.springframework.beans.factory.annotation.Autowired;
1111
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
12-
import org.springframework.boot.test.mock.mockito.MockBean;
12+
import org.springframework.boot.test.mock.mockito.MockitoBean;
1313
import org.springframework.context.annotation.Import;
1414
import org.springframework.http.MediaType;
1515
import org.springframework.security.test.context.support.WithMockUser;
@@ -27,7 +27,7 @@
2727
@Import(WebSecurityConfig.class)
2828
class ReviewControllerTest {
2929

30-
@MockBean private ReviewService reviewService;
30+
@MockitoBean private ReviewService reviewService;
3131

3232
@Autowired private MockMvc mockMvc;
3333

src/test/java/de/rieckpil/courses/cache/BookControllerOneTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.junit.jupiter.api.Test;
1010
import org.springframework.beans.factory.annotation.Autowired;
1111
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
12-
import org.springframework.boot.test.mock.mockito.MockBean;
12+
import org.springframework.boot.test.mock.mockito.MockitoBean;
1313
import org.springframework.context.annotation.Import;
1414
import org.springframework.http.HttpHeaders;
1515
import org.springframework.http.MediaType;
@@ -28,7 +28,7 @@
2828
@Import(WebSecurityConfig.class)
2929
class BookControllerOneTest {
3030

31-
@MockBean private BookManagementService bookManagementService;
31+
@MockitoBean private BookManagementService bookManagementService;
3232

3333
@Autowired private MockMvc mockMvc;
3434

src/test/java/de/rieckpil/courses/cache/BookControllerTwoTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.junit.jupiter.api.Test;
1010
import org.springframework.beans.factory.annotation.Autowired;
1111
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
12-
import org.springframework.boot.test.mock.mockito.MockBean;
12+
import org.springframework.boot.test.mock.mockito.MockitoBean;
1313
import org.springframework.context.annotation.Import;
1414
import org.springframework.http.HttpHeaders;
1515
import org.springframework.http.MediaType;
@@ -31,7 +31,7 @@
3131
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
3232
class BookControllerTwoTest {
3333

34-
@MockBean private BookManagementService bookManagementService;
34+
@MockitoBean private BookManagementService bookManagementService;
3535

3636
@Autowired private MockMvc mockMvc;
3737

0 commit comments

Comments
 (0)