use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testFindBySubject.
@Test
public void testFindBySubject() throws Exception {
final Integer subjectId = 3;
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
final List<TopicEntity> topicsEntities = this.getTopicsEntities();
final List<TopicModelInterface> topicsModels = getTopicsModels();
Mockito.when(subjectModel.getId()).thenReturn(subjectId);
given(this.topicsMapper.findBySubjectId(subjectId)).willReturn(topicsEntities);
final List<TopicModelInterface> foundedTopicsModels = this.topicsService.findBySubject(subjectModel);
verify(this.topicsMapper).findBySubjectId(subjectId);
Assert.assertEquals(topicsModels, foundedTopicsModels);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method testFindByUserWithOptions.
@Test
public void testFindByUserWithOptions() throws Exception {
final Integer subjectId = 3;
final SubjectModelInterface subjectModel = Mockito.mock(SubjectModelInterface.class);
final List<TopicEntity> topicsEntities = this.getTopicsEntities();
final List<TopicModelInterface> topicsModels = this.getTopicsModels();
given(subjectModel.getId()).willReturn(subjectId);
given(this.topicsMapper.findBySubjectId(subjectId)).willReturn(topicsEntities);
final TopicsOptionsInterface topicOptions = Mockito.mock(TopicsOptionsInterface.class);
given(topicOptions.withRelations(topicsModels)).willReturn(topicsModels);
final List<TopicModelInterface> foundedTopicsModels = this.topicsService.findBySubject(subjectModel, topicOptions);
verify(this.topicsMapper).findBySubjectId(subjectId);
verify(topicOptions).withRelations(topicsModels);
Assert.assertEquals(topicsModels, foundedTopicsModels);
}
use of easytests.core.models.TopicModelInterface in project easy-tests by malinink.
the class TopicsServiceTest method mapTopicModel.
private TopicModelInterface mapTopicModel(TopicEntity topicEntity) {
final TopicModelInterface topicModel = new TopicModel();
topicModel.map(topicEntity);
return topicModel;
}
use of easytests.core.models.TopicModelInterface 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.models.TopicModelInterface 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);
}
Aggregations