use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testDeleteUnidentifiedModel.
@Test
public void testDeleteUnidentifiedModel() throws Exception {
final QuestionModelInterface questionModel = Models.createQuestionModel(null, "Text", 1, 1);
exception.expect(DeleteUnidentifiedModelException.class);
this.questionsService.delete(questionModel);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testFindPresentModel.
@Test
public void testFindPresentModel() throws Exception {
final Integer id = 1;
final QuestionEntity questionEntity = Entities.createQuestionEntityMock(id, "NewText", 1, 1);
given(this.questionsMapper.find(id)).willReturn(questionEntity);
final QuestionModelInterface questionModel = this.questionsService.find(id);
Assert.assertEquals(this.mapQuestionModel(questionEntity), questionModel);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class PointsOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
final PointsOptionsInterface pointsOptions = new PointsOptions();
pointModel.setId(1);
given(pointModel.getQuiz()).willReturn(new QuizModelEmpty(1));
given(pointModel.getQuestion()).willReturn(new QuestionModelEmpty(1));
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
final SolutionsServiceInterface solutionsService = Mockito.mock(SolutionsServiceInterface.class);
pointsOptions.setQuizzesService(quizzesService);
pointsOptions.setQuestionsService(questionsService);
pointsOptions.setSolutionsService(solutionsService);
final QuizzesOptionsInterface quizOptions = Mockito.mock(QuizzesOptionsInterface.class);
final QuestionsOptionsInterface questionOptions = Mockito.mock(QuestionsOptionsInterface.class);
final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
pointsOptions.withQuiz(quizOptions);
pointsOptions.withQuestion(questionOptions);
pointsOptions.withSolutions(solutionsOptions);
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
final List<SolutionModelInterface> solutionsModels = new ArrayList<>();
solutionsModels.add(Mockito.mock(SolutionModelInterface.class));
given(quizzesService.find(pointModel.getQuiz().getId(), quizOptions)).willReturn(quizModel);
given(questionsService.find(pointModel.getQuestion().getId(), questionOptions)).willReturn(questionModel);
given(solutionsService.findByPoint(pointModel, solutionsOptions)).willReturn(solutionsModels);
final PointModelInterface pointModelWithRelations = pointsOptions.withRelations(pointModel);
Assert.assertEquals(pointModel, pointModelWithRelations);
verify(quizzesService).find(1, quizOptions);
verify(questionsService).find(1, questionOptions);
verify(solutionsService).findByPoint(pointModel, solutionsOptions);
verify(pointModel).setQuiz(quizModel);
verify(pointModel).setQuestion(questionModel);
verify(pointModel).setSolutions(solutionsModels);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
questionModel.setId(1);
given(questionModel.getTopic()).willReturn(new TopicModelEmpty(1));
given(questionModel.getQuestionType()).willReturn(new QuestionTypeModelEmpty(1));
final QuestionsOptionsInterface questionsOptions = new QuestionsOptions();
final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
final QuestionTypesServiceInterface questionTypesService = Mockito.mock(QuestionTypesServiceInterface.class);
final QuestionTypesOptionsInterface questionTypesOptions = Mockito.mock(QuestionTypesOptionsInterface.class);
questionsOptions.setAnswersService(answersService);
questionsOptions.withAnswers(answersOptions);
questionsOptions.setTopicsService(topicsService);
questionsOptions.withTopic(topicsOptions);
questionsOptions.setQuestionTypesService(questionTypesService);
questionsOptions.withQuestionType(questionTypesOptions);
final List<AnswerModelInterface> answersModels = new ArrayList<>();
answersModels.add(Mockito.mock(AnswerModelInterface.class));
TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
QuestionTypeModelInterface questionTypeModel = Mockito.mock(QuestionTypeModelInterface.class);
given(answersService.findByQuestion(questionModel, answersOptions)).willReturn(answersModels);
given(topicsService.find(questionModel.getTopic().getId(), topicsOptions)).willReturn(topicModel);
given(questionTypesService.find(questionModel.getQuestionType().getId(), questionTypesOptions)).willReturn(questionTypeModel);
final QuestionModelInterface questionModelWithRelations = questionsOptions.withRelations(questionModel);
Assert.assertEquals(questionModel, questionModelWithRelations);
verify(answersService).findByQuestion(questionModel, answersOptions);
verify(topicsService).find(questionModel.getTopic().getId(), topicsOptions);
verify(questionTypesService).find(questionModel.getQuestionType().getId(), questionTypesOptions);
verify(questionModel).setAnswers(answersModels);
verify(questionModel).setTopic(topicModel);
verify(questionModel).setQuestionType(questionTypeModel);
verify(questionModel).setAnswers(Mockito.anyList());
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsOptionsTest method testDeleteWithRelations.
@Test
public void testDeleteWithRelations() throws Exception {
final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
final QuestionsOptionsInterface questionsOptions = new QuestionsOptions();
final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
questionsOptions.setQuestionsService(questionsService);
questionsOptions.setAnswersService(answersService);
questionsOptions.withAnswers(answersOptions);
questionsOptions.setTopicsService(topicsService);
questionsOptions.withTopic(topicsOptions);
final List<AnswerModelInterface> answersModels = new ArrayList<>();
answersModels.add(Mockito.mock(AnswerModelInterface.class));
TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
given(questionModel.getAnswers()).willReturn(answersModels);
given(questionModel.getTopic()).willReturn(topicModel);
final InOrder inOrder = Mockito.inOrder(answersService, questionsService, topicsService);
questionsOptions.deleteWithRelations(questionModel);
inOrder.verify(answersService).delete(answersModels, answersOptions);
inOrder.verify(questionsService).delete(questionModel);
inOrder.verify(topicsService).delete(topicModel, topicsOptions);
}
Aggregations