ComboPlugin extends PluginBase implements PumpInterface, ConstraintsInterface { long calculateFakeBolusDate(Bolus pumpBolus) { double bolus = pumpBolus.amount - 0.1; int secondsFromBolus = (int) (bolus * 10 * 1000); return pumpBolus.timestamp + Math.min(secondsFromBolus, 59 * 1000); } private  ComboPlugin(); static ComboPlugin getPlugin(); ComboPump getPump(); @Override void switchAllowed(boolean newState, FragmentActivity activity, PluginType type); @Override boolean isInitialized(); @Override boolean isSuspended(); @Override boolean isBusy(); @Override boolean isConnected(); @Override boolean isConnecting(); @Override boolean isHandshakeInProgress(); @Override void finishHandshaking(); @Override void connect(String reason); @Override void disconnect(String reason); @Override void stopConnecting(); @Override synchronized PumpEnactResult setNewBasalProfile(Profile profile); @Override boolean isThisProfileSet(Profile profile); @Override long lastDataTime(); @Override synchronized void getPumpStatus(); @Override double getBaseBasalRate(); @Override double getReservoirLevel(); @Override int getBatteryLevel(); @Override PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo); @Override void stopBolusDelivering(); @Override PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean force); @Override PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes, Profile profile, boolean forceNew); @Override PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes); @Override PumpEnactResult cancelTempBasal(boolean enforceNew); void setValidBasalRateProfileSelectedOnPump(boolean value); @Override PumpEnactResult cancelExtendedBolus(); @Override JSONObject getJSONStatus(Profile profile, String profileName); @Override ManufacturerType manufacturer(); @Override PumpType model(); @Override String serialNumber(); @Override PumpDescription getPumpDescription(); @Override String shortStatus(boolean veryShort); @Override boolean isFakingTempsByExtendedBoluses(); @Override PumpEnactResult loadTDDs(); @Override Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value); @Override Constraint<Double> applyMaxIOBConstraints(Constraint<Double> maxIob); @Override List<CustomAction> getCustomActions(); @Override void executeCustomAction(CustomActionType customActionType); @Override boolean canHandleDST(); @Override void timeDateOrTimeZoneChanged();  }
@Test public void calculateFakePumpTimestamp() throws Exception { long now = System.currentTimeMillis(); long pumpTimestamp = now - now % 1000; Assert.assertNotEquals( comboPlugin.calculateFakeBolusDate(new Bolus(pumpTimestamp, 0.1, true)), comboPlugin.calculateFakeBolusDate(new Bolus(pumpTimestamp, 0.3, true)) ); Assert.assertNotEquals( comboPlugin.calculateFakeBolusDate(new Bolus(pumpTimestamp, 0.3, true)), comboPlugin.calculateFakeBolusDate(new Bolus(pumpTimestamp + 60 * 1000, 0.3, true)) ); Bolus bolus = new Bolus(pumpTimestamp, 0.2, true); long calculatedTimestamp = comboPlugin.calculateFakeBolusDate(bolus); assertEquals(calculatedTimestamp, calculatedTimestamp - calculatedTimestamp % 1000); }