@Test public void testBuildDistrictwiseAlert() { List<DistrictwiseData> deltas = asList( new DistrictwiseData("Maharashtra", "Mumbai", "120", "90", "5", "9", "12", "3", "1", "") ); List<DistrictwiseData> dailies = asList( new DistrictwiseData("Maharashtra", "Mumbai", "25", "40", "12", "3", "11", "23", "4", "") ); AtomicReference<String> alertText = new AtomicReference<>(); String expected = "12 new cases, 1 death, 3 recoveries in Mumbai\n"; String actual = buildDistrictwiseAlert(deltas, dailies); assertEquals(expected, actual); }
public static String buildDistrictwiseAlert(List<DistrictwiseData> deltas, List<DistrictwiseData> dailies) { AtomicReference<String> alertText = new AtomicReference<>(""); deltas.forEach(delta -> buildDistrictDeltaAlertLine(alertText, delta)); if (alertText.get().isEmpty() || "\n".equalsIgnoreCase(alertText.get())) { LOG.info("No useful update to alert on. Skipping..."); return ""; } LOG.info("Districtwise alert text generated:\n{}", alertText.get()); return alertText.get(); }
DistrictAlertUtils { public static String buildDistrictwiseAlert(List<DistrictwiseData> deltas, List<DistrictwiseData> dailies) { AtomicReference<String> alertText = new AtomicReference<>(""); deltas.forEach(delta -> buildDistrictDeltaAlertLine(alertText, delta)); if (alertText.get().isEmpty() || "\n".equalsIgnoreCase(alertText.get())) { LOG.info("No useful update to alert on. Skipping..."); return ""; } LOG.info("Districtwise alert text generated:\n{}", alertText.get()); return alertText.get(); } }
DistrictAlertUtils { public static String buildDistrictwiseAlert(List<DistrictwiseData> deltas, List<DistrictwiseData> dailies) { AtomicReference<String> alertText = new AtomicReference<>(""); deltas.forEach(delta -> buildDistrictDeltaAlertLine(alertText, delta)); if (alertText.get().isEmpty() || "\n".equalsIgnoreCase(alertText.get())) { LOG.info("No useful update to alert on. Skipping..."); return ""; } LOG.info("Districtwise alert text generated:\n{}", alertText.get()); return alertText.get(); }  }
DistrictAlertUtils { public static String buildDistrictwiseAlert(List<DistrictwiseData> deltas, List<DistrictwiseData> dailies) { AtomicReference<String> alertText = new AtomicReference<>(""); deltas.forEach(delta -> buildDistrictDeltaAlertLine(alertText, delta)); if (alertText.get().isEmpty() || "\n".equalsIgnoreCase(alertText.get())) { LOG.info("No useful update to alert on. Skipping..."); return ""; } LOG.info("Districtwise alert text generated:\n{}", alertText.get()); return alertText.get(); }  static String buildDistrictwiseAlert(List<DistrictwiseData> deltas, List<DistrictwiseData> dailies); static void buildDistrictDeltaAlertLine(AtomicReference<String> updateText, DistrictwiseData delta); }
DistrictAlertUtils { public static String buildDistrictwiseAlert(List<DistrictwiseData> deltas, List<DistrictwiseData> dailies) { AtomicReference<String> alertText = new AtomicReference<>(""); deltas.forEach(delta -> buildDistrictDeltaAlertLine(alertText, delta)); if (alertText.get().isEmpty() || "\n".equalsIgnoreCase(alertText.get())) { LOG.info("No useful update to alert on. Skipping..."); return ""; } LOG.info("Districtwise alert text generated:\n{}", alertText.get()); return alertText.get(); }  static String buildDistrictwiseAlert(List<DistrictwiseData> deltas, List<DistrictwiseData> dailies); static void buildDistrictDeltaAlertLine(AtomicReference<String> updateText, DistrictwiseData delta);  }