Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Formatting and removing public modifier from test methods.

See #1502
Original pull request #1855
  • Loading branch information
schauder committed Aug 14, 2024
1 parent fb42959 commit bec7627
Showing 1 changed file with 39 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.");
Expand All @@ -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.");
Expand All @@ -129,8 +125,7 @@ public void doesNotEmitEvents() {
verifyNoInteractions(eventPublisher);
}

@Test
// GH-1137
@Test // GH-1137
void savePreparesInstanceWithInitialVersion_onInsert() {

EntityWithVersion entity = new EntityWithVersion(1L);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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.");
Expand All @@ -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.");
Expand All @@ -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.");
Expand All @@ -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;

Expand All @@ -366,23 +353,21 @@ 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;
}
}

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;
Expand All @@ -396,19 +381,17 @@ public Long getVersion() {
return this.version;
}

public void setVersion(Long version) {
void setVersion(Long version) {
this.version = 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;
Expand All @@ -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;
Expand All @@ -445,19 +426,17 @@ public long getVersion() {
return this.version;
}

public void setVersion(long version) {
void setVersion(long version) {
this.version = 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;
Expand Down

0 comments on commit bec7627

Please sign in to comment.