Search in sources :

Example 16 with SolutionEntity

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

the class SolutionsMapperTest method testDelete.

@Test
public void testDelete() throws Exception {
    final Integer id = this.solutionsSupport.getEntityFixtureMock(0).getId();
    final SolutionEntity solutionFoundedEntity = this.solutionsMapper.find(id);
    Assert.assertNotNull(solutionFoundedEntity);
    this.solutionsMapper.delete(solutionFoundedEntity);
    Assert.assertNull(this.solutionsMapper.find(id));
}
Also used : SolutionEntity(easytests.core.entities.SolutionEntity) Test(org.junit.Test)

Example 17 with SolutionEntity

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

the class SolutionsMapperTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    final SolutionEntity solutionChangedEntity = this.solutionsSupport.getEntityAdditionalMock(1);
    final SolutionEntity solutionBeforeUpdateEntity = this.solutionsMapper.find(solutionChangedEntity.getId());
    Assert.assertNotNull(solutionBeforeUpdateEntity);
    this.solutionsSupport.assertNotEqualsWithoutId(solutionChangedEntity, solutionBeforeUpdateEntity);
    this.solutionsMapper.update(solutionChangedEntity);
    final SolutionEntity solutionUpdatedEntity = this.solutionsMapper.find(solutionChangedEntity.getId());
    this.solutionsSupport.assertEquals(solutionChangedEntity, solutionUpdatedEntity);
}
Also used : SolutionEntity(easytests.core.entities.SolutionEntity) Test(org.junit.Test)

Example 18 with SolutionEntity

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

the class SolutionsService method map.

private SolutionEntity map(SolutionModelInterface solutionModel) {
    final SolutionEntity solutionEntity = new SolutionEntity();
    solutionEntity.map(solutionModel);
    return solutionEntity;
}
Also used : SolutionEntity(easytests.core.entities.SolutionEntity)

Example 19 with SolutionEntity

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

the class SolutionsServiceTest method testFindByPointPresentModel.

@Test
public void testFindByPointPresentModel() throws Exception {
    Integer pointId = 1;
    final List<SolutionEntity> solutionEntities = new ArrayList<>(2);
    solutionEntities.add(this.createSolutionEntityMock(1, 10, pointId));
    solutionEntities.add(this.createSolutionEntityMock(2, 20, pointId));
    given(this.solutionsMapper.findByPointId(pointId)).willReturn(solutionEntities);
    final PointModelInterface pointModel = mock(PointModelInterface.class);
    when(pointModel.getId()).thenReturn(pointId);
    final List<SolutionModelInterface> solutionModels = this.solutionsService.findByPoint(pointModel);
    Assert.assertNotNull(solutionModels);
    Assert.assertEquals(solutionEntities.size(), solutionModels.size());
    for (int i = 0; i < solutionEntities.size(); i++) {
        Assert.assertEquals(solutionModels.get(i), this.mapSolutionModel(solutionEntities.get(i)));
    }
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) ArrayList(java.util.ArrayList) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 20 with SolutionEntity

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

the class SolutionsServiceTest method testSaveInsertsEntity.

@Test
public void testSaveInsertsEntity() throws Exception {
    final SolutionModelInterface solutionModel = this.createSolutionModel(null, 13, 4);
    final Integer id = 5;
    doAnswer(invocations -> {
        final SolutionEntity solutionEntity = (SolutionEntity) invocations.getArguments()[0];
        solutionEntity.setId(id);
        return null;
    }).when(this.solutionsMapper).insert(Mockito.any(SolutionEntity.class));
    this.solutionsService.save(solutionModel);
    verify(this.solutionsMapper, times(1)).insert(this.mapSolutionEntity(solutionModel));
    Assert.assertEquals(id, solutionModel.getId());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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