Skip to content

Commit 5940b60

Browse files
Update dependencies and improve test method naming conventions
Signed-off-by: Patrick Baumgartner <contact@patbaumgartner.com>
1 parent e316074 commit 5940b60

16 files changed

+77
-66
lines changed

pom.xml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4+
45
<parent>
56
<groupId>org.springframework.boot</groupId>
67
<artifactId>spring-boot-starter-parent</artifactId>
7-
<version>4.0.1</version>
8+
<version>4.0.3</version>
89
</parent>
10+
911
<groupId>org.springframework.samples</groupId>
1012
<artifactId>spring-petclinic</artifactId>
1113
<version>4.0.0-SNAPSHOT</version>
14+
1215
<name>petclinic</name>
1316

1417
<properties>
@@ -20,11 +23,11 @@
2023
<project.build.outputTimestamp>2024-11-28T14:37:52Z</project.build.outputTimestamp>
2124

2225
<!-- Web dependencies -->
23-
<webjars-locator.version>1.1.2</webjars-locator.version>
26+
<webjars-locator.version>1.1.3</webjars-locator.version>
2427
<webjars-bootstrap.version>5.3.8</webjars-bootstrap.version>
2528
<webjars-font-awesome.version>4.7.0</webjars-font-awesome.version>
2629

27-
<checkstyle.version>12.1.2</checkstyle.version>
30+
<checkstyle.version>13.3.0</checkstyle.version>
2831
<jacoco.version>0.8.14</jacoco.version>
2932
<libsass.version>0.3.4</libsass.version>
3033
<lifecycle-mapping>1.0.0</lifecycle-mapping>
@@ -33,13 +36,6 @@
3336
<spring-format.version>0.0.47</spring-format.version>
3437
</properties>
3538

36-
<licenses>
37-
<license>
38-
<name>Apache License, Version 2.0</name>
39-
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
40-
</license>
41-
</licenses>
42-
4339
<dependencies>
4440
<!-- Spring and Spring Boot dependencies -->
4541
<dependency>
@@ -126,6 +122,11 @@
126122
<artifactId>spring-boot-starter-data-jpa-test</artifactId>
127123
<scope>test</scope>
128124
</dependency>
125+
<dependency>
126+
<groupId>org.springframework.boot</groupId>
127+
<artifactId>spring-boot-starter-restclient</artifactId>
128+
<scope>test</scope>
129+
</dependency>
129130
<dependency>
130131
<groupId>org.springframework.boot</groupId>
131132
<artifactId>spring-boot-starter-restclient-test</artifactId>
@@ -290,6 +291,13 @@
290291
</plugin>
291292
</plugins>
292293
</build>
294+
<licenses>
295+
<license>
296+
<name>Apache License, Version 2.0</name>
297+
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
298+
</license>
299+
</licenses>
300+
293301
<profiles>
294302
<profile>
295303
<id>css</id>

src/main/java/org/springframework/samples/petclinic/model/NamedEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void setName(String name) {
4545
@Override
4646
public String toString() {
4747
String name = this.getName();
48-
return (name != null) ? name : "<null>";
48+
return name != null ? name : "<null>";
4949
}
5050

5151
}

src/main/java/org/springframework/samples/petclinic/owner/PetController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ public String initCreationForm(Owner owner, ModelMap model) {
106106
public String processCreationForm(Owner owner, @Valid Pet pet, BindingResult result,
107107
RedirectAttributes redirectAttributes) {
108108

109-
if (StringUtils.hasText(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null)
109+
if (StringUtils.hasText(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null) {
110110
result.rejectValue("name", "duplicate", "already exists");
111+
}
111112

112113
LocalDate currentDate = LocalDate.now();
113114
if (pet.getBirthDate() != null && pet.getBirthDate().isAfter(currentDate)) {

src/main/java/org/springframework/samples/petclinic/owner/PetTypeFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public PetTypeFormatter(PetTypeRepository types) {
4545
@Override
4646
public String print(PetType petType, Locale locale) {
4747
String name = petType.getName();
48-
return (name != null) ? name : "<null>";
48+
return name != null ? name : "<null>";
4949
}
5050

5151
@Override

src/test/java/org/springframework/samples/petclinic/MySqlIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ class MySqlIntegrationTests {
5959
private RestTemplateBuilder builder;
6060

6161
@Test
62-
void testFindAll() {
62+
void findAll() {
6363
vets.findAll();
6464
vets.findAll(); // served from cache
6565
}
6666

6767
@Test
68-
void testOwnerDetails() {
68+
void ownerDetails() {
6969
RestTemplate template = builder.rootUri("http://localhost:" + port).build();
7070
ResponseEntity<String> result = template.exchange(RequestEntity.get("/owners/1").build(), String.class);
7171
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);

src/test/java/org/springframework/samples/petclinic/PetClinicIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ public class PetClinicIntegrationTests {
4444
private RestTemplateBuilder builder;
4545

4646
@Test
47-
void testFindAll() {
47+
void findAll() {
4848
vets.findAll();
4949
vets.findAll(); // served from cache
5050
}
5151

5252
@Test
53-
void testOwnerDetails() {
53+
void ownerDetails() {
5454
RestTemplate template = builder.rootUri("http://localhost:" + port).build();
5555
ResponseEntity<String> result = template.exchange(RequestEntity.get("/owners/1").build(), String.class);
5656
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
5757
}
5858

5959
@Test
60-
void testOwnerList() {
60+
void ownerList() {
6161
RestTemplate template = builder.rootUri("http://localhost:" + port).build();
6262
ResponseEntity<String> result = template.exchange(RequestEntity.get("/owners?lastName=").build(), String.class);
6363
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);

src/test/java/org/springframework/samples/petclinic/PostgresIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ public static void main(String[] args) {
7979
}
8080

8181
@Test
82-
void testFindAll() throws Exception {
82+
void findAll() throws Exception {
8383
vets.findAll();
8484
vets.findAll(); // served from cache
8585
}
8686

8787
@Test
88-
void testOwnerDetails() {
88+
void ownerDetails() {
8989
RestTemplate template = builder.rootUri("http://localhost:" + port).build();
9090
ResponseEntity<String> result = template.exchange(RequestEntity.get("/owners/1").build(), String.class);
9191
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);

src/test/java/org/springframework/samples/petclinic/owner/OwnerControllerTests.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ void setup() {
102102
}
103103

104104
@Test
105-
void testInitCreationForm() throws Exception {
105+
void initCreationForm() throws Exception {
106106
mockMvc.perform(get("/owners/new"))
107107
.andExpect(status().isOk())
108108
.andExpect(model().attributeExists("owner"))
109109
.andExpect(view().name("owners/createOrUpdateOwnerForm"));
110110
}
111111

112112
@Test
113-
void testProcessCreationFormSuccess() throws Exception {
113+
void processCreationFormSuccess() throws Exception {
114114
mockMvc
115115
.perform(post("/owners/new").param("firstName", "Joe")
116116
.param("lastName", "Bloggs")
@@ -121,7 +121,7 @@ void testProcessCreationFormSuccess() throws Exception {
121121
}
122122

123123
@Test
124-
void testProcessCreationFormHasErrors() throws Exception {
124+
void processCreationFormHasErrors() throws Exception {
125125
mockMvc
126126
.perform(post("/owners/new").param("firstName", "Joe").param("lastName", "Bloggs").param("city", "London"))
127127
.andExpect(status().isOk())
@@ -132,22 +132,22 @@ void testProcessCreationFormHasErrors() throws Exception {
132132
}
133133

134134
@Test
135-
void testInitFindForm() throws Exception {
135+
void initFindForm() throws Exception {
136136
mockMvc.perform(get("/owners/find"))
137137
.andExpect(status().isOk())
138138
.andExpect(model().attributeExists("owner"))
139139
.andExpect(view().name("owners/findOwners"));
140140
}
141141

142142
@Test
143-
void testProcessFindFormSuccess() throws Exception {
143+
void processFindFormSuccess() throws Exception {
144144
Page<Owner> tasks = new PageImpl<>(List.of(george(), new Owner()));
145145
when(this.owners.findByLastNameStartingWith(anyString(), any(Pageable.class))).thenReturn(tasks);
146146
mockMvc.perform(get("/owners?page=1")).andExpect(status().isOk()).andExpect(view().name("owners/ownersList"));
147147
}
148148

149149
@Test
150-
void testProcessFindFormByLastName() throws Exception {
150+
void processFindFormByLastName() throws Exception {
151151
Page<Owner> tasks = new PageImpl<>(List.of(george()));
152152
when(this.owners.findByLastNameStartingWith(eq("Franklin"), any(Pageable.class))).thenReturn(tasks);
153153
mockMvc.perform(get("/owners?page=1").param("lastName", "Franklin"))
@@ -156,7 +156,7 @@ void testProcessFindFormByLastName() throws Exception {
156156
}
157157

158158
@Test
159-
void testProcessFindFormNoOwnersFound() throws Exception {
159+
void processFindFormNoOwnersFound() throws Exception {
160160
Page<Owner> tasks = new PageImpl<>(List.of());
161161
when(this.owners.findByLastNameStartingWith(eq("Unknown Surname"), any(Pageable.class))).thenReturn(tasks);
162162
mockMvc.perform(get("/owners?page=1").param("lastName", "Unknown Surname"))
@@ -168,7 +168,7 @@ void testProcessFindFormNoOwnersFound() throws Exception {
168168
}
169169

170170
@Test
171-
void testInitUpdateOwnerForm() throws Exception {
171+
void initUpdateOwnerForm() throws Exception {
172172
mockMvc.perform(get("/owners/{ownerId}/edit", TEST_OWNER_ID))
173173
.andExpect(status().isOk())
174174
.andExpect(model().attributeExists("owner"))
@@ -181,7 +181,7 @@ void testInitUpdateOwnerForm() throws Exception {
181181
}
182182

183183
@Test
184-
void testProcessUpdateOwnerFormSuccess() throws Exception {
184+
void processUpdateOwnerFormSuccess() throws Exception {
185185
mockMvc
186186
.perform(post("/owners/{ownerId}/edit", TEST_OWNER_ID).param("firstName", "Joe")
187187
.param("lastName", "Bloggs")
@@ -193,14 +193,14 @@ void testProcessUpdateOwnerFormSuccess() throws Exception {
193193
}
194194

195195
@Test
196-
void testProcessUpdateOwnerFormUnchangedSuccess() throws Exception {
196+
void processUpdateOwnerFormUnchangedSuccess() throws Exception {
197197
mockMvc.perform(post("/owners/{ownerId}/edit", TEST_OWNER_ID))
198198
.andExpect(status().is3xxRedirection())
199199
.andExpect(view().name("redirect:/owners/{ownerId}"));
200200
}
201201

202202
@Test
203-
void testProcessUpdateOwnerFormHasErrors() throws Exception {
203+
void processUpdateOwnerFormHasErrors() throws Exception {
204204
mockMvc
205205
.perform(post("/owners/{ownerId}/edit", TEST_OWNER_ID).param("firstName", "Joe")
206206
.param("lastName", "Bloggs")
@@ -214,7 +214,7 @@ void testProcessUpdateOwnerFormHasErrors() throws Exception {
214214
}
215215

216216
@Test
217-
void testShowOwner() throws Exception {
217+
void showOwner() throws Exception {
218218
mockMvc.perform(get("/owners/{ownerId}", TEST_OWNER_ID))
219219
.andExpect(status().isOk())
220220
.andExpect(model().attribute("owner", hasProperty("lastName", is("Franklin"))))
@@ -229,7 +229,7 @@ void testShowOwner() throws Exception {
229229
}
230230

231231
@Test
232-
public void testProcessUpdateOwnerFormWithIdMismatch() throws Exception {
232+
void processUpdateOwnerFormWithIdMismatch() throws Exception {
233233
int pathOwnerId = 1;
234234

235235
Owner owner = new Owner();

src/test/java/org/springframework/samples/petclinic/owner/PetControllerTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ void setup() {
8484
}
8585

8686
@Test
87-
void testInitCreationForm() throws Exception {
87+
void initCreationForm() throws Exception {
8888
mockMvc.perform(get("/owners/{ownerId}/pets/new", TEST_OWNER_ID))
8989
.andExpect(status().isOk())
9090
.andExpect(view().name("pets/createOrUpdatePetForm"))
9191
.andExpect(model().attributeExists("pet"));
9292
}
9393

9494
@Test
95-
void testProcessCreationFormSuccess() throws Exception {
95+
void processCreationFormSuccess() throws Exception {
9696
mockMvc
9797
.perform(post("/owners/{ownerId}/pets/new", TEST_OWNER_ID).param("name", "Betty")
9898
.param("type", "hamster")
@@ -105,7 +105,7 @@ void testProcessCreationFormSuccess() throws Exception {
105105
class ProcessCreationFormHasErrors {
106106

107107
@Test
108-
void testProcessCreationFormWithBlankName() throws Exception {
108+
void processCreationFormWithBlankName() throws Exception {
109109
mockMvc
110110
.perform(post("/owners/{ownerId}/pets/new", TEST_OWNER_ID).param("name", "\t \n")
111111
.param("birthDate", "2015-02-12"))
@@ -118,7 +118,7 @@ void testProcessCreationFormWithBlankName() throws Exception {
118118
}
119119

120120
@Test
121-
void testProcessCreationFormWithDuplicateName() throws Exception {
121+
void processCreationFormWithDuplicateName() throws Exception {
122122
mockMvc
123123
.perform(post("/owners/{ownerId}/pets/new", TEST_OWNER_ID).param("name", "petty")
124124
.param("birthDate", "2015-02-12"))
@@ -131,7 +131,7 @@ void testProcessCreationFormWithDuplicateName() throws Exception {
131131
}
132132

133133
@Test
134-
void testProcessCreationFormWithMissingPetType() throws Exception {
134+
void processCreationFormWithMissingPetType() throws Exception {
135135
mockMvc
136136
.perform(post("/owners/{ownerId}/pets/new", TEST_OWNER_ID).param("name", "Betty")
137137
.param("birthDate", "2015-02-12"))
@@ -144,7 +144,7 @@ void testProcessCreationFormWithMissingPetType() throws Exception {
144144
}
145145

146146
@Test
147-
void testProcessCreationFormWithInvalidBirthDate() throws Exception {
147+
void processCreationFormWithInvalidBirthDate() throws Exception {
148148
LocalDate currentDate = LocalDate.now();
149149
String futureBirthDate = currentDate.plusMonths(1).toString();
150150

@@ -160,7 +160,7 @@ void testProcessCreationFormWithInvalidBirthDate() throws Exception {
160160
}
161161

162162
@Test
163-
void testInitUpdateForm() throws Exception {
163+
void initUpdateForm() throws Exception {
164164
mockMvc.perform(get("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID))
165165
.andExpect(status().isOk())
166166
.andExpect(model().attributeExists("pet"))
@@ -170,7 +170,7 @@ void testInitUpdateForm() throws Exception {
170170
}
171171

172172
@Test
173-
void testProcessUpdateFormSuccess() throws Exception {
173+
void processUpdateFormSuccess() throws Exception {
174174
mockMvc
175175
.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID).param("name", "Betty")
176176
.param("type", "hamster")
@@ -183,7 +183,7 @@ void testProcessUpdateFormSuccess() throws Exception {
183183
class ProcessUpdateFormHasErrors {
184184

185185
@Test
186-
void testProcessUpdateFormWithInvalidBirthDate() throws Exception {
186+
void processUpdateFormWithInvalidBirthDate() throws Exception {
187187
mockMvc
188188
.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID).param("name", " ")
189189
.param("birthDate", "2015/02/12"))
@@ -195,7 +195,7 @@ void testProcessUpdateFormWithInvalidBirthDate() throws Exception {
195195
}
196196

197197
@Test
198-
void testProcessUpdateFormWithBlankName() throws Exception {
198+
void processUpdateFormWithBlankName() throws Exception {
199199
mockMvc
200200
.perform(post("/owners/{ownerId}/pets/{petId}/edit", TEST_OWNER_ID, TEST_PET_ID).param("name", " ")
201201
.param("birthDate", "2015-02-12"))

0 commit comments

Comments
 (0)