From 2560f284a409915873d62f03b86f47fc61aaa6c6 Mon Sep 17 00:00:00 2001 From: Ephraim Kigamba Date: Thu, 20 Jun 2019 12:46:15 +0300 Subject: [PATCH] Fix SyncSenderHandlerTest coverage not reflecting --- .../p2p/shadows/ShadowSyncSenderHandler.java | 20 -------------- .../sync/handler/SyncSenderHandlerTest.java | 7 +++-- .../sync/handler/TestSyncSenderHandler.java | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 24 deletions(-) delete mode 100644 p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowSyncSenderHandler.java create mode 100644 p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/TestSyncSenderHandler.java diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowSyncSenderHandler.java b/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowSyncSenderHandler.java deleted file mode 100644 index 930461d..0000000 --- a/p2p-sync/src/test/java/org/smartregister/p2p/shadows/ShadowSyncSenderHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.smartregister.p2p.shadows; - -import android.support.annotation.NonNull; - -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; -import org.smartregister.p2p.sync.handler.SyncSenderHandler; - -/** - * Created by Ephraim Kigamba - ekigamba@ona.io on 2019-06-12 - */ - -@Implements(SyncSenderHandler.class) -public class ShadowSyncSenderHandler { - - @Implementation - public void startNewThread(@NonNull Runnable runnable) { - runnable.run(); - } -} diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncSenderHandlerTest.java b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncSenderHandlerTest.java index 7e33455..726c6f8 100644 --- a/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncSenderHandlerTest.java +++ b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/SyncSenderHandlerTest.java @@ -27,7 +27,6 @@ import org.smartregister.p2p.model.dao.SenderTransferDao; import org.smartregister.p2p.shadows.ShadowAppDatabase; import org.smartregister.p2p.shadows.ShadowPayload; -import org.smartregister.p2p.shadows.ShadowSyncSenderHandler; import org.smartregister.p2p.shadows.ShadowTasker; import org.smartregister.p2p.sync.data.JsonData; import org.smartregister.p2p.sync.data.MultiMediaData; @@ -53,13 +52,13 @@ */ @RunWith(RobolectricTestRunner.class) -@Config(shadows = {ShadowAppDatabase.class, ShadowTasker.class, ShadowSyncSenderHandler.class, ShadowPayload.class}) +@Config(shadows = {ShadowAppDatabase.class, ShadowTasker.class, ShadowPayload.class}) public class SyncSenderHandlerTest { @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); - private SyncSenderHandler syncSenderHandler; + private TestSyncSenderHandler syncSenderHandler; @Mock private P2pModeSelectContract.SenderPresenter senderPresenter; @@ -86,7 +85,7 @@ public void setUp() throws Exception { dataSyncOrder.add(client); dataSyncOrder.add(event); - syncSenderHandler = Mockito.spy(new SyncSenderHandler(senderPresenter, dataSyncOrder, null)); + syncSenderHandler = Mockito.spy(new TestSyncSenderHandler(senderPresenter, dataSyncOrder, null)); } @Test diff --git a/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/TestSyncSenderHandler.java b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/TestSyncSenderHandler.java new file mode 100644 index 0000000..0a0bd8e --- /dev/null +++ b/p2p-sync/src/test/java/org/smartregister/p2p/sync/handler/TestSyncSenderHandler.java @@ -0,0 +1,27 @@ +package org.smartregister.p2p.sync.handler; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import org.smartregister.p2p.contract.P2pModeSelectContract; +import org.smartregister.p2p.model.DataType; +import org.smartregister.p2p.model.P2pReceivedHistory; + +import java.util.List; +import java.util.TreeSet; + +/** + * Created by Ephraim Kigamba - ekigamba@ona.io on 2019-06-12 + */ + +public class TestSyncSenderHandler extends SyncSenderHandler{ + + public TestSyncSenderHandler(@NonNull P2pModeSelectContract.SenderPresenter presenter, @NonNull TreeSet dataSyncOrder, @Nullable List receivedHistory) { + super(presenter, dataSyncOrder, receivedHistory); + } + + @Override + public void startNewThread(@NonNull Runnable runnable) { + runnable.run(); + } +}