use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class QuizzesServiceTest method testSaveUpdatesEntity.
@Test
public void testSaveUpdatesEntity() throws Exception {
final QuizModelInterface quizModel = this.createQuizModel(1, "test", 1);
this.quizzesService.save(quizModel);
verify(this.quizzesMapper, times(1)).update(this.mapQuizEntity(quizModel));
}
use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class TesteesServiceTest method testFindWithOptions.
@Test
public void testFindWithOptions() throws Exception {
final Integer id = 1;
final Integer quizId = 1;
final TesteeModelInterface testeeModel = Models.createTesteeModel(id, "FirstName1", "LastName1", "Surname1", 301, quizId);
final QuizModelInterface quizModel = Models.createQuizModel(quizId, "test_invite_code1", 1, LocalDateTime.of(2003, 2, 1, 0, 0, 0), LocalDateTime.of(2003, 3, 1, 0, 0, 0), false);
testeeModel.setQuiz(quizModel);
final TesteeModelInterface foundedTesteeModel = this.testeesService.find(id, new TesteesOptions().withQuiz(new QuizzesOptions()));
Assert.assertEquals(testeeModel, foundedTesteeModel);
Assert.assertEquals(quizModel, foundedTesteeModel.getQuiz());
}
use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class PointsOptionsTest method testWithRelationsOnModelsList.
@Test
public void testWithRelationsOnModelsList() throws Exception {
final PointModelInterface pointModelFirst = Mockito.mock(PointModelInterface.class);
final PointModelInterface pointModelSecond = Mockito.mock(PointModelInterface.class);
pointModelFirst.setId(1);
pointModelSecond.setId(2);
given(pointModelFirst.getQuiz()).willReturn(new QuizModelEmpty(1));
given(pointModelSecond.getQuiz()).willReturn(new QuizModelEmpty(2));
given(pointModelFirst.getQuestion()).willReturn(new QuestionModelEmpty(1));
given(pointModelSecond.getQuestion()).willReturn(new QuestionModelEmpty(2));
final List<PointModelInterface> pointsModels = new ArrayList<>();
pointsModels.add(pointModelFirst);
pointsModels.add(pointModelSecond);
final PointsOptionsInterface pointsOptions = new PointsOptions();
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 quizModelFirst = Mockito.mock(QuizModelInterface.class);
final QuizModelInterface quizModelSecond = Mockito.mock(QuizModelInterface.class);
given(quizzesService.find(1, quizOptions)).willReturn(quizModelFirst);
given(quizzesService.find(2, quizOptions)).willReturn(quizModelSecond);
final QuestionModelInterface questionModelFirst = Mockito.mock(QuestionModelInterface.class);
final QuestionModelInterface questionModelSecond = Mockito.mock(QuestionModelInterface.class);
given(questionsService.find(1, questionOptions)).willReturn(questionModelFirst);
given(questionsService.find(2, questionOptions)).willReturn(questionModelSecond);
final List<SolutionModelInterface> solutionsModelsFirst = new ArrayList<>();
solutionsModelsFirst.add(Mockito.mock(SolutionModelInterface.class));
final List<SolutionModelInterface> solutionsModelsSecond = new ArrayList<>();
solutionsModelsSecond.add(Mockito.mock(SolutionModelInterface.class));
solutionsModelsSecond.add(Mockito.mock(SolutionModelInterface.class));
given(solutionsService.findByPoint(pointModelFirst, solutionsOptions)).willReturn(solutionsModelsFirst);
given(solutionsService.findByPoint(pointModelSecond, solutionsOptions)).willReturn(solutionsModelsSecond);
final List<PointModelInterface> pointsModelsWithRelations = pointsOptions.withRelations(pointsModels);
Assert.assertEquals(pointsModels, pointsModelsWithRelations);
verify(quizzesService).find(1, quizOptions);
verify(questionsService).find(1, questionOptions);
verify(solutionsService).findByPoint(pointModelFirst, solutionsOptions);
verify(pointsModels.get(0)).setQuiz(quizModelFirst);
verify(pointsModels.get(0)).setQuestion(questionModelFirst);
verify(pointsModels.get(0)).setSolutions(solutionsModelsFirst);
verify(pointsModels.get(0)).setSolutions(Mockito.anyList());
verify(quizzesService).find(2, quizOptions);
verify(questionsService).find(2, questionOptions);
verify(solutionsService).findByPoint(pointModelSecond, solutionsOptions);
verify(pointsModels.get(1)).setQuiz(quizModelSecond);
verify(pointsModels.get(1)).setQuestion(questionModelSecond);
verify(pointsModels.get(1)).setSolutions(solutionsModelsSecond);
verify(pointsModels.get(1)).setSolutions(Mockito.anyList());
}
use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class QuizzesOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
quizModel.setId(1);
given(quizModel.getIssue()).willReturn(new IssueModelEmpty(1));
final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
final TesteesServiceInterface testeeService = Mockito.mock(TesteesServiceInterface.class);
final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
final TesteesOptionsInterface testeeOptions = Mockito.mock(TesteesOptionsInterface.class);
final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
quizzesOptions.setPointsService(pointsService);
quizzesOptions.setIssuesService(issuesService);
quizzesOptions.setTesteesService(testeeService);
quizzesOptions.withTestee(testeeOptions);
quizzesOptions.withPoints(pointsOptions);
quizzesOptions.withIssue(issuesOptions);
final List<PointModelInterface> pointsModels = new ArrayList<>();
pointsModels.add(Mockito.mock(PointModelInterface.class));
final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
given(testeeService.findByQuiz(quizModel, testeeOptions)).willReturn(testeeModel);
given(pointsService.findByQuiz(quizModel, pointsOptions)).willReturn(pointsModels);
given(issuesService.find(quizModel.getIssue().getId(), issuesOptions)).willReturn(issueModel);
final QuizModelInterface quizModelWithRelations = quizzesOptions.withRelations(quizModel);
Assert.assertEquals(quizModel, quizModelWithRelations);
verify(testeeService).findByQuiz(quizModel, testeeOptions);
verify(pointsService).findByQuiz(quizModel, pointsOptions);
verify(issuesService).find(1, issuesOptions);
verify(quizModel).setTestee(testeeModel);
verify(quizModel).setPoints(pointsModels);
verify(quizModel).setIssue(issueModel);
}
use of easytests.core.models.QuizModelInterface in project easy-tests by malinink.
the class QuizzesOptionsTest method testWithRelationsOnNull.
@Test
public void testWithRelationsOnNull() throws Exception {
final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
final IssuesOptionsInterface issueOptions = Mockito.mock(IssuesOptionsInterface.class);
quizzesOptions.setTesteesService(testeesService);
quizzesOptions.setPointsService(pointsService);
quizzesOptions.setIssuesService(issuesService);
quizzesOptions.withPoints(pointsOptions).withIssue(issueOptions).withTestee(testeesOptions);
final QuizModelInterface nullQuizModel = null;
final QuizModelInterface quizModelWithRelations = quizzesOptions.withRelations(nullQuizModel);
Assert.assertNull(quizModelWithRelations);
}
Aggregations