HerdStringUtils { public static void checkCsvInjection(String text, String errorMessage) { if (StringUtils.isNotEmpty(text) && text.matches(CSV_INJECTION_REGEX)) { throw new IllegalArgumentException(errorMessage); } }  static String decodeBase64(String base64EncodedText); static String getShortDescription(String description, Integer shortDescMaxLength); static String stripHtml(String fragment, String... whitelistTags); static void checkCsvInjection(String text, String errorMessage); static Integer convertStringToInteger(final String stringValue, final Integer defaultValue); static String sanitizeLogText(String loggingText); static final String HIDDEN_TEXT; }
@Test public void testCheckCsvInjectionStartsWithEqualsToCharacter() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(is(CSV_INJECTION_ERROR_MSG)); HerdStringUtils.checkCsvInjection("=abc", CSV_INJECTION_ERROR_MSG); }
@Test public void testCheckCsvInjectionStartsWithPlusCharacter() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(is(CSV_INJECTION_ERROR_MSG)); HerdStringUtils.checkCsvInjection("+abc", CSV_INJECTION_ERROR_MSG); }
@Test public void testCheckCsvInjectionStartsWithAtCharacter() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(is(CSV_INJECTION_ERROR_MSG)); HerdStringUtils.checkCsvInjection("@abc", CSV_INJECTION_ERROR_MSG); }
@Test public void testCheckCsvInjectionStartsWithMinusCharacter() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(is(CSV_INJECTION_ERROR_MSG)); HerdStringUtils.checkCsvInjection("-abc", CSV_INJECTION_ERROR_MSG); }
@Test public void testCheckCsvInjectionValidEmptyCharacter() { HerdStringUtils.checkCsvInjection("", CSV_INJECTION_ERROR_MSG); }
@Test public void testCheckCsvInjectionValidNull() { HerdStringUtils.checkCsvInjection(null, CSV_INJECTION_ERROR_MSG); }
@Test public void testCheckCsvInjectionValidStartsWithNormalCharacter() { HerdStringUtils.checkCsvInjection("hello", CSV_INJECTION_ERROR_MSG); }
@Test public void testCheckCsvInjectionValidPlusCharacterInMiddle() { HerdStringUtils.checkCsvInjection("abc+def", CSV_INJECTION_ERROR_MSG); }
@Test public void testCheckCsvInjectionValidStartsWithBlank() { HerdStringUtils.checkCsvInjection(" bc+def", CSV_INJECTION_ERROR_MSG); }