Search in sources :

Example 11 with TopicEntity

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

the class TopicsService method save.

@Override
public void save(TopicModelInterface topicModel) {
    final TopicEntity topicEntity = this.map(topicModel);
    if (topicEntity.getId() == null) {
        this.topicsMapper.insert(topicEntity);
        topicModel.setId(topicEntity.getId());
        return;
    }
    this.topicsMapper.update(topicEntity);
}
Also used : TopicEntity(easytests.core.entities.TopicEntity)

Example 12 with TopicEntity

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

the class TopicsService method map.

private TopicEntity map(TopicModelInterface topicModel) {
    final TopicEntity topicEntity = new TopicEntity();
    topicEntity.map(topicModel);
    return topicEntity;
}
Also used : TopicEntity(easytests.core.entities.TopicEntity)

Example 13 with TopicEntity

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

the class TopicsServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final TopicEntity topicExistentEntity = this.topicsSupport.getEntityFixtureMock(0);
    when(this.topicsMapper.find(topicExistentEntity.getId())).thenReturn(topicExistentEntity);
    final TopicModelInterface topicFoundedModel = this.topicsService.find(topicExistentEntity.getId());
    this.topicsSupport.assertEquals(this.topicsSupport.getModelFixtureMock(0), topicFoundedModel);
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with TopicEntity

use of easytests.core.entities.TopicEntity 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 15 with TopicEntity

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

the class TopicsSupport method assertEntitiesListEquals.

public void assertEntitiesListEquals(List<TopicEntity> expected, List<TopicEntity> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Integer i = 0;
    for (TopicEntity topicEntity : expected) {
        this.assertEquals(topicEntity, actual.get(i));
        i++;
    }
}
Also used : TopicEntity(easytests.core.entities.TopicEntity)

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