use of easytests.core.options.TopicsOptionsInterface in project easy-tests by malinink.
the class TopicsServiceTest method testSaveWithOptions.
@Test
public void testSaveWithOptions() throws Exception {
final TopicModelInterface topicModel = this.topicsSupport.getModelFixtureMock(0);
final TopicsOptionsInterface topicOptions = mock(TopicsOptionsInterface.class);
this.topicsService.save(topicModel, topicOptions);
verify(topicOptions, times(1)).saveWithRelations(topicModel);
this.assertServicesSet(topicOptions);
verifyNoMoreInteractions(this.topicsMapper);
}
use of easytests.core.options.TopicsOptionsInterface in project easy-tests by malinink.
the class TopicsController method getTopicModel.
private TopicModelInterface getTopicModel(Integer id, Integer subjectId) {
final TopicsOptionsInterface topicsOptionsBuilder = this.topicsOptionsBuilder.forAuth();
final TopicModelInterface topicModel = this.topicsService.find(id, topicsOptionsBuilder);
checkModel(topicModel, subjectId);
return topicModel;
}
use of easytests.core.options.TopicsOptionsInterface in project easy-tests by malinink.
the class TopicsServiceTest method testFindAllWithOptions.
@Test
public void testFindAllWithOptions() throws Exception {
final ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
final List<TopicEntity> topicsEntities = this.getTopicsFixturesEntities();
final List<TopicModelInterface> topicsModels = this.getTopicsFixturesModels();
final TopicsOptionsInterface topicsOptions = mock(TopicsOptionsInterface.class);
when(this.topicsMapper.findAll()).thenReturn(topicsEntities);
when(topicsOptions.withRelations(listCaptor.capture())).thenReturn(topicsModels);
final List<TopicModelInterface> topicsFoundedModels = this.topicsService.findAll(topicsOptions);
this.topicsSupport.assertModelsListEquals(topicsModels, listCaptor.getValue());
Assert.assertSame(topicsModels, topicsFoundedModels);
this.assertServicesSet(topicsOptions);
}
use of easytests.core.options.TopicsOptionsInterface in project easy-tests by malinink.
the class TopicsServiceTest method testFindByUserWithOptions.
@Test
public void testFindByUserWithOptions() throws Exception {
final Integer subjectId = 3;
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
final List<TopicEntity> topicsEntities = this.getTopicsEntities();
final List<TopicModelInterface> topicsModels = this.getTopicsModels();
given(subjectModel.getId()).willReturn(subjectId);
given(this.topicsMapper.findBySubjectId(subjectId)).willReturn(topicsEntities);
final TopicsOptionsInterface topicOptions = Mockito.mock(TopicsOptionsInterface.class);
given(topicOptions.withRelations(topicsModels)).willReturn(topicsModels);
final List<TopicModelInterface> foundedTopicsModels = this.topicsService.findBySubject(subjectModel, topicOptions);
verify(this.topicsMapper).findBySubjectId(subjectId);
verify(topicOptions).withRelations(topicsModels);
Assert.assertEquals(topicsModels, foundedTopicsModels);
}
Aggregations