use of easytests.core.services.IssuesServiceInterface in project easy-tests by malinink.
the class QuizzesOptionsTest method testWithRelationsOnModelsList.
@Test
public void testWithRelationsOnModelsList() throws Exception {
final QuizModelInterface quizModelFirst = Mockito.mock(QuizModelInterface.class);
quizModelFirst.setId(1);
given(quizModelFirst.getIssue()).willReturn(new IssueModelEmpty(1));
final QuizModelInterface quizModelSecond = Mockito.mock(QuizModelInterface.class);
quizModelSecond.setId(2);
given(quizModelSecond.getIssue()).willReturn(new IssueModelEmpty(2));
final List<QuizModelInterface> quizzesModels = new ArrayList<>(2);
quizzesModels.add(quizModelFirst);
quizzesModels.add(quizModelSecond);
final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
final IssuesOptionsInterface issueOptions = Mockito.mock(IssuesOptionsInterface.class);
quizzesOptions.setTesteesService(testeesService);
quizzesOptions.setPointsService(pointsService);
quizzesOptions.setIssuesService(issuesService);
quizzesOptions.withTestee(testeesOptions);
quizzesOptions.withPoints(pointsOptions);
quizzesOptions.withIssue(issueOptions);
final List<PointModelInterface> pointsModelsFirst = new ArrayList<>();
pointsModelsFirst.add(Mockito.mock(PointModelInterface.class));
final List<PointModelInterface> pointsModelsSecond = new ArrayList<>();
pointsModelsSecond.add(Mockito.mock(PointModelInterface.class));
pointsModelsSecond.add(Mockito.mock(PointModelInterface.class));
given(pointsService.findByQuiz(quizModelFirst, pointsOptions)).willReturn(pointsModelsFirst);
given(pointsService.findByQuiz(quizModelSecond, pointsOptions)).willReturn(pointsModelsSecond);
final IssueModelInterface issueModelFirst = Mockito.mock(IssueModelInterface.class);
final IssueModelInterface issueModelSecond = Mockito.mock(IssueModelInterface.class);
given(issuesService.find(1, issueOptions)).willReturn(issueModelFirst);
given(issuesService.find(2, issueOptions)).willReturn(issueModelSecond);
final TesteeModelInterface testeeModelFirst = Mockito.mock(TesteeModelInterface.class);
final TesteeModelInterface testeeModelSecond = Mockito.mock(TesteeModelInterface.class);
given(testeesService.findByQuiz(quizModelFirst, testeesOptions)).willReturn(testeeModelFirst);
given(testeesService.findByQuiz(quizModelSecond, testeesOptions)).willReturn(testeeModelSecond);
final List<QuizModelInterface> quizzesModelsWithRelations = quizzesOptions.withRelations(quizzesModels);
Assert.assertEquals(quizzesModelsWithRelations, quizzesModels);
verify(testeesService).findByQuiz(quizModelFirst, testeesOptions);
verify(pointsService).findByQuiz(quizModelFirst, pointsOptions);
verify(issuesService).find(1, issueOptions);
verify(quizzesModels.get(0)).setPoints(pointsModelsFirst);
verify(quizzesModels.get(0)).setPoints(Mockito.anyList());
verify(quizzesModels.get(0)).setIssue(issueModelFirst);
verify(quizzesModels.get(0)).setTestee(testeeModelFirst);
verify(testeesService).findByQuiz(quizModelSecond, testeesOptions);
verify(pointsService).findByQuiz(quizModelSecond, pointsOptions);
verify(issuesService).find(2, issueOptions);
verify(quizzesModels.get(1)).setPoints(pointsModelsSecond);
verify(quizzesModels.get(1)).setPoints(Mockito.anyList());
verify(quizzesModels.get(1)).setIssue(issueModelSecond);
verify(quizzesModels.get(1)).setTestee(testeeModelSecond);
}
use of easytests.core.services.IssuesServiceInterface in project easy-tests by malinink.
the class QuizzesOptionsTest method testSaveDeleteWithIssue.
@Test
public void testSaveDeleteWithIssue() {
final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
quizzesOptions.setQuizzesService(quizzesService);
quizzesOptions.setIssuesService(issuesService);
quizzesOptions.withIssue(issuesOptions);
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
final QuizzesOptionsInterface quizzesOptionsSpy = Mockito.spy(quizzesOptions);
quizzesOptionsSpy.deleteWithRelations(quizModel);
verify(issuesService, times(1)).delete(quizModel.getIssue(), issuesOptions);
quizzesOptionsSpy.saveWithRelations(quizModel);
verify(issuesService, times(1)).save(quizModel.getIssue(), issuesOptions);
}
use of easytests.core.services.IssuesServiceInterface in project easy-tests by malinink.
the class IssuesOptionsTest method testSaveWithRelations.
@Test
public void testSaveWithRelations() throws Exception {
final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
final IssuesOptionsInterface issuesOptions = new IssuesOptions();
final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
issuesOptions.setIssuesService(issuesService);
issuesOptions.setQuizzesService(quizzesService);
issuesOptions.withQuizzes(quizzesOptions);
final List<QuizModelInterface> quizzesModels = new ArrayList<>();
quizzesModels.add(Mockito.mock(QuizModelInterface.class));
given(issueModel.getQuizzes()).willReturn(quizzesModels);
final InOrder inOrder = Mockito.inOrder(quizzesService, issuesService);
issuesOptions.saveWithRelations(issueModel);
inOrder.verify(issuesService).save(issueModel);
inOrder.verify(quizzesService).save(quizzesModels, quizzesOptions);
}
use of easytests.core.services.IssuesServiceInterface in project easy-tests by malinink.
the class IssuesOptionsTest method testSaveDeleteWithSubject.
@Test
public void testSaveDeleteWithSubject() {
final IssuesOptionsInterface issuesOptions = new IssuesOptions();
final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
final SubjectsOptionsInterface subjectsOptions = Mockito.mock(SubjectsOptionsInterface.class);
final SubjectsServiceInterface subjectsService = Mockito.mock(SubjectsServiceInterface.class);
issuesOptions.setIssuesService(issuesService);
issuesOptions.setSubjectsService(subjectsService);
issuesOptions.withSubject(subjectsOptions);
final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
final IssuesOptionsInterface issuesOptionsSpy = Mockito.spy(issuesOptions);
issuesOptionsSpy.saveWithRelations(issueModel);
verify(subjectsService, times(1)).save(issueModel.getSubject(), subjectsOptions);
issuesOptionsSpy.deleteWithRelations(issueModel);
verify(subjectsService, times(1)).delete(issueModel.getSubject(), subjectsOptions);
}
use of easytests.core.services.IssuesServiceInterface 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);
}
Aggregations