InsulinOrefBasePlugin extends PluginBase implements InsulinInterface { public Iob iobCalcForTreatment(Treatment treatment, long time) { return this.iobCalcForTreatment(treatment, time, 0d); } InsulinOrefBasePlugin(); @Override double getDia(); String getNotificationPattern(); double getUserDefinedDia(); Iob iobCalcForTreatment(Treatment treatment, long time); @Override Iob iobCalcForTreatment(Treatment treatment, long time, double dia); @Override String getComment(); static double MIN_DIA; }
@Test public void testIobCalcForTreatment() { Treatment treatment = new Treatment(); Iob expected = new Iob(); assertEquals(expected, this.iobCalcForTreatment(treatment, 0, 0d)); this.peak = 30; this.dia = 4; long time = System.currentTimeMillis(); treatment.date = time; treatment.insulin = 10d; assertEquals(10d, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1); treatment.date = time - 1 * 60 * 60 * 1000; treatment.insulin = 10d; assertEquals(3.92, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1); treatment.date = time - 2 * 60 * 60 * 1000; treatment.insulin = 10d; assertEquals(0.77, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1); treatment.date = time - 3 * 60 * 60 * 1000; treatment.insulin = 10d; assertEquals(0.10, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1); treatment.date = time - 4 * 60 * 60 * 1000; treatment.insulin = 10d; assertEquals(0d, this.iobCalcForTreatment(treatment, time).iobContrib, 0.1); }