use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.
the class PointsOptionsTest method testDeleteWithRelations.
@Test
public void testDeleteWithRelations() throws Exception {
final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
final PointsOptionsInterface pointsOptions = new PointsOptions();
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final SolutionsServiceInterface solutionsService = Mockito.mock(SolutionsServiceInterface.class);
pointsOptions.setPointsService(pointsService);
pointsOptions.setQuizzesService(quizzesService);
pointsOptions.setSolutionsService(solutionsService);
final QuizzesOptionsInterface quizOptions = Mockito.mock(QuizzesOptionsInterface.class);
final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
pointsOptions.withQuiz(quizOptions);
pointsOptions.withSolutions(solutionsOptions);
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
final List<SolutionModelInterface> solutionsModels = new ArrayList<>();
solutionsModels.add(Mockito.mock(SolutionModelInterface.class));
given(pointModel.getQuiz()).willReturn(quizModel);
given(pointModel.getSolutions()).willReturn(solutionsModels);
final InOrder inOrder = Mockito.inOrder(solutionsService, pointsService, quizzesService);
pointsOptions.deleteWithRelations(pointModel);
inOrder.verify(solutionsService).delete(solutionsModels, solutionsOptions);
inOrder.verify(pointsService).delete(pointModel);
inOrder.verify(quizzesService).delete(quizModel, quizOptions);
}
use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.
the class PointsOptionsTest method testSaveWithRelations.
@Test
public void testSaveWithRelations() throws Exception {
final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
final PointsOptionsInterface pointsOptions = new PointsOptions();
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final SolutionsServiceInterface solutionsService = Mockito.mock(SolutionsServiceInterface.class);
pointsOptions.setPointsService(pointsService);
pointsOptions.setQuizzesService(quizzesService);
pointsOptions.setSolutionsService(solutionsService);
final QuizzesOptionsInterface quizOptions = Mockito.mock(QuizzesOptionsInterface.class);
final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
pointsOptions.withQuiz(quizOptions);
pointsOptions.withSolutions(solutionsOptions);
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
final List<SolutionModelInterface> solutionsModels = new ArrayList<>();
solutionsModels.add(Mockito.mock(SolutionModelInterface.class));
given(pointModel.getQuiz()).willReturn(quizModel);
given(pointModel.getSolutions()).willReturn(solutionsModels);
final InOrder inOrder = Mockito.inOrder(quizzesService, pointsService, solutionsService);
pointsOptions.saveWithRelations(pointModel);
inOrder.verify(quizzesService).save(quizModel, quizOptions);
inOrder.verify(pointsService).save(pointModel);
inOrder.verify(solutionsService).save(solutionsModels, solutionsOptions);
}
use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.
the class SolutionsOptionsTest method testSaveDeleteWithPoint.
@Test
public void testSaveDeleteWithPoint() {
final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
final SolutionsOptionsInterface solutionsOptions = new SolutionsOptions();
final SolutionsServiceInterface solutionsService = Mockito.mock(SolutionsServiceInterface.class);
final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
solutionsOptions.setSolutionsService(solutionsService);
solutionsOptions.setPointsService(pointsService);
solutionsOptions.withPoint(pointsOptions);
solutionsOptions.setAnswersService(answersService);
solutionsOptions.withAnswer(answersOptions);
final SolutionsOptionsInterface solutionsOptionsSpy = Mockito.spy(solutionsOptions);
solutionsOptionsSpy.deleteWithRelations(solutionModel);
verify(pointsOptions, times(1)).deleteWithRelations(solutionModel.getPoint());
/* solutionsOptionsSpy.saveWithRelations(solutionModel);
verify(pointsOptions, times(1)).saveWithRelations(solutionModel.getPoint());*/
}
use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.
the class SolutionsOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
solutionModel.setId(1);
given(solutionModel.getPoint()).willReturn(new PointModelEmpty(1));
given(solutionModel.getAnswer()).willReturn(new AnswerModelEmpty(1));
final SolutionsOptionsInterface solutionsOptions = new SolutionsOptions();
final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
final AnswersOptionsInterface answerOptions = Mockito.mock(AnswersOptionsInterface.class);
final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
solutionsOptions.setPointsService(pointsService);
solutionsOptions.setAnswersService(answersService);
solutionsOptions.withPoint(pointsOptions);
solutionsOptions.withAnswer(answerOptions);
final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
given(pointsService.find(solutionModel.getPoint().getId(), pointsOptions)).willReturn(pointModel);
given(answersService.find(solutionModel.getAnswer().getId(), answerOptions)).willReturn(answerModel);
final SolutionModelInterface solutionModelWithRelations = solutionsOptions.withRelations(solutionModel);
Assert.assertEquals(solutionModel, solutionModelWithRelations);
verify(pointsService).find(solutionModel.getPoint().getId(), pointsOptions);
verify(answersService).find(solutionModel.getAnswer().getId(), answerOptions);
verify(solutionModel).setPoint(pointModel);
verify(solutionModel).setAnswer(answerModel);
}
use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.
the class SolutionsServiceTest method testFindByPointAbsentList.
@Test
public void testFindByPointAbsentList() throws Exception {
final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
when(this.solutionsMapper.findByPointId(pointModel.getId())).thenReturn(new ArrayList<>(0));
final List<SolutionModelInterface> solutionsFoundedModels = this.solutionsService.findByPoint(pointModel);
Assert.assertEquals(0, solutionsFoundedModels.size());
}
Aggregations