From 0e8e8a4799937cd4908b17cdb11b995f25fd1e6f Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Fri, 12 Mar 2021 11:22:04 +0100 Subject: [PATCH] Polishing. Improves tests by also testing for the negative case. Original pull request #938 --- .../BasicJdbcPersistentPropertyUnitTests.java | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentPropertyUnitTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentPropertyUnitTests.java index 5e5ad09b..7a566a84 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentPropertyUnitTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentPropertyUnitTests.java @@ -27,6 +27,7 @@ import java.util.Date; import java.util.List; import java.util.UUID; +import org.assertj.core.api.SoftAssertions; import org.junit.jupiter.api.Test; import org.springframework.data.annotation.Id; import org.springframework.data.mapping.PersistentPropertyPath; @@ -98,10 +99,33 @@ public class BasicJdbcPersistentPropertyUnitTests { @Test // #938 void considersAggregateReferenceAnAssociation() { - RelationalPersistentEntity entity = context.getRequiredPersistentEntity(WithAssociations.class); - RelationalPersistentProperty property = entity.getRequiredPersistentProperty("association"); + RelationalPersistentEntity entity = context.getRequiredPersistentEntity(DummyEntity.class); - assertThat(property.isAssociation()).isTrue(); + SoftAssertions.assertSoftly(softly -> { + + softly.assertThat(entity.getRequiredPersistentProperty("reference").isAssociation()) // + .as("reference") // + .isTrue(); + + softly.assertThat(entity.getRequiredPersistentProperty("id").isAssociation()) // + .as("id") // + .isFalse(); + softly.assertThat(entity.getRequiredPersistentProperty("someEnum").isAssociation()) // + .as("someEnum") // + .isFalse(); + softly.assertThat(entity.getRequiredPersistentProperty("localDateTime").isAssociation()) // + .as("localDateTime") // + .isFalse(); + softly.assertThat(entity.getRequiredPersistentProperty("zonedDateTime").isAssociation()) // + .as("zonedDateTime") // + .isFalse(); + softly.assertThat(entity.getRequiredPersistentProperty("listField").isAssociation()) // + .as("listField") // + .isFalse(); + softly.assertThat(entity.getRequiredPersistentProperty("uuid").isAssociation()) // + .as("uuid") // + .isFalse(); + }); } private PersistentPropertyPathExtension getPersistentPropertyPath(Class type, String propertyName) { @@ -158,8 +182,4 @@ public class BasicJdbcPersistentPropertyUnitTests { @MappedCollection(idColumn = "override_id", keyColumn = "override_key") // List overrideList; } - - static class WithAssociations { - AggregateReference association; - } }