Skip to content

Commit 0e8e8a4

Browse files
committed
Polishing.
Improves tests by also testing for the negative case. Original pull request #938
1 parent 32d79cc commit 0e8e8a4

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentPropertyUnitTests.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.List;
2828
import java.util.UUID;
2929

30+
import org.assertj.core.api.SoftAssertions;
3031
import org.junit.jupiter.api.Test;
3132
import org.springframework.data.annotation.Id;
3233
import org.springframework.data.mapping.PersistentPropertyPath;
@@ -98,10 +99,33 @@ public void detectsKeyColumnOverrideNameFromMappedCollectionAnnotation() {
9899
@Test // #938
99100
void considersAggregateReferenceAnAssociation() {
100101

101-
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(WithAssociations.class);
102-
RelationalPersistentProperty property = entity.getRequiredPersistentProperty("association");
103-
104-
assertThat(property.isAssociation()).isTrue();
102+
RelationalPersistentEntity<?> entity = context.getRequiredPersistentEntity(DummyEntity.class);
103+
104+
SoftAssertions.assertSoftly(softly -> {
105+
106+
softly.assertThat(entity.getRequiredPersistentProperty("reference").isAssociation()) //
107+
.as("reference") //
108+
.isTrue();
109+
110+
softly.assertThat(entity.getRequiredPersistentProperty("id").isAssociation()) //
111+
.as("id") //
112+
.isFalse();
113+
softly.assertThat(entity.getRequiredPersistentProperty("someEnum").isAssociation()) //
114+
.as("someEnum") //
115+
.isFalse();
116+
softly.assertThat(entity.getRequiredPersistentProperty("localDateTime").isAssociation()) //
117+
.as("localDateTime") //
118+
.isFalse();
119+
softly.assertThat(entity.getRequiredPersistentProperty("zonedDateTime").isAssociation()) //
120+
.as("zonedDateTime") //
121+
.isFalse();
122+
softly.assertThat(entity.getRequiredPersistentProperty("listField").isAssociation()) //
123+
.as("listField") //
124+
.isFalse();
125+
softly.assertThat(entity.getRequiredPersistentProperty("uuid").isAssociation()) //
126+
.as("uuid") //
127+
.isFalse();
128+
});
105129
}
106130

107131
private PersistentPropertyPathExtension getPersistentPropertyPath(Class<?> type, String propertyName) {
@@ -158,8 +182,4 @@ private static class WithCollections {
158182
@MappedCollection(idColumn = "override_id", keyColumn = "override_key") //
159183
List<Integer> overrideList;
160184
}
161-
162-
static class WithAssociations {
163-
AggregateReference<Object, Long> association;
164-
}
165185
}

0 commit comments

Comments
 (0)