2222
2323import  lombok .AllArgsConstructor ;
2424import  lombok .Data ;
25- 
2625import  lombok .RequiredArgsConstructor ;
26+ 
2727import  org .junit .jupiter .api .BeforeEach ;
2828import  org .junit .jupiter .api .Test ;
2929import  org .junit .jupiter .api .extension .ExtendWith ;
@@ -115,7 +115,7 @@ public void callbackOnSave() {
115115assertThat (last ).isEqualTo (third );
116116}
117117
118- @ Test 
118+ @ Test   // GH-1137 
119119void  savePreparesInstanceWithInitialVersion_onInsert () {
120120
121121EntityWithVersion  entity  = new  EntityWithVersion (1L );
@@ -125,11 +125,12 @@ void savePreparesInstanceWithInitialVersion_onInsert() {
125125
126126ArgumentCaptor <Object > aggregateRootCaptor  = ArgumentCaptor .forClass (Object .class );
127127verify (callbacks ).callback (eq (BeforeSaveCallback .class ), aggregateRootCaptor .capture (), any ());
128+ 
128129EntityWithVersion  afterConvert  = (EntityWithVersion ) aggregateRootCaptor .getValue ();
129130assertThat (afterConvert .getVersion ()).isEqualTo (0L );
130131}
131132
132- @ Test 
133+ @ Test   // GH-1137 
133134void  savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsImmutable () {
134135
135136EntityWithImmutableVersion  entity  = new  EntityWithImmutableVersion (1L , null );
@@ -139,11 +140,12 @@ void savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsImmuta
139140
140141ArgumentCaptor <Object > aggregateRootCaptor  = ArgumentCaptor .forClass (Object .class );
141142verify (callbacks ).callback (eq (BeforeSaveCallback .class ), aggregateRootCaptor .capture (), any ());
143+ 
142144EntityWithImmutableVersion  afterConvert  = (EntityWithImmutableVersion ) aggregateRootCaptor .getValue ();
143145assertThat (afterConvert .getVersion ()).isEqualTo (0L );
144146}
145147
146- @ Test    // DATAJDBC-507  
148+ @ Test  // GH-1137  
147149void  savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsPrimitiveType () {
148150
149151EntityWithPrimitiveVersion  entity  = new  EntityWithPrimitiveVersion (1L );
@@ -153,11 +155,12 @@ void savePreparesInstanceWithInitialVersion_onInsert_whenVersionPropertyIsPrimit
153155
154156ArgumentCaptor <Object > aggregateRootCaptor  = ArgumentCaptor .forClass (Object .class );
155157verify (callbacks ).callback (eq (BeforeSaveCallback .class ), aggregateRootCaptor .capture (), any ());
158+ 
156159EntityWithPrimitiveVersion  afterConvert  = (EntityWithPrimitiveVersion ) aggregateRootCaptor .getValue ();
157160assertThat (afterConvert .getVersion ()).isEqualTo (1L );
158161}
159162
160- @ Test    // DATAJDBC-507  
163+ @ Test  // GH-1137  
161164void  savePreparesInstanceWithInitialVersion_onInsert__whenVersionPropertyIsImmutableAndPrimitiveType () {
162165
163166EntityWithImmutablePrimitiveVersion  entity  = new  EntityWithImmutablePrimitiveVersion (1L , 0L );
@@ -167,11 +170,13 @@ void savePreparesInstanceWithInitialVersion_onInsert__whenVersionPropertyIsImmut
167170
168171ArgumentCaptor <Object > aggregateRootCaptor  = ArgumentCaptor .forClass (Object .class );
169172verify (callbacks ).callback (eq (BeforeSaveCallback .class ), aggregateRootCaptor .capture (), any ());
170- EntityWithImmutablePrimitiveVersion  afterConvert  = (EntityWithImmutablePrimitiveVersion ) aggregateRootCaptor .getValue ();
173+ 
174+ EntityWithImmutablePrimitiveVersion  afterConvert  = (EntityWithImmutablePrimitiveVersion ) aggregateRootCaptor 
175+ .getValue ();
171176assertThat (afterConvert .getVersion ()).isEqualTo (1L );
172177}
173178
174- @ Test 
179+ @ Test   // GH-1137 
175180void  savePreparesChangeWithPreviousVersion_onUpdate () {
176181
177182when (dataAccessStrategy .updateWithVersion (any (), any (), any ())).thenReturn (true );
@@ -183,11 +188,12 @@ void savePreparesChangeWithPreviousVersion_onUpdate() {
183188
184189ArgumentCaptor <Object > aggregateChangeCaptor  = ArgumentCaptor .forClass (Object .class );
185190verify (callbacks ).callback (eq (BeforeSaveCallback .class ), any (), aggregateChangeCaptor .capture ());
191+ 
186192MutableAggregateChange <?> aggregateChange  = (MutableAggregateChange <?>) aggregateChangeCaptor .getValue ();
187193assertThat (aggregateChange .getPreviousVersion ()).isEqualTo (1L );
188194}
189195
190- @ Test 
196+ @ Test   // GH-1137 
191197void  savePreparesInstanceWithNextVersion_onUpdate () {
192198
193199when (dataAccessStrategy .updateWithVersion (any (), any (), any ())).thenReturn (true );
@@ -199,11 +205,12 @@ void savePreparesInstanceWithNextVersion_onUpdate() {
199205
200206ArgumentCaptor <Object > aggregateRootCaptor  = ArgumentCaptor .forClass (Object .class );
201207verify (callbacks ).callback (eq (BeforeSaveCallback .class ), aggregateRootCaptor .capture (), any ());
208+ 
202209EntityWithVersion  afterConvert  = (EntityWithVersion ) aggregateRootCaptor .getValue ();
203210assertThat (afterConvert .getVersion ()).isEqualTo (2L );
204211}
205212
206- @ Test 
213+ @ Test   // GH-1137 
207214void  savePreparesInstanceWithNextVersion_onUpdate_whenVersionPropertyIsImmutable () {
208215
209216when (dataAccessStrategy .updateWithVersion (any (), any (), any ())).thenReturn (true );
@@ -218,7 +225,7 @@ void savePreparesInstanceWithNextVersion_onUpdate_whenVersionPropertyIsImmutable
218225assertThat (afterConvert .getVersion ()).isEqualTo (2L );
219226}
220227
221- @ Test 
228+ @ Test   // GH-1137 
222229void  deletePreparesChangeWithPreviousVersion_onDeleteByInstance () {
223230
224231EntityWithImmutableVersion  entity  = new  EntityWithImmutableVersion (1L , 1L );
@@ -228,11 +235,11 @@ void deletePreparesChangeWithPreviousVersion_onDeleteByInstance() {
228235
229236ArgumentCaptor <Object > aggregateChangeCaptor  = ArgumentCaptor .forClass (Object .class );
230237verify (callbacks ).callback (eq (BeforeDeleteCallback .class ), any (), aggregateChangeCaptor .capture ());
238+ 
231239MutableAggregateChange <?> aggregateChange  = (MutableAggregateChange <?>) aggregateChangeCaptor .getValue ();
232240assertThat (aggregateChange .getPreviousVersion ()).isEqualTo (1L );
233241}
234242
235- 
236243@ Test  // DATAJDBC-393 
237244public  void  callbackOnDelete () {
238245
0 commit comments