Search in sources :

Example 11 with SolutionEntity

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

the class SolutionsService method save.

@Override
public void save(SolutionModelInterface solutionModel) {
    final SolutionEntity solutionEntity = this.map(solutionModel);
    if (solutionEntity.getId() != null) {
        this.solutionsMapper.update(solutionEntity);
        return;
    }
    this.solutionsMapper.insert(solutionEntity);
    solutionModel.setId(solutionEntity.getId());
}
Also used : SolutionEntity(easytests.core.entities.SolutionEntity)

Example 12 with SolutionEntity

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

the class SolutionsServiceTest method testSaveUpdateEntityIdOnCreation.

@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
    final Integer id = 5;
    final SolutionModelInterface solutionModel = this.solutionsSupport.getModelAdditionalMock(0);
    doAnswer(invocation -> {
        final SolutionEntity solutionEntity = (SolutionEntity) invocation.getArguments()[0];
        solutionEntity.setId(id);
        return null;
    }).when(this.solutionsMapper).insert(any());
    this.solutionsService.save(solutionModel);
    verify(solutionModel, times(1)).setId(id);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity)

Example 13 with SolutionEntity

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

the class SolutionsServiceTest method testSaveCreatesEntity.

@Test
public void testSaveCreatesEntity() throws Exception {
    final ArgumentCaptor<SolutionEntity> solutionEntityCaptor = ArgumentCaptor.forClass(SolutionEntity.class);
    final SolutionModelInterface solutionModel = this.solutionsSupport.getModelAdditionalMock(0);
    this.solutionsService.save(solutionModel);
    verify(this.solutionsMapper, times(1)).insert(solutionEntityCaptor.capture());
    this.solutionsSupport.assertEquals(this.solutionsSupport.getEntityAdditionalMock(0), solutionEntityCaptor.getValue());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity)

Example 14 with SolutionEntity

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

the class SolutionsServiceTest method testFindByPointPresentList.

@Test
public void testFindByPointPresentList() throws Exception {
    final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
    final List<SolutionEntity> solutionsEntities = this.getSolutionsFixturesEntities();
    when(this.solutionsMapper.findByPointId(pointModel.getId())).thenReturn(solutionsEntities);
    final List<SolutionModelInterface> solutionsFoundedModels = this.solutionsService.findByPoint(pointModel);
    this.solutionsSupport.assertModelsListEquals(this.getSolutionsFixturesModels(), solutionsFoundedModels);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) PointModelInterface(easytests.core.models.PointModelInterface)

Example 15 with SolutionEntity

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

the class SolutionsMapperTest method testFind.

@Test
public void testFind() throws Exception {
    final SolutionEntity solutionFixtureEntity = this.solutionsSupport.getEntityFixtureMock(0);
    final SolutionEntity solutionFoundedEntity = this.solutionsMapper.find(solutionFixtureEntity.getId());
    this.solutionsSupport.assertEquals(solutionFixtureEntity, solutionFoundedEntity);
}
Also used : SolutionEntity(easytests.core.entities.SolutionEntity) Test(org.junit.Test)

Aggregations

SolutionEntity (easytests.core.entities.SolutionEntity)23 Test (org.junit.Test)12 SolutionModelInterface (easytests.core.models.SolutionModelInterface)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 PointModelInterface (easytests.core.models.PointModelInterface)3 SolutionsOptionsInterface (easytests.core.options.SolutionsOptionsInterface)3 ArrayList (java.util.ArrayList)3 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1 List (java.util.List)1