use of easytests.core.models.empty.QuizModelEmpty 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.empty.QuizModelEmpty in project easy-tests by malinink.
the class TesteesOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
final TesteesOptionsInterface testeesOptions = new TesteesOptions();
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
final Integer quizId = 3;
Mockito.when(testeeModel.getQuiz()).thenReturn(new QuizModelEmpty(quizId));
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
Mockito.when(quizModel.getId()).thenReturn(quizId);
given(quizzesService.find(quizId, quizzesOptions)).willReturn(quizModel);
final TesteeModelInterface testeeModelWithoutRelations = testeesOptions.withRelations(testeeModel);
verify(quizzesService, times(0)).find(quizId, quizzesOptions);
Assert.assertEquals(testeeModel, testeeModelWithoutRelations);
verify(testeeModel, times(0)).setQuiz(quizModel);
testeesOptions.setQuizzesService(quizzesService);
testeesOptions.withQuiz(quizzesOptions);
final TesteeModelInterface testeeModelWithRelations = testeesOptions.withRelations(testeeModel);
verify(quizzesService, times(1)).find(quizId, quizzesOptions);
Assert.assertEquals(testeeModel, testeeModelWithRelations);
verify(testeeModel, times(1)).setQuiz(quizModel);
}
use of easytests.core.models.empty.QuizModelEmpty in project easy-tests by malinink.
the class PointModelTest method testMap.
@Test
public void testMap() throws Exception {
final Integer pointId = 3;
final Integer questionId = 2;
final Integer quizId = 2;
final PointEntity pointEntity = Mockito.mock(PointEntity.class);
Mockito.when(pointEntity.getId()).thenReturn(pointId);
Mockito.when(pointEntity.getQuestionId()).thenReturn(questionId);
Mockito.when(pointEntity.getQuizId()).thenReturn(quizId);
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
Mockito.when(quizModel.getId()).thenReturn(quizId);
final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
Mockito.when(questionModel.getId()).thenReturn(questionId);
final PointModel pointModel = new PointModel();
pointModel.map(pointEntity);
Assert.assertEquals(pointId, pointModel.getId());
Assert.assertEquals(new QuestionModelEmpty(questionId), pointModel.getQuestion());
Assert.assertEquals(new QuizModelEmpty(quizId), pointModel.getQuiz());
}
use of easytests.core.models.empty.QuizModelEmpty in project easy-tests by malinink.
the class TesteesSupport method assertEquals.
public void assertEquals(TesteeEntity expected, TesteeModelInterface actual) {
assertEquals(actual, expected);
Assert.assertEquals(new QuizModelEmpty(expected.getQuizId()), actual.getQuiz());
}
use of easytests.core.models.empty.QuizModelEmpty in project easy-tests by malinink.
the class PointModel method map.
public void map(PointEntity pointEntity) {
this.setId(pointEntity.getId());
this.setQuestion(new QuestionModelEmpty(pointEntity.getQuestionId()));
this.setQuiz(new QuizModelEmpty(pointEntity.getQuizId()));
this.setSolutions(new ModelsListEmpty());
}
Aggregations