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);
}
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;
}
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);
}
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);
}
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++;
}
}
Aggregations