use of easytests.core.models.PointModelInterface in project easy-tests by malinink.
the class QuizzesOptionsTest method testDeleteWithRelations.
@Test
public void testDeleteWithRelations() throws Exception {
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
quizzesOptions.setTesteesService(testeesService);
quizzesOptions.setQuizzesService(quizzesService);
quizzesOptions.setPointsService(pointsService);
quizzesOptions.withPoints(pointsOptions);
quizzesOptions.withTestee(testeesOptions);
final List<PointModelInterface> pointsModels = new ArrayList<>();
quizModel.setPoints(pointsModels);
final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
quizModel.setTestee(testeeModel);
final InOrder inOrder = Mockito.inOrder(pointsService, quizzesService, testeesService);
quizzesOptions.deleteWithRelations(quizModel);
inOrder.verify(pointsService).delete(quizModel.getPoints(), pointsOptions);
inOrder.verify(quizzesService).delete(quizModel);
inOrder.verify(testeesService).delete(quizModel.getTestee(), testeesOptions);
}
use of easytests.core.models.PointModelInterface 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.PointModelInterface in project easy-tests by malinink.
the class PointsServiceTest method testDeleteUnidentifiedModel.
@Test
public void testDeleteUnidentifiedModel() throws Exception {
final PointModelInterface pointModel = this.pointsSupport.getModelAdditionalMock(0);
exception.expect(DeleteUnidentifiedModelException.class);
this.pointsService.delete(pointModel);
}
use of easytests.core.models.PointModelInterface in project easy-tests by malinink.
the class PointsServiceTest method testSaveUpdatesEntity.
@Test
public void testSaveUpdatesEntity() throws Exception {
final ArgumentCaptor<PointEntity> pointEntityCaptor = ArgumentCaptor.forClass(PointEntity.class);
final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
this.pointsService.save(pointModel);
verify(this.pointsMapper, times(1)).update(pointEntityCaptor.capture());
this.pointsSupport.assertEquals(this.pointsSupport.getEntityFixtureMock(0), pointEntityCaptor.getValue());
}
use of easytests.core.models.PointModelInterface in project easy-tests by malinink.
the class PointsServiceTest method testDeleteModelWithOptions.
@Test
public void testDeleteModelWithOptions() throws Exception {
final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
this.pointsService.delete(pointModel, pointsOptions);
this.assertServicesSet(pointsOptions);
verify(pointsOptions, times(1)).deleteWithRelations(pointModel);
verifyNoMoreInteractions(this.pointsMapper);
}
Aggregations