PumpEnactResult { public String toString() { String ret = MainApp.gs(R.string.success) + ": " + success; if (enacted) { if (bolusDelivered > 0) { ret += "\n" + MainApp.gs(R.string.enacted) + ": " + enacted; ret += "\n" + MainApp.gs(R.string.comment) + ": " + comment; ret += "\n" + MainApp.gs(R.string.configbuilder_insulin) + ": " + bolusDelivered + " " + MainApp.gs(R.string.insulin_unit_shortname); } else if (isTempCancel) { ret += "\n" + MainApp.gs(R.string.enacted) + ": " + enacted; if (!comment.isEmpty()) ret += "\n" + MainApp.gs(R.string.comment) + ": " + comment; ret += "\n" + MainApp.gs(R.string.canceltemp); } else if (isPercent) { ret += "\n" + MainApp.gs(R.string.enacted) + ": " + enacted; if (!comment.isEmpty()) ret += "\n" + MainApp.gs(R.string.comment) + ": " + comment; ret += "\n" + MainApp.gs(R.string.duration) + ": " + duration + " min"; ret += "\n" + MainApp.gs(R.string.percent) + ": " + percent + "%"; } else { ret += "\n" + MainApp.gs(R.string.enacted) + ": " + enacted; if (!comment.isEmpty()) ret += "\n" + MainApp.gs(R.string.comment) + ": " + comment; ret += "\n" + MainApp.gs(R.string.duration) + ": " + duration + " min"; ret += "\n" + MainApp.gs(R.string.absolute) + ": " + absolute + " U/h"; } } else { ret += "\n" + MainApp.gs(R.string.comment) + ": " + comment; } return ret; }  PumpEnactResult success(boolean success); PumpEnactResult enacted(boolean enacted); PumpEnactResult comment(String comment); PumpEnactResult comment(int comment); PumpEnactResult duration(int duration); PumpEnactResult absolute(double absolute); PumpEnactResult percent(int percent); PumpEnactResult isPercent(boolean isPercent); PumpEnactResult isTempCancel(boolean isTempCancel); PumpEnactResult bolusDelivered(double bolusDelivered); PumpEnactResult carbsDelivered(double carbsDelivered); PumpEnactResult queued(boolean queued); String log(); String toString(); String toHtml(); JSONObject json(Profile profile); public boolean success; public boolean enacted; public String comment; public int duration; public double absolute; public int percent; public boolean isPercent; public boolean isTempCancel; public double bolusDelivered; public double carbsDelivered; public boolean queued; }
@Test public void toStringTest() throws Exception { per = new PumpEnactResult().enacted(true).bolusDelivered(10).comment("AAA"); Assert.assertEquals("Success: false\n" + "Enacted: true\n" + "Comment: AAA\n" + "Insulin: 10.0 U", per.toString()); per = new PumpEnactResult().enacted(true).isTempCancel(true).comment("AAA"); Assert.assertEquals("Success: false\n" + "Enacted: true\n" + "Comment: AAA\n" + "Cancel temp basal", per.toString()); per = new PumpEnactResult().enacted(true).isPercent(true).percent(90).duration(20).comment("AAA"); Assert.assertEquals("Success: false\n" + "Enacted: true\n" + "Comment: AAA\n" + "Duration: 20 min\n" + "Percent: 90%", per.toString()); per = new PumpEnactResult().enacted(true).isPercent(false).absolute(1).duration(30).comment("AAA"); Assert.assertEquals("Success: false\n" + "Enacted: true\n" + "Comment: AAA\n" + "Duration: 30 min\n" + "Absolute: 1.0 U/h", per.toString()); per = new PumpEnactResult().enacted(false).comment("AAA"); Assert.assertEquals("Success: false\n" + "Comment: AAA", per.toString()); }