Search in sources :

Example 11 with IssueStandardModelInterface

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));
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with IssueStandardModelInterface

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());
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) SubjectsOptions(easytests.core.options.SubjectsOptions) IssueStandardsOptions(easytests.core.options.IssueStandardsOptions) SubjectModelInterface(easytests.core.models.SubjectModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with IssueStandardModelInterface

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;
}
Also used : SubjectModelEmpty(easytests.core.models.empty.SubjectModelEmpty) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty)

Example 14 with IssueStandardModelInterface

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;
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardModel(easytests.core.models.IssueStandardModel)

Example 15 with IssueStandardModelInterface

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";
}
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

IssueStandardModelInterface (easytests.core.models.IssueStandardModelInterface)30 Test (org.junit.Test)25 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)24 IssueStandardsServiceInterface (easytests.core.services.IssueStandardsServiceInterface)10 IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)9 IssueStandardTopicPriorityModelInterface (easytests.core.models.IssueStandardTopicPriorityModelInterface)9 SubjectModelInterface (easytests.core.models.SubjectModelInterface)7 IssueStandardQuestionTypeOptionsServiceInterface (easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface)7 IssueStandardTopicPrioritiesServiceInterface (easytests.core.services.IssueStandardTopicPrioritiesServiceInterface)7 ArrayList (java.util.ArrayList)6 InOrder (org.mockito.InOrder)6 SubjectModelEmpty (easytests.core.models.empty.SubjectModelEmpty)5 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)5 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)4 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)4 IssueStandardsOptions (easytests.core.options.IssueStandardsOptions)3 IssueStandardModel (easytests.core.models.IssueStandardModel)2 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 SubjectModel (easytests.core.models.SubjectModel)2 TopicModelInterface (easytests.core.models.TopicModelInterface)2