Search in sources :

Example 6 with PointEntity

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

the class PointsServiceTest method getPointsEntities.

private List<PointEntity> getPointsEntities() {
    final List<PointEntity> pointEntities = new ArrayList<>(2);
    final PointEntity pointEntityFirst = Entities.createPointEntityMock(1, 1, 1);
    final PointEntity pointEntitySecond = Entities.createPointEntityMock(2, 2, 2);
    pointEntities.add(pointEntityFirst);
    pointEntities.add(pointEntitySecond);
    return pointEntities;
}
Also used : ArrayList(java.util.ArrayList) PointEntity(easytests.core.entities.PointEntity)

Example 7 with PointEntity

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

the class PointsServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final Integer id = 1;
    final PointEntity pointEntity = Entities.createPointEntityMock(id, 1, 1);
    given(this.pointsMapper.find(id)).willReturn(pointEntity);
    final PointModelInterface pointModel = this.pointsService.find(id);
    Assert.assertEquals(this.mapPointModel(pointEntity), pointModel);
}
Also used : PointEntity(easytests.core.entities.PointEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with PointEntity

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

the class PointsServiceTest method testFindAllWithOptions.

@Test
public void testFindAllWithOptions() throws Exception {
    final List<PointEntity> pointsEntities = this.getPointsEntities();
    final List<PointModelInterface> pointsModels = this.getPointsModels();
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    given(this.pointsMapper.findAll()).willReturn(pointsEntities);
    given(pointsOptions.withRelations(Mockito.anyList())).willReturn(pointsModels);
    final List<PointModelInterface> foundPointsModels = this.pointsService.findAll(pointsOptions);
    verify(pointsOptions).withRelations(foundPointsModels);
    Assert.assertEquals(pointsModels, foundPointsModels);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) PointEntity(easytests.core.entities.PointEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with PointEntity

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

the class PointsServiceTest method mapPointEntity.

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

Example 10 with PointEntity

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

the class PointsServiceTest method testSaveCreatesEntity.

@Test
public void testSaveCreatesEntity() throws Exception {
    final PointModelInterface pointModel = Models.createPointModel(null, 1, 1);
    doAnswer(invocation -> {
        final PointEntity pointEntity = (PointEntity) invocation.getArguments()[0];
        pointEntity.setId(5);
        return null;
    }).when(this.pointsMapper).insert(Mockito.any(PointEntity.class));
    this.pointsService.save(pointModel);
    verify(this.pointsMapper, times(1)).insert(this.mapPointEntity(pointModel));
    Assert.assertEquals((Integer) 5, pointModel.getId());
}
Also used : PointEntity(easytests.core.entities.PointEntity) 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