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());
}
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()));
}
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;
}
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;
}
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";
}
Aggregations