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;
}
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);
}
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);
}
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;
}
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());
}
Aggregations