|
19 | 19 |
|
20 | 20 | import java.util.ArrayList; |
21 | 21 | import java.util.Arrays; |
| 22 | +import java.util.HashMap; |
22 | 23 | import java.util.List; |
23 | 24 | import java.util.Optional; |
24 | 25 |
|
|
37 | 38 | import software.xdev.spring.data.eclipse.store.helper.TestUtil; |
38 | 39 | import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; |
39 | 40 | import software.xdev.spring.data.eclipse.store.repository.lazy.SpringDataEclipseStoreLazy; |
| 41 | +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.EntityData; |
| 42 | +import software.xdev.spring.data.eclipse.store.repository.root.v2_4.LazyEntityData; |
40 | 43 |
|
41 | 44 |
|
42 | 45 | @SuppressWarnings("checkstyle:MethodName") |
@@ -302,7 +305,6 @@ void lazyClearBeforeSave() |
302 | 305 | } |
303 | 306 |
|
304 | 307 | @Test |
305 | | - @Disabled("This should work at some point. At least a warning should be displayed.") |
306 | 308 | void lazyUseEclipseStoreLazy(@Autowired final ObjectWithLazyRepository<SimpleObject> repository) |
307 | 309 | { |
308 | 310 | final ObjectWithLazy<SimpleObject> newLazy = new ObjectWithLazy<>(); |
@@ -515,19 +517,25 @@ void simpleEntityWithIdLazyWrappedRepository_FindById( |
515 | 517 | void simpleEntityWithIdLazyRepository_FindById(@Autowired final SimpleEntityWithIdLazyRepository repository) |
516 | 518 | { |
517 | 519 | final SimpleEntityWithId objectToStore1 = new SimpleEntityWithId(TestData.DUMMY_STRING); |
518 | | - repository.save(objectToStore1); |
| 520 | + final Long object1Id = repository.save(objectToStore1).getId(); |
519 | 521 | final SimpleEntityWithId objectToStore2 = new SimpleEntityWithId(TestData.DUMMY_STRING); |
520 | | - repository.save(objectToStore2); |
521 | | - |
522 | | - final List<SimpleEntityWithId> all = repository.findAll(); |
| 522 | + final Long object2Id = repository.save(objectToStore2).getId(); |
523 | 523 |
|
524 | 524 | TestUtil.doBeforeAndAfterRestartOfDatastore( |
525 | 525 | this.configuration, |
526 | 526 | () -> { |
527 | | - final Optional<SimpleEntityWithId> reloadedObject = |
528 | | - repository.findById(all.get(0).getId()); |
| 527 | + LazyReferenceManager.get().cleanUp(); |
| 528 | + final Optional<SimpleEntityWithId> reloadedObject = repository.findById(object1Id); |
529 | 529 | Assertions.assertTrue(reloadedObject.isPresent()); |
530 | 530 | } |
531 | 531 | ); |
| 532 | + final EntityData<SimpleEntityWithId, Long> entityData = this.configuration.getStorageInstance() |
| 533 | + .getRoot() |
| 534 | + .getCurrentRootData() |
| 535 | + .getEntityData(SimpleEntityWithId.class); |
| 536 | + final HashMap<Long, Lazy<SimpleEntityWithId>> lazyEntitiesById = |
| 537 | + ((LazyEntityData<SimpleEntityWithId, Long>)entityData).getNativeLazyEntitiesById(); |
| 538 | + Assertions.assertTrue(lazyEntitiesById.get(object1Id).isLoaded()); |
| 539 | + Assertions.assertFalse(lazyEntitiesById.get(object2Id).isLoaded()); |
532 | 540 | } |
533 | 541 | } |
0 commit comments