ProcessInitialDataQuality { public static InitialDataQuality getInitialDataQuality() { JoH.clearCache(); final List<BgReading> uncalculated = BgReading.latestUnCalculated(3); return getInitialDataQuality(uncalculated); }  static InitialDataQuality getInitialDataQuality(); static InitialDataQuality getInitialDataQuality(final List<BgReading> uncalculated);  }
@Test public void testGetInitialDataQuality() { ProcessInitialDataQuality.InitialDataQuality test; test = ProcessInitialDataQuality.getInitialDataQuality(null); assertThat("Result object not null", test != null, is(true)); assertThat("Null input should fail", test.pass, is(false)); List<BgReading> bgReadingList = new ArrayList<>(); test = ProcessInitialDataQuality.getInitialDataQuality(bgReadingList); assertThat("Result object not null", test != null, is(true)); assertThat("Empty input should fail", test.pass, is(false)); for (int frequency = 5; frequency < 21; frequency = frequency + 1) { bgReadingList.clear(); for (int i = 1; i <= 3; i++) { bgReadingList.add(getGoodMockBgReading(i * Constants.MINUTE_IN_MS * frequency)); test = ProcessInitialDataQuality.getInitialDataQuality(bgReadingList); log("Frequency: " + frequency + " Loop " + i + " size:" + bgReadingList.size() + " Newest age: " + JoH.niceTimeScalar(JoH.msSince(bgReadingList.get(0).timestamp)) + " Oldest age: " + JoH.niceTimeScalar(JoH.msSince(bgReadingList.get(bgReadingList.size() - 1).timestamp)) + " / Mock Advice: " + test.advice + " VERDICT: " + (test.pass ? "PASS" : "NOT PASSED")); assertThat("Result object not null", test != null, is(true)); if (i < 3) assertThat("Empty input should fail", test.pass, is(false)); assertThat("There should be some advice on loop " + i, test.advice.length() > 0, is(true)); final long ms_since = (JoH.msSince(bgReadingList.get(bgReadingList.size() - 1).timestamp)); if ((ms_since > Constants.STALE_CALIBRATION_CUT_OFF + COMPUTATION_GRACE_TIME) || (i < 3)) { assertThat("Stale data should fail: i:" + i + " tm:" + ms_since, test.pass, is(false)); } if ((ms_since <= Constants.STALE_CALIBRATION_CUT_OFF) && (bgReadingList.size() >= 3)) { assertThat("Good data should pass", test.pass, is(true)); } } } }