From bec76278ff132e17f33fb7567adccb4db063b3a4 Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Tue, 13 Aug 2024 09:38:43 +0200 Subject: [PATCH] Polishing. Formatting and removing public modifier from test methods. See #1502 Original pull request #1855 --- .../core/JdbcAggregateTemplateUnitTests.java | 99 ++++++++----------- 1 file changed, 39 insertions(+), 60 deletions(-) diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateUnitTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateUnitTests.java index d9e6ed33683..39090350e9d 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateUnitTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateUnitTests.java @@ -59,17 +59,13 @@ public class JdbcAggregateTemplateUnitTests { JdbcAggregateTemplate template; - @Mock - DataAccessStrategy dataAccessStrategy; - @Mock - ApplicationEventPublisher eventPublisher; - @Mock - RelationResolver relationResolver; - @Mock - EntityCallbacks callbacks; + @Mock DataAccessStrategy dataAccessStrategy; + @Mock ApplicationEventPublisher eventPublisher; + @Mock RelationResolver relationResolver; + @Mock EntityCallbacks callbacks; @BeforeEach - public void setUp() { + void setUp() { RelationalMappingContext mappingContext = new RelationalMappingContext(); JdbcConverter converter = new MappingJdbcConverter(mappingContext, relationResolver); @@ -80,24 +76,24 @@ public void setUp() { } @Test // DATAJDBC-378 - public void findAllByIdMustNotAcceptNullArgumentForType() { + void findAllByIdMustNotAcceptNullArgumentForType() { assertThatThrownBy(() -> template.findAllById(singleton(23L), null)).isInstanceOf(IllegalArgumentException.class); } @Test // DATAJDBC-378 - public void findAllByIdMustNotAcceptNullArgumentForIds() { + void findAllByIdMustNotAcceptNullArgumentForIds() { assertThatThrownBy(() -> template.findAllById(null, SampleEntity.class)) .isInstanceOf(IllegalArgumentException.class); } @Test // DATAJDBC-378 - public void findAllByIdWithEmptyListMustReturnEmptyResult() { + void findAllByIdWithEmptyListMustReturnEmptyResult() { assertThat(template.findAllById(emptyList(), SampleEntity.class)).isEmpty(); } @Test // DATAJDBC-393, GH-1291 - public void callbackOnSave() { + void callbackOnSave() { SampleEntity first = new SampleEntity(null, "Alfred"); SampleEntity second = new SampleEntity(23L, "Alfred E."); @@ -115,7 +111,7 @@ public void callbackOnSave() { } @Test // GH-1291 - public void doesNotEmitEvents() { + void doesNotEmitEvents() { SampleEntity first = new SampleEntity(null, "Alfred"); SampleEntity second = new SampleEntity(23L, "Alfred E."); @@ -129,8 +125,7 @@ public void doesNotEmitEvents() { verifyNoInteractions(eventPublisher); } - @Test - // GH-1137 + @Test // GH-1137 void savePreparesInstanceWithInitialVersion_onInsert() { EntityWithVersion entity = new EntityWithVersion(1L); @@ -145,8 +140,7 @@ void savePreparesInstanceWithInitialVersion_onInsert() { assertThat(afterConvert.getVersion()).isEqualTo(0L); } - @Test - // GH-1137 + @Test // GH-1137 void savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsImmutable() { EntityWithImmutableVersion entity = new EntityWithImmutableVersion(1L, null); @@ -161,8 +155,7 @@ void savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsImmuta assertThat(afterConvert.getVersion()).isEqualTo(0L); } - @Test - // GH-1137 + @Test // GH-1137 void savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsPrimitiveType() { EntityWithPrimitiveVersion entity = new EntityWithPrimitiveVersion(1L); @@ -177,8 +170,7 @@ void savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsPrimit assertThat(afterConvert.getVersion()).isEqualTo(1L); } - @Test - // GH-1137 + @Test // GH-1137 void savePreparesInstanceWithInitialVersion_onInsert__whenVersionPropertyIsImmutableAndPrimitiveType() { EntityWithImmutablePrimitiveVersion entity = new EntityWithImmutablePrimitiveVersion(1L, 0L); @@ -194,8 +186,7 @@ void savePreparesInstanceWithInitialVersion_onInsert__whenVersionPropertyIsImmut assertThat(afterConvert.getVersion()).isEqualTo(1L); } - @Test - // GH-1137 + @Test // GH-1137 void savePreparesChangeWithPreviousVersion_onUpdate() { when(dataAccessStrategy.updateWithVersion(any(), any(), any())).thenReturn(true); @@ -212,8 +203,7 @@ void savePreparesChangeWithPreviousVersion_onUpdate() { assertThat(aggregateChange.getPreviousVersion()).isEqualTo(1L); } - @Test - // GH-1137 + @Test // GH-1137 void savePreparesInstanceWithNextVersion_onUpdate() { when(dataAccessStrategy.updateWithVersion(any(), any(), any())).thenReturn(true); @@ -230,8 +220,7 @@ void savePreparesInstanceWithNextVersion_onUpdate() { assertThat(afterConvert.getVersion()).isEqualTo(2L); } - @Test - // GH-1137 + @Test // GH-1137 void savePreparesInstanceWithNextVersion_onUpdate_whenVersionPropertyIsImmutable() { when(dataAccessStrategy.updateWithVersion(any(), any(), any())).thenReturn(true); @@ -246,8 +235,7 @@ void savePreparesInstanceWithNextVersion_onUpdate_whenVersionPropertyIsImmutable assertThat(afterConvert.getVersion()).isEqualTo(2L); } - @Test - // GH-1137 + @Test // GH-1137 void deletePreparesChangeWithPreviousVersion_onDeleteByInstance() { EntityWithImmutableVersion entity = new EntityWithImmutableVersion(1L, 1L); @@ -263,7 +251,7 @@ void deletePreparesChangeWithPreviousVersion_onDeleteByInstance() { } @Test // DATAJDBC-393 - public void callbackOnDelete() { + void callbackOnDelete() { SampleEntity first = new SampleEntity(23L, "Alfred"); SampleEntity second = new SampleEntity(23L, "Alfred E."); @@ -277,7 +265,7 @@ public void callbackOnDelete() { } @Test // DATAJDBC-101 - public void callbackOnLoadSorted() { + void callbackOnLoadSorted() { SampleEntity alfred1 = new SampleEntity(23L, "Alfred"); SampleEntity alfred2 = new SampleEntity(23L, "Alfred E."); @@ -299,7 +287,7 @@ public void callbackOnLoadSorted() { } @Test // DATAJDBC-101 - public void callbackOnLoadPaged() { + void callbackOnLoadPaged() { SampleEntity alfred1 = new SampleEntity(23L, "Alfred"); SampleEntity alfred2 = new SampleEntity(23L, "Alfred E."); @@ -321,35 +309,34 @@ public void callbackOnLoadPaged() { } @Test // GH-1401 - public void saveAllWithEmptyListDoesNothing() { + void saveAllWithEmptyListDoesNothing() { assertThat(template.saveAll(emptyList())).isEmpty(); } @Test // GH-1401 - public void insertAllWithEmptyListDoesNothing() { + void insertAllWithEmptyListDoesNothing() { assertThat(template.insertAll(emptyList())).isEmpty(); } @Test // GH-1401 - public void updateAllWithEmptyListDoesNothing() { + void updateAllWithEmptyListDoesNothing() { assertThat(template.updateAll(emptyList())).isEmpty(); } @Test // GH-1401 - public void deleteAllWithEmptyListDoesNothing() { + void deleteAllWithEmptyListDoesNothing() { template.deleteAll(emptyList()); } @Test // GH-1401 - public void deleteAllByIdWithEmptyListDoesNothing() { + void deleteAllByIdWithEmptyListDoesNothing() { template.deleteAllById(emptyList(), SampleEntity.class); } private static class SampleEntity { @Column("id1") - @Id - private Long id; + @Id private Long id; private String name; @@ -366,11 +353,11 @@ public String getName() { return this.name; } - public void setId(Long id) { + void setId(Long id) { this.id = id; } - public void setName(String name) { + void setName(String name) { this.name = name; } } @@ -378,11 +365,9 @@ public void setName(String name) { private static class EntityWithVersion { @Column("id1") - @Id - private final Long id; + @Id private final Long id; - @Version - private Long version; + @Version private Long version; public EntityWithVersion(Long id) { this.id = id; @@ -396,7 +381,7 @@ public Long getVersion() { return this.version; } - public void setVersion(Long version) { + void setVersion(Long version) { this.version = version; } } @@ -404,11 +389,9 @@ public void setVersion(Long version) { private static class EntityWithImmutableVersion { @Column("id1") - @Id - private final Long id; + @Id private final Long id; - @Version - private final Long version; + @Version private final Long version; public EntityWithImmutableVersion(Long id, Long version) { this.id = id; @@ -427,11 +410,9 @@ public Long getVersion() { private static class EntityWithPrimitiveVersion { @Column("id1") - @Id - private final Long id; + @Id private final Long id; - @Version - private long version; + @Version private long version; public EntityWithPrimitiveVersion(Long id) { this.id = id; @@ -445,7 +426,7 @@ public long getVersion() { return this.version; } - public void setVersion(long version) { + void setVersion(long version) { this.version = version; } } @@ -453,11 +434,9 @@ public void setVersion(long version) { private static class EntityWithImmutablePrimitiveVersion { @Column("id1") - @Id - private final Long id; + @Id private final Long id; - @Version - private final long version; + @Version private final long version; public EntityWithImmutablePrimitiveVersion(Long id, long version) { this.id = id;