Search in sources :

Example 31 with QuestionModelInterface

use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.

the class QuestionsServiceTest method testDeleteIdentifiedModel.

@Test
public void testDeleteIdentifiedModel() throws Exception {
    final QuestionModelInterface questionModel = Models.createQuestionModel(1, "Text", 1, 1);
    this.questionsService.delete(questionModel);
    verify(this.questionsMapper, times(1)).delete(this.mapQuestionEntity(questionModel));
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface)

Example 32 with QuestionModelInterface

use of easytests.core.models.QuestionModelInterface 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 33 with QuestionModelInterface

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

Example 34 with QuestionModelInterface

use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.

the class QuestionsServiceTest method testSaveEntitiesList.

@Test
public void testSaveEntitiesList() throws Exception {
    final QuestionModelInterface questionModelFirst = Models.createQuestionModel(null, "Text1", 1, 1);
    final QuestionModelInterface questionModelSecond = Models.createQuestionModel(null, "Text2", 2, 1);
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    final List<QuestionModelInterface> questionsModels = new ArrayList<>();
    questionsModels.add(questionModelFirst);
    questionsModels.add(questionModelSecond);
    final QuestionsServiceInterface questionsServiceSpy = Mockito.spy(questionsService);
    questionsServiceSpy.save(questionsModels);
    verify(questionsServiceSpy, times(1)).save(questionModelFirst);
    verify(questionsServiceSpy, times(1)).save(questionModelSecond);
    questionsServiceSpy.save(questionsModels, questionsOptions);
    verify(questionsServiceSpy, times(1)).save(questionModelFirst, questionsOptions);
    verify(questionsServiceSpy, times(1)).save(questionModelSecond, questionsOptions);
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) ArrayList(java.util.ArrayList) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface)

Example 35 with QuestionModelInterface

use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.

the class QuestionsServiceTest method mapQuestionModel.

private QuestionModelInterface mapQuestionModel(QuestionEntity questionEntity) {
    final QuestionModelInterface questionModel = new QuestionModel();
    questionModel.map(questionEntity);
    return questionModel;
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) QuestionModel(easytests.core.models.QuestionModel)

Aggregations

QuestionModelInterface (easytests.core.models.QuestionModelInterface)40 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)15 TopicModelInterface (easytests.core.models.TopicModelInterface)14 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)10 QuestionsOptionsInterface (easytests.core.options.QuestionsOptionsInterface)9 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)9 QuestionEntity (easytests.core.entities.QuestionEntity)8 AnswerModelInterface (easytests.core.models.AnswerModelInterface)6 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)5 InOrder (org.mockito.InOrder)4 PointModelInterface (easytests.core.models.PointModelInterface)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)3 QuizModelInterface (easytests.core.models.QuizModelInterface)3 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)3 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)3 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)3 QuestionModel (easytests.core.models.QuestionModel)2 SolutionModelInterface (easytests.core.models.SolutionModelInterface)2