Search in sources :

Example 6 with SubjectModel

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

the class SubjectsController method create.

@PostMapping("create")
public String create(@Valid @NotNull SubjectDto subject, BindingResult bindingResult, Model model) {
    if (bindingResult.hasErrors()) {
        model.addAttribute("methodType", "create");
        model.addAttribute("subject", subject);
        model.addAttribute("errors", bindingResult);
        return "subjects/form";
    }
    final SubjectModelInterface subjectModel = new SubjectModel();
    subject.mapInto(subjectModel);
    subjectModel.setUser(this.getCurrentUserModel());
    subjectsService.save(subjectModel);
    final IssueStandardModelInterface issueStandardModel = new IssueStandardModel();
    issueStandardModel.setSubject(new SubjectModelEmpty(subjectModel.getId()));
    issueStandardsService.save(issueStandardModel);
    return "redirect:/personal/subjects/list";
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardModel(easytests.core.models.IssueStandardModel) SubjectModel(easytests.core.models.SubjectModel) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 7 with SubjectModel

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

the class SubjectsServiceTest method mapSubjectModel.

private SubjectModelInterface mapSubjectModel(SubjectEntity subjectEntity) {
    final SubjectModelInterface subjectModel = new SubjectModel();
    subjectModel.map(subjectEntity);
    return subjectModel;
}
Also used : SubjectModel(easytests.core.models.SubjectModel) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Aggregations

SubjectModel (easytests.core.models.SubjectModel)7 SubjectModelInterface (easytests.core.models.SubjectModelInterface)6 TopicModelInterface (easytests.core.models.TopicModelInterface)3 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)3 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)2 InOrder (org.mockito.InOrder)2 IssueStandardModel (easytests.core.models.IssueStandardModel)1 UserModelInterface (easytests.core.models.UserModelInterface)1 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)1