@@ -48,22 +48,16 @@ protected BoxStore createBoxStore() {
4848
4949 final List <Class > classesWithChanges = new ArrayList <>();
5050
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 ();
5754 };
5855
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 ());
6761 };
6862
6963 @ Before
@@ -83,12 +77,9 @@ public void testTwoObjectClassesChanged_catchAllObserverWeak() {
8377
8478 public void testTwoObjectClassesChanged_catchAllObserver (boolean weak ) {
8579 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 ();
9283 });
9384 assertEquals (0 , classesWithChanges .size ());
9485
@@ -172,31 +163,21 @@ private void testTransform(TestScheduler scheduler) throws InterruptedException
172163 final Thread testThread = Thread .currentThread ();
173164
174165 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+ });
183170 if (scheduler != null ) {
184171 subscriptionBuilder .on (scheduler );
185172 }
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 ();
192176 });
193177
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 ();
200181 });
201182
202183 store .runInTx (txRunnable );
@@ -262,24 +243,14 @@ public void testTransformError(Scheduler scheduler) throws InterruptedException
262243 final CountDownLatch latch = new CountDownLatch (2 );
263244 final Thread testThread = Thread .currentThread ();
264245
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" );
283254 });
284255
285256 store .runInTx (txRunnable );
@@ -312,18 +283,12 @@ public void testObserverError(Scheduler scheduler) throws InterruptedException {
312283 final CountDownLatch latch = new CountDownLatch (2 );
313284 final Thread testThread = Thread .currentThread ();
314285
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" );
327292 });
328293
329294 store .runInTx (txRunnable );
@@ -430,13 +395,9 @@ public void testSingle(boolean weak, boolean wrapped) {
430395 @ Test
431396 public void testSingleCancelSubscription () throws InterruptedException {
432397 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 ;
440401 }).observer (objectClassObserver );
441402 subscription .cancel ();
442403 Thread .sleep (40 );
0 commit comments