|
23 | 23 | import java.lang.annotation.Annotation; |
24 | 24 | import java.lang.annotation.Retention; |
25 | 25 | import java.lang.annotation.RetentionPolicy; |
| 26 | +import java.util.ArrayList; |
26 | 27 | import java.util.Comparator; |
27 | 28 | import java.util.Iterator; |
28 | 29 | import java.util.List; |
|
36 | 37 | import org.mockito.Mock; |
37 | 38 | import org.mockito.Mockito; |
38 | 39 | import org.mockito.junit.jupiter.MockitoExtension; |
39 | | - |
40 | 40 | import org.springframework.core.annotation.AliasFor; |
41 | 41 | import org.springframework.data.annotation.AccessType; |
42 | 42 | import org.springframework.data.annotation.AccessType.Type; |
|
45 | 45 | import org.springframework.data.annotation.Immutable; |
46 | 46 | import org.springframework.data.annotation.LastModifiedBy; |
47 | 47 | import org.springframework.data.annotation.Persistent; |
| 48 | +import org.springframework.data.annotation.Reference; |
48 | 49 | import org.springframework.data.annotation.Transient; |
49 | 50 | import org.springframework.data.annotation.TypeAlias; |
50 | 51 | import org.springframework.data.domain.Persistable; |
@@ -361,6 +362,17 @@ void exposesPropertyPopulationNotRequired() { |
361 | 362 | .forEach(it -> assertThat(createPopulatedPersistentEntity(it).requiresPropertyPopulation()).isFalse()); |
362 | 363 | } |
363 | 364 |
|
| 365 | + @Test // #2325 |
| 366 | + void doWithAllInvokesPropertyHandlerForBothAPropertiesAndAssociations() { |
| 367 | + |
| 368 | + PersistentEntity<?, ?> entity = createPopulatedPersistentEntity(WithAssociation.class); |
| 369 | + |
| 370 | + List<String> seenProperties = new ArrayList<>(); |
| 371 | + entity.doWithAll(property -> seenProperties.add(property.getName())); |
| 372 | + |
| 373 | + assertThat(seenProperties).containsExactlyInAnyOrder("property", "association"); |
| 374 | + } |
| 375 | + |
364 | 376 | private <S> BasicPersistentEntity<S, T> createEntity(Class<S> type) { |
365 | 377 | return createEntity(type, null); |
366 | 378 | } |
@@ -461,4 +473,12 @@ private static class PropertyPopulationNotRequiredWithTransient { |
461 | 473 | private final String firstname, lastname; |
462 | 474 | private @Transient String email; |
463 | 475 | } |
| 476 | + |
| 477 | + // #2325 |
| 478 | + |
| 479 | + static class WithAssociation { |
| 480 | + |
| 481 | + String property; |
| 482 | + @Reference WithAssociation association; |
| 483 | + } |
464 | 484 | } |
0 commit comments