Search in sources :

Example 6 with SolutionEntity

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

the class SolutionsMapperTest method testFindByPointId.

@Test
public void testFindByPointId() throws Exception {
    final List<SolutionEntity> solutionsFixtureEntities = new ArrayList<>();
    solutionsFixtureEntities.add(this.solutionsSupport.getEntityFixtureMock(0));
    solutionsFixtureEntities.add(this.solutionsSupport.getEntityFixtureMock(1));
    final List<SolutionEntity> solutionFoundedEntities = this.solutionsMapper.findByPointId(1);
    Assert.assertEquals(2, solutionFoundedEntities.size());
    Integer index = 0;
    for (SolutionEntity solutionEntity : solutionFoundedEntities) {
        this.solutionsSupport.assertEquals(solutionsFixtureEntities.get(index), solutionEntity);
        index++;
    }
}
Also used : SolutionEntity(easytests.core.entities.SolutionEntity) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with SolutionEntity

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

the class SolutionsServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    Integer id = 1;
    final SolutionEntity solutionEntity = this.createSolutionEntityMock(id, 2, 3);
    given(this.solutionsMapper.find(id)).willReturn(solutionEntity);
    final SolutionModelInterface solutionModel = this.solutionsService.find(id);
    Assert.assertNotNull(solutionModel);
    Assert.assertEquals(solutionModel, this.mapSolutionModel(solutionEntity));
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with SolutionEntity

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

the class SolutionsServiceTest method mapSolutionEntity.

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

Example 9 with SolutionEntity

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

the class SolutionsServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final SolutionEntity solutionEntity = this.createSolutionEntityMock(id, 1, 1);
    final SolutionModelInterface solutionModel = this.mapSolutionModel(solutionEntity);
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    given(this.solutionsMapper.find(id)).willReturn(solutionEntity);
    given(solutionsOptions.withRelations(solutionModel)).willReturn(solutionModel);
    final SolutionModelInterface foundedSolutionModel = this.solutionsService.find(id, solutionsOptions);
    Assert.assertEquals(solutionModel, foundedSolutionModel);
    verify(solutionsOptions).withRelations(solutionModel);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with SolutionEntity

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

the class SolutionsService method delete.

@Override
public void delete(SolutionModelInterface solutionModel) {
    final SolutionEntity solutionEntity = this.map(solutionModel);
    if (solutionEntity.getId() == null) {
        throw new DeleteUnidentifiedModelException();
    }
    this.solutionsMapper.delete(solutionEntity);
}
Also used : SolutionEntity(easytests.core.entities.SolutionEntity) DeleteUnidentifiedModelException(easytests.core.services.exceptions.DeleteUnidentifiedModelException)

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