Polishing.
Improves tests by also testing for the negative case. Original pull request #938
This commit is contained in:
@@ -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<Integer> overrideList;
|
||||
}
|
||||
|
||||
static class WithAssociations {
|
||||
AggregateReference<Object, Long> association;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user