use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsOptionsTest method testWithRelationsSubjectOnSingleModel.
@Test
public void testWithRelationsSubjectOnSingleModel() throws Exception {
final TopicsOptionsInterface topicsOptions = new TopicsOptions();
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
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 = Mockito.mock(SubjectModelInterface.class);
final SubjectModelInterface subjectModelWithId = Mockito.mock(SubjectModelInterface.class);
given(topicModel.getSubject()).willReturn(subjectModelWithId);
given(subjectsService.find(topicModel.getSubject().getId(), subjectsOptions)).willReturn(subjectModel);
final TopicModelInterface topicModelWithRelations = topicsOptions.withRelations(topicModel);
Assert.assertEquals(topicModel, topicModelWithRelations);
subjectsService.find(1, subjectsOptions);
verify(topicModel).setSubject(subjectModel);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testSaveModelsListWithOptions.
@Test
public void testSaveModelsListWithOptions() throws Exception {
final ArgumentCaptor<SubjectModelInterface> subjectModelCaptor = ArgumentCaptor.forClass(SubjectModelInterface.class);
final List<SubjectModelInterface> subjectsModels = this.getSubjectsFixturesModels();
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
this.subjectsService.save(subjectsModels, subjectsOptions);
this.assertServicesSet(subjectsOptions, subjectsModels.size());
verify(subjectsOptions, times(subjectsModels.size())).saveWithRelations(subjectModelCaptor.capture());
this.subjectsSupport.assertModelsListEquals(subjectsModels, subjectModelCaptor.getAllValues());
verifyNoMoreInteractions(this.subjectsMapper);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testDeleteModelsListWithOptions.
@Test
public void testDeleteModelsListWithOptions() throws Exception {
final ArgumentCaptor<SubjectModelInterface> subjectModelCaptor = ArgumentCaptor.forClass(SubjectModelInterface.class);
final List<SubjectModelInterface> subjectsModels = this.getSubjectsFixturesModels();
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
this.subjectsService.delete(subjectsModels, subjectsOptions);
this.assertServicesSet(subjectsOptions, subjectsModels.size());
verify(subjectsOptions, times(subjectsModels.size())).deleteWithRelations(subjectModelCaptor.capture());
this.subjectsSupport.assertModelsListEquals(subjectsModels, subjectModelCaptor.getAllValues());
verifyNoMoreInteractions(this.subjectsMapper);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class SubjectsServiceTest method testFindByUserPresentList.
@Test
public void testFindByUserPresentList() throws Exception {
final UserModelInterface userModel = this.usersSupport.getModelFixtureMock(0);
final List<SubjectEntity> subjectsEntities = this.getSubjectsFixturesEntities();
when(this.subjectsMapper.findByUserId(userModel.getId())).thenReturn(subjectsEntities);
final List<SubjectModelInterface> subjectsFoundedModels = this.subjectsService.findByUser(userModel);
this.subjectsSupport.assertModelsListEquals(this.getSubjectsFixturesModels(), subjectsFoundedModels);
}
use of easytests.core.models.SubjectModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testFindBySubjectPresentList.
@Test
public void testFindBySubjectPresentList() throws Exception {
final SubjectModelInterface subjectModel = this.subjectsSupport.getModelFixtureMock(0);
final List<TopicEntity> topicsEntities = this.getTopicsFixturesEntities();
when(this.topicsMapper.findBySubjectId(subjectModel.getId())).thenReturn(topicsEntities);
final List<TopicModelInterface> topicsFoundedModels = this.topicsService.findBySubject(subjectModel);
this.topicsSupport.assertModelsListEquals(this.getTopicsFixturesModels(), topicsFoundedModels);
}
Aggregations