Search in sources :

Example 6 with SubjectModelEmpty

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

the class IssueEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer issueId = 420;
    final String name = "Name";
    final Integer subjectId = 13;
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    Mockito.when(issueModel.getId()).thenReturn(issueId);
    Mockito.when(issueModel.getName()).thenReturn(name);
    Mockito.when(issueModel.getSubject()).thenReturn(new SubjectModelEmpty(subjectId));
    final IssueEntity issueEntity = new IssueEntity();
    issueEntity.map(issueModel);
    Assert.assertEquals(issueId, issueEntity.getId());
    Assert.assertEquals(name, issueEntity.getName());
    Assert.assertEquals(subjectId, issueEntity.getSubjectId());
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test)

Example 7 with SubjectModelEmpty

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

the class IssueStandardDto method mapInto.

public void mapInto(IssueStandardModelInterface issueStandardModel) {
    final List<IssueStandardTopicPriorityModelInterface> topicPriorityModelList = new ArrayList<>(this.getTopicPriorities().size());
    for (IssueStandardTopicPriorityDto topicPriorityDto : this.getTopicPriorities()) {
        final IssueStandardTopicPriorityModelInterface topicPriorityModel = new IssueStandardTopicPriorityModel();
        topicPriorityDto.mapInto(topicPriorityModel, this.getId());
        topicPriorityModelList.add(topicPriorityModel);
    }
    final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModelList = new ArrayList<>(this.getQuestionTypeOptions().size());
    for (IssueStandardQuestionTypeOptionDto questionTypeOptionDto : this.getQuestionTypeOptions()) {
        final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = new IssueStandardQuestionTypeOptionModel();
        questionTypeOptionDto.mapInto(questionTypeOptionModel, this.getId());
        questionTypeOptionModelList.add(questionTypeOptionModel);
    }
    issueStandardModel.setTimeLimit(this.getTimeLimit());
    issueStandardModel.setQuestionsNumber(this.getQuestionsNumber());
    issueStandardModel.setTopicPriorities(topicPriorityModelList);
    issueStandardModel.setQuestionTypeOptions(questionTypeOptionModelList);
    issueStandardModel.setSubject(new SubjectModelEmpty(this.getSubjectId()));
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) ArrayList(java.util.ArrayList)

Example 8 with SubjectModelEmpty

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

the class IssueStandardSupport method getModelMock.

private IssueStandardModelInterface getModelMock(Integer id, Integer timeLimit, Integer questionsNumber, Integer subjectId) {
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getId()).thenReturn(id);
    Mockito.when(issueStandardModel.getTimeLimit()).thenReturn(timeLimit);
    Mockito.when(issueStandardModel.getQuestionsNumber()).thenReturn(questionsNumber);
    Mockito.when(issueStandardModel.getTopicPriorities()).thenReturn(new ModelsListEmpty());
    Mockito.when(issueStandardModel.getQuestionTypeOptions()).thenReturn(new ModelsListEmpty());
    Mockito.when(issueStandardModel.getSubject()).thenReturn(new SubjectModelEmpty(subjectId));
    return issueStandardModel;
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty)

Example 9 with SubjectModelEmpty

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

the class TopicsSupport method getModelMock.

private TopicModelInterface getModelMock(Integer id, String name, Integer subjectId) {
    final TopicModelInterface topicModelMock = Mockito.mock(TopicModelInterface.class);
    Mockito.when(topicModelMock.getId()).thenReturn(id);
    Mockito.when(topicModelMock.getName()).thenReturn(name);
    Mockito.when(topicModelMock.getSubject()).thenReturn(new SubjectModelEmpty(subjectId));
    Mockito.when(topicModelMock.getQuestions()).thenReturn(new ModelsListEmpty());
    return topicModelMock;
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) TopicModelInterface(easytests.core.models.TopicModelInterface)

Example 10 with SubjectModelEmpty

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

Aggregations

SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)16 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)11 Test (org.junit.Test)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)5 SubjectModelInterface (easytests.core.models.SubjectModelInterface)5 ArrayList (java.util.ArrayList)5 IssueModelInterface (easytests.core.models.IssueModelInterface)4 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)4 IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)2 IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)2 QuizModelInterface (easytests.core.models.QuizModelInterface)2 IssueStandardQuestionTypeOptionsServiceInterface (easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface)2 IssueStandardTopicPrioritiesServiceInterface (easytests.core.services.IssueStandardTopicPrioritiesServiceInterface)2 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)2 IssueEntity (easytests.core.entities.IssueEntity)1 IssueStandardEntity (easytests.core.entities.IssueStandardEntity)1 IssueModel (easytests.core.models.IssueModel)1 IssueStandardModel (easytests.core.models.IssueStandardModel)1 SubjectModel (easytests.core.models.SubjectModel)1