use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.
the class IssueStandardsServiceTest method testSaveUpdatesModel.
@Test
public void testSaveUpdatesModel() throws Exception {
final Integer id = 1;
final IssueStandardModelInterface issueStandardModel = Models.createIssueStandardModel(id, 200, 10, 2);
Assert.assertNotEquals(issueStandardModel, this.issueStandardsService.find(id));
this.issueStandardsService.save(issueStandardModel);
Assert.assertEquals(issueStandardModel, this.issueStandardsService.find(id));
}
use of easytests.core.models.IssueStandardModelInterface in project easy-tests by malinink.
the class IssueStandardsServiceTest method testFindWithOptions.
@Test
public void testFindWithOptions() throws Exception {
final Integer id = 1;
final Integer subjectId = 1;
final IssueStandardModelInterface issueStandardModel = Models.createIssueStandardModel(id, 300, 30, subjectId);
final SubjectModelInterface subjectModel = Models.createSubjectModel(subjectId, "test1", "testdescription1", 2);
issueStandardModel.setSubject(subjectModel);
final IssueStandardModelInterface foundedIssueStandardModel = this.issueStandardsService.find(id, new IssueStandardsOptions().withSubject(new SubjectsOptions()));
Assert.assertEquals(issueStandardModel, foundedIssueStandardModel);
Assert.assertEquals(subjectModel, foundedIssueStandardModel.getSubject());
}
use of easytests.core.models.IssueStandardModelInterface 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.IssueStandardModelInterface in project easy-tests by malinink.
the class IssueStandardsService method map.
private IssueStandardModelInterface map(IssueStandardEntity issueStandardEntity) {
final IssueStandardModelInterface issueStandardModel = new IssueStandardModel();
issueStandardModel.map(issueStandardEntity);
return issueStandardModel;
}
use of easytests.core.models.IssueStandardModelInterface 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