Search in sources :

Example 1 with AnswerModelEmpty

use of easytests.core.models.empty.AnswerModelEmpty 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);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) AnswerModelEmpty(easytests.core.models.empty.AnswerModelEmpty) PointsServiceInterface(easytests.core.services.PointsServiceInterface) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) PointModelEmpty(easytests.core.models.empty.PointModelEmpty) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test)

Example 2 with AnswerModelEmpty

use of easytests.core.models.empty.AnswerModelEmpty 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()));
}
Also used : AnswerModelEmpty(easytests.core.models.empty.AnswerModelEmpty) PointModelEmpty(easytests.core.models.empty.PointModelEmpty)

Example 3 with AnswerModelEmpty

use of easytests.core.models.empty.AnswerModelEmpty 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());
}
Also used : AnswerModelEmpty(easytests.core.models.empty.AnswerModelEmpty) PointModelEmpty(easytests.core.models.empty.PointModelEmpty)

Example 4 with AnswerModelEmpty

use of easytests.core.models.empty.AnswerModelEmpty 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;
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) AnswerModelEmpty(easytests.core.models.empty.AnswerModelEmpty) PointModelEmpty(easytests.core.models.empty.PointModelEmpty)

Aggregations

AnswerModelEmpty (easytests.core.models.empty.AnswerModelEmpty)4 PointModelEmpty (easytests.core.models.empty.PointModelEmpty)4 SolutionModelInterface (easytests.core.models.SolutionModelInterface)2 AnswerModelInterface (easytests.core.models.AnswerModelInterface)1 PointModelInterface (easytests.core.models.PointModelInterface)1 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)1 PointsServiceInterface (easytests.core.services.PointsServiceInterface)1 Test (org.junit.Test)1