@@ -199,9 +199,7 @@ void shouldDelegateRunTx( Function<RxSession,Publisher<String>> runTx ) throws T
199
199
// Given
200
200
NetworkSession session = mock ( NetworkSession .class );
201
201
UnmanagedTransaction tx = mock ( UnmanagedTransaction .class );
202
- when ( tx .isOpen () ).thenReturn ( true );
203
- when ( tx .commitAsync () ).thenReturn ( completedWithNull () );
204
- when ( tx .rollbackAsync () ).thenReturn ( completedWithNull () );
202
+ when ( tx .closeAsync ( true ) ).thenReturn ( completedWithNull () );
205
203
206
204
when ( session .beginTransactionAsync ( any ( AccessMode .class ), any ( TransactionConfig .class ) ) ).thenReturn ( completedFuture ( tx ) );
207
205
when ( session .retryLogic () ).thenReturn ( new FixedRetryLogic ( 1 ) );
@@ -213,7 +211,7 @@ void shouldDelegateRunTx( Function<RxSession,Publisher<String>> runTx ) throws T
213
211
214
212
// Then
215
213
verify ( session ).beginTransactionAsync ( any ( AccessMode .class ), any ( TransactionConfig .class ) );
216
- verify ( tx ).commitAsync ( );
214
+ verify ( tx ).closeAsync ( true );
217
215
}
218
216
219
217
@ Test
@@ -223,25 +221,24 @@ void shouldRetryOnError() throws Throwable
223
221
int retryCount = 2 ;
224
222
NetworkSession session = mock ( NetworkSession .class );
225
223
UnmanagedTransaction tx = mock ( UnmanagedTransaction .class );
226
- when ( tx .isOpen () ).thenReturn ( true );
227
- when ( tx .commitAsync () ).thenReturn ( completedWithNull () );
228
- when ( tx .rollbackAsync () ).thenReturn ( completedWithNull () );
224
+ when ( tx .closeAsync ( false ) ).thenReturn ( completedWithNull () );
229
225
230
226
when ( session .beginTransactionAsync ( any ( AccessMode .class ), any ( TransactionConfig .class ) ) ).thenReturn ( completedFuture ( tx ) );
231
227
when ( session .retryLogic () ).thenReturn ( new FixedRetryLogic ( retryCount ) );
232
228
InternalRxSession rxSession = new InternalRxSession ( session );
233
229
234
230
// When
235
- Publisher <String > strings = rxSession .readTransaction ( t ->
236
- Flux .just ( "a" ).then ( Mono .error ( new RuntimeException ( "Errored" ) ) ) );
231
+ Publisher <String > strings = rxSession .readTransaction (
232
+ t ->
233
+ Flux .just ( "a" ).then ( Mono .error ( new RuntimeException ( "Errored" ) ) ) );
237
234
StepVerifier .create ( Flux .from ( strings ) )
238
- // we lost the "a"s too as the user only see the last failure
239
- .expectError ( RuntimeException .class )
240
- .verify ();
235
+ // we lost the "a"s too as the user only see the last failure
236
+ .expectError ( RuntimeException .class )
237
+ .verify ();
241
238
242
239
// Then
243
240
verify ( session , times ( retryCount + 1 ) ).beginTransactionAsync ( any ( AccessMode .class ), any ( TransactionConfig .class ) );
244
- verify ( tx , times ( retryCount + 1 ) ).closeAsync ();
241
+ verify ( tx , times ( retryCount + 1 ) ).closeAsync ( false );
245
242
}
246
243
247
244
@ Test
@@ -251,33 +248,34 @@ void shouldObtainResultIfRetrySucceed() throws Throwable
251
248
int retryCount = 2 ;
252
249
NetworkSession session = mock ( NetworkSession .class );
253
250
UnmanagedTransaction tx = mock ( UnmanagedTransaction .class );
254
- when ( tx .isOpen () ).thenReturn ( true );
255
- when ( tx .commitAsync () ).thenReturn ( completedWithNull () );
256
- when ( tx .rollbackAsync () ).thenReturn ( completedWithNull () );
251
+ when ( tx .closeAsync ( false ) ).thenReturn ( completedWithNull () );
252
+ when ( tx .closeAsync ( true ) ).thenReturn ( completedWithNull () );
257
253
258
254
when ( session .beginTransactionAsync ( any ( AccessMode .class ), any ( TransactionConfig .class ) ) ).thenReturn ( completedFuture ( tx ) );
259
255
when ( session .retryLogic () ).thenReturn ( new FixedRetryLogic ( retryCount ) );
260
256
InternalRxSession rxSession = new InternalRxSession ( session );
261
257
262
258
// When
263
259
AtomicInteger count = new AtomicInteger ();
264
- Publisher <String > strings = rxSession .readTransaction ( t -> {
265
- // we fail for the first few retries, and then success on the last run.
266
- if ( count .getAndIncrement () == retryCount )
267
- {
268
- return Flux .just ( "a" );
269
- }
270
- else
271
- {
272
- return Flux .just ( "a" ).then ( Mono .error ( new RuntimeException ( "Errored" ) ) );
273
- }
274
- } );
260
+ Publisher <String > strings = rxSession .readTransaction (
261
+ t ->
262
+ {
263
+ // we fail for the first few retries, and then success on the last run.
264
+ if ( count .getAndIncrement () == retryCount )
265
+ {
266
+ return Flux .just ( "a" );
267
+ }
268
+ else
269
+ {
270
+ return Flux .just ( "a" ).then ( Mono .error ( new RuntimeException ( "Errored" ) ) );
271
+ }
272
+ } );
275
273
StepVerifier .create ( Flux .from ( strings ) ).expectNext ( "a" ).verifyComplete ();
276
274
277
275
// Then
278
276
verify ( session , times ( retryCount + 1 ) ).beginTransactionAsync ( any ( AccessMode .class ), any ( TransactionConfig .class ) );
279
- verify ( tx , times ( retryCount ) ).closeAsync ();
280
- verify ( tx ).commitAsync ( );
277
+ verify ( tx , times ( retryCount ) ).closeAsync ( false );
278
+ verify ( tx ).closeAsync ( true );
281
279
}
282
280
283
281
@ Test
0 commit comments