Browse Source

Polishing.

Reduce test element visibility.

See #1750
Original pull request: #1785
pull/1794/head
Mark Paluch 2 years ago
parent
commit
121d3723d6
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 31
      spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/MappingJdbcConverterUnitTests.java

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

@ -56,15 +56,16 @@ import org.springframework.data.util.TypeInformation;
* @author Mark Paluch * @author Mark Paluch
* @author Jens Schauder * @author Jens Schauder
*/ */
public class MappingJdbcConverterUnitTests { class MappingJdbcConverterUnitTests {
public static final UUID UUID = java.util.UUID.fromString("87a48aa8-a071-705e-54a9-e52fe3a012f1"); private static final UUID UUID = java.util.UUID.fromString("87a48aa8-a071-705e-54a9-e52fe3a012f1");
public static final byte[] BYTES_REPRESENTING_UUID = { -121, -92, -118, -88, -96, 113, 112, 94, 84, -87, -27, 47, -29, private static final byte[] BYTES_REPRESENTING_UUID = { -121, -92, -118, -88, -96, 113, 112, 94, 84, -87, -27, 47,
-29,
-96, 18, -15 }; -96, 18, -15 };
JdbcMappingContext context = new JdbcMappingContext(); private JdbcMappingContext context = new JdbcMappingContext();
StubbedJdbcTypeFactory typeFactory = new StubbedJdbcTypeFactory(); private StubbedJdbcTypeFactory typeFactory = new StubbedJdbcTypeFactory();
MappingJdbcConverter converter = new MappingJdbcConverter( // private MappingJdbcConverter converter = new MappingJdbcConverter( //
context, // context, //
(identifier, path) -> { (identifier, path) -> {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -74,7 +75,7 @@ public class MappingJdbcConverterUnitTests {
); );
@Test // DATAJDBC-104, DATAJDBC-1384 @Test // DATAJDBC-104, DATAJDBC-1384
public void testTargetTypesForPropertyType() { void testTargetTypesForPropertyType() {
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(DummyEntity.class); RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(DummyEntity.class);
@ -95,7 +96,7 @@ public class MappingJdbcConverterUnitTests {
} }
@Test // DATAJDBC-259 @Test // DATAJDBC-259
public void classificationOfCollectionLikeProperties() { void classificationOfCollectionLikeProperties() {
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(DummyEntity.class); RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(DummyEntity.class);
@ -111,7 +112,7 @@ public class MappingJdbcConverterUnitTests {
} }
@Test // DATAJDBC-221 @Test // DATAJDBC-221
public void referencesAreNotEntitiesAndGetStoredAsTheirId() { void referencesAreNotEntitiesAndGetStoredAsTheirId() {
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(DummyEntity.class); RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(DummyEntity.class);
@ -176,7 +177,7 @@ public class MappingJdbcConverterUnitTests {
typeFactory // typeFactory //
); );
SoftAssertions.assertSoftly(softly -> { assertSoftly(softly -> {
checkReadConversion(softly, converter, "uuidRef", AggregateReference.to(UUID)); checkReadConversion(softly, converter, "uuidRef", AggregateReference.to(UUID));
checkReadConversion(softly, converter, "uuid", UUID); checkReadConversion(softly, converter, "uuid", UUID);
checkReadConversion(softly, converter, "optionalUuid", Optional.of(UUID)); checkReadConversion(softly, converter, "optionalUuid", Optional.of(UUID));
@ -337,7 +338,7 @@ public class MappingJdbcConverterUnitTests {
private static class OtherEntity {} private static class OtherEntity {}
private static class StubbedJdbcTypeFactory implements JdbcTypeFactory { private static class StubbedJdbcTypeFactory implements JdbcTypeFactory {
public Object[] arraySource; Object[] arraySource;
@Override @Override
public Array createArray(Object[] value) { public Array createArray(Object[] value) {
@ -346,16 +347,16 @@ public class MappingJdbcConverterUnitTests {
} }
} }
record WithOneToOne(@Id String id, @MappedCollection(idColumn = "renamed") Referenced referenced) { private record WithOneToOne(@Id String id, @MappedCollection(idColumn = "renamed") Referenced referenced) {
} }
record Referenced(@Id Long id) { private record Referenced(@Id Long id) {
} }
record ReferencedByUuid(@Id UUID id) { private record ReferencedByUuid(@Id UUID id) {
} }
class ByteArrayToUuid implements Converter<byte[], UUID> { static class ByteArrayToUuid implements Converter<byte[], UUID> {
@Override @Override
public UUID convert(byte[] source) { public UUID convert(byte[] source) {

Loading…
Cancel
Save