UserValidator { public String normalizeUserName(String name) throws ServerException { return accountValidator.normalizeAccountName(name, GENERATED_NAME_PREFIX); } @Inject  UserValidator(AccountValidator accountValidator); void checkUser(User user); void checkPassword(String password); boolean isValidName(String name); String normalizeUserName(String name);  }
@Test public void shouldReturnNameNormalizedByAccountValidator() throws Exception { when(accountValidator.normalizeAccountName(anyString(), anyString())).thenReturn("testname"); assertEquals(userNameValidator.normalizeUserName("toNormalize"), "testname"); verify(accountValidator) .normalizeAccountName("toNormalize", UserValidator.GENERATED_NAME_PREFIX); }