Skip to content

Commit bec7627

Browse files
committed
Polishing.
Formatting and removing public modifier from test methods. See #1502 Original pull request #1855
1 parent fb42959 commit bec7627

File tree

1 file changed

+39
-60
lines changed

1 file changed

+39
-60
lines changed

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateUnitTests.java

+39-60
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,13 @@ public class JdbcAggregateTemplateUnitTests {
5959

6060
JdbcAggregateTemplate template;
6161

62-
@Mock
63-
DataAccessStrategy dataAccessStrategy;
64-
@Mock
65-
ApplicationEventPublisher eventPublisher;
66-
@Mock
67-
RelationResolver relationResolver;
68-
@Mock
69-
EntityCallbacks callbacks;
62+
@Mock DataAccessStrategy dataAccessStrategy;
63+
@Mock ApplicationEventPublisher eventPublisher;
64+
@Mock RelationResolver relationResolver;
65+
@Mock EntityCallbacks callbacks;
7066

7167
@BeforeEach
72-
public void setUp() {
68+
void setUp() {
7369

7470
RelationalMappingContext mappingContext = new RelationalMappingContext();
7571
JdbcConverter converter = new MappingJdbcConverter(mappingContext, relationResolver);
@@ -80,24 +76,24 @@ public void setUp() {
8076
}
8177

8278
@Test // DATAJDBC-378
83-
public void findAllByIdMustNotAcceptNullArgumentForType() {
79+
void findAllByIdMustNotAcceptNullArgumentForType() {
8480
assertThatThrownBy(() -> template.findAllById(singleton(23L), null)).isInstanceOf(IllegalArgumentException.class);
8581
}
8682

8783
@Test // DATAJDBC-378
88-
public void findAllByIdMustNotAcceptNullArgumentForIds() {
84+
void findAllByIdMustNotAcceptNullArgumentForIds() {
8985

9086
assertThatThrownBy(() -> template.findAllById(null, SampleEntity.class))
9187
.isInstanceOf(IllegalArgumentException.class);
9288
}
9389

9490
@Test // DATAJDBC-378
95-
public void findAllByIdWithEmptyListMustReturnEmptyResult() {
91+
void findAllByIdWithEmptyListMustReturnEmptyResult() {
9692
assertThat(template.findAllById(emptyList(), SampleEntity.class)).isEmpty();
9793
}
9894

9995
@Test // DATAJDBC-393, GH-1291
100-
public void callbackOnSave() {
96+
void callbackOnSave() {
10197

10298
SampleEntity first = new SampleEntity(null, "Alfred");
10399
SampleEntity second = new SampleEntity(23L, "Alfred E.");
@@ -115,7 +111,7 @@ public void callbackOnSave() {
115111
}
116112

117113
@Test // GH-1291
118-
public void doesNotEmitEvents() {
114+
void doesNotEmitEvents() {
119115

120116
SampleEntity first = new SampleEntity(null, "Alfred");
121117
SampleEntity second = new SampleEntity(23L, "Alfred E.");
@@ -129,8 +125,7 @@ public void doesNotEmitEvents() {
129125
verifyNoInteractions(eventPublisher);
130126
}
131127

132-
@Test
133-
// GH-1137
128+
@Test // GH-1137
134129
void savePreparesInstanceWithInitialVersion_onInsert() {
135130

136131
EntityWithVersion entity = new EntityWithVersion(1L);
@@ -145,8 +140,7 @@ void savePreparesInstanceWithInitialVersion_onInsert() {
145140
assertThat(afterConvert.getVersion()).isEqualTo(0L);
146141
}
147142

148-
@Test
149-
// GH-1137
143+
@Test // GH-1137
150144
void savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsImmutable() {
151145

152146
EntityWithImmutableVersion entity = new EntityWithImmutableVersion(1L, null);
@@ -161,8 +155,7 @@ void savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsImmuta
161155
assertThat(afterConvert.getVersion()).isEqualTo(0L);
162156
}
163157

164-
@Test
165-
// GH-1137
158+
@Test // GH-1137
166159
void savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsPrimitiveType() {
167160

168161
EntityWithPrimitiveVersion entity = new EntityWithPrimitiveVersion(1L);
@@ -177,8 +170,7 @@ void savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsPrimit
177170
assertThat(afterConvert.getVersion()).isEqualTo(1L);
178171
}
179172

180-
@Test
181-
// GH-1137
173+
@Test // GH-1137
182174
void savePreparesInstanceWithInitialVersion_onInsert__whenVersionPropertyIsImmutableAndPrimitiveType() {
183175

184176
EntityWithImmutablePrimitiveVersion entity = new EntityWithImmutablePrimitiveVersion(1L, 0L);
@@ -194,8 +186,7 @@ void savePreparesInstanceWithInitialVersion_onInsert__whenVersionPropertyIsImmut
194186
assertThat(afterConvert.getVersion()).isEqualTo(1L);
195187
}
196188

197-
@Test
198-
// GH-1137
189+
@Test // GH-1137
199190
void savePreparesChangeWithPreviousVersion_onUpdate() {
200191

201192
when(dataAccessStrategy.updateWithVersion(any(), any(), any())).thenReturn(true);
@@ -212,8 +203,7 @@ void savePreparesChangeWithPreviousVersion_onUpdate() {
212203
assertThat(aggregateChange.getPreviousVersion()).isEqualTo(1L);
213204
}
214205

215-
@Test
216-
// GH-1137
206+
@Test // GH-1137
217207
void savePreparesInstanceWithNextVersion_onUpdate() {
218208

219209
when(dataAccessStrategy.updateWithVersion(any(), any(), any())).thenReturn(true);
@@ -230,8 +220,7 @@ void savePreparesInstanceWithNextVersion_onUpdate() {
230220
assertThat(afterConvert.getVersion()).isEqualTo(2L);
231221
}
232222

233-
@Test
234-
// GH-1137
223+
@Test // GH-1137
235224
void savePreparesInstanceWithNextVersion_onUpdate_whenVersionPropertyIsImmutable() {
236225

237226
when(dataAccessStrategy.updateWithVersion(any(), any(), any())).thenReturn(true);
@@ -246,8 +235,7 @@ void savePreparesInstanceWithNextVersion_onUpdate_whenVersionPropertyIsImmutable
246235
assertThat(afterConvert.getVersion()).isEqualTo(2L);
247236
}
248237

249-
@Test
250-
// GH-1137
238+
@Test // GH-1137
251239
void deletePreparesChangeWithPreviousVersion_onDeleteByInstance() {
252240

253241
EntityWithImmutableVersion entity = new EntityWithImmutableVersion(1L, 1L);
@@ -263,7 +251,7 @@ void deletePreparesChangeWithPreviousVersion_onDeleteByInstance() {
263251
}
264252

265253
@Test // DATAJDBC-393
266-
public void callbackOnDelete() {
254+
void callbackOnDelete() {
267255

268256
SampleEntity first = new SampleEntity(23L, "Alfred");
269257
SampleEntity second = new SampleEntity(23L, "Alfred E.");
@@ -277,7 +265,7 @@ public void callbackOnDelete() {
277265
}
278266

279267
@Test // DATAJDBC-101
280-
public void callbackOnLoadSorted() {
268+
void callbackOnLoadSorted() {
281269

282270
SampleEntity alfred1 = new SampleEntity(23L, "Alfred");
283271
SampleEntity alfred2 = new SampleEntity(23L, "Alfred E.");
@@ -299,7 +287,7 @@ public void callbackOnLoadSorted() {
299287
}
300288

301289
@Test // DATAJDBC-101
302-
public void callbackOnLoadPaged() {
290+
void callbackOnLoadPaged() {
303291

304292
SampleEntity alfred1 = new SampleEntity(23L, "Alfred");
305293
SampleEntity alfred2 = new SampleEntity(23L, "Alfred E.");
@@ -321,35 +309,34 @@ public void callbackOnLoadPaged() {
321309
}
322310

323311
@Test // GH-1401
324-
public void saveAllWithEmptyListDoesNothing() {
312+
void saveAllWithEmptyListDoesNothing() {
325313
assertThat(template.saveAll(emptyList())).isEmpty();
326314
}
327315

328316
@Test // GH-1401
329-
public void insertAllWithEmptyListDoesNothing() {
317+
void insertAllWithEmptyListDoesNothing() {
330318
assertThat(template.insertAll(emptyList())).isEmpty();
331319
}
332320

333321
@Test // GH-1401
334-
public void updateAllWithEmptyListDoesNothing() {
322+
void updateAllWithEmptyListDoesNothing() {
335323
assertThat(template.updateAll(emptyList())).isEmpty();
336324
}
337325

338326
@Test // GH-1401
339-
public void deleteAllWithEmptyListDoesNothing() {
327+
void deleteAllWithEmptyListDoesNothing() {
340328
template.deleteAll(emptyList());
341329
}
342330

343331
@Test // GH-1401
344-
public void deleteAllByIdWithEmptyListDoesNothing() {
332+
void deleteAllByIdWithEmptyListDoesNothing() {
345333
template.deleteAllById(emptyList(), SampleEntity.class);
346334
}
347335

348336
private static class SampleEntity {
349337

350338
@Column("id1")
351-
@Id
352-
private Long id;
339+
@Id private Long id;
353340

354341
private String name;
355342

@@ -366,23 +353,21 @@ public String getName() {
366353
return this.name;
367354
}
368355

369-
public void setId(Long id) {
356+
void setId(Long id) {
370357
this.id = id;
371358
}
372359

373-
public void setName(String name) {
360+
void setName(String name) {
374361
this.name = name;
375362
}
376363
}
377364

378365
private static class EntityWithVersion {
379366

380367
@Column("id1")
381-
@Id
382-
private final Long id;
368+
@Id private final Long id;
383369

384-
@Version
385-
private Long version;
370+
@Version private Long version;
386371

387372
public EntityWithVersion(Long id) {
388373
this.id = id;
@@ -396,19 +381,17 @@ public Long getVersion() {
396381
return this.version;
397382
}
398383

399-
public void setVersion(Long version) {
384+
void setVersion(Long version) {
400385
this.version = version;
401386
}
402387
}
403388

404389
private static class EntityWithImmutableVersion {
405390

406391
@Column("id1")
407-
@Id
408-
private final Long id;
392+
@Id private final Long id;
409393

410-
@Version
411-
private final Long version;
394+
@Version private final Long version;
412395

413396
public EntityWithImmutableVersion(Long id, Long version) {
414397
this.id = id;
@@ -427,11 +410,9 @@ public Long getVersion() {
427410
private static class EntityWithPrimitiveVersion {
428411

429412
@Column("id1")
430-
@Id
431-
private final Long id;
413+
@Id private final Long id;
432414

433-
@Version
434-
private long version;
415+
@Version private long version;
435416

436417
public EntityWithPrimitiveVersion(Long id) {
437418
this.id = id;
@@ -445,19 +426,17 @@ public long getVersion() {
445426
return this.version;
446427
}
447428

448-
public void setVersion(long version) {
429+
void setVersion(long version) {
449430
this.version = version;
450431
}
451432
}
452433

453434
private static class EntityWithImmutablePrimitiveVersion {
454435

455436
@Column("id1")
456-
@Id
457-
private final Long id;
437+
@Id private final Long id;
458438

459-
@Version
460-
private final long version;
439+
@Version private final long version;
461440

462441
public EntityWithImmutablePrimitiveVersion(Long id, long version) {
463442
this.id = id;

0 commit comments

Comments
 (0)