Search in sources :

Example 1 with QuestionModelInterface

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

the class TopicsOptionsTest method testWithRelationsQuestionsOnSingleModel.

@Test
public void testWithRelationsQuestionsOnSingleModel() throws Exception {
    final TopicsOptionsInterface topicsOptions = new TopicsOptions();
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    topicsOptions.setQuestionsService(questionsService);
    topicsOptions.setTopicsService(topicsService);
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    topicsOptions.withQuestions(questionsOptions);
    final List<QuestionModelInterface> questionsModels = new ArrayList<>();
    questionsModels.add(Mockito.mock(QuestionModelInterface.class));
    given(questionsService.findByTopic(topicModel, questionsOptions)).willReturn(questionsModels);
    final TopicModelInterface topicModelWithRelations = topicsOptions.withRelations(topicModel);
    Assert.assertEquals(topicModel, topicModelWithRelations);
    verify(questionsService).findByTopic(topicModel, questionsOptions);
    verify(topicModel).setQuestions(questionsModels);
}
Also used : QuestionsServiceInterface(easytests.core.services.QuestionsServiceInterface) QuestionModelInterface(easytests.core.models.QuestionModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) ArrayList(java.util.ArrayList) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with QuestionModelInterface

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

the class TopicsOptionsTest method testDeleteWithRelationsQuestion.

@Test
public void testDeleteWithRelationsQuestion() throws Exception {
    final TopicsOptionsInterface topicsOptions = new TopicsOptions();
    final TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    topicsOptions.setQuestionsService(questionsService);
    topicsOptions.setTopicsService(topicsService);
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    topicsOptions.withQuestions(questionsOptions);
    final List<QuestionModelInterface> questionsModels = new ArrayList<>();
    topicModel.setQuestions(questionsModels);
    final InOrder inOrder = Mockito.inOrder(questionsService, topicsService);
    topicsOptions.deleteWithRelations(topicModel);
    inOrder.verify(questionsService).save(topicModel.getQuestions(), questionsOptions);
    inOrder.verify(topicsService).delete(topicModel);
}
Also used : InOrder(org.mockito.InOrder) QuestionsServiceInterface(easytests.core.services.QuestionsServiceInterface) QuestionModelInterface(easytests.core.models.QuestionModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) ArrayList(java.util.ArrayList) TopicModelInterface(easytests.core.models.TopicModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with QuestionModelInterface

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

the class QuestionsServiceTest method testDeleteModelsListWithOptions.

@Test
public void testDeleteModelsListWithOptions() throws Exception {
    final ArgumentCaptor<QuestionModelInterface> questionModelCaptor = ArgumentCaptor.forClass(QuestionModelInterface.class);
    final List<QuestionModelInterface> questionsModels = this.getQuestionsFixturesModels();
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    this.questionsService.delete(questionsModels, questionsOptions);
    this.assertServicesSet(questionsOptions, questionsModels.size());
    verify(questionsOptions, times(questionsModels.size())).deleteWithRelations(questionModelCaptor.capture());
    this.questionsSupport.assertModelsListEquals(questionsModels, questionModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.questionsMapper);
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface)

Example 4 with QuestionModelInterface

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

the class QuestionsServiceTest method testSaveModelsListWithOptions.

@Test
public void testSaveModelsListWithOptions() throws Exception {
    final ArgumentCaptor<QuestionModelInterface> questionsModelCaptor = ArgumentCaptor.forClass(QuestionModelInterface.class);
    final List<QuestionModelInterface> questionsModels = this.getQuestionsFixturesModels();
    final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
    this.questionsService.save(questionsModels, questionsOptions);
    this.assertServicesSet(questionsOptions, questionsModels.size());
    verify(questionsOptions, times(questionsModels.size())).saveWithRelations(questionsModelCaptor.capture());
    this.questionsSupport.assertModelsListEquals(questionsModels, questionsModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.questionsMapper);
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface)

Example 5 with QuestionModelInterface

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

the class QuestionsSupport method assertModelsListEquals.

public void assertModelsListEquals(List<QuestionModelInterface> expected, List<QuestionModelInterface> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Integer i = 0;
    for (QuestionModelInterface questionModel : expected) {
        this.assertEquals(questionModel, actual.get(i));
        i++;
    }
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface)

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