use of easytests.core.models.UserModel in project easy-tests by malinink.
the class AuthUsersServiceTest method testLoadUserByUsername.
@Test
public void testLoadUserByUsername() throws Exception {
final UsersServiceInterface usersService = Mockito.mock(UsersServiceInterface.class);
final String email = "email3@gmail.com";
userModel = new UserModel();
userModel.setId(1);
userModel.setFirstName("FirstName3");
userModel.setLastName("LastName3");
userModel.setSurname("Surname3");
userModel.setEmail(email);
userModel.setPassword("hash3");
userModel.setIsAdmin(true);
userModel.setState(3);
when(usersService.findByEmail(email)).thenReturn(userModel);
final UserDetails user = this.authUsersService.loadUserByUsername(email);
Assert.assertEquals(usersService.findByEmail(email).getEmail(), user.getUsername());
Assert.assertEquals(usersService.findByEmail(email).getPassword(), user.getPassword());
Assert.assertEquals(usersService.findByEmail(email).getState() == 3, user.isEnabled());
Assert.assertEquals(3, user.getAuthorities().size());
verify(usersService, times(3)).findByEmail(email);
}
use of easytests.core.models.UserModel in project easy-tests by malinink.
the class UsersService method map.
private UserModelInterface map(UserEntity userEntity) {
if (userEntity == null) {
return null;
}
final UserModelInterface userModel = new UserModel();
userModel.map(userEntity);
return userModel;
}
use of easytests.core.models.UserModel in project easy-tests by malinink.
the class UsersController method insert.
@PostMapping("create/")
public String insert(Model model, @Valid UserModelDto userModelDto, BindingResult bindingResult) {
this.userModelDtoValidator.validate(userModelDto, bindingResult);
if (bindingResult.hasErrors()) {
model.addAttribute("user", userModelDto);
model.addAttribute("errors", bindingResult);
setCreateBehaviour(model);
return "admin/users/form";
}
final UserModelInterface userModel = new UserModel();
userModelDto.mapInto(userModel);
this.usersService.save(userModel);
return "redirect:/admin/users/";
}
use of easytests.core.models.UserModel in project easy-tests by malinink.
the class UsersServiceTest method mapUserModel.
private UserModelInterface mapUserModel(UserEntity userEntity) {
final UserModelInterface userModel = new UserModel();
userModel.map(userEntity);
return userModel;
}
Aggregations