@@ -188,16 +188,8 @@ void lazyWorkingCopyChangeAfterRestart(@Autowired final ObjectWithLazyRepository
188188 @ Test
189189 void lazyStoreComplexObject (@ Autowired final ObjectWithLazyRepository <ComplexLazyObject > repository )
190190 {
191- final ObjectWithLazy <ComplexLazyObject > newLazy = new ObjectWithLazy <>();
192- final ComplexLazyObject objectToStore = new ComplexLazyObject (
193- SpringDataEclipseStoreLazy .build (new SimpleObject (TestData .DUMMY_STRING )),
194- new ArrayList <>(Arrays .asList (
195- SpringDataEclipseStoreLazy .build (new ArrayList <>(Arrays .asList (TestData .DUMMY_STRING ))),
196- SpringDataEclipseStoreLazy .build (new ArrayList <>(Arrays .asList (TestData .DUMMY_STRING_ALTERNATIVE )))
197- ))
198- );
199- newLazy .setLazy (SpringDataEclipseStoreLazy .build (objectToStore ));
200- repository .save (newLazy );
191+ final ComplexLazyObject objectToStore =
192+ prepareLazyComplexObject (repository );
201193
202194 TestUtil .doBeforeAndAfterRestartOfDatastore (
203195 this .configuration ,
@@ -222,16 +214,7 @@ void lazyStoreComplexObject(@Autowired final ObjectWithLazyRepository<ComplexLaz
222214 @ Test
223215 void lazyChangeComplexObject (@ Autowired final ObjectWithLazyRepository <ComplexLazyObject > repository )
224216 {
225- final ObjectWithLazy <ComplexLazyObject > newLazy = new ObjectWithLazy <>();
226- final ComplexLazyObject objectToStore = new ComplexLazyObject (
227- SpringDataEclipseStoreLazy .build (new SimpleObject (TestData .DUMMY_STRING )),
228- new ArrayList <>(Arrays .asList (
229- SpringDataEclipseStoreLazy .build (new ArrayList <>(Arrays .asList (TestData .DUMMY_STRING ))),
230- SpringDataEclipseStoreLazy .build (new ArrayList <>(Arrays .asList (TestData .DUMMY_STRING_ALTERNATIVE )))
231- ))
232- );
233- newLazy .setLazy (SpringDataEclipseStoreLazy .build (objectToStore ));
234- repository .save (newLazy );
217+ prepareLazyComplexObject (repository );
235218
236219 restartDatastore (this .configuration );
237220
@@ -243,50 +226,43 @@ void lazyChangeComplexObject(@Autowired final ObjectWithLazyRepository<ComplexLa
243226 .add (SpringDataEclipseStoreLazy .build (List .of (TestData .DUMMY_STRING_ALTERNATIVE )));
244227 repository .save (loadedObjectToChange );
245228
246- TestUtil .doBeforeAndAfterRestartOfDatastore (
247- this .configuration ,
248- () -> {
249- final ObjectWithLazy <ComplexLazyObject > loadedObject = repository .findAll ().get (0 );
250- Assertions .assertNotSame (loadedObjectToChange , loadedObject );
251- Assertions .assertNotSame (
252- loadedObjectToChange .getLazy ().get (),
253- loadedObject .getLazy ().get ()
254- );
255- Assertions .assertEquals (
256- loadedObjectToChange .getLazy ().get ().getListOfLazyListOfString ().size (),
257- loadedObject .getLazy ().get ().getListOfLazyListOfString ().size ()
258- );
259- Assertions .assertEquals (
260- loadedObjectToChange .getLazy ().get ().getListOfLazyListOfString ().get (0 ).get ().size (),
261- loadedObject .getLazy ().get ().getListOfLazyListOfString ().get (0 ).get ().size ()
262- );
263- Assertions .assertEquals (
264- loadedObjectToChange .getLazy ().get ().getListOfLazyListOfString ().get (0 ).get ().get (0 ),
265- loadedObject .getLazy ().get ().getListOfLazyListOfString ().get (0 ).get ().get (0 )
266- );
267- }
268- );
229+ this .validateLazyComplexObject (repository , loadedObjectToChange );
269230 }
270231
271232 @ Test
272233 void lazyReloadAndRestoreComplexObject (@ Autowired final ObjectWithLazyRepository <ComplexLazyObject > repository )
234+ {
235+ prepareLazyComplexObject (repository );
236+
237+ restartDatastore (this .configuration );
238+
239+ final ObjectWithLazy <ComplexLazyObject > loadedObjectToChange = repository .findAll ().get (0 );
240+ repository .save (loadedObjectToChange );
241+
242+ this .validateLazyComplexObject (repository , loadedObjectToChange );
243+ }
244+
245+ private static ComplexLazyObject prepareLazyComplexObject (
246+ final ObjectWithLazyRepository <ComplexLazyObject > repository )
273247 {
274248 final ObjectWithLazy <ComplexLazyObject > newLazy = new ObjectWithLazy <>();
275249 final ComplexLazyObject objectToStore = new ComplexLazyObject (
276250 SpringDataEclipseStoreLazy .build (new SimpleObject (TestData .DUMMY_STRING )),
277251 new ArrayList <>(Arrays .asList (
278- SpringDataEclipseStoreLazy .build (new ArrayList <>(Arrays . asList (TestData .DUMMY_STRING ))),
279- SpringDataEclipseStoreLazy .build (new ArrayList <>(Arrays . asList (TestData .DUMMY_STRING_ALTERNATIVE )))
252+ SpringDataEclipseStoreLazy .build (new ArrayList <>(List . of (TestData .DUMMY_STRING ))),
253+ SpringDataEclipseStoreLazy .build (new ArrayList <>(List . of (TestData .DUMMY_STRING_ALTERNATIVE )))
280254 ))
281255 );
282256 newLazy .setLazy (SpringDataEclipseStoreLazy .build (objectToStore ));
283257 repository .save (newLazy );
284258
285- restartDatastore (this .configuration );
286-
287- final ObjectWithLazy <ComplexLazyObject > loadedObjectToChange = repository .findAll ().get (0 );
288- repository .save (loadedObjectToChange );
289-
259+ return objectToStore ;
260+ }
261+
262+ private void validateLazyComplexObject (
263+ final ObjectWithLazyRepository <ComplexLazyObject > repository ,
264+ final ObjectWithLazy <ComplexLazyObject > loadedObjectToChange )
265+ {
290266 TestUtil .doBeforeAndAfterRestartOfDatastore (
291267 this .configuration ,
292268 () -> {
0 commit comments