Util { public static String obfuscateEmailAddress(final String username) { if (username.contains(AT)) { final String[] parts = COMPILE.split(username.toLowerCase()); return cutMiddle(parts[0].trim()) + AT + cutMiddle(parts[1].trim()); } else { throw new IllegalArgumentException("Not a valid e-mail address: " + username); } } private  Util(); static Date toDate(final LocalDate localDate); static Date toDate(final OffsetDateTime offsetDateTime); static Date toDate(final ZonedDateTime zonedDateTime); static String identifyLoan(final LoanBased event); static Map<String, Object> getLoanData(final Loan loan); static Map<String, Object> getDelinquencyData(final Investment investment); static Map<String, Object> getLoanData(final Investment i, final Loan l); static Map<String, Object> summarizePortfolioStructure(final PortfolioOverview portfolioOverview); static Map<String, Object> summarizePortfolioStructure(final ExtendedPortfolioOverview portfolioOverview); static boolean isNetworkProblem(final Throwable ex); static Map<String, Object> getDelinquentData(final Investment i, final Loan loan, final LocalDate date); static String stackTraceToString(final Throwable t); static String obfuscateEmailAddress(final String username);  }
@Test void emailObfuscation() { assertThat(Util.obfuscateEmailAddress("someone@somewhere.net")).isEqualTo("s...e@s...t"); assertThat(Util.obfuscateEmailAddress("ab@cd")).isEqualTo("a...b@c...d"); assertThat(Util.obfuscateEmailAddress("a@b")).isEqualTo("a@b"); }