Search in sources :

Example 1 with SolutionsOptionsInterface

use of easytests.core.options.SolutionsOptionsInterface in project easy-tests by malinink.

the class SolutionsServiceTest method testSaveModelsListWithOptions.

@Test
public void testSaveModelsListWithOptions() throws Exception {
    final ArgumentCaptor<SolutionModelInterface> solutionModelCaptor = ArgumentCaptor.forClass(SolutionModelInterface.class);
    final List<SolutionModelInterface> solutionsModels = this.getSolutionsFixturesModels();
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    this.solutionsService.save(solutionsModels, solutionsOptions);
    this.assertServicesSet(solutionsOptions, solutionsModels.size());
    verify(solutionsOptions, times(solutionsModels.size())).saveWithRelations(solutionModelCaptor.capture());
    this.solutionsSupport.assertModelsListEquals(solutionsModels, solutionModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.solutionsMapper);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface)

Example 2 with SolutionsOptionsInterface

use of easytests.core.options.SolutionsOptionsInterface 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 3 with SolutionsOptionsInterface

use of easytests.core.options.SolutionsOptionsInterface in project easy-tests by malinink.

the class SolutionsServiceTest method testDeleteWithOptions.

@Test
public void testDeleteWithOptions() throws Exception {
    final SolutionModelInterface solutionModel = this.createSolutionModel(1, 1, 1);
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    this.solutionsService.delete(solutionModel, solutionsOptions);
    verify(solutionsOptions).deleteWithRelations(solutionModel);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with SolutionsOptionsInterface

use of easytests.core.options.SolutionsOptionsInterface 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 5 with SolutionsOptionsInterface

use of easytests.core.options.SolutionsOptionsInterface in project easy-tests by malinink.

the class SolutionsServiceTest method testDeleteModelsListWithOptions.

@Test
public void testDeleteModelsListWithOptions() throws Exception {
    final ArgumentCaptor<SolutionModelInterface> solutionModelCaptor = ArgumentCaptor.forClass(SolutionModelInterface.class);
    final List<SolutionModelInterface> solutionsModels = this.getSolutionsFixturesModels();
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    this.solutionsService.delete(solutionsModels, solutionsOptions);
    this.assertServicesSet(solutionsOptions, solutionsModels.size());
    verify(solutionsOptions, times(solutionsModels.size())).deleteWithRelations(solutionModelCaptor.capture());
    this.solutionsSupport.assertModelsListEquals(solutionsModels, solutionModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.solutionsMapper);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface)

Aggregations

SolutionModelInterface (easytests.core.models.SolutionModelInterface)8 SolutionsOptionsInterface (easytests.core.options.SolutionsOptionsInterface)8 Test (org.junit.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 SolutionEntity (easytests.core.entities.SolutionEntity)3 ArrayList (java.util.ArrayList)2 PointModelInterface (easytests.core.models.PointModelInterface)1 List (java.util.List)1