use of easytests.core.services.TesteesServiceInterface 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.services.TesteesServiceInterface 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