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