@@ -48,22 +48,16 @@ protected BoxStore createBoxStore() {
48
48
49
49
final List <Class > classesWithChanges = new ArrayList <>();
50
50
51
- DataObserver objectClassObserver = new DataObserver <Class >() {
52
- @ Override
53
- public void onData (Class objectClass ) {
54
- classesWithChanges .add (objectClass );
55
- observerLatch .countDown ();
56
- }
51
+ DataObserver objectClassObserver = (DataObserver <Class >) objectClass -> {
52
+ classesWithChanges .add (objectClass );
53
+ observerLatch .countDown ();
57
54
};
58
55
59
- Runnable txRunnable = new Runnable () {
60
- @ Override
61
- public void run () {
62
- putTestEntities (3 );
63
- Box <TestEntityMinimal > boxMini = store .boxFor (TestEntityMinimal .class );
64
- boxMini .put (new TestEntityMinimal (), new TestEntityMinimal ());
65
- assertEquals (0 , classesWithChanges .size ());
66
- }
56
+ Runnable txRunnable = () -> {
57
+ putTestEntities (3 );
58
+ Box <TestEntityMinimal > boxMini = store .boxFor (TestEntityMinimal .class );
59
+ boxMini .put (new TestEntityMinimal (), new TestEntityMinimal ());
60
+ assertEquals (0 , classesWithChanges .size ());
67
61
};
68
62
69
63
@ Before
@@ -83,12 +77,9 @@ public void testTwoObjectClassesChanged_catchAllObserverWeak() {
83
77
84
78
public void testTwoObjectClassesChanged_catchAllObserver (boolean weak ) {
85
79
DataSubscription subscription = subscribe (weak , null );
86
- store .runInTx (new Runnable () {
87
- @ Override
88
- public void run () {
89
- // Dummy TX, still will be committed
90
- getTestEntityBox ().count ();
91
- }
80
+ store .runInTx (() -> {
81
+ // Dummy TX, still will be committed
82
+ getTestEntityBox ().count ();
92
83
});
93
84
assertEquals (0 , classesWithChanges .size ());
94
85
@@ -172,31 +163,21 @@ private void testTransform(TestScheduler scheduler) throws InterruptedException
172
163
final Thread testThread = Thread .currentThread ();
173
164
174
165
SubscriptionBuilder <Long > subscriptionBuilder = store .subscribe ().onlyChanges ().
175
- transform (new DataTransformer <Class , Long >() {
176
- @ Override
177
- @ SuppressWarnings ("NullableProblems" )
178
- public Long transform (Class source ) throws Exception {
179
- assertNotSame (testThread , Thread .currentThread ());
180
- return store .boxFor (source ).count ();
181
- }
182
- });
166
+ transform (source -> {
167
+ assertNotSame (testThread , Thread .currentThread ());
168
+ return store .boxFor (source ).count ();
169
+ });
183
170
if (scheduler != null ) {
184
171
subscriptionBuilder .on (scheduler );
185
172
}
186
- DataSubscription subscription = subscriptionBuilder .observer (new DataObserver <Long >() {
187
- @ Override
188
- public void onData (Long data ) {
189
- objectCounts .add (data );
190
- latch .countDown ();
191
- }
173
+ DataSubscription subscription = subscriptionBuilder .observer (data -> {
174
+ objectCounts .add (data );
175
+ latch .countDown ();
192
176
});
193
177
194
- store .runInTx (new Runnable () {
195
- @ Override
196
- public void run () {
197
- // Dummy TX, still will be committed, should not add anything to objectCounts
198
- getTestEntityBox ().count ();
199
- }
178
+ store .runInTx (() -> {
179
+ // Dummy TX, still will be committed, should not add anything to objectCounts
180
+ getTestEntityBox ().count ();
200
181
});
201
182
202
183
store .runInTx (txRunnable );
@@ -262,24 +243,14 @@ public void testTransformError(Scheduler scheduler) throws InterruptedException
262
243
final CountDownLatch latch = new CountDownLatch (2 );
263
244
final Thread testThread = Thread .currentThread ();
264
245
265
- DataSubscription subscription = store .subscribe ().onlyChanges ().transform (new DataTransformer <Class , Long >() {
266
- @ Override
267
- @ SuppressWarnings ("NullableProblems" )
268
- public Long transform (Class source ) throws Exception {
269
- throw new Exception ("Boo" );
270
- }
271
- }).onError (new ErrorObserver () {
272
- @ Override
273
- public void onError (Throwable th ) {
274
- assertNotSame (testThread , Thread .currentThread ());
275
- errors .add (th );
276
- latch .countDown ();
277
- }
278
- }).on (scheduler ).observer (new DataObserver <Long >() {
279
- @ Override
280
- public void onData (Long data ) {
281
- throw new RuntimeException ("Should not reach this" );
282
- }
246
+ DataSubscription subscription = store .subscribe ().onlyChanges ().transform ((DataTransformer <Class , Long >) source -> {
247
+ throw new Exception ("Boo" );
248
+ }).onError (throwable -> {
249
+ assertNotSame (testThread , Thread .currentThread ());
250
+ errors .add (throwable );
251
+ latch .countDown ();
252
+ }).on (scheduler ).observer (data -> {
253
+ throw new RuntimeException ("Should not reach this" );
283
254
});
284
255
285
256
store .runInTx (txRunnable );
@@ -312,18 +283,12 @@ public void testObserverError(Scheduler scheduler) throws InterruptedException {
312
283
final CountDownLatch latch = new CountDownLatch (2 );
313
284
final Thread testThread = Thread .currentThread ();
314
285
315
- DataSubscription subscription = store .subscribe ().onlyChanges ().onError (new ErrorObserver () {
316
- @ Override
317
- public void onError (Throwable th ) {
318
- assertNotSame (testThread , Thread .currentThread ());
319
- errors .add (th );
320
- latch .countDown ();
321
- }
322
- }).on (scheduler ).observer (new DataObserver <Class >() {
323
- @ Override
324
- public void onData (Class data ) {
325
- throw new RuntimeException ("Boo" );
326
- }
286
+ DataSubscription subscription = store .subscribe ().onlyChanges ().onError (th -> {
287
+ assertNotSame (testThread , Thread .currentThread ());
288
+ errors .add (th );
289
+ latch .countDown ();
290
+ }).on (scheduler ).observer (data -> {
291
+ throw new RuntimeException ("Boo" );
327
292
});
328
293
329
294
store .runInTx (txRunnable );
@@ -430,13 +395,9 @@ public void testSingle(boolean weak, boolean wrapped) {
430
395
@ Test
431
396
public void testSingleCancelSubscription () throws InterruptedException {
432
397
DataSubscription subscription = store .subscribe ().single ()
433
- .transform (new DataTransformer <Class , Class >() {
434
- @ Override
435
- @ SuppressWarnings ("NullableProblems" )
436
- public Class transform (Class source ) throws Exception {
437
- Thread .sleep (20 );
438
- return source ;
439
- }
398
+ .transform (source -> {
399
+ Thread .sleep (20 );
400
+ return source ;
440
401
}).observer (objectClassObserver );
441
402
subscription .cancel ();
442
403
Thread .sleep (40 );
0 commit comments