use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testFindPresentModel.
@Test
public void testFindPresentModel() throws Exception {
final Integer id = 1;
final SubjectEntity subjectEntity = this.createSubjectEntityMock(id, "test", "description", 1);
given(this.subjectsMapper.find(id)).willReturn(subjectEntity);
final SubjectModelInterface subjectModel = this.subjectsService.find(id);
Assert.assertEquals(this.mapSubjectModel(subjectEntity), subjectModel);
}
use of easytests.core.models.SubjectModelInterface 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.SubjectModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testWithRelationsSubjectOnList.
@Test
public void testWithRelationsSubjectOnList() throws Exception {
final TopicModelInterface topicModelFirst = Mockito.mock(TopicModelInterface.class);
final TopicModelInterface topicModelSecond = Mockito.mock(TopicModelInterface.class);
final List<TopicModelInterface> topicsModels = new ArrayList<>(2);
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
topicsOptions.setTopicsService(topicsService);
topicsOptions.setSubjectsService(subjectsService);
topicsOptions.withSubject(subjectsOptions);
topicsModels.add(topicModelFirst);
topicsModels.add(topicModelSecond);
final SubjectModelInterface subjectModelFirst = Mockito.mock(SubjectModelInterface.class);
final SubjectModelInterface subjectModelWithIdFirst = Mockito.mock(SubjectModelInterface.class);
final SubjectModelInterface subjectModelSecond = Mockito.mock(SubjectModelInterface.class);
final SubjectModelInterface subjectModelWithIdSecond = Mockito.mock(SubjectModelInterface.class);
given(topicModelFirst.getSubject()).willReturn(subjectModelWithIdFirst);
given(topicModelSecond.getSubject()).willReturn(subjectModelWithIdSecond);
given(topicModelFirst.getSubject().getId()).willReturn(1);
given(topicModelSecond.getSubject().getId()).willReturn(2);
given(subjectsService.find(topicModelFirst.getSubject().getId(), subjectsOptions)).willReturn(subjectModelFirst);
given(subjectsService.find(topicModelSecond.getSubject().getId(), subjectsOptions)).willReturn(subjectModelSecond);
final List<TopicModelInterface> topicsModelsWithRelations = topicsOptions.withRelations(topicsModels);
Assert.assertEquals(topicsModelsWithRelations, topicsModels);
subjectsService.find(1, subjectsOptions);
subjectsService.find(2, subjectsOptions);
verify(topicsModels.get(0)).setSubject(subjectModelFirst);
verify(topicsModels.get(1)).setSubject(subjectModelSecond);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testDeleteWithRelationsSubject.
@Test
public void testDeleteWithRelationsSubject() throws Exception {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final SubjectModelInterface subjectModelId = Mockito.mock(SubjectModelInterface.class);
given(topicModel.getSubject()).willReturn(subjectModelId);
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
topicsOptions.setSubjectsService(subjectsService);
topicsOptions.setTopicsService(topicsService);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
topicsOptions.withSubject(subjectsOptions);
final SubjectModelInterface subjectModel = new SubjectModel();
topicModel.setSubject(subjectModel);
final InOrder inOrder = Mockito.inOrder(topicsService, subjectsService);
topicsOptions.deleteWithRelations(topicModel);
inOrder.verify(topicsService).delete(topicModel);
inOrder.verify(subjectsService).save(topicModel.getSubject(), subjectsOptions);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testSaveDeleteWithRelationsSubject.
@Test
public void testSaveDeleteWithRelationsSubject() {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final SubjectModelInterface subjectModelId = Mockito.mock(SubjectModelInterface.class);
given(topicModel.getSubject()).willReturn(subjectModelId);
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
topicsOptions.setSubjectsService(subjectsService);
topicsOptions.setTopicsService(topicsService);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
topicsOptions.withSubject(subjectsOptions);
final SubjectModelInterface subjectModel = new SubjectModel();
topicModel.setSubject(subjectModel);
topicsOptions.saveWithRelations(topicModel);
verify(topicsService).save(topicModel);
topicsOptions.deleteWithRelations(topicModel);
verify(topicsService).delete(topicModel);
verify(subjectsService, times(2)).save(topicModel.getSubject(), subjectsOptions);
}
Aggregations