use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsServiceTest method testFindByTopicPresentList.
@Test
public void testFindByTopicPresentList() throws Exception {
final TopicModelInterface topicModel = this.topicsSupport.getModelFixtureMock(0);
final List<QuestionEntity> questionEntities = this.getQuestionsFixturesEntities();
when(this.questionsMapper.findByTopicId(topicModel.getId())).thenReturn(questionEntities);
final List<QuestionModelInterface> questionsFoundedModels = this.questionsService.findByTopic(topicModel);
this.questionsSupport.assertModelsListEquals(this.getQuestionsFixturesModels(), questionsFoundedModels);
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsMapperTest method testFindAll.
@Test
public void testFindAll() throws Exception {
final List<QuestionEntity> questionsFoundedEntities = this.questionsMapper.findAll();
Assert.assertEquals(3, questionsFoundedEntities.size());
Integer index = 0;
for (QuestionEntity questionEntity : questionsFoundedEntities) {
final QuestionEntity questionFixtureEntity = this.questionsSupport.getEntityFixtureMock(index);
this.questionsSupport.assertEquals(questionFixtureEntity, questionEntity);
index++;
}
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsService method save.
@Override
public void save(QuestionModelInterface questionModel) {
final QuestionEntity questionEntity = this.map(questionModel);
if (questionEntity.getId() == null) {
this.questionsMapper.insert(questionEntity);
questionModel.setId(questionEntity.getId());
return;
}
this.questionsMapper.update(questionEntity);
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsService method delete.
@Override
public void delete(QuestionModelInterface questionModel) {
final QuestionEntity questionEntity = this.map(questionModel);
if (questionEntity.getId() == null) {
throw new DeleteUnidentifiedModelException();
}
this.questionsMapper.delete(questionEntity);
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsServiceTest method testFindWithOptions.
@Test
public void testFindWithOptions() throws Exception {
final Integer id = 1;
final QuestionEntity questionEntity = Entities.createQuestionEntityMock(id, "NewText", 1, 1);
final QuestionModelInterface questionModel = this.mapQuestionModel(questionEntity);
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
given(this.questionsMapper.find(id)).willReturn(questionEntity);
given(questionsOptions.withRelations(questionModel)).willReturn(questionModel);
final QuestionModelInterface foundedQuestionModel = this.questionsService.find(id, questionsOptions);
Assert.assertEquals(questionModel, foundedQuestionModel);
verify(questionsOptions).withRelations(questionModel);
}
Aggregations