use of easytests.core.models.SolutionModelInterface 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);
}
use of easytests.core.models.SolutionModelInterface 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);
}
use of easytests.core.models.SolutionModelInterface 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));
}
use of easytests.core.models.SolutionModelInterface 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);
}
use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.
the class SolutionsServiceTest method testFindByPointAbsentModel.
@Test
public void testFindByPointAbsentModel() throws Exception {
Integer pointId = 10;
given(this.solutionsMapper.findByPointId(pointId)).willReturn(new ArrayList<>(0));
final PointModelInterface pointModel = mock(PointModelInterface.class);
when(pointModel.getId()).thenReturn(pointId);
final List<SolutionModelInterface> solutionModels = this.solutionsService.findByPoint(pointModel);
Assert.assertNotNull(solutionModels);
Assert.assertEquals(0, solutionModels.size());
}
Aggregations