fix tests
This commit is contained in:
parent
952a6fe509
commit
a6bd81a1b9
6 changed files with 14 additions and 10 deletions
|
@ -59,7 +59,7 @@ public class GlucoseStatus {
|
|||
//long fromtime = DateUtil.now() - 60 * 1000L * 45;
|
||||
//List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
|
||||
|
||||
synchronized (IobCobCalculatorPlugin.getPlugin().dataLock) {
|
||||
synchronized (IobCobCalculatorPlugin.getPlugin().getDataLock()) {
|
||||
|
||||
List<BgReading> data = IobCobCalculatorPlugin.getPlugin().getBgReadings();
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
private volatile List<BgReading> bgReadings = null; // newest at index 0
|
||||
private volatile List<BgReading> bucketed_data = null;
|
||||
|
||||
final Object dataLock = new Object();
|
||||
private final Object dataLock = new Object();
|
||||
|
||||
boolean stopCalculationTrigger = false;
|
||||
private Thread thread = null;
|
||||
|
@ -108,6 +108,10 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
|||
return bucketed_data;
|
||||
}
|
||||
|
||||
public Object getDataLock() {
|
||||
return dataLock;
|
||||
}
|
||||
|
||||
// roundup to whole minute
|
||||
public static long roundUpTime(long time) {
|
||||
if (time % 60000 == 0)
|
||||
|
|
|
@ -96,7 +96,7 @@ public class IobCobOref1Thread extends Thread {
|
|||
|
||||
long oldestTimeWithData = iobCobCalculatorPlugin.calculateDetectionStart(end, limitDataToOldestAvailable);
|
||||
|
||||
synchronized (iobCobCalculatorPlugin.dataLock) {
|
||||
synchronized (iobCobCalculatorPlugin.getDataLock()) {
|
||||
if (bgDataReload) {
|
||||
iobCobCalculatorPlugin.loadBgData(end);
|
||||
iobCobCalculatorPlugin.createBucketedData();
|
||||
|
|
|
@ -95,7 +95,7 @@ public class IobCobThread extends Thread {
|
|||
|
||||
long oldestTimeWithData = iobCobCalculatorPlugin.calculateDetectionStart(end, limitDataToOldestAvailable);
|
||||
|
||||
synchronized (iobCobCalculatorPlugin.dataLock) {
|
||||
synchronized (iobCobCalculatorPlugin.getDataLock()) {
|
||||
if (bgDataReload) {
|
||||
iobCobCalculatorPlugin.loadBgData(end);
|
||||
iobCobCalculatorPlugin.createBucketedData();
|
||||
|
|
|
@ -282,10 +282,13 @@ public class AAPSMocker {
|
|||
PowerMockito.when(ProfileFunctions.getInstance().getProfileName()).thenReturn(TESTPROFILENAME);
|
||||
}
|
||||
|
||||
public static void mockIobCobCalculatorPlugin() {
|
||||
public static IobCobCalculatorPlugin mockIobCobCalculatorPlugin() {
|
||||
PowerMockito.mockStatic(IobCobCalculatorPlugin.class);
|
||||
IobCobCalculatorPlugin iobCobCalculatorPlugin = PowerMockito.mock(IobCobCalculatorPlugin.class);
|
||||
PowerMockito.when(IobCobCalculatorPlugin.getPlugin()).thenReturn(iobCobCalculatorPlugin);
|
||||
Object dataLock = new Object();
|
||||
PowerMockito.when(iobCobCalculatorPlugin.getDataLock()).thenReturn(dataLock);
|
||||
return iobCobCalculatorPlugin;
|
||||
}
|
||||
|
||||
private static MockedBus bus = new MockedBus();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.data;
|
||||
package info.nightscout.androidaps.plugins.iob.iobCobCalculatorPlugin;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -134,10 +134,7 @@ public class GlucoseStatusTest {
|
|||
public void initMocking() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockStrings();
|
||||
|
||||
PowerMockito.mockStatic(IobCobCalculatorPlugin.class);
|
||||
iobCobCalculatorPlugin = mock(IobCobCalculatorPlugin.class);
|
||||
when(IobCobCalculatorPlugin.getPlugin()).thenReturn(iobCobCalculatorPlugin);
|
||||
iobCobCalculatorPlugin = AAPSMocker.mockIobCobCalculatorPlugin();
|
||||
|
||||
PowerMockito.mockStatic(DateUtil.class);
|
||||
when(DateUtil.now()).thenReturn(1514766900000L + T.mins(1).msecs());
|
Loading…
Reference in a new issue