DisplayFormat { public static Pair<String, String> detailedIob(RawDisplayData raw) { final String iob1 = new SmallestDoubleString(raw.sIOB1, SmallestDoubleString.Units.USE).minimise(MAX_FIELD_LEN_SHORT); String iob2 = ""; if (raw.sIOB2.contains("|")) { String[] iobs = raw.sIOB2.replace("(", "").replace(")", "").split("\\|"); String iobBolus = new SmallestDoubleString(iobs[0]).minimise(MIN_FIELD_LEN_IOB); if (iobBolus.trim().length() == 0) { iobBolus = "--"; } String iobBasal = new SmallestDoubleString(iobs[1]).minimise((MAX_FIELD_LEN_SHORT -1) - Math.max(MIN_FIELD_LEN_IOB, iobBolus.length())); if (iobBasal.trim().length() == 0) { iobBasal = "--"; } iob2 = iobBolus+" "+iobBasal; } return Pair.create(iob1, iob2); }  static String deltaSymbol(); static String verticalSeparatorSymbol(); static String basalRateSymbol(); static String shortTimeSince(final long refTime); static String shortTrend(final RawDisplayData raw); static String longGlucoseLine(final RawDisplayData raw); static String longDetailsLine(final RawDisplayData raw); static Pair<String, String> detailedIob(RawDisplayData raw); static Pair<String, String> detailedCob(final RawDisplayData raw); static final int MAX_FIELD_LEN_LONG; static final int MAX_FIELD_LEN_SHORT; static final int MIN_FIELD_LEN_COB; static final int MIN_FIELD_LEN_IOB; }
@Test public void detailedIobTest() { assertThat(DisplayFormat.detailedIob(rawIob("-1.29U", "(0,910|-2,20)")), is(Pair.create("-1.29U", ",91 -2"))); assertThat(DisplayFormat.detailedIob(rawIob("3.50U", "")), is(Pair.create("3.50U", ""))); assertThat(DisplayFormat.detailedIob(rawIob("12.5U", "(+1,4|-4.78)")), is(Pair.create("12.5U", "1,4 -5"))); assertThat(DisplayFormat.detailedIob(rawIob("0.67U", "some junks")), is(Pair.create(".67U", ""))); assertThat(DisplayFormat.detailedIob(rawIob("-11.0U", "(broken|data)")), is(Pair.create("-11U", "-- --"))); assertThat(DisplayFormat.detailedIob(rawIob("5.52U", "(0,5439|wrong)")), is(Pair.create("5.52U", ",54 --"))); assertThat(DisplayFormat.detailedIob(rawIob("-8.1U", "(|-8,1)")), is(Pair.create("-8.1U", "-- -8"))); assertThat(DisplayFormat.detailedIob(rawIob("-8.1U", "(|-8,1)")), is(Pair.create("-8.1U", "-- -8"))); assertThat(DisplayFormat.detailedIob(rawIob("7.6U", "(malformed)")), is(Pair.create("7.6U", ""))); assertThat(DisplayFormat.detailedIob(rawIob("-4.26U", "(6,97|1,3422|too much)")), is(Pair.create("-4.26U", "7 1,3"))); }