Search in sources :

Example 21 with TopicModelInterface

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

the class TopicsController method delete.

@PostMapping("delete/{topicId}")
public String delete(Model model, @PathVariable("topicId") Integer topicId, @PathVariable("subjectId") Integer subjectId) {
    final SubjectModelInterface subjectModel = getCurrentSubjectModel(subjectId, false);
    final TopicModelInterface topicModel = getTopicModel(topicId, subjectId, topicsOptionsBuilder.forDelete());
    if (questionsService.findByTopic(topicModel).isEmpty()) {
        topicsService.delete(topicModel);
    } else {
        topicsService.delete(topicModel, this.topicsOptionsBuilder.forDelete());
    }
    return "redirect:/personal/subjects/" + subjectId + "/topics/";
}
Also used : SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 22 with TopicModelInterface

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

the class TopicsController method list.

@GetMapping("")
public String list(Model model, @PathVariable("subjectId") Integer subjectId) {
    final SubjectModelInterface subjectModel = getCurrentSubjectModel(subjectId, true);
    final List<TopicModelInterface> topics = subjectModel.getTopics();
    model.addAttribute("topics", topics);
    model.addAttribute("subjectId", subjectId);
    return "topics/list";
}
Also used : SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 23 with TopicModelInterface

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

the class TopicsController method getTopicModel.

private TopicModelInterface getTopicModel(Integer id, Integer subjectId) {
    final TopicsOptionsInterface topicsOptionsBuilder = this.topicsOptionsBuilder.forAuth();
    final TopicModelInterface topicModel = this.topicsService.find(id, topicsOptionsBuilder);
    checkModel(topicModel, subjectId);
    return topicModel;
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicModelInterface(easytests.core.models.TopicModelInterface)

Example 24 with TopicModelInterface

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

the class TopicsController method deleteConfirmation.

@GetMapping("delete/{topicId}")
public String deleteConfirmation(Model model, @PathVariable("topicId") Integer topicId, @PathVariable("subjectId") Integer subjectId) {
    final SubjectModelInterface subjectModel = getCurrentSubjectModel(subjectId, false);
    final TopicModelInterface topicModel = this.getTopicModel(topicId, subjectId);
    model.addAttribute("subjectId", subjectId);
    return "topics/delete";
}
Also used : SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 25 with TopicModelInterface

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

the class TopicsService method map.

private TopicModelInterface map(TopicEntity topicEntity) {
    if (topicEntity == null) {
        return null;
    }
    final TopicModelInterface topicModel = new TopicModel();
    topicModel.map(topicEntity);
    return topicModel;
}
Also used : TopicModel(easytests.core.models.TopicModel) TopicModelInterface(easytests.core.models.TopicModelInterface)

Aggregations

TopicModelInterface (easytests.core.models.TopicModelInterface)52 Test (org.junit.Test)34 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)32 SubjectModelInterface (easytests.core.models.SubjectModelInterface)18 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)16 ArrayList (java.util.ArrayList)15 QuestionModelInterface (easytests.core.models.QuestionModelInterface)14 TopicsOptionsInterface (easytests.core.options.TopicsOptionsInterface)9 TopicEntity (easytests.core.entities.TopicEntity)8 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)7 InOrder (org.mockito.InOrder)6 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)5 AnswerModelInterface (easytests.core.models.AnswerModelInterface)4 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)4 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 QuestionEntity (easytests.core.entities.QuestionEntity)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)3 SubjectModel (easytests.core.models.SubjectModel)3 TopicModel (easytests.core.models.TopicModel)3