@Test void getByUsername_WillReturnAuthServerRepresentationOfPeristableUser() { PersistableUser persistableUser = mock(PersistableUser.class); when(persistableUser.getUsername()).thenReturn("found-username"); when(persistableUser.getEncodedPassword()).thenReturn("encoded-password"); when(persistableUser.isDisabled()).thenReturn(false); when(usersRepository.findByUsernameIgnoreCase("username")).thenReturn(Optional.of(persistableUser)); AuthServerUser expectedAuthServerUser = new AuthServerUser("found-username", "encoded-password", false); assertEquals(expectedAuthServerUser, defaultAuthServerUserReadService.getByUsername("username")); }
@Override public AuthServerUser getByUsername(String username) { var persistableUser = usersRepository.findByUsernameIgnoreCase(username).orElseThrow(); return new AuthServerUser(persistableUser.getUsername(), persistableUser.getEncodedPassword(), persistableUser.isDisabled()); }
DefaultAuthServerUserReadService implements AuthServerUserReadService { @Override public AuthServerUser getByUsername(String username) { var persistableUser = usersRepository.findByUsernameIgnoreCase(username).orElseThrow(); return new AuthServerUser(persistableUser.getUsername(), persistableUser.getEncodedPassword(), persistableUser.isDisabled()); } }
DefaultAuthServerUserReadService implements AuthServerUserReadService { @Override public AuthServerUser getByUsername(String username) { var persistableUser = usersRepository.findByUsernameIgnoreCase(username).orElseThrow(); return new AuthServerUser(persistableUser.getUsername(), persistableUser.getEncodedPassword(), persistableUser.isDisabled()); } DefaultAuthServerUserReadService(UsersRepository usersRepository); }
DefaultAuthServerUserReadService implements AuthServerUserReadService { @Override public AuthServerUser getByUsername(String username) { var persistableUser = usersRepository.findByUsernameIgnoreCase(username).orElseThrow(); return new AuthServerUser(persistableUser.getUsername(), persistableUser.getEncodedPassword(), persistableUser.isDisabled()); } DefaultAuthServerUserReadService(UsersRepository usersRepository); @Override AuthServerUser getByUsername(String username); }
DefaultAuthServerUserReadService implements AuthServerUserReadService { @Override public AuthServerUser getByUsername(String username) { var persistableUser = usersRepository.findByUsernameIgnoreCase(username).orElseThrow(); return new AuthServerUser(persistableUser.getUsername(), persistableUser.getEncodedPassword(), persistableUser.isDisabled()); } DefaultAuthServerUserReadService(UsersRepository usersRepository); @Override AuthServerUser getByUsername(String username);  }