Search in sources :

Example 21 with UserModelInterface

use of easytests.core.models.UserModelInterface 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;
}
Also used : UserModel(easytests.core.models.UserModel) UserModelInterface(easytests.core.models.UserModelInterface)

Example 22 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersController method save.

@PostMapping("update/{userId}/")
public String save(Model model, @PathVariable Integer userId, @Valid UserModelDto userModelDto, BindingResult bindingResult) {
    final UserModelInterface userModel = this.getUserModel(userId);
    userModelDto.setId(userId);
    this.userModelDtoValidator.validate(userModelDto, bindingResult);
    if (bindingResult.hasErrors()) {
        model.addAttribute("user", userModelDto);
        model.addAttribute("errors", bindingResult);
        setUpdateBehaviour(model);
        return "admin/users/form";
    }
    userModelDto.mapInto(userModel);
    this.usersService.save(userModel);
    return "redirect:/admin/users/";
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface)

Example 23 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersController method view.

@GetMapping("{userId}/")
public String view(Model model, @PathVariable Integer userId) {
    final UserModelInterface userModel = this.getUserModel(userId);
    model.addAttribute("user", userModel);
    return "admin/users/view";
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface)

Example 24 with UserModelInterface

use of easytests.core.models.UserModelInterface 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/";
}
Also used : UserModel(easytests.core.models.UserModel) UserModelInterface(easytests.core.models.UserModelInterface)

Example 25 with UserModelInterface

use of easytests.core.models.UserModelInterface in project easy-tests by malinink.

the class UsersController method update.

@GetMapping("update/{userId}/")
public String update(Model model, @PathVariable Integer userId) {
    final UserModelInterface userModel = this.getUserModel(userId);
    final UserModelDto userModelDto = new UserModelDto();
    userModelDto.map(userModel);
    model.addAttribute("user", userModelDto);
    setUpdateBehaviour(model);
    return "admin/users/form";
}
Also used : UserModelInterface(easytests.core.models.UserModelInterface) UserModelDto(easytests.admin.dto.UserModelDto)

Aggregations

UserModelInterface (easytests.core.models.UserModelInterface)40 Test (org.junit.Test)11 SubjectModelInterface (easytests.core.models.SubjectModelInterface)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 UserEntity (easytests.core.entities.UserEntity)7 UsersOptionsInterface (easytests.core.options.UsersOptionsInterface)7 ArrayList (java.util.ArrayList)6 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)5 SubjectEntity (easytests.core.entities.SubjectEntity)3 UserModel (easytests.core.models.UserModel)3 UsersServiceInterface (easytests.core.services.UsersServiceInterface)2 InOrder (org.mockito.InOrder)2 UserModelDto (easytests.admin.dto.UserModelDto)1 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)1 SubjectModel (easytests.core.models.SubjectModel)1 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)1 SubjectsOptionsInterface (easytests.core.options.SubjectsOptionsInterface)1 UsersOptions (easytests.core.options.UsersOptions)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1