Search in sources :

Example 21 with PointEntity

use of easytests.core.entities.PointEntity in project easy-tests by malinink.

the class PointsService method save.

@Override
public void save(PointModelInterface pointModel) {
    final PointEntity pointEntity = this.map(pointModel);
    if (pointEntity.getId() == null) {
        this.pointsMapper.insert(pointEntity);
        pointModel.setId(pointEntity.getId());
        return;
    }
    this.pointsMapper.update(pointEntity);
}
Also used : PointEntity(easytests.core.entities.PointEntity)

Example 22 with PointEntity

use of easytests.core.entities.PointEntity in project easy-tests by malinink.

the class PointsService method map.

private PointEntity map(PointModelInterface pointModel) {
    final PointEntity pointEntity = new PointEntity();
    pointEntity.map(pointModel);
    return pointEntity;
}
Also used : PointEntity(easytests.core.entities.PointEntity)

Example 23 with PointEntity

use of easytests.core.entities.PointEntity in project easy-tests by malinink.

the class PointsServiceTest method testFindByQuizWithOptions.

@Test
@Ignore
public void testFindByQuizWithOptions() throws Exception {
    final Integer quizId = 5;
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    Mockito.when(quizModel.getId()).thenReturn(quizId);
    final PointEntity pointEntityFirst = Entities.createPointEntityMock(1, 1, 1);
    final PointEntity pointEntitySecond = Entities.createPointEntityMock(4, 4, 4);
    final List<PointEntity> pointsEntities = new ArrayList<>();
    pointsEntities.add(pointEntityFirst);
    pointsEntities.add(pointEntitySecond);
    given(this.pointsMapper.findByQuizId(quizId)).willReturn(pointsEntities);
    final List<PointModelInterface> pointsModels = new ArrayList<>();
    pointsModels.add(this.mapPointModel(pointEntityFirst));
    pointsModels.add(this.mapPointModel(pointEntitySecond));
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptions.class);
    given(pointsOptions.withRelations(pointsModels)).willReturn(pointsModels);
    final List<PointModelInterface> foundPointsModels = this.pointsService.findByQuiz(quizModel);
    verify(this.pointsMapper).findByQuizId(quizId);
    verify(pointsOptions).withRelations(pointsModels);
    Assert.assertEquals(pointsModels, foundPointsModels);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) ArrayList(java.util.ArrayList) PointEntity(easytests.core.entities.PointEntity) Ignore(org.junit.Ignore) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

PointEntity (easytests.core.entities.PointEntity)23 Test (org.junit.Test)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 ArrayList (java.util.ArrayList)4 PointModelInterface (easytests.core.models.PointModelInterface)3 PointsOptionsInterface (easytests.core.options.PointsOptionsInterface)3 QuizModelInterface (easytests.core.models.QuizModelInterface)1 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)1 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)1 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1 Ignore (org.junit.Ignore)1