fix tests
This commit is contained in:
parent
37d10fbcbf
commit
99a8c94cff
2 changed files with 35 additions and 34 deletions
|
@ -58,11 +58,11 @@ public class ConstraintsCheckerTest {
|
||||||
|
|
||||||
boolean notificationSent = false;
|
boolean notificationSent = false;
|
||||||
|
|
||||||
public ConstraintsCheckerTest() throws JSONException {
|
public ConstraintsCheckerTest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isLoopInvokationAllowedTest() throws Exception {
|
public void isLoopInvokationAllowedTest() {
|
||||||
comboPlugin.setPluginEnabled(PluginType.PUMP, true);
|
comboPlugin.setPluginEnabled(PluginType.PUMP, true);
|
||||||
comboPlugin.setValidBasalRateProfileSelectedOnPump(false);
|
comboPlugin.setValidBasalRateProfileSelectedOnPump(false);
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@ public class ConstraintsCheckerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isClosedLoopAllowedTest() throws Exception {
|
public void isClosedLoopAllowedTest() {
|
||||||
when(SP.getString(R.string.key_aps_mode, "open")).thenReturn("closed");
|
when(SP.getString(R.string.key_aps_mode, "open")).thenReturn("closed");
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.CLOSED_LOOP_OBJECTIVE).setStartedOn(null);
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getMAXIOB_ZERO_CL_OBJECTIVE()).setStartedOn(0);
|
||||||
|
|
||||||
Constraint<Boolean> c = constraintChecker.isClosedLoopAllowed();
|
Constraint<Boolean> c = constraintChecker.isClosedLoopAllowed();
|
||||||
Assert.assertEquals(true, c.getReasonList().size() == 2); // Safety & Objectives
|
Assert.assertEquals(true, c.getReasonList().size() == 2); // Safety & Objectives
|
||||||
|
@ -90,8 +90,8 @@ public class ConstraintsCheckerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAutosensModeEnabledTest() throws Exception {
|
public void isAutosensModeEnabledTest() {
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.Companion.getAUTOSENS_OBJECTIVE()).setStartedOn(null);
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getAUTOSENS_OBJECTIVE()).setStartedOn(0);
|
||||||
when(SP.getBoolean(R.string.key_openapsama_useautosens, false)).thenReturn(false);
|
when(SP.getBoolean(R.string.key_openapsama_useautosens, false)).thenReturn(false);
|
||||||
|
|
||||||
Constraint<Boolean> c = constraintChecker.isAutosensModeEnabled();
|
Constraint<Boolean> c = constraintChecker.isAutosensModeEnabled();
|
||||||
|
@ -101,8 +101,8 @@ public class ConstraintsCheckerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAMAModeEnabledTest() throws Exception {
|
public void isAMAModeEnabledTest() {
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.Companion.getAMA_OBJECTIVE()).setStartedOn(null);
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getAMA_OBJECTIVE()).setStartedOn(0);
|
||||||
|
|
||||||
Constraint<Boolean> c = constraintChecker.isAMAModeEnabled();
|
Constraint<Boolean> c = constraintChecker.isAMAModeEnabled();
|
||||||
Assert.assertEquals(true, c.getReasonList().size() == 1); // Objectives
|
Assert.assertEquals(true, c.getReasonList().size() == 1); // Objectives
|
||||||
|
@ -111,7 +111,7 @@ public class ConstraintsCheckerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAdvancedFilteringEnabledTest() throws Exception {
|
public void isAdvancedFilteringEnabledTest() {
|
||||||
when(ConfigBuilderPlugin.getPlugin().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin());
|
when(ConfigBuilderPlugin.getPlugin().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin());
|
||||||
|
|
||||||
Constraint<Boolean> c = constraintChecker.isAdvancedFilteringEnabled();
|
Constraint<Boolean> c = constraintChecker.isAdvancedFilteringEnabled();
|
||||||
|
@ -130,7 +130,7 @@ public class ConstraintsCheckerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSMBModeEnabledTest() throws Exception {
|
public void isSMBModeEnabledTest() throws Exception {
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.Companion.getSMB_OBJECTIVE()).setStartedOn(null);
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getSMB_OBJECTIVE()).setStartedOn(0);
|
||||||
when(SP.getBoolean(R.string.key_use_smb, false)).thenReturn(false);
|
when(SP.getBoolean(R.string.key_use_smb, false)).thenReturn(false);
|
||||||
when(MainApp.getConstraintChecker().isClosedLoopAllowed()).thenReturn(new Constraint<>(true));
|
when(MainApp.getConstraintChecker().isClosedLoopAllowed()).thenReturn(new Constraint<>(true));
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ public class ConstraintsCheckerTest {
|
||||||
constraintChecker = new ConstraintChecker();
|
constraintChecker = new ConstraintChecker();
|
||||||
|
|
||||||
safetyPlugin = SafetyPlugin.getPlugin();
|
safetyPlugin = SafetyPlugin.getPlugin();
|
||||||
objectivesPlugin = ObjectivesPlugin.Companion.getPlugin();
|
objectivesPlugin = ObjectivesPlugin.INSTANCE;
|
||||||
comboPlugin = ComboPlugin.getPlugin();
|
comboPlugin = ComboPlugin.getPlugin();
|
||||||
danaRPlugin = DanaRPlugin.getPlugin();
|
danaRPlugin = DanaRPlugin.getPlugin();
|
||||||
danaRSPlugin = DanaRSPlugin.getPlugin();
|
danaRSPlugin = DanaRSPlugin.getPlugin();
|
||||||
|
|
|
@ -14,6 +14,7 @@ import info.AAPSMocker;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,53 +28,53 @@ public class ObjectivesPluginTest {
|
||||||
ObjectivesPlugin objectivesPlugin;
|
ObjectivesPlugin objectivesPlugin;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void notStartedObjectivesShouldLimitLoopInvocation() throws Exception {
|
public void notStartedObjectivesShouldLimitLoopInvocation() {
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.Companion.getFIRST_OBJECTIVE()).setStartedOn(null);
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getFIRST_OBJECTIVE()).setStartedOn(0);
|
||||||
|
|
||||||
Constraint<Boolean> c = new Constraint<>(true);
|
Constraint<Boolean> c = new Constraint<>(true);
|
||||||
c = objectivesPlugin.isLoopInvocationAllowed(c);
|
c = objectivesPlugin.isLoopInvocationAllowed(c);
|
||||||
Assert.assertEquals("Objectives: Objective 1 not started", c.getReasons());
|
Assert.assertEquals("Objectives: Objective 1 not started", c.getReasons());
|
||||||
Assert.assertEquals(Boolean.FALSE, c.value());
|
Assert.assertEquals(Boolean.FALSE, c.value());
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.Companion.getFIRST_OBJECTIVE()).setStartedOn(new Date());
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getFIRST_OBJECTIVE()).setStartedOn(DateUtil.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void notStartedObjective4ShouldLimitClosedLoop() throws Exception {
|
public void notStartedObjective6ShouldLimitClosedLoop() {
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.CLOSED_LOOP_OBJECTIVE).setStartedOn(null);
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getMAXIOB_ZERO_CL_OBJECTIVE()).setStartedOn(0);
|
||||||
|
|
||||||
Constraint<Boolean> c = new Constraint<>(true);
|
Constraint<Boolean> c = new Constraint<>(true);
|
||||||
c = objectivesPlugin.isClosedLoopAllowed(c);
|
c = objectivesPlugin.isClosedLoopAllowed(c);
|
||||||
Assert.assertEquals(true, c.getReasons().contains("Objective 4 not started"));
|
|
||||||
Assert.assertEquals(Boolean.FALSE, c.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void notStartedObjective6ShouldLimitAutosensMode() throws Exception {
|
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.Companion.getAUTOSENS_OBJECTIVE()).setStartedOn(null);
|
|
||||||
|
|
||||||
Constraint<Boolean> c = new Constraint<>(true);
|
|
||||||
c = objectivesPlugin.isAutosensModeEnabled(c);
|
|
||||||
Assert.assertEquals(true, c.getReasons().contains("Objective 6 not started"));
|
Assert.assertEquals(true, c.getReasons().contains("Objective 6 not started"));
|
||||||
Assert.assertEquals(Boolean.FALSE, c.value());
|
Assert.assertEquals(Boolean.FALSE, c.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void notStartedObjective7ShouldLimitAMAMode() throws Exception {
|
public void notStartedObjective8ShouldLimitAutosensMode() {
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.Companion.getAMA_OBJECTIVE()).setStartedOn(null);
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getAUTOSENS_OBJECTIVE()).setStartedOn(0);
|
||||||
|
|
||||||
Constraint<Boolean> c = new Constraint<>(true);
|
Constraint<Boolean> c = new Constraint<>(true);
|
||||||
c = objectivesPlugin.isAMAModeEnabled(c);
|
c = objectivesPlugin.isAutosensModeEnabled(c);
|
||||||
Assert.assertEquals(true, c.getReasons().contains("Objective 7 not started"));
|
Assert.assertEquals(true, c.getReasons().contains("Objective 8 not started"));
|
||||||
Assert.assertEquals(Boolean.FALSE, c.value());
|
Assert.assertEquals(Boolean.FALSE, c.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void notStartedObjective8ShouldLimitSMBMode() throws Exception {
|
public void notStartedObjective9ShouldLimitAMAMode() {
|
||||||
objectivesPlugin.getObjectives().get(ObjectivesPlugin.Companion.getSMB_OBJECTIVE()).setStartedOn(null);
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getAMA_OBJECTIVE()).setStartedOn(0);
|
||||||
|
|
||||||
|
Constraint<Boolean> c = new Constraint<>(true);
|
||||||
|
c = objectivesPlugin.isAMAModeEnabled(c);
|
||||||
|
Assert.assertEquals(true, c.getReasons().contains("Objective 9 not started"));
|
||||||
|
Assert.assertEquals(Boolean.FALSE, c.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void notStartedObjective10ShouldLimitSMBMode() {
|
||||||
|
objectivesPlugin.getObjectives().get(ObjectivesPlugin.INSTANCE.getSMB_OBJECTIVE()).setStartedOn(0);
|
||||||
|
|
||||||
Constraint<Boolean> c = new Constraint<>(true);
|
Constraint<Boolean> c = new Constraint<>(true);
|
||||||
c = objectivesPlugin.isSMBModeEnabled(c);
|
c = objectivesPlugin.isSMBModeEnabled(c);
|
||||||
Assert.assertEquals(true, c.getReasons().contains("Objective 8 not started"));
|
Assert.assertEquals(true, c.getReasons().contains("Objective 10 not started"));
|
||||||
Assert.assertEquals(Boolean.FALSE, c.value());
|
Assert.assertEquals(Boolean.FALSE, c.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +86,6 @@ public class ObjectivesPluginTest {
|
||||||
AAPSMocker.mockSP();
|
AAPSMocker.mockSP();
|
||||||
AAPSMocker.mockStrings();
|
AAPSMocker.mockStrings();
|
||||||
|
|
||||||
objectivesPlugin = ObjectivesPlugin.Companion.getPlugin();
|
objectivesPlugin = ObjectivesPlugin.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue