/** * Constructs and returns a string object that is the result of interposing a separator between the elements of the array */ public static <T> String join(T[] array) { return join(array, ","); }
/** * Constructs and returns a string object that is the result of interposing a separator between the elements of the list */ public static <T> String join(List<T> list) { return join(list, ","); }
/** * Saves current session to the persistent storage */ static void saveCurrentSession(Context context, LogMonitorSession session) { if (context == null) { throw new IllegalArgumentException("Context is null"); } if (session == null) { throw new IllegalArgumentException("Session is null"); } SharedPreferences prefs = getPrefs(context); SharedPreferences.Editor editor = prefs.edit(); editor.putString(PREFS_KEY_EMAIL_RECIPIENTS, StringUtils.join(session.emailRecipients)); editor.apply(); }
protected void assertResult(String... expected) { // Make sure the expected and result sets contain the same number of items if (expected.length != result.size()) { fail(String.format("Expected: [%s], Actual: [%s]", StringUtils.join(expected), StringUtils.join(result))); } // Make sure the order and values are the same as well for (int i = 0; i < expected.length; ++i) { assertEquals(String.format("Expected: [%s], Actual: [%s],", StringUtils.join(expected), StringUtils.join(result)), expected[i], result.get(i)); } result.clear(); } //endregion
private void assertFiles(File[] files, String... expected) { List<String> actual = TestUtils.map(files, new TestUtils.Map<File, String>() { @Override public String map(File value) { return readLogFile(value); } }); String message = String.format("Expected: [%s], Actual: [%s]", StringUtils.join(expected).replace("\n", "\\n"), StringUtils.join(actual).replace("\n", "\\n")); assertEquals(message, expected.length, files.length); for (int i = 0; i < files.length; ++i) { assertEquals(message, expected[i], readLogFile(files[i])); } }