Search in sources :

Example 6 with IssueStandardModelInterface

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

the class IssueStandardOptionsTest method testSaveWithRelations.

@Test
public void testSaveWithRelations() throws Exception {
    final IssueStandardsOptionsInterface issueStandardsOptions = new IssueStandardsOptions();
    final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
    final IssueStandardTopicPrioritiesServiceInterface topicPrioritiesService = Mockito.mock(IssueStandardTopicPrioritiesServiceInterface.class);
    final IssueStandardTopicPrioritiesOptionsInterface topicPrioritiesOptions = Mockito.mock(IssueStandardTopicPrioritiesOptionsInterface.class);
    final IssueStandardQuestionTypeOptionsServiceInterface questionTypeOptionsService = Mockito.mock(IssueStandardQuestionTypeOptionsServiceInterface.class);
    final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = Mockito.mock(IssueStandardQuestionTypeOptionsOptionsInterface.class);
    final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
    final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
    final Integer subjectId = 3;
    final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
    Mockito.when(subjectModel.getId()).thenReturn(subjectId);
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getTopicPriorities()).thenReturn(new ArrayList<>());
    Mockito.when(issueStandardModel.getQuestionTypeOptions()).thenReturn(new ArrayList<>());
    Mockito.when(issueStandardModel.getSubject()).thenReturn(subjectModel);
    issueStandardsOptions.setIssueStandardsService(issueStandardsService);
    issueStandardsOptions.setTopicPrioritiesService(topicPrioritiesService);
    issueStandardsOptions.setQuestionTypeOptionsService(questionTypeOptionsService);
    issueStandardsOptions.setSubjectsService(subjectsService);
    issueStandardsOptions.withTopicPriorities(topicPrioritiesOptions).withQuestionTypeOptions(questionTypeOptionsOptions).withSubject(subjectsOptions);
    final InOrder inOrder = Mockito.inOrder(subjectsService, issueStandardsService, topicPrioritiesService, questionTypeOptionsService);
    issueStandardsOptions.saveWithRelations(issueStandardModel);
    inOrder.verify(subjectsService, times(1)).save(issueStandardModel.getSubject(), subjectsOptions);
    inOrder.verify(issueStandardsService, times(1)).save(issueStandardModel);
    inOrder.verify(topicPrioritiesService, times(1)).save(issueStandardModel.getTopicPriorities(), topicPrioritiesOptions);
    inOrder.verify(questionTypeOptionsService, times(1)).save(issueStandardModel.getQuestionTypeOptions(), questionTypeOptionsOptions);
}
Also used : IssueStandardsServiceInterface(easytests.core.services.IssueStandardsServiceInterface) InOrder(org.mockito.InOrder) SubjectsServiceInterface(easytests.core.services.SubjectsServiceInterface) IssueStandardTopicPrioritiesServiceInterface(easytests.core.services.IssueStandardTopicPrioritiesServiceInterface) SubjectModelInterface(easytests.core.models.SubjectModelInterface) IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardQuestionTypeOptionsServiceInterface(easytests.core.services.IssueStandardQuestionTypeOptionsServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with IssueStandardModelInterface

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

the class SubjectsServiceTest method createSubjectModel.

private SubjectModelInterface createSubjectModel(Integer id, String name, String description, Integer userId, Integer issueStandardId) {
    final SubjectModelInterface subjectModel = new SubjectModel();
    subjectModel.setId(id);
    subjectModel.setName(name);
    subjectModel.setDescription(description);
    final UserModelInterface userModel = Mockito.mock(UserModelInterface.class);
    Mockito.when(userModel.getId()).thenReturn(userId);
    final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
    Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
    subjectModel.setUser(userModel);
    subjectModel.setIssueStandard(issueStandardModel);
    return subjectModel;
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) UserModelInterface(easytests.core.models.UserModelInterface) SubjectModel(easytests.core.models.SubjectModel) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 8 with IssueStandardModelInterface

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

the class IssueStandardQuestionTypeOptionsServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final Integer issueStandardId = 1;
    final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = Models.createQuestionTypeOptionModel(id, 1, 1, null, null, issueStandardId);
    final IssueStandardModelInterface issueStandardModel = Models.createIssueStandardModel(issueStandardId, 300, 30, 1);
    questionTypeOptionModel.setIssueStandard(issueStandardModel);
    final IssueStandardQuestionTypeOptionModelInterface foundedQuestionTypeOptionModel = this.questionTypeOptionsService.find(id, new IssueStandardQuestionTypeOptionsOptions().withIssueStandard(new IssueStandardsOptions()));
    Assert.assertEquals(questionTypeOptionModel, foundedQuestionTypeOptionModel);
    Assert.assertEquals(issueStandardModel, foundedQuestionTypeOptionModel.getIssueStandard());
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) IssueStandardQuestionTypeOptionsOptions(easytests.core.options.IssueStandardQuestionTypeOptionsOptions) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) IssueStandardsOptions(easytests.core.options.IssueStandardsOptions) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with IssueStandardModelInterface

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

the class IssueStandardsServiceTest method testFindAbsentModel.

@Test
public void testFindAbsentModel() throws Exception {
    final Integer id = 10;
    final IssueStandardModelInterface foundedIssueStandardModel = this.issueStandardsService.find(id);
    Assert.assertNull(foundedIssueStandardModel);
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with IssueStandardModelInterface

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

the class IssueStandardsServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final Integer id = 1;
    final IssueStandardModelInterface issueStandardModel = Models.createIssueStandardModel(id, 300, 30, 1);
    final IssueStandardModelInterface foundedIssueStandardModel = this.issueStandardsService.find(id);
    Assert.assertEquals(issueStandardModel, foundedIssueStandardModel);
}
Also used : IssueStandardModelInterface(easytests.core.models.IssueStandardModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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