Browse Source

Polishing.

Simplifying test code
issue/1828-aggregate-ref-with-convertable
Jens Schauder 1 year ago
parent
commit
88a7e1246f
No known key found for this signature in database
GPG Key ID: 74F6C554AE971567
  1. 133
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/MappingJdbcConverterUnitTests.java

133
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/MappingJdbcConverterUnitTests.java

@ -79,12 +79,13 @@ class MappingJdbcConverterUnitTests { @@ -79,12 +79,13 @@ class MappingJdbcConverterUnitTests {
context.setSimpleTypeHolder(converter.getConversions().getSimpleTypeHolder());
}
@Test // DATAJDBC-104, DATAJDBC-1384
@Test
// DATAJDBC-104, DATAJDBC-1384
void testTargetTypesForPropertyType() {
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(DummyEntity.class);
SoftAssertions softly = new SoftAssertions();
SoftAssertions.assertSoftly(softly -> {
checkTargetType(softly, entity, "someEnum", String.class);
checkTargetType(softly, entity, "localDateTime", LocalDateTime.class);
@ -99,11 +100,11 @@ class MappingJdbcConverterUnitTests { @@ -99,11 +100,11 @@ class MappingJdbcConverterUnitTests {
checkTargetType(softly, entity, "reference", Long.class);
checkTargetType(softly, entity, "enumIdReference", String.class);
checkTargetType(softly, entity, "customIdReference", Long.class);
softly.assertAll();
});
}
@Test // DATAJDBC-259
@Test
// DATAJDBC-259
void classificationOfCollectionLikeProperties() {
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(DummyEntity.class);
@ -119,22 +120,24 @@ class MappingJdbcConverterUnitTests { @@ -119,22 +120,24 @@ class MappingJdbcConverterUnitTests {
softly.assertAll();
}
@Test // DATAJDBC-221
@Test
// DATAJDBC-221
void referencesAreNotEntitiesAndGetStoredAsTheirId() {
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(DummyEntity.class);
SoftAssertions softly = new SoftAssertions();
RelationalPersistentProperty reference = entity.getRequiredPersistentProperty("reference");
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(reference.isEntity()).isFalse();
softly.assertThat(converter.getColumnType(reference)).isEqualTo(Long.class);
softly.assertAll();
});
}
@Test // DATAJDBC-637
@Test
// DATAJDBC-637
void conversionOfDateLikeValueAndBackYieldsOriginalValue() {
RelationalPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(DummyEntity.class);
@ -150,7 +153,8 @@ class MappingJdbcConverterUnitTests { @@ -150,7 +153,8 @@ class MappingJdbcConverterUnitTests {
}
@Test // GH-945
@Test
// GH-945
void conversionOfPrimitiveArrays() {
int[] ints = {1, 2, 3, 4, 5};
@ -160,7 +164,8 @@ class MappingJdbcConverterUnitTests { @@ -160,7 +164,8 @@ class MappingJdbcConverterUnitTests {
assertThat(typeFactory.arraySource).containsExactly(1, 2, 3, 4, 5);
}
@Test // GH-1684
@Test
// GH-1684
void accessesCorrectValuesForOneToOneRelationshipWithIdenticallyNamedIdProperties() {
RowDocument rowdocument = new RowDocument(Map.of("ID", "one", "REFERENCED_ID", 23));
@ -170,7 +175,8 @@ class MappingJdbcConverterUnitTests { @@ -170,7 +175,8 @@ class MappingJdbcConverterUnitTests {
assertThat(result).isEqualTo(new WithOneToOne("one", new Referenced(23L)));
}
@Test // GH-1750
@Test
// GH-1750
void readByteArrayToNestedUuidWithCustomConverter() {
JdbcMappingContext context = new JdbcMappingContext();
@ -241,99 +247,11 @@ class MappingJdbcConverterUnitTests { @@ -241,99 +247,11 @@ class MappingJdbcConverterUnitTests {
Optional<UUID> optionalUuid,
// DATAJDBC-259
private final List<String> listOfString;
private final String[] arrayOfString;
private final List<OtherEntity> listOfEntity;
private final OtherEntity[] arrayOfEntity;
private DummyEntity(Long id, SomeEnum someEnum, LocalDateTime localDateTime, LocalDate localDate,
LocalTime localTime, ZonedDateTime zonedDateTime, OffsetDateTime offsetDateTime, Instant instant, Date date,
Timestamp timestamp, AggregateReference<DummyEntity, Long> reference, UUID uuid,
AggregateReference<ReferencedByUuid, UUID> uuidRef, Optional<java.util.UUID> optionalUUID, List<String> listOfString, String[] arrayOfString,
List<OtherEntity> listOfEntity, OtherEntity[] arrayOfEntity) {
this.id = id;
this.someEnum = someEnum;
this.localDateTime = localDateTime;
this.localDate = localDate;
this.localTime = localTime;
this.zonedDateTime = zonedDateTime;
this.offsetDateTime = offsetDateTime;
this.instant = instant;
this.date = date;
this.timestamp = timestamp;
this.reference = reference;
this.uuid = uuid;
this.uuidRef = uuidRef;
this.optionalUuid = optionalUUID;
this.listOfString = listOfString;
this.arrayOfString = arrayOfString;
this.listOfEntity = listOfEntity;
this.arrayOfEntity = arrayOfEntity;
}
public Long getId() {
return this.id;
}
public SomeEnum getSomeEnum() {
return this.someEnum;
}
public LocalDateTime getLocalDateTime() {
return this.localDateTime;
}
public LocalDate getLocalDate() {
return this.localDate;
}
public LocalTime getLocalTime() {
return this.localTime;
}
public ZonedDateTime getZonedDateTime() {
return this.zonedDateTime;
}
public OffsetDateTime getOffsetDateTime() {
return this.offsetDateTime;
}
public Instant getInstant() {
return this.instant;
}
public Date getDate() {
return this.date;
}
public Timestamp getTimestamp() {
return this.timestamp;
}
public AggregateReference<DummyEntity, Long> getReference() {
return this.reference;
}
public UUID getUuid() {
return this.uuid;
}
public List<String> getListOfString() {
return this.listOfString;
}
public String[] getArrayOfString() {
return this.arrayOfString;
}
public List<OtherEntity> getListOfEntity() {
return this.listOfEntity;
}
public OtherEntity[] getArrayOfEntity() {
return this.arrayOfEntity;
}
List<String> listOfString,
String[] arrayOfString,
List<OtherEntity> listOfEntity,
OtherEntity[] arrayOfEntity
) {
}
@SuppressWarnings("unused")
@ -342,7 +260,8 @@ class MappingJdbcConverterUnitTests { @@ -342,7 +260,8 @@ class MappingJdbcConverterUnitTests {
}
@SuppressWarnings("unused")
private static class OtherEntity {}
private static class OtherEntity {
}
private static class EnumIdEntity {
@Id SomeEnum id;

Loading…
Cancel
Save