Utils { public static String toStringResult(List<String> result) { String res = ""; if (result == null) { return res; } for (int i = 0; i < result.size(); i++) { String item = result.get(i); if (i == 0) { res += item; } else { res += ", " + item; } } return res; }  static String toStringResult(List<String> result); static Map convert(String mapString); static Date getRegisterDateAsDdMmYyyy(String registrationDateString); static Date getRegisterDateByYyyyMmDd(String registrationDateString); static void clearAudioFile(String fileName); static void showMessageByToast(Context context, int ResId, int duration); static void showMessageByToast(Context context, String message, int duration);  }
@Test public void should_convert_list_to_string() { List<String> items = new ArrayList<>(); items.add("Language1"); items.add("Language2"); String result = Utils.toStringResult(items); assertThat(result, is("Language1, Language2")); items = null; result = Utils.toStringResult(items); assertThat(result, is("")); items = new ArrayList<>(); result = Utils.toStringResult(items); assertThat(result, is("")); }