diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateIntegrationTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateIntegrationTests.java index 8a3bccb0..4153ac6b 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateIntegrationTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/JdbcAggregateTemplateIntegrationTests.java @@ -89,7 +89,7 @@ import org.springframework.transaction.annotation.Transactional; @Transactional @TestExecutionListeners(value = AssumeFeatureTestExecutionListener.class, mergeMode = MERGE_WITH_DEFAULTS) @ExtendWith(SpringExtension.class) -public class JdbcAggregateTemplateIntegrationTests { +class JdbcAggregateTemplateIntegrationTests { @Autowired JdbcAggregateOperations template; @Autowired NamedParameterJdbcOperations jdbcTemplate; @@ -194,7 +194,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-112 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadAnEntityWithReferencedEntityById() { + void saveAndLoadAnEntityWithReferencedEntityById() { template.save(legoSet); @@ -216,7 +216,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-112 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadManyEntitiesWithReferencedEntity() { + void saveAndLoadManyEntitiesWithReferencedEntity() { template.save(legoSet); @@ -229,7 +229,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-101 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadManyEntitiesWithReferencedEntitySorted() { + void saveAndLoadManyEntitiesWithReferencedEntitySorted() { template.save(createLegoSet("Lava")); template.save(createLegoSet("Star")); @@ -244,7 +244,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-101 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadManyEntitiesWithReferencedEntitySortedAndPaged() { + void saveAndLoadManyEntitiesWithReferencedEntitySortedAndPaged() { template.save(createLegoSet("Lava")); template.save(createLegoSet("Star")); @@ -259,7 +259,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-112 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadManyEntitiesByIdWithReferencedEntity() { + void saveAndLoadManyEntitiesByIdWithReferencedEntity() { template.save(legoSet); @@ -271,7 +271,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-112 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadAnEntityWithReferencedNullEntity() { + void saveAndLoadAnEntityWithReferencedNullEntity() { legoSet.setManual(null); @@ -284,7 +284,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-112 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndDeleteAnEntityWithReferencedEntity() { + void saveAndDeleteAnEntityWithReferencedEntity() { template.save(legoSet); @@ -300,7 +300,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-112 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndDeleteAllWithReferencedEntity() { + void saveAndDeleteAllWithReferencedEntity() { template.save(legoSet); @@ -316,7 +316,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-112 @EnabledOnFeature({ SUPPORTS_QUOTED_IDS, SUPPORTS_GENERATED_IDS_IN_REFERENCED_ENTITIES }) - public void updateReferencedEntityFromNull() { + void updateReferencedEntityFromNull() { legoSet.setManual(null); template.save(legoSet); @@ -335,7 +335,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-112 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void updateReferencedEntityToNull() { + void updateReferencedEntityToNull() { template.save(legoSet); @@ -354,7 +354,7 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // DATAJDBC-438 - public void updateFailedRootDoesNotExist() { + void updateFailedRootDoesNotExist() { LegoSet entity = new LegoSet(); entity.setId(100L); // does not exist in the database @@ -366,7 +366,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-112 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void replaceReferencedEntity() { + void replaceReferencedEntity() { template.save(legoSet); @@ -388,7 +388,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-112 @EnabledOnFeature({ SUPPORTS_QUOTED_IDS, TestDatabaseFeatures.Feature.SUPPORTS_GENERATED_IDS_IN_REFERENCED_ENTITIES }) - public void changeReferencedEntity() { + void changeReferencedEntity() { template.save(legoSet); @@ -403,7 +403,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-266 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void oneToOneChildWithoutId() { + void oneToOneChildWithoutId() { OneToOneParent parent = new OneToOneParent(); @@ -420,7 +420,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-266 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void oneToOneNullChildWithoutId() { + void oneToOneNullChildWithoutId() { OneToOneParent parent = new OneToOneParent(); @@ -436,7 +436,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-266 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void oneToOneNullAttributes() { + void oneToOneNullAttributes() { OneToOneParent parent = new OneToOneParent(); @@ -452,7 +452,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-125 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadAnEntityWithSecondaryReferenceNull() { + void saveAndLoadAnEntityWithSecondaryReferenceNull() { template.save(legoSet); @@ -465,7 +465,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-125 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadAnEntityWithSecondaryReferenceNotNull() { + void saveAndLoadAnEntityWithSecondaryReferenceNotNull() { legoSet.alternativeInstructions = new Manual(); legoSet.alternativeInstructions.content = "alternative content"; @@ -487,7 +487,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-276 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadAnEntityWithListOfElementsWithoutId() { + void saveAndLoadAnEntityWithListOfElementsWithoutId() { ListParent entity = new ListParent(); entity.name = "name"; @@ -506,7 +506,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // GH-498 DATAJDBC-273 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadAnEntityWithListOfElementsInConstructor() { + void saveAndLoadAnEntityWithListOfElementsInConstructor() { ElementNoId element = new ElementNoId(); element.content = "content"; @@ -521,7 +521,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-259 @EnabledOnFeature(SUPPORTS_ARRAYS) - public void saveAndLoadAnEntityWithArray() { + void saveAndLoadAnEntityWithArray() { ArrayOwner arrayOwner = new ArrayOwner(); arrayOwner.digits = new String[] { "one", "two", "three" }; @@ -539,7 +539,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-259, DATAJDBC-512 @EnabledOnFeature(SUPPORTS_MULTIDIMENSIONAL_ARRAYS) - public void saveAndLoadAnEntityWithMultidimensionalArray() { + void saveAndLoadAnEntityWithMultidimensionalArray() { ArrayOwner arrayOwner = new ArrayOwner(); arrayOwner.multidimensional = new String[][] { { "one-a", "two-a", "three-a" }, { "one-b", "two-b", "three-b" } }; @@ -558,7 +558,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-259 @EnabledOnFeature(SUPPORTS_ARRAYS) - public void saveAndLoadAnEntityWithList() { + void saveAndLoadAnEntityWithList() { ListOwner arrayOwner = new ListOwner(); arrayOwner.digits.addAll(asList("one", "two", "three")); @@ -576,7 +576,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // GH-1033 @EnabledOnFeature(SUPPORTS_ARRAYS) - public void saveAndLoadAnEntityWithListOfDouble() { + void saveAndLoadAnEntityWithListOfDouble() { DoubleListOwner doubleListOwner = new DoubleListOwner(); doubleListOwner.digits.addAll(asList(1.2, 1.3, 1.4)); @@ -594,7 +594,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // GH-1033, GH-1046 @EnabledOnFeature(SUPPORTS_ARRAYS) - public void saveAndLoadAnEntityWithListOfFloat() { + void saveAndLoadAnEntityWithListOfFloat() { FloatListOwner floatListOwner = new FloatListOwner(); final List values = asList(1.2f, 1.3f, 1.4f); @@ -613,7 +613,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-259 @EnabledOnFeature(SUPPORTS_ARRAYS) - public void saveAndLoadAnEntityWithSet() { + void saveAndLoadAnEntityWithSet() { SetOwner setOwner = new SetOwner(); setOwner.digits.addAll(asList("one", "two", "three")); @@ -630,7 +630,7 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // DATAJDBC-327 - public void saveAndLoadAnEntityWithByteArray() { + void saveAndLoadAnEntityWithByteArray() { ByteArrayOwner owner = new ByteArrayOwner(); owner.binaryData = new byte[] { 1, 23, 42 }; @@ -646,7 +646,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-340 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadLongChain() { + void saveAndLoadLongChain() { Chain4 chain4 = new Chain4(); chain4.fourValue = "omega"; @@ -675,7 +675,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-359 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void saveAndLoadLongChainWithoutIds() { + void saveAndLoadLongChainWithoutIds() { NoIdChain4 chain4 = new NoIdChain4(); chain4.fourValue = "omega"; @@ -705,7 +705,7 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // DATAJDBC-223 - public void saveAndLoadLongChainOfListsWithoutIds() { + void saveAndLoadLongChainOfListsWithoutIds() { NoIdListChain4 saved = template.save(createNoIdTree()); @@ -716,7 +716,7 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // DATAJDBC-223 - public void shouldDeleteChainOfListsWithoutIds() { + void shouldDeleteChainOfListsWithoutIds() { NoIdListChain4 saved = template.save(createNoIdTree()); template.deleteById(saved.four, NoIdListChain4.class); @@ -732,7 +732,7 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // DATAJDBC-223 - public void saveAndLoadLongChainOfMapsWithoutIds() { + void saveAndLoadLongChainOfMapsWithoutIds() { NoIdMapChain4 saved = template.save(createNoIdMapTree()); @@ -743,7 +743,7 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // DATAJDBC-223 - public void shouldDeleteChainOfMapsWithoutIds() { + void shouldDeleteChainOfMapsWithoutIds() { NoIdMapChain4 saved = template.save(createNoIdMapTree()); template.deleteById(saved.four, NoIdMapChain4.class); @@ -760,7 +760,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-431 @EnabledOnFeature(IS_HSQL) - public void readOnlyGetsLoadedButNotWritten() { + void readOnlyGetsLoadedButNotWritten() { WithReadOnly entity = new WithReadOnly(); entity.name = "Alfred"; @@ -774,7 +774,7 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // DATAJDBC-219 Test that immutable version attribute works as expected. - public void saveAndUpdateAggregateWithImmutableVersion() { + void saveAndUpdateAggregateWithImmutableVersion() { AggregateWithImmutableVersion aggregate = new AggregateWithImmutableVersion(null, null); aggregate = template.save(aggregate); @@ -805,7 +805,7 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // DATAJDBC-219 Test that a delete with a version attribute works as expected. - public void deleteAggregateWithVersion() { + void deleteAggregateWithVersion() { AggregateWithImmutableVersion aggregate = new AggregateWithImmutableVersion(null, null); aggregate = template.save(aggregate); @@ -837,38 +837,38 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // DATAJDBC-219 - public void saveAndUpdateAggregateWithLongVersion() { + void saveAndUpdateAggregateWithLongVersion() { saveAndUpdateAggregateWithVersion(new AggregateWithLongVersion(), Number::longValue); } @Test // DATAJDBC-219 - public void saveAndUpdateAggregateWithPrimitiveLongVersion() { + void saveAndUpdateAggregateWithPrimitiveLongVersion() { saveAndUpdateAggregateWithPrimitiveVersion(new AggregateWithPrimitiveLongVersion(), Number::longValue); } @Test // DATAJDBC-219 - public void saveAndUpdateAggregateWithIntegerVersion() { + void saveAndUpdateAggregateWithIntegerVersion() { saveAndUpdateAggregateWithVersion(new AggregateWithIntegerVersion(), Number::intValue); } @Test // DATAJDBC-219 - public void saveAndUpdateAggregateWithPrimitiveIntegerVersion() { + void saveAndUpdateAggregateWithPrimitiveIntegerVersion() { saveAndUpdateAggregateWithPrimitiveVersion(new AggregateWithPrimitiveIntegerVersion(), Number::intValue); } @Test // DATAJDBC-219 - public void saveAndUpdateAggregateWithShortVersion() { + void saveAndUpdateAggregateWithShortVersion() { saveAndUpdateAggregateWithVersion(new AggregateWithShortVersion(), Number::shortValue); } @Test // DATAJDBC-219 - public void saveAndUpdateAggregateWithPrimitiveShortVersion() { + void saveAndUpdateAggregateWithPrimitiveShortVersion() { saveAndUpdateAggregateWithPrimitiveVersion(new AggregateWithPrimitiveShortVersion(), Number::shortValue); } @Test // DATAJDBC-462 @EnabledOnFeature(SUPPORTS_QUOTED_IDS) - public void resavingAnUnversionedEntity() { + void resavingAnUnversionedEntity() { LegoSet legoSet = new LegoSet(); @@ -879,7 +879,7 @@ public class JdbcAggregateTemplateIntegrationTests { @Test // DATAJDBC-637 @EnabledOnFeature(SUPPORTS_NANOSECOND_PRECISION) - public void saveAndLoadDateTimeWithFullPrecision() { + void saveAndLoadDateTimeWithFullPrecision() { WithLocalDateTime entity = new WithLocalDateTime(); entity.id = 23L; @@ -893,7 +893,7 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // DATAJDBC-637 - public void saveAndLoadDateTimeWithMicrosecondPrecision() { + void saveAndLoadDateTimeWithMicrosecondPrecision() { WithLocalDateTime entity = new WithLocalDateTime(); entity.id = 23L; @@ -907,7 +907,7 @@ public class JdbcAggregateTemplateIntegrationTests { } @Test // GH-777 - public void insertWithIdOnly() { + void insertWithIdOnly() { WithIdOnly entity = new WithIdOnly(); diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/EntityRowMapperUnitTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/EntityRowMapperUnitTests.java index 7983cc99..8e518626 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/EntityRowMapperUnitTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/EntityRowMapperUnitTests.java @@ -78,10 +78,10 @@ import org.springframework.util.LinkedCaseInsensitiveMap; */ public class EntityRowMapperUnitTests { - public static final long ID_FOR_ENTITY_REFERENCING_MAP = 42L; - public static final long ID_FOR_ENTITY_REFERENCING_LIST = 4711L; - public static final long ID_FOR_ENTITY_NOT_REFERENCING_MAP = 23L; - public static final NamingStrategy X_APPENDING_NAMINGSTRATEGY = new NamingStrategy() { + static final long ID_FOR_ENTITY_REFERENCING_MAP = 42L; + static final long ID_FOR_ENTITY_REFERENCING_LIST = 4711L; + static final long ID_FOR_ENTITY_NOT_REFERENCING_MAP = 23L; + static final NamingStrategy X_APPENDING_NAMINGSTRATEGY = new NamingStrategy() { @Override public String getColumnName(RelationalPersistentProperty property) { return NamingStrategy.super.getColumnName(property).concat("x"); @@ -89,7 +89,7 @@ public class EntityRowMapperUnitTests { }; @Test // DATAJDBC-113 - public void simpleEntitiesGetProperlyExtracted() throws SQLException { + void simpleEntitiesGetProperlyExtracted() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha"); @@ -104,7 +104,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-181 - public void namingStrategyGetsHonored() throws SQLException { + void namingStrategyGetsHonored() throws SQLException { ResultSet rs = mockResultSet(asList("IDX", "NAMEX"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha"); @@ -119,7 +119,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-181 - public void namingStrategyGetsHonoredForConstructor() throws SQLException { + void namingStrategyGetsHonoredForConstructor() throws SQLException { ResultSet rs = mockResultSet(asList("IDX", "NAMEX"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha"); @@ -134,7 +134,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-427 - public void simpleWithReferenceGetProperlyExtracted() throws SQLException { + void simpleWithReferenceGetProperlyExtracted() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "TRIVIAL_ID"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 100L); @@ -149,7 +149,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-113 - public void simpleOneToOneGetsProperlyExtracted() throws SQLException { + void simpleOneToOneGetsProperlyExtracted() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "CHILD_ID", "CHILD_NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 24L, "beta"); @@ -164,7 +164,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-286 - public void immutableOneToOneGetsProperlyExtracted() throws SQLException { + void immutableOneToOneGetsProperlyExtracted() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "CHILD_ID", "CHILD_NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 24L, "beta"); @@ -179,7 +179,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-427 - public void immutableWithReferenceGetsProperlyExtracted() throws SQLException { + void immutableWithReferenceGetsProperlyExtracted() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "TRIVIAL_ID"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 100L); @@ -195,7 +195,7 @@ public class EntityRowMapperUnitTests { // TODO add additional test for multilevel embeddables @Test // DATAJDBC-111 - public void simpleEmbeddedGetsProperlyExtracted() throws SQLException { + void simpleEmbeddedGetsProperlyExtracted() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "PREFIX_ID", "PREFIX_NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 24L, "beta"); @@ -210,7 +210,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-113 - public void collectionReferenceGetsLoadedWithAdditionalSelect() throws SQLException { + void collectionReferenceGetsLoadedWithAdditionalSelect() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha"); @@ -225,7 +225,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-131 - public void mapReferenceGetsLoadedWithAdditionalSelect() throws SQLException { + void mapReferenceGetsLoadedWithAdditionalSelect() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME"), // ID_FOR_ENTITY_REFERENCING_MAP, "alpha"); @@ -240,7 +240,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-130 - public void listReferenceGetsLoadedWithAdditionalSelect() throws SQLException { + void listReferenceGetsLoadedWithAdditionalSelect() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME"), // ID_FOR_ENTITY_REFERENCING_LIST, "alpha"); @@ -255,7 +255,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-252 - public void doesNotTryToSetPropertiesThatAreSetViaConstructor() throws SQLException { + void doesNotTryToSetPropertiesThatAreSetViaConstructor() throws SQLException { ResultSet rs = mockResultSet(singletonList("VALUE"), // "value-from-resultSet"); @@ -268,7 +268,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-252 - public void handlesMixedProperties() throws SQLException { + void handlesMixedProperties() throws SQLException { ResultSet rs = mockResultSet(asList("ONE", "TWO", "THREE"), // "111", "222", "333"); @@ -282,7 +282,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-359 - public void chainedEntitiesWithoutId() throws SQLException { + void chainedEntitiesWithoutId() throws SQLException { // @formatter:off Fixture fixture = this. buildFixture() // @@ -318,7 +318,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-370 - public void simpleNullableImmutableEmbeddedGetsProperlyExtracted() throws SQLException { + void simpleNullableImmutableEmbeddedGetsProperlyExtracted() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "VALUE", "NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "ru'Ha'", "Alfred"); @@ -334,7 +334,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-374 - public void simpleEmptyImmutableEmbeddedGetsProperlyExtracted() throws SQLException { + void simpleEmptyImmutableEmbeddedGetsProperlyExtracted() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "VALUE", "NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, null, null); @@ -349,7 +349,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-370 - public void simplePrimitiveImmutableEmbeddedGetsProperlyExtracted() throws SQLException { + void simplePrimitiveImmutableEmbeddedGetsProperlyExtracted() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "VALUE"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, 24); @@ -365,7 +365,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-370 - public void simpleImmutableEmbeddedShouldBeNullIfAllOfTheEmbeddableAreNull() throws SQLException { + void simpleImmutableEmbeddedShouldBeNullIfAllOfTheEmbeddableAreNull() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "VALUE", "NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, null, null); @@ -381,7 +381,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-370 - public void embeddedShouldBeNullWhenFieldsAreNull() throws SQLException { + void embeddedShouldBeNullWhenFieldsAreNull() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "PREFIX_ID", "PREFIX_NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", null, null); @@ -396,7 +396,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-370 - public void embeddedShouldNotBeNullWhenAtLeastOneFieldIsNotNull() throws SQLException { + void embeddedShouldNotBeNullWhenAtLeastOneFieldIsNotNull() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "PREFIX_ID", "PREFIX_NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 24, null); @@ -411,7 +411,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-370 - public void primitiveEmbeddedShouldBeNullWhenNoValuePresent() throws SQLException { + void primitiveEmbeddedShouldBeNullWhenNoValuePresent() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "VALUE"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, null); @@ -427,7 +427,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-370 - public void deepNestedEmbeddable() throws SQLException { + void deepNestedEmbeddable() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "LEVEL0", "LEVEL1_VALUE", "LEVEL1_LEVEL2_VALUE", "LEVEL1_LEVEL2_NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "0", "1", "2", "Rumpelstilzchen"); @@ -442,7 +442,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void missingValueForObjectGetsMappedToZero() throws SQLException { + void missingValueForObjectGetsMappedToZero() throws SQLException { ResultSet rs = mockResultSet(singletonList("id"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP); @@ -457,7 +457,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void missingValueForConstructorArgCausesException() throws SQLException { + void missingValueForConstructorArgCausesException() throws SQLException { ResultSet rs = mockResultSet(singletonList("id"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP); @@ -470,7 +470,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void missingColumnForPrimitiveGetsMappedToZero() throws SQLException { + void missingColumnForPrimitiveGetsMappedToZero() throws SQLException { ResultSet rs = mockResultSet(singletonList("id"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP); @@ -486,7 +486,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void columnNamesAreCaseInsensitive() throws SQLException { + void columnNamesAreCaseInsensitive() throws SQLException { ResultSet rs = mockResultSet(asList("id", "name"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha"); @@ -501,7 +501,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void immutableEmbeddedWithAllColumnsMissingShouldBeNull() throws SQLException { + void immutableEmbeddedWithAllColumnsMissingShouldBeNull() throws SQLException { ResultSet rs = mockResultSet(asList("ID"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP); @@ -517,7 +517,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void immutableEmbeddedWithSomeColumnsMissingShouldNotBeEmpty() throws SQLException { + void immutableEmbeddedWithSomeColumnsMissingShouldNotBeEmpty() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "VALUE"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "some value"); @@ -529,7 +529,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void immutableEmbeddedWithSomeColumnsMissingAndSomeNullShouldBeNull() throws SQLException { + void immutableEmbeddedWithSomeColumnsMissingAndSomeNullShouldBeNull() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "VALUE"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, null); @@ -545,7 +545,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void embeddedShouldBeNullWhenAllFieldsAreMissing() throws SQLException { + void embeddedShouldBeNullWhenAllFieldsAreMissing() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha"); @@ -560,7 +560,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void missingColumnsInEmbeddedShouldBeUnset() throws SQLException { + void missingColumnsInEmbeddedShouldBeUnset() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "PREFIX_ID"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 24); @@ -575,7 +575,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void primitiveEmbeddedShouldBeNullWhenAllColumnsAreMissing() throws SQLException { + void primitiveEmbeddedShouldBeNullWhenAllColumnsAreMissing() throws SQLException { ResultSet rs = mockResultSet(asList("ID"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP); @@ -591,7 +591,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void oneToOneWithMissingColumnResultsInNullProperty() throws SQLException { + void oneToOneWithMissingColumnResultsInNullProperty() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "CHILD_ID"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", 24L); @@ -606,7 +606,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void oneToOneWithMissingIdColumnResultsInNullProperty() throws SQLException { + void oneToOneWithMissingIdColumnResultsInNullProperty() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "CHILD_NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", "Alfred"); @@ -618,7 +618,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-341 - public void immutableOneToOneWithIdMissingColumnResultsInNullReference() throws SQLException { + void immutableOneToOneWithIdMissingColumnResultsInNullReference() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "NAME", "CHILD_NAME"), // ID_FOR_ENTITY_NOT_REFERENCING_MAP, "alpha", "Alfred"); @@ -632,7 +632,7 @@ public class EntityRowMapperUnitTests { } @Test // DATAJDBC-508 - public void materializesObjectWithAtValue() throws SQLException { + void materializesObjectWithAtValue() throws SQLException { ResultSet rs = mockResultSet(asList("ID", "FIRST_NAME"), // 123L, "Hello World"); @@ -939,7 +939,7 @@ public class EntityRowMapperUnitTests { private final List> values; private int index = -1; - public ResultSetAnswer(List names, List> values) { + ResultSetAnswer(List names, List> values) { this.names = names; this.values = values; diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/BasicRelationalConverter.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/BasicRelationalConverter.java index 2df973be..22f950e2 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/BasicRelationalConverter.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/BasicRelationalConverter.java @@ -218,6 +218,7 @@ public class BasicRelationalConverter implements RelationalConverter { @Nullable @SuppressWarnings({ "rawtypes", "unchecked" }) private Object getPotentiallyConvertedSimpleRead(Object value, TypeInformation type) { + Class target = type.getType(); if (ClassUtils.isAssignableValue(target, value)) { return value; diff --git a/spring-data-relational/src/test/java/org/springframework/data/relational/core/conversion/BasicRelationalConverterUnitTests.java b/spring-data-relational/src/test/java/org/springframework/data/relational/core/conversion/BasicRelationalConverterUnitTests.java index 5499b83b..5d3ed288 100644 --- a/spring-data-relational/src/test/java/org/springframework/data/relational/core/conversion/BasicRelationalConverterUnitTests.java +++ b/spring-data-relational/src/test/java/org/springframework/data/relational/core/conversion/BasicRelationalConverterUnitTests.java @@ -17,6 +17,9 @@ package org.springframework.data.relational.core.conversion; import static org.assertj.core.api.Assertions.*; +import lombok.Data; +import lombok.Value; + import java.util.Arrays; import java.util.List; import java.util.Set; @@ -33,16 +36,13 @@ import org.springframework.data.relational.core.mapping.RelationalPersistentProp import org.springframework.data.util.ClassTypeInformation; import org.springframework.data.util.TypeInformation; -import lombok.Data; -import lombok.Value; - /** * Unit tests for {@link BasicRelationalConverter}. * * @author Mark Paluch * @author Chirag Tailor */ -public class BasicRelationalConverterUnitTests { +class BasicRelationalConverterUnitTests { RelationalMappingContext context = new RelationalMappingContext(); RelationalConverter converter; @@ -61,7 +61,7 @@ public class BasicRelationalConverterUnitTests { @Test // DATAJDBC-235 @SuppressWarnings("unchecked") - public void shouldUseConvertingPropertyAccessor() { + void shouldUseConvertingPropertyAccessor() { RelationalPersistentEntity entity = (RelationalPersistentEntity) context .getRequiredPersistentEntity(MyEntity.class); @@ -76,7 +76,7 @@ public class BasicRelationalConverterUnitTests { } @Test // DATAJDBC-235 - public void shouldConvertEnumToString() { + void shouldConvertEnumToString() { Object result = converter.writeValue(MyEnum.ON, ClassTypeInformation.from(String.class)); @@ -84,7 +84,7 @@ public class BasicRelationalConverterUnitTests { } @Test // DATAJDBC-235 - public void shouldConvertStringToEnum() { + void shouldConvertStringToEnum() { Object result = converter.readValue("OFF", ClassTypeInformation.from(MyEnum.class)); @@ -93,15 +93,17 @@ public class BasicRelationalConverterUnitTests { @Test // GH-1046 void shouldConvertArrayElementsToTargetElementType() throws NoSuchMethodException { - TypeInformation typeInformation = ClassTypeInformation.fromReturnTypeOf(EntityWithArray.class.getMethod("getFloats")); - Double[] value = {1.2d, 1.3d, 1.4d}; + + TypeInformation typeInformation = ClassTypeInformation + .fromReturnTypeOf(EntityWithArray.class.getMethod("getFloats")); + Double[] value = { 1.2d, 1.3d, 1.4d }; Object result = converter.readValue(value, typeInformation); assertThat(result).isEqualTo(Arrays.asList(1.2f, 1.3f, 1.4f)); } @Test // DATAJDBC-235 @SuppressWarnings("unchecked") - public void shouldCreateInstance() { + void shouldCreateInstance() { RelationalPersistentEntity entity = (RelationalPersistentEntity) context .getRequiredPersistentEntity(WithConstructorCreation.class); @@ -112,7 +114,7 @@ public class BasicRelationalConverterUnitTests { } @Test // DATAJDBC-516 - public void shouldConsiderWriteConverter() { + void shouldConsiderWriteConverter() { Object result = converter.writeValue(new MyValue("hello-world"), ClassTypeInformation.from(MyValue.class)); @@ -120,7 +122,7 @@ public class BasicRelationalConverterUnitTests { } @Test // DATAJDBC-516 - public void shouldConsiderReadConverter() { + void shouldConsiderReadConverter() { Object result = converter.readValue("hello-world", ClassTypeInformation.from(MyValue.class));