Search in sources :

Example 6 with TopicsOptionsInterface

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);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with TopicsOptionsInterface

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;
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicModelInterface(easytests.core.models.TopicModelInterface)

Example 8 with TopicsOptionsInterface

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);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicEntity(easytests.core.entities.TopicEntity) ArrayList(java.util.ArrayList) List(java.util.List) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with TopicsOptionsInterface

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);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicEntity(easytests.core.entities.TopicEntity) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

TopicModelInterface (easytests.core.models.TopicModelInterface)9 TopicsOptionsInterface (easytests.core.options.TopicsOptionsInterface)9 Test (org.junit.Test)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 TopicEntity (easytests.core.entities.TopicEntity)4 SubjectModelInterface (easytests.core.models.SubjectModelInterface)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2