Search in sources :

Example 41 with SubjectModelInterface

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

the class SubjectsController method deleteConfirmation.

@GetMapping("delete/{id}")
public String deleteConfirmation(@PathVariable("id") Integer id, Model model) {
    final SubjectDto subjectDto = new SubjectDto();
    final SubjectModelInterface subjectModel = getSubjectModel(id);
    subjectDto.map(subjectModel);
    model.addAttribute("subject", subjectDto);
    return "subjects/delete";
}
Also used : SubjectDto(easytests.personal.dto.SubjectDto) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 42 with SubjectModelInterface

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

the class SubjectsController method delete.

@PostMapping("delete/{id}")
public String delete(@PathVariable("id") Integer subjectId, SubjectDto subjectDto, BindingResult bindingResult, Model model) {
    final SubjectModelInterface subjectModel = getSubjectModel(subjectId, subjectsOptionsBuilder.forDelete());
    subjectsService.delete(subjectModel, subjectsOptionsBuilder.forDelete());
    return "redirect:/personal/subjects/list";
}
Also used : SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 43 with SubjectModelInterface

use of easytests.core.models.SubjectModelInterface 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 44 with SubjectModelInterface

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

the class SubjectsController method update.

@PostMapping("update/{id}")
public String update(@PathVariable("id") Integer subjectId, @Valid @NotNull SubjectDto subject, BindingResult bindingResult, Model model) {
    if (bindingResult.hasErrors()) {
        model.addAttribute("methodType", "update");
        model.addAttribute("subject", subject);
        model.addAttribute("errors", bindingResult);
        return "subjects/form";
    }
    final SubjectModelInterface subjectModel = getSubjectModel(subjectId);
    subject.mapInto(subjectModel);
    subjectsService.save(subjectModel);
    return "redirect:/personal/subjects/list";
}
Also used : SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 45 with SubjectModelInterface

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

the class TopicsController method getCurrentSubjectModel.

private SubjectModelInterface getCurrentSubjectModel(Integer subjectId, boolean withTopics) {
    final SubjectsOptionsInterface subjectsOptions = this.subjectsOptionsBuilder.forAuth();
    final SubjectModelInterface subjectModel = subjectsService.find(subjectId, subjectsOptions);
    if (withTopics) {
        final List<TopicModelInterface> topics = this.topicsService.findBySubject(subjectModel);
        subjectModel.setTopics(topics);
    }
    checkModel(subjectModel);
    return subjectModel;
}
Also used : SubjectsOptionsInterface(easytests.core.options.SubjectsOptionsInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface)

Aggregations

SubjectModelInterface (easytests.core.models.SubjectModelInterface)64 Test (org.junit.Test)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)21 TopicModelInterface (easytests.core.models.TopicModelInterface)18 ArrayList (java.util.ArrayList)16 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)15 SubjectsOptionsInterface (easytests.core.options.SubjectsOptionsInterface)11 UserModelInterface (easytests.core.models.UserModelInterface)9 SubjectEntity (easytests.core.entities.SubjectEntity)7 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)7 SubjectModel (easytests.core.models.SubjectModel)6 InOrder (org.mockito.InOrder)6 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)5 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)5 GetMapping (org.springframework.web.bind.annotation.GetMapping)5 TopicEntity (easytests.core.entities.TopicEntity)4 IssueModelInterface (easytests.core.models.IssueModelInterface)4 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)4 IssueStandardQuestionTypeOptionsServiceInterface (easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface)4 IssueStandardTopicPrioritiesServiceInterface (easytests.core.services.IssueStandardTopicPrioritiesServiceInterface)4