Search in sources :

Example 1 with TopicEntity

use of easytests.core.entities.TopicEntity 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);
}
Also used : 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)

Example 2 with TopicEntity

use of easytests.core.entities.TopicEntity in project easy-tests by malinink.

the class TopicsServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final ArgumentCaptor<TopicModelInterface> topicModelCaptor = ArgumentCaptor.forClass(TopicModelInterface.class);
    final TopicEntity topicEntity = this.topicsSupport.getEntityFixtureMock(0);
    final TopicModelInterface topicModel = this.topicsSupport.getModelFixtureMock(0);
    final TopicsOptionsInterface topicOptions = mock(TopicsOptionsInterface.class);
    when(this.topicsMapper.find(topicModel.getId())).thenReturn(topicEntity);
    when(topicOptions.withRelations(topicModelCaptor.capture())).thenReturn(topicModel);
    final TopicModelInterface topicFoundedModel = this.topicsService.find(topicModel.getId(), topicOptions);
    this.topicsSupport.assertEquals(topicModel, topicModelCaptor.getValue());
    Assert.assertSame(topicModel, topicFoundedModel);
    this.assertServicesSet(topicOptions);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicEntity(easytests.core.entities.TopicEntity) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with TopicEntity

use of easytests.core.entities.TopicEntity in project easy-tests by malinink.

the class TopicsServiceTest method testFindBySubjectWithOptions.

@Test
public void testFindBySubjectWithOptions() throws Exception {
    final ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
    final List<TopicEntity> topicsEntities = this.getTopicsFixturesEntities();
    final List<TopicModelInterface> topicsModels = this.getTopicsFixturesModels();
    final TopicsOptionsInterface topicOptions = mock(TopicsOptionsInterface.class);
    final SubjectModelInterface subjectModel = this.subjectsSupport.getModelFixtureMock(0);
    when(this.topicsMapper.findBySubjectId(subjectModel.getId())).thenReturn(topicsEntities);
    when(topicOptions.withRelations(listCaptor.capture())).thenReturn(topicsModels);
    final List<TopicModelInterface> topicsFoundedModels = this.topicsService.findBySubject(subjectModel, topicOptions);
    this.topicsSupport.assertModelsListEquals(topicsModels, listCaptor.getValue());
    Assert.assertSame(topicsModels, topicsFoundedModels);
    this.assertServicesSet(topicOptions);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicEntity(easytests.core.entities.TopicEntity) ArrayList(java.util.ArrayList) List(java.util.List) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with TopicEntity

use of easytests.core.entities.TopicEntity in project easy-tests by malinink.

the class TopicsServiceTest method testSaveUpdatesEntityIdOnCreation.

@Test
public void testSaveUpdatesEntityIdOnCreation() throws Exception {
    final TopicModelInterface topicAdditionalModel = this.topicsSupport.getModelAdditionalMock(0);
    final Integer updatedId = 10;
    doAnswer(invocation -> {
        final TopicEntity topicEntity = invocation.getArgument(0);
        topicEntity.setId(updatedId);
        return null;
    }).when(this.topicsMapper).insert(any(TopicEntity.class));
    this.topicsService.save(topicAdditionalModel);
    verify(topicAdditionalModel, times(1)).setId(updatedId);
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with TopicEntity

use of easytests.core.entities.TopicEntity in project easy-tests by malinink.

the class TopicModelTest method testMap.

@Test
public void testMap() throws Exception {
    final TopicEntity topicEntity = this.topicsSupport.getEntityFixtureMock(0);
    final TopicModel topicModel = new TopicModel();
    topicModel.map(topicEntity);
    this.topicsSupport.assertEquals(topicEntity, topicModel);
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) Test(org.junit.Test)

Aggregations

TopicEntity (easytests.core.entities.TopicEntity)21 Test (org.junit.Test)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 TopicModelInterface (easytests.core.models.TopicModelInterface)8 SubjectModelInterface (easytests.core.models.SubjectModelInterface)4 TopicsOptionsInterface (easytests.core.options.TopicsOptionsInterface)4 ArrayList (java.util.ArrayList)4 List (java.util.List)2 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1