use of easytests.core.models.empty.PointModelEmpty 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.empty.PointModelEmpty in project easy-tests by malinink.
the class SolutionModel method map.
// private Integer sort;
public void map(SolutionEntity solutionEntity) {
this.setId(solutionEntity.getId());
this.setAnswer(new AnswerModelEmpty(solutionEntity.getAnswerId()));
this.setPoint(new PointModelEmpty(solutionEntity.getPointId()));
}
use of easytests.core.models.empty.PointModelEmpty in project easy-tests by malinink.
the class SolutionsSupport method assertEquals.
public void assertEquals(SolutionEntity expected, SolutionModelInterface actual) {
assertEquals(actual, expected);
Assert.assertEquals(new PointModelEmpty(expected.getPointId()), actual.getPoint());
Assert.assertEquals(new AnswerModelEmpty(expected.getAnswerId()), actual.getAnswer());
}
use of easytests.core.models.empty.PointModelEmpty in project easy-tests by malinink.
the class SolutionsSupport method getModelMock.
private SolutionModelInterface getModelMock(Integer id, Integer answer, Integer point) {
final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
Mockito.when(solutionModel.getId()).thenReturn(id);
Mockito.when(solutionModel.getAnswer()).thenReturn(new AnswerModelEmpty(answer));
Mockito.when(solutionModel.getPoint()).thenReturn(new PointModelEmpty(point));
return solutionModel;
}
Aggregations