IobTotal implements DataPointWithLabelInterface { public static IobTotal combine(IobTotal bolusIOB, IobTotal basalIob) { IobTotal result = new IobTotal(bolusIOB.time); result.iob = bolusIOB.iob + basalIob.basaliob; result.activity = bolusIOB.activity + basalIob.activity; result.bolussnooze = bolusIOB.bolussnooze; result.basaliob = bolusIOB.basaliob + basalIob.basaliob; result.netbasalinsulin = bolusIOB.netbasalinsulin + basalIob.netbasalinsulin; result.hightempinsulin = basalIob.hightempinsulin + bolusIOB.hightempinsulin; result.netInsulin = basalIob.netInsulin + bolusIOB.netInsulin; result.extendedBolusInsulin = basalIob.extendedBolusInsulin + bolusIOB.extendedBolusInsulin; result.lastBolusTime = bolusIOB.lastBolusTime; result.iobWithZeroTemp = basalIob.iobWithZeroTemp; return result; } IobTotal(long time); IobTotal copy(); IobTotal plus(IobTotal other); static IobTotal combine(IobTotal bolusIOB, IobTotal basalIob); IobTotal round(); JSONObject json(); JSONObject determineBasalJson(); @Override double getX(); @Override double getY(); @Override void setY(double y); @Override String getLabel(); @Override long getDuration(); @Override PointsWithLabelGraphSeries.Shape getShape(); @Override float getSize(); @Override int getColor(); IobTotal setColor(int color); public double iob; public double activity; public double bolussnooze; public double basaliob; public double netbasalinsulin; public double hightempinsulin; public long lastBolusTime; public IobTotal iobWithZeroTemp; public double netInsulin; public double netRatio; public double extendedBolusInsulin; }
@Test public void combineTest() { IobTotal a = new IobTotal(now); a.iob = 10; a.activity = 11; a.bolussnooze = 12; a.basaliob = 13; a.netbasalinsulin = 14; a.hightempinsulin = 15; a.netInsulin = 16; a.extendedBolusInsulin = 17; IobTotal b = a.copy(); IobTotal c = IobTotal.combine(a, b); Assert.assertEquals(a.time, c.time, 0.01d); Assert.assertEquals(23, c.iob, 0.01d); Assert.assertEquals(22, c.activity, 0.01d); Assert.assertEquals(12, c.bolussnooze, 0.01d); Assert.assertEquals(26, c.basaliob, 0.01d); Assert.assertEquals(28, c.netbasalinsulin, 0.01d); Assert.assertEquals(30, c.hightempinsulin, 0.01d); Assert.assertEquals(32, c.netInsulin, 0.01d); Assert.assertEquals(34, c.extendedBolusInsulin, 0.01d); }