Search in sources :

Example 11 with SubjectModelInterface

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

the class SubjectEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer subjectId = 5;
    final String subjectName = "Test subject";
    final Integer subjectUserId = 1;
    final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
    Mockito.when(subjectModel.getId()).thenReturn(subjectId);
    Mockito.when(subjectModel.getName()).thenReturn(subjectName);
    Mockito.when(subjectModel.getTopics()).thenReturn(new ModelsListEmpty());
    Mockito.when(subjectModel.getUser()).thenReturn(new UserModelEmpty(subjectUserId));
    Mockito.when(subjectModel.getIssueStandard()).thenReturn(new IssueStandardModelEmpty());
    Mockito.when(subjectModel.getIssues()).thenReturn(new ModelsListEmpty());
    final SubjectEntity subjectEntity = new SubjectEntity();
    subjectEntity.map(subjectModel);
    Assert.assertEquals(subjectId, subjectEntity.getId());
    Assert.assertEquals(subjectName, subjectEntity.getName());
    Assert.assertEquals(subjectUserId, subjectEntity.getUserId());
}
Also used : ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) UserModelEmpty(easytests.core.models.empty.UserModelEmpty) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty) SubjectModelInterface(easytests.core.models.SubjectModelInterface) Test(org.junit.Test)

Example 12 with SubjectModelInterface

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

the class TopicsController method create.

@GetMapping("create/")
public String create(Model model, @PathVariable("subjectId") Integer subjectId) {
    final SubjectModelInterface subjectModel = getCurrentSubjectModel(subjectId, false);
    final TopicDto topic = new TopicDto();
    setCreateBehaviour(model);
    model.addAttribute("topic", topic);
    model.addAttribute("subjectId", subjectId);
    return "topics/form";
}
Also used : TopicDto(easytests.personal.dto.TopicDto) SubjectModelInterface(easytests.core.models.SubjectModelInterface) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 13 with SubjectModelInterface

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

the class TopicsController method read.

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

Example 14 with SubjectModelInterface

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

the class TopicsController method update.

@GetMapping("update/{topicId}/")
public String update(Model model, @PathVariable Integer topicId, @PathVariable("subjectId") Integer subjectId) {
    final SubjectModelInterface subjectModel = getCurrentSubjectModel(subjectId, false);
    final TopicModelInterface topicModel = this.getTopicModel(topicId, subjectId);
    final TopicDto topic = new TopicDto();
    topic.map(topicModel);
    setUpdateBehaviour(model);
    model.addAttribute("topic", topic);
    model.addAttribute("subjectId", subjectId);
    return "topics/form";
}
Also used : TopicDto(easytests.personal.dto.TopicDto) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 15 with SubjectModelInterface

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

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