UserValidator { public boolean isValidName(String name) { return accountValidator.isValidName(name); } @Inject  UserValidator(AccountValidator accountValidator); void checkUser(User user); void checkPassword(String password); boolean isValidName(String name); String normalizeUserName(String name);  }
@Test public void shouldReturnFalseWhenInputIsInvalidAccountName() throws Exception { when(accountValidator.isValidName(any())).thenReturn(false); assertEquals(userNameValidator.isValidName("toTest"), false); verify(accountValidator).isValidName("toTest"); }
@Test public void shouldReturnTrueWhenInputIsValidAccountName() throws Exception { when(accountValidator.isValidName(any())).thenReturn(true); assertEquals(userNameValidator.isValidName("toTest"), true); verify(accountValidator).isValidName("toTest"); }