From 83e987f3c8d7a24d9600423f1b6cc34009b7a70c Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 9 Apr 2019 22:55:12 +0200 Subject: [PATCH] Fix DanaRS tests --- .../DanaRS_Packet_APS_History_EventsTest.java | 41 +++++++++++-------- ...naRS_Packet_APS_Set_Event_HistoryTest.java | 33 +++++++++------ 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.java index 18527e0612..309644d7f0 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_APS_History_EventsTest.java @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm; import android.content.Context; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.mockito.PowerMockito; @@ -20,34 +21,26 @@ import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.treatments.TreatmentService; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; +import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.SP; import static org.junit.Assert.assertEquals; +import static org.powermock.api.mockito.PowerMockito.when; /** * Created by Rumen on 31.07.2018. */ @RunWith(PowerMockRunner.class) -@PrepareForTest({SP.class, MainApp.class, ConfigBuilderPlugin.class, Context.class, NSUpload.class, TreatmentsPlugin.class, TreatmentService.class, DatabaseHelper.class}) +@PrepareForTest({SP.class, MainApp.class, ConfigBuilderPlugin.class, Context.class, NSUpload.class, TreatmentsPlugin.class, TreatmentService.class, DatabaseHelper.class, DateUtil.class}) public class DanaRS_Packet_APS_History_EventsTest extends DanaRS_Packet_APS_History_Events { @Test public void runTest() { - AAPSMocker.mockMainApp(); - AAPSMocker.mockApplicationContext(); - AAPSMocker.mockSP(); - AAPSMocker.mockBus(); - SPMocker.prepareMock(); - SP.putString("profile", AAPSMocker.getValidProfileStore().getData().toString()); - AAPSMocker.mockConfigBuilder(); - AAPSMocker.mockStrings(); - PowerMockito.mockStatic(NSUpload.class); - AAPSMocker.mockDatabaseHelper(); - DanaRS_Packet_APS_History_Events testPacket = new DanaRS_Packet_APS_History_Events(System.currentTimeMillis()); + DanaRS_Packet_APS_History_Events testPacket = new DanaRS_Packet_APS_History_Events(DateUtil.now()); // test getRequestedParams byte[] returnedValues = testPacket.getRequestParams(); - byte[] expectedValues = getCalender(System.currentTimeMillis()); + byte[] expectedValues = getCalender(DateUtil.now()); //year assertEquals(expectedValues[0], returnedValues[0]); //month @@ -70,15 +63,15 @@ public class DanaRS_Packet_APS_History_EventsTest extends DanaRS_Packet_APS_Hist assertEquals("APS_HISTORY_EVENTS", getFriendlyName()); } - byte[] createArray(int length, byte fillWith){ + byte[] createArray(int length, byte fillWith) { byte[] ret = new byte[length]; - for(int i = 0; i