|
16 | 16 | package org.springframework.data.mapping.model; |
17 | 17 |
|
18 | 18 | import static org.assertj.core.api.Assertions.*; |
19 | | -import static org.junit.Assume.assumeThat; |
| 19 | +import static org.junit.Assume.*; |
20 | 20 | import static org.mockito.Mockito.*; |
21 | 21 |
|
22 | 22 | import java.lang.annotation.Retention; |
|
27 | 27 | import java.util.Optional; |
28 | 28 |
|
29 | 29 | import org.hamcrest.CoreMatchers; |
30 | | -import org.junit.Assert; |
31 | 30 | import org.junit.Rule; |
32 | 31 | import org.junit.Test; |
33 | 32 | import org.junit.rules.ExpectedException; |
|
41 | 40 | import org.springframework.data.annotation.LastModifiedBy; |
42 | 41 | import org.springframework.data.annotation.TypeAlias; |
43 | 42 | import org.springframework.data.mapping.Alias; |
44 | | -import org.springframework.data.mapping.Association; |
45 | 43 | import org.springframework.data.mapping.PersistentEntity; |
46 | 44 | import org.springframework.data.mapping.PersistentEntitySpec; |
47 | 45 | import org.springframework.data.mapping.PersistentProperty; |
48 | 46 | import org.springframework.data.mapping.PersistentPropertyAccessor; |
49 | 47 | import org.springframework.data.mapping.Person; |
50 | | -import org.springframework.data.mapping.SimpleAssociationHandler; |
51 | 48 | import org.springframework.data.mapping.context.SampleMappingContext; |
52 | 49 | import org.springframework.data.mapping.context.SamplePersistentProperty; |
53 | 50 | import org.springframework.data.util.ClassTypeInformation; |
@@ -243,13 +240,12 @@ public void invalidBeanAccessCreatesDescriptiveErrorMessage() { |
243 | 240 | entity.getPropertyAccessor(new Object()); |
244 | 241 | } |
245 | 242 |
|
246 | | - @Test // DATACMNS-934 |
247 | | - public void doesNotThrowAnExceptionForNullAssociation() { |
| 243 | + @Test // DATACMNS-934, DATACMNS-867 |
| 244 | + public void rejectsNullAssociation() { |
248 | 245 |
|
249 | | - BasicPersistentEntity<Entity, T> entity = createEntity(Entity.class); |
250 | | - entity.addAssociation(null); |
| 246 | + MutablePersistentEntity<Entity, T> entity = createEntity(Entity.class); |
251 | 247 |
|
252 | | - entity.doWithAssociations((SimpleAssociationHandler) association -> Assert.fail("Expected the method to never be called!")); |
| 248 | + assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> entity.addAssociation(null)); |
253 | 249 | } |
254 | 250 |
|
255 | 251 | private <S> BasicPersistentEntity<S, T> createEntity(Class<S> type) { |
|
0 commit comments