AccountValidator { public boolean isValidName(String name) { return name != null && VALID_ACCOUNT_NAME.matcher(name).matches(); } @Inject  AccountValidator(AccountManager accountManager); boolean isValidName(String name); String normalizeAccountName(String name, String prefix);  }
@Test(dataProvider = "namesToValidate") public void testValidUserName(String input, boolean expected) throws Exception { doThrow(NotFoundException.class).when(accountManager).getByName(anyString()); Assert.assertEquals(accountValidator.isValidName(input), expected); }