SafetyPlugin extends PluginBase implements ConstraintsInterface { @Override public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value) { if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isTempBasalCapable) value.set(false, MainApp.gs(R.string.pumpisnottempbasalcapable), this); return value; } SafetyPlugin(); static SafetyPlugin getPlugin(); @Override Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> value); @Override Constraint<Boolean> isClosedLoopAllowed(Constraint<Boolean> value); @Override Constraint<Boolean> isAutosensModeEnabled(Constraint<Boolean> value); @Override Constraint<Boolean> isSMBModeEnabled(Constraint<Boolean> value); @Override Constraint<Boolean> isUAMEnabled(Constraint<Boolean> value); @Override Constraint<Boolean> isAdvancedFilteringEnabled(Constraint<Boolean> value); @Override Constraint<Double> applyBasalConstraints(Constraint<Double> absoluteRate, Profile profile); @Override Constraint<Integer> applyBasalPercentConstraints(Constraint<Integer> percentRate, Profile profile); @Override Constraint<Double> applyBolusConstraints(Constraint<Double> insulin); @Override Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin); @Override Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs); @Override Constraint<Double> applyMaxIOBConstraints(Constraint<Double> maxIob);  }
@Test public void pumpDescriptionShouldLimitLoopInvocation() { pump.getPumpDescription().isTempBasalCapable = false; Constraint<Boolean> c = new Constraint<>(true); c = safetyPlugin.isLoopInvocationAllowed(c); Assert.assertEquals("Safety: Pump is not temp basal capable", c.getReasons()); Assert.assertEquals(Boolean.FALSE, c.value()); }