Skip to content

Commit c882218

Browse files
authored
Merge pull request #434 from piomin/renovate/org.springdoc-springdoc-openapi-starter-webmvc-ui-3.x
Update dependency org.springdoc:springdoc-openapi-starter-webmvc-ui to v3
2 parents 3866867 + 17d7259 commit c882218

7 files changed

Lines changed: 123 additions & 49 deletions

File tree

micro-springboot/insurance-service/pom.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.5.11</version>
8+
<version>4.0.3</version>
99
<relativePath />
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
@@ -43,17 +43,17 @@
4343
<dependency>
4444
<groupId>org.springdoc</groupId>
4545
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
46-
<version>2.8.16</version>
46+
<version>3.0.2</version>
4747
</dependency>
4848

4949
<dependency>
5050
<groupId>com.blazebit</groupId>
51-
<artifactId>blaze-persistence-integration-spring-data-3.4</artifactId>
51+
<artifactId>blaze-persistence-integration-spring-data-4.0</artifactId>
5252
<version>${blaze.version}</version>
5353
</dependency>
5454
<dependency>
5555
<groupId>com.blazebit</groupId>
56-
<artifactId>blaze-persistence-integration-hibernate-6.2</artifactId>
56+
<artifactId>blaze-persistence-integration-hibernate-7.1</artifactId>
5757
<version>${blaze.version}</version>
5858
<scope>runtime</scope>
5959
</dependency>
@@ -68,6 +68,11 @@
6868
<artifactId>spring-boot-starter-test</artifactId>
6969
<scope>test</scope>
7070
</dependency>
71+
<dependency>
72+
<groupId>org.springframework.boot</groupId>
73+
<artifactId>spring-boot-starter-webflux</artifactId>
74+
<scope>test</scope>
75+
</dependency>
7176
<dependency>
7277
<groupId>org.springframework.boot</groupId>
7378
<artifactId>spring-boot-testcontainers</artifactId>

micro-springboot/insurance-service/src/main/java/pl/redhat/samples/insurance/InsuranceApplication.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.blazebit.persistence.view.spi.EntityViewConfiguration;
1010
import org.springframework.boot.SpringApplication;
1111
import org.springframework.boot.autoconfigure.SpringBootApplication;
12-
import org.springframework.boot.web.client.RestTemplateBuilder;
1312
import org.springframework.context.annotation.Bean;
1413
import org.springframework.web.client.RestTemplate;
1514

@@ -27,7 +26,7 @@ public static void main(String[] args) {
2726

2827
@Bean
2928
RestTemplate restTemplate() {
30-
return new RestTemplateBuilder().build();
29+
return new RestTemplate();
3130
}
3231

3332
@PersistenceUnit
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
insert into insurance(personId, type, amount) values(1, 'MEDICAL', 1000);
2-
insert into insurance(personId, type, amount) values(2, 'MEDICAL', 800);
3-
insert into insurance(personId, type, amount) values(3, 'LIFE', 30000);
4-
insert into insurance(personId, type, amount) values(4, 'LIFE', 20000);
5-
insert into insurance(personId, type, amount) values(5, 'MEDICAL', 1500);
6-
insert into insurance(personId, type, amount) values(6, 'LIFE', 50000);
7-
insert into insurance(personId, type, amount) values(7, 'LIFE', 50000);
1+
insert into insurance(person_id, type, amount) values(1, 'MEDICAL', 1000);
2+
insert into insurance(person_id, type, amount) values(2, 'MEDICAL', 800);
3+
insert into insurance(person_id, type, amount) values(3, 'LIFE', 30000);
4+
insert into insurance(person_id, type, amount) values(4, 'LIFE', 20000);
5+
insert into insurance(person_id, type, amount) values(5, 'MEDICAL', 1500);
6+
insert into insurance(person_id, type, amount) values(6, 'LIFE', 50000);
7+
insert into insurance(person_id, type, amount) values(7, 'LIFE', 50000);

micro-springboot/insurance-service/src/test/java/pl/redhat/samples/insurance/InsuranceControllerTests.java

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,33 @@
33
import org.instancio.Instancio;
44
import org.instancio.Select;
55
import org.junit.jupiter.api.*;
6-
import org.springframework.beans.factory.annotation.Autowired;
76
import org.springframework.boot.test.context.SpringBootTest;
8-
import org.springframework.boot.test.web.client.TestRestTemplate;
7+
import org.springframework.boot.test.web.server.LocalServerPort;
98
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
10-
import org.springframework.test.context.DynamicPropertyRegistry;
11-
import org.springframework.test.context.DynamicPropertySource;
9+
import org.springframework.test.web.reactive.server.WebTestClient;
1210
import org.testcontainers.containers.PostgreSQLContainer;
1311
import org.testcontainers.junit.jupiter.Container;
1412
import org.testcontainers.junit.jupiter.Testcontainers;
1513
import pl.redhat.samples.insurance.domain.Insurance;
1614

15+
import java.util.List;
16+
1717
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1818
@Testcontainers
1919
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
2020
public class InsuranceControllerTests {
2121

22-
@Autowired
23-
TestRestTemplate restTemplate;
22+
@LocalServerPort
23+
int port;
24+
25+
WebTestClient webTestClient;
26+
27+
@BeforeEach
28+
void setUp() {
29+
webTestClient = WebTestClient.bindToServer()
30+
.baseUrl("http://localhost:" + port)
31+
.build();
32+
}
2433

2534
@Container
2635
@ServiceConnection
@@ -33,9 +42,14 @@ void add() {
3342
Insurance insurance = Instancio.of(Insurance.class)
3443
.ignore(Select.field("id"))
3544
.create();
36-
insurance = restTemplate.postForObject("/insurances", insurance, Insurance.class);
37-
Assertions.assertNotNull(insurance);
38-
Assertions.assertNotNull(insurance.getId());
45+
Insurance saved = webTestClient.post().uri("/insurances")
46+
.bodyValue(insurance)
47+
.exchange()
48+
.expectStatus().isOk()
49+
.expectBody(Insurance.class)
50+
.returnResult().getResponseBody();
51+
Assertions.assertNotNull(saved);
52+
Assertions.assertNotNull(saved.getId());
3953
}
4054

4155
@Test
@@ -45,25 +59,42 @@ void updateAndGet() {
4559
Insurance insurance = Instancio.of(Insurance.class)
4660
.set(Select.field("id"), id)
4761
.create();
48-
restTemplate.put("/insurances", insurance);
49-
Insurance updated = restTemplate.getForObject("/insurances/{id}", Insurance.class, id);
50-
Assertions.assertNotNull(insurance);
51-
Assertions.assertNotNull(insurance.getId());
52-
Assertions.assertEquals(id, insurance.getId());
62+
webTestClient.put().uri("/insurances")
63+
.bodyValue(insurance)
64+
.exchange();
65+
Insurance updated = webTestClient.get().uri("/insurances/{id}", id)
66+
.exchange()
67+
.expectStatus().isOk()
68+
.expectBody(Insurance.class)
69+
.returnResult().getResponseBody();
70+
Assertions.assertNotNull(updated);
71+
Assertions.assertNotNull(updated.getId());
72+
Assertions.assertEquals(id, updated.getId());
5373
}
5474

5575
@Test
5676
@Order(3)
5777
void getAll() {
58-
Insurance[] insurances = restTemplate.getForObject("/insurances", Insurance[].class);
59-
Assertions.assertEquals(1, insurances.length);
78+
List<Insurance> insurances = webTestClient.get().uri("/insurances")
79+
.exchange()
80+
.expectStatus().isOk()
81+
.expectBodyList(Insurance.class)
82+
.hasSize(8)
83+
.returnResult().getResponseBody();
84+
Assertions.assertNotNull(insurances);
85+
Assertions.assertEquals(8, insurances.size());
6086
}
6187

6288
@Test
6389
@Order(4)
6490
void deleteAndGet() {
65-
restTemplate.delete("/insurances/{id}", 1);
66-
Insurance insurance = restTemplate.getForObject("/insurances/{id}", Insurance.class, 1);
91+
webTestClient.delete().uri("/insurances/{id}", 1)
92+
.exchange()
93+
.expectStatus().isOk();
94+
Insurance insurance = webTestClient.get().uri("/insurances/{id}", 1)
95+
.exchange()
96+
.expectBody(Insurance.class)
97+
.returnResult().getResponseBody();
6798
Assertions.assertNull(insurance);
6899
}
69100

micro-springboot/person-service/pom.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.5.11</version>
8+
<version>4.0.3</version>
99
<relativePath />
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
@@ -47,17 +47,17 @@
4747
<dependency>
4848
<groupId>org.springdoc</groupId>
4949
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
50-
<version>2.8.16</version>
50+
<version>3.0.2</version>
5151
</dependency>
5252

5353
<dependency>
5454
<groupId>com.blazebit</groupId>
55-
<artifactId>blaze-persistence-integration-spring-data-3.4</artifactId>
55+
<artifactId>blaze-persistence-integration-spring-data-4.0</artifactId>
5656
<version>${blaze.version}</version>
5757
</dependency>
5858
<dependency>
5959
<groupId>com.blazebit</groupId>
60-
<artifactId>blaze-persistence-integration-hibernate-6.2</artifactId>
60+
<artifactId>blaze-persistence-integration-hibernate-7.1</artifactId>
6161
<version>${blaze.version}</version>
6262
<scope>runtime</scope>
6363
</dependency>
@@ -72,6 +72,11 @@
7272
<artifactId>spring-boot-starter-test</artifactId>
7373
<scope>test</scope>
7474
</dependency>
75+
<dependency>
76+
<groupId>org.springframework.boot</groupId>
77+
<artifactId>spring-boot-starter-webflux</artifactId>
78+
<scope>test</scope>
79+
</dependency>
7580
<dependency>
7681
<groupId>org.springframework.boot</groupId>
7782
<artifactId>spring-boot-testcontainers</artifactId>

micro-springboot/person-service/src/test/java/pl/redhat/samples/person/PersonControllerTests.java

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,33 @@
33
import org.instancio.Instancio;
44
import org.instancio.Select;
55
import org.junit.jupiter.api.*;
6-
import org.springframework.beans.factory.annotation.Autowired;
76
import org.springframework.boot.test.context.SpringBootTest;
8-
import org.springframework.boot.test.web.client.TestRestTemplate;
7+
import org.springframework.boot.test.web.server.LocalServerPort;
98
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
9+
import org.springframework.test.web.reactive.server.WebTestClient;
1010
import org.testcontainers.containers.PostgreSQLContainer;
1111
import org.testcontainers.junit.jupiter.Container;
1212
import org.testcontainers.junit.jupiter.Testcontainers;
1313
import pl.redhat.samples.person.domain.Person;
1414

15+
import java.util.List;
16+
1517
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
1618
@Testcontainers
1719
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
1820
public class PersonControllerTests {
1921

20-
@Autowired
21-
TestRestTemplate restTemplate;
22+
@LocalServerPort
23+
int port;
24+
25+
WebTestClient webTestClient;
26+
27+
@BeforeEach
28+
void setUp() {
29+
webTestClient = WebTestClient.bindToServer()
30+
.baseUrl("http://localhost:" + port)
31+
.build();
32+
}
2233

2334
@Container
2435
@ServiceConnection
@@ -31,9 +42,14 @@ void add() {
3142
Person person = Instancio.of(Person.class)
3243
.ignore(Select.field("id"))
3344
.create();
34-
person = restTemplate.postForObject("/persons", person, Person.class);
35-
Assertions.assertNotNull(person);
36-
Assertions.assertNotNull(person.getId());
45+
Person saved = webTestClient.post().uri("/persons")
46+
.bodyValue(person)
47+
.exchange()
48+
.expectStatus().isOk()
49+
.expectBody(Person.class)
50+
.returnResult().getResponseBody();
51+
Assertions.assertNotNull(saved);
52+
Assertions.assertNotNull(saved.getId());
3753
}
3854

3955
@Test
@@ -43,8 +59,15 @@ void updateAndGet() {
4359
Person person = Instancio.of(Person.class)
4460
.set(Select.field("id"), id)
4561
.create();
46-
restTemplate.put("/persons", person);
47-
Person updated = restTemplate.getForObject("/persons/{id}", Person.class, id);
62+
webTestClient.put().uri("/persons")
63+
.bodyValue(person)
64+
.exchange()
65+
.expectStatus().isOk();
66+
Person updated = webTestClient.get().uri("/persons/{id}", id)
67+
.exchange()
68+
.expectStatus().isOk()
69+
.expectBody(Person.class)
70+
.returnResult().getResponseBody();
4871
Assertions.assertNotNull(updated);
4972
Assertions.assertNotNull(updated.getId());
5073
Assertions.assertEquals(id, updated.getId());
@@ -53,15 +76,26 @@ void updateAndGet() {
5376
@Test
5477
@Order(3)
5578
void getAll() {
56-
Person[] persons = restTemplate.getForObject("/persons", Person[].class);
57-
Assertions.assertEquals(1, persons.length);
79+
List<Person> persons = webTestClient.get().uri("/persons")
80+
.exchange()
81+
.expectStatus().isOk()
82+
.expectBodyList(Person.class)
83+
.hasSize(1)
84+
.returnResult().getResponseBody();
85+
Assertions.assertNotNull(persons);
86+
Assertions.assertEquals(1, persons.size());
5887
}
5988

6089
@Test
6190
@Order(4)
6291
void deleteAndGet() {
63-
restTemplate.delete("/persons/{id}", 1);
64-
Person person = restTemplate.getForObject("/persons/{id}", Person.class, 1);
92+
webTestClient.delete().uri("/persons/{id}", 1)
93+
.exchange()
94+
.expectStatus().isOk();
95+
Person person = webTestClient.get().uri("/persons/{id}", 1)
96+
.exchange()
97+
.expectBody(Person.class)
98+
.returnResult().getResponseBody();
6599
Assertions.assertNull(person);
66100
}
67101

micro-springboot/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<properties>
2323
<testcontainers.version>1.21.4</testcontainers.version>
24-
<blaze.version>1.6.11</blaze.version>
24+
<blaze.version>1.6.18</blaze.version>
2525
<sonar.moduleKey>${project.artifactId}</sonar.moduleKey>
2626
</properties>
2727

0 commit comments

Comments
 (0)