Search in sources :

Example 1 with SolutionEntity

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

the class SolutionsServiceTest method testFindByPointWithOptions.

@Test
public void testFindByPointWithOptions() throws Exception {
    final ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
    final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
    final List<SolutionEntity> solutionsEntities = this.getSolutionsFixturesEntities();
    when(this.solutionsMapper.findByPointId(pointModel.getId())).thenReturn(solutionsEntities);
    final List<SolutionModelInterface> solutionsModels = this.getSolutionsFixturesModels();
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    when(solutionsOptions.withRelations(listCaptor.capture())).thenReturn(solutionsModels);
    final List<SolutionModelInterface> solutionsFoundedModels = this.solutionsService.findByPoint(pointModel, solutionsOptions);
    this.assertServicesSet(solutionsOptions);
    this.solutionsSupport.assertModelsListEquals(solutionsModels, listCaptor.getValue());
    Assert.assertSame(solutionsModels, solutionsFoundedModels);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) ArrayList(java.util.ArrayList) List(java.util.List) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface) PointModelInterface(easytests.core.models.PointModelInterface)

Example 2 with SolutionEntity

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

the class SolutionsSupport method assertEntitiesListEquals.

public void assertEntitiesListEquals(List<SolutionEntity> expected, List<SolutionEntity> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Integer i = 0;
    for (SolutionEntity solutionEntity : expected) {
        this.assertEquals(solutionEntity, actual.get(i));
        i++;
    }
}
Also used : SolutionEntity(easytests.core.entities.SolutionEntity)

Example 3 with SolutionEntity

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

the class SolutionsSupport method getEntityMock.

private SolutionEntity getEntityMock(Integer id, Integer answerId, Integer pointId) {
    final SolutionEntity solutionEntity = Mockito.mock(SolutionEntity.class);
    Mockito.when(solutionEntity.getId()).thenReturn(id);
    Mockito.when(solutionEntity.getAnswerId()).thenReturn(answerId);
    Mockito.when(solutionEntity.getPointId()).thenReturn(pointId);
    return solutionEntity;
}
Also used : SolutionEntity(easytests.core.entities.SolutionEntity)

Example 4 with SolutionEntity

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

the class SolutionsMapperTest method testFindAll.

@Test
public void testFindAll() throws Exception {
    final List<SolutionEntity> solutionsFoundedEntities = this.solutionsMapper.findAll();
    Assert.assertEquals(5, solutionsFoundedEntities.size());
    Integer index = 0;
    for (SolutionEntity solutionEntity : solutionsFoundedEntities) {
        final SolutionEntity solutionFixtureEntity = this.solutionsSupport.getEntityFixtureMock(index);
        this.solutionsSupport.assertEquals(solutionFixtureEntity, solutionEntity);
        index++;
    }
}
Also used : SolutionEntity(easytests.core.entities.SolutionEntity) Test(org.junit.Test)

Example 5 with SolutionEntity

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

the class SolutionsMapperTest method testInsert.

@Test
public void testInsert() throws Exception {
    final ArgumentCaptor<Integer> id = ArgumentCaptor.forClass(Integer.class);
    final SolutionEntity solutionUnidentifiedEntity = this.solutionsSupport.getEntityAdditionalMock(0);
    this.solutionsMapper.insert(solutionUnidentifiedEntity);
    verify(solutionUnidentifiedEntity, times(1)).setId(id.capture());
    Assert.assertNotNull(id.getValue());
    final SolutionEntity solutionInsertedEntity = this.solutionsMapper.find(id.getValue());
    Assert.assertNotNull(solutionInsertedEntity);
    this.solutionsSupport.assertEqualsWithoutId(solutionUnidentifiedEntity, solutionInsertedEntity);
}
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