use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsServiceTest method testFindByTopicWithOptions.
@Test
public void testFindByTopicWithOptions() throws Exception {
final Integer topicId = 7;
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final QuestionEntity questionEntityFirst = Entities.createQuestionEntityMock(3, "test3", 1, topicId);
final QuestionEntity questionEntitySecond = Entities.createQuestionEntityMock(12, "test12", 1, topicId);
final List<QuestionEntity> questionsEntities = new ArrayList<>();
questionsEntities.add(questionEntityFirst);
questionsEntities.add(questionEntitySecond);
given(topicModel.getId()).willReturn(topicId);
given(this.questionsMapper.findByTopicId(topicId)).willReturn(questionsEntities);
final List<QuestionModelInterface> questionsModels = new ArrayList<>();
questionsModels.add(this.mapQuestionModel(questionEntityFirst));
questionsModels.add(this.mapQuestionModel(questionEntitySecond));
final QuestionsOptionsInterface questionOptions = Mockito.mock(QuestionsOptionsInterface.class);
given(questionOptions.withRelations(questionsModels)).willReturn(questionsModels);
final List<QuestionModelInterface> foundedQuestionsModels = this.questionsService.findByTopic(topicModel, questionOptions);
verify(this.questionsMapper).findByTopicId(topicId);
verify(questionOptions).withRelations(questionsModels);
Assert.assertEquals(questionsModels, foundedQuestionsModels);
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsServiceTest method testFindAllWithOptions.
@Test
public void testFindAllWithOptions() throws Exception {
final List<QuestionEntity> questionsEntities = this.getQuestionsEntities();
final List<QuestionModelInterface> questionsModels = this.getQuestionsModels();
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
given(this.questionsMapper.findAll()).willReturn(questionsEntities);
given(questionsOptions.withRelations(Mockito.anyList())).willReturn(questionsModels);
final List<QuestionModelInterface> foundedQuestionsModels = this.questionsService.findAll(questionsOptions);
verify(questionsOptions).withRelations(questionsModels);
Assert.assertEquals(questionsModels, foundedQuestionsModels);
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsServiceTest method testFindByTopic.
@Test
public void testFindByTopic() throws Exception {
final Integer topicId = 7;
final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
final QuestionEntity questionEntityFirst = Entities.createQuestionEntityMock(3, "test3", 1, topicId);
final QuestionEntity questionEntitySecond = Entities.createQuestionEntityMock(12, "test12", 1, topicId);
final List<QuestionEntity> questionsEntities = new ArrayList<>();
questionsEntities.add(questionEntityFirst);
questionsEntities.add(questionEntitySecond);
Mockito.when(topicModel.getId()).thenReturn(topicId);
given(this.questionsMapper.findByTopicId(topicId)).willReturn(questionsEntities);
final List<QuestionModelInterface> questionsModels = new ArrayList<>();
questionsModels.add(this.mapQuestionModel(questionEntityFirst));
questionsModels.add(this.mapQuestionModel(questionEntitySecond));
final List<QuestionModelInterface> foundedQuestionsModels = this.questionsService.findByTopic(topicModel);
verify(this.questionsMapper).findByTopicId(topicId);
Assert.assertEquals(questionsModels, foundedQuestionsModels);
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsMapperTest method testFind.
@Test
public void testFind() throws Exception {
final QuestionEntity question = this.questionsMapper.find(1);
Assert.assertEquals((long) 1, (long) question.getId());
Assert.assertEquals("test1", question.getText());
Assert.assertEquals((long) 1, (long) question.getQuestionTypeId());
Assert.assertEquals((long) 1, (long) question.getTopicId());
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsMapperTest method testFindByTopicId.
@Test
public void testFindByTopicId() throws Exception {
final List<QuestionEntity> questions = this.questionsMapper.findByTopicId(2);
Assert.assertEquals((Integer) 1, (Integer) questions.size());
final QuestionEntity question = questions.get(0);
Assert.assertEquals((Integer) 3, question.getId());
Assert.assertEquals("test3", question.getText());
Assert.assertEquals((Integer) 3, question.getQuestionTypeId());
Assert.assertEquals((Integer) 2, question.getTopicId());
}
Aggregations