@@ -0,0 +1,2650 @@
+package info.nightscout.androidaps.plugins.PumpCombo;%0A%0Aimport android.content.Context;%0A%0Aimport com.squareup.otto.Bus;%0Aimport com.squareup.otto.ThreadEnforcer;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.powermock.api.mockito.PowerMockito;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0Aimport org.powermock.modules.junit4.PowerMockRunner;%0A%0Aimport info.nightscout.androidaps.MainApp;%0Aimport info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;%0Aimport info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;%0Aimport info.nightscout.utils.ToastUtils;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0A@RunWith(PowerMockRunner.class)%0A@PrepareForTest(%7BMainApp.class, ConfigBuilderPlugin.class, ConfigBuilderPlugin.class, ToastUtils.class, Context.class%7D)%0Apublic class ComboPluginTest %7B%0A%0A    @Before%0A    public void prepareMocks() throws Exception %7B%0A        ConfigBuilderPlugin configBuilderPlugin = mock(ConfigBuilderPlugin.class);%0A        PowerMockito.mockStatic(ConfigBuilderPlugin.class);%0A%0A        PowerMockito.mockStatic(MainApp.class);%0A        MainApp mainApp = mock(MainApp.class);%0A        when(MainApp.getConfigBuilder()).thenReturn(configBuilderPlugin);%0A        when(MainApp.instance()).thenReturn(mainApp);%0A        Bus bus = new Bus(ThreadEnforcer.ANY);%0A        when(MainApp.bus()).thenReturn(bus);%0A        when(MainApp.gs(0)).thenReturn(%22%22);%0A    %7D%0A%0A    @Test%0A    public void calculateFakePumpTimestamp() throws Exception %7B%0A        ComboPlugin plugin = ComboPlugin.getPlugin();%0A        long now = System.currentTimeMillis();%0A        long pumpTimestamp = now - now %25 1000;%0A        // same timestamp, different bolus leads to different fake timestamp%0A        Assert.assertNotEquals(%0A                plugin.calculateFakeBolusDate(new Bolus(pumpTimestamp, 0.1, true)),%0A                plugin.calculateFakeBolusDate(new Bolus(pumpTimestamp, 0.3, true))%0A        );%0A        // different timestamp, same bolus leads to different fake timestamp%0A        Assert.assertNotEquals(%0A                plugin.calculateFakeBolusDate(new Bolus(pumpTimestamp, 0.3, true)),%0A                plugin.calculateFakeBolusDate(new Bolus(pumpTimestamp + 60 * 1000, 0.3, true))%0A        );%0A        // generated timestamp has second-precision%0A        Bolus bolus = new Bolus(pumpTimestamp, 0.2, true);%0A        long calculatedTimestamp = plugin.calculateFakeBolusDate(bolus);%0A        assertEquals(calculatedTimestamp, calculatedTimestamp - calculatedTimestamp %25 1000);%0A    %7D%0A%7D

add unit test for calculateFakeBolusDate.