Search in sources :

Example 46 with TopicModelInterface

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);
}
Also used : TopicEntity(easytests.core.entities.TopicEntity) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 47 with TopicModelInterface

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);
}
Also used : TopicsOptionsInterface(easytests.core.options.TopicsOptionsInterface) TopicEntity(easytests.core.entities.TopicEntity) SubjectModelInterface(easytests.core.models.SubjectModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 48 with TopicModelInterface

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;
}
Also used : TopicModel(easytests.core.models.TopicModel) TopicModelInterface(easytests.core.models.TopicModelInterface)

Example 49 with TopicModelInterface

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);
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) QuestionModelInterface(easytests.core.models.QuestionModelInterface) ArrayList(java.util.ArrayList) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface) TopicModelInterface(easytests.core.models.TopicModelInterface)

Example 50 with TopicModelInterface

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);
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) QuestionModelInterface(easytests.core.models.QuestionModelInterface) ArrayList(java.util.ArrayList) TopicModelInterface(easytests.core.models.TopicModelInterface)

Aggregations

TopicModelInterface (easytests.core.models.TopicModelInterface)52 Test (org.junit.Test)34 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)32 SubjectModelInterface (easytests.core.models.SubjectModelInterface)18 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)16 ArrayList (java.util.ArrayList)15 QuestionModelInterface (easytests.core.models.QuestionModelInterface)14 TopicsOptionsInterface (easytests.core.options.TopicsOptionsInterface)9 TopicEntity (easytests.core.entities.TopicEntity)8 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)7 InOrder (org.mockito.InOrder)6 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)5 AnswerModelInterface (easytests.core.models.AnswerModelInterface)4 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)4 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 QuestionEntity (easytests.core.entities.QuestionEntity)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)3 SubjectModel (easytests.core.models.SubjectModel)3 TopicModel (easytests.core.models.TopicModel)3