more tests
This commit is contained in:
parent
f3a4f883a4
commit
e36499f9d4
2 changed files with 27 additions and 4 deletions
|
@ -68,18 +68,20 @@ public class APSResult {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public APSResult tempBasalRequested(boolean tempBasalRequested) {
|
public APSResult tempBasalRequested(boolean tempBasalRequested) {
|
||||||
this.tempBasalRequested = tempBasalRequested;
|
this.tempBasalRequested = tempBasalRequested;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public APSResult usePercent(boolean usePercent) {
|
public APSResult usePercent(boolean usePercent) {
|
||||||
this.usePercent = usePercent;
|
this.usePercent = usePercent;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public APSResult json(JSONObject json) {
|
||||||
|
this.json = json;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -151,7 +153,7 @@ public class APSResult {
|
||||||
|
|
||||||
protected void doClone(APSResult newResult) {
|
protected void doClone(APSResult newResult) {
|
||||||
newResult.date = date;
|
newResult.date = date;
|
||||||
newResult.reason = new String(reason);
|
newResult.reason = reason != null ? new String(reason) : null;
|
||||||
newResult.rate = rate;
|
newResult.rate = rate;
|
||||||
newResult.duration = duration;
|
newResult.duration = duration;
|
||||||
newResult.tempBasalRequested = tempBasalRequested;
|
newResult.tempBasalRequested = tempBasalRequested;
|
||||||
|
|
|
@ -14,18 +14,20 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.ConstraintChecker;
|
import info.nightscout.androidaps.data.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
import info.nightscout.utils.JsonHelper;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, SP.class, Context.class, ProfileFunctions.class, TreatmentsPlugin.class})
|
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, SP.class, Context.class, ProfileFunctions.class, TreatmentsPlugin.class, L.class})
|
||||||
public class APSREsultTest {
|
public class APSREsultTest {
|
||||||
VirtualPumpPlugin virtualPumpPlugin;
|
VirtualPumpPlugin virtualPumpPlugin;
|
||||||
TreatmentsPlugin treatmentsPlugin;
|
TreatmentsPlugin treatmentsPlugin;
|
||||||
|
@ -148,6 +150,25 @@ public class APSREsultTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void cloneTest() {
|
||||||
|
APSResult apsResult = new APSResult();
|
||||||
|
apsResult.rate(10);
|
||||||
|
|
||||||
|
APSResult apsResult2 = apsResult.clone();
|
||||||
|
Assert.assertEquals(apsResult.rate, apsResult2.rate, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void jsonTest() {
|
||||||
|
closedLoopEnabled.set(true);
|
||||||
|
APSResult apsResult = new APSResult();
|
||||||
|
apsResult.rate(20).tempBasalRequested(true);
|
||||||
|
Assert.assertEquals(20d, JsonHelper.safeGetDouble(apsResult.json(), "rate"), 0d);
|
||||||
|
|
||||||
|
apsResult.rate(20).tempBasalRequested(false);
|
||||||
|
Assert.assertEquals(false, apsResult.json().has("rate"));
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void prepareMock() throws Exception {
|
public void prepareMock() throws Exception {
|
||||||
|
|
Loading…
Reference in a new issue