Skip to content

Commit 0ca8dc5

Browse files
Added Lazy Tests
1 parent 40ff3e0 commit 0ca8dc5

File tree

1 file changed

+31
-0
lines changed
  • spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy

1 file changed

+31
-0
lines changed

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/lazy/LazyTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,46 @@ void lazyClearAfterSave(@Autowired final ObjectWithLazyRepository<SimpleObject>
338338
final ObjectWithLazy<SimpleObject> newLazy = new ObjectWithLazy<>();
339339
final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
340340
newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
341+
342+
Assertions.assertTrue(newLazy.getLazy().isLoaded());
343+
Assertions.assertFalse(newLazy.getLazy().isStored());
344+
341345
repository.save(newLazy);
346+
347+
Assertions.assertTrue(newLazy.getLazy().isLoaded());
348+
Assertions.assertTrue(newLazy.getLazy().isStored());
349+
342350
newLazy.getLazy().clear();
343351

344352
TestUtil.doBeforeAndAfterRestartOfDatastore(
345353
this.configuration,
346354
() -> {
347355
Assertions.assertEquals(1, repository.findAll().size());
348356
final Lazy<SimpleObject> lazy = repository.findAll().get(0).getLazy();
357+
Assertions.assertFalse(lazy.isLoaded());
358+
Assertions.assertEquals(objectToStore, lazy.get());
359+
Assertions.assertTrue(lazy.isLoaded());
360+
}
361+
);
362+
}
363+
364+
@Test
365+
void lazyClearThroughLazyManagerAfterSave(@Autowired final ObjectWithLazyRepository<SimpleObject> repository)
366+
{
367+
final ObjectWithLazy<SimpleObject> newLazy = new ObjectWithLazy<>();
368+
final SimpleObject objectToStore = new SimpleObject(TestData.DUMMY_STRING);
369+
newLazy.setLazy(SpringDataEclipseStoreLazy.build(objectToStore));
370+
repository.save(newLazy);
371+
LazyReferenceManager.get().cleanUp();
372+
373+
TestUtil.doBeforeAndAfterRestartOfDatastore(
374+
this.configuration,
375+
() -> {
376+
Assertions.assertEquals(1, repository.findAll().size());
377+
final Lazy<SimpleObject> lazy = repository.findAll().get(0).getLazy();
378+
Assertions.assertFalse(lazy.isLoaded());
349379
Assertions.assertEquals(objectToStore, lazy.get());
380+
Assertions.assertTrue(lazy.isLoaded());
350381
}
351382
);
352383
}

0 commit comments

Comments
 (0)