use of easytests.core.models.SolutionModelInterface 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());
}
use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.
the class SolutionsServiceTest method testFindAllWithOptions.
@Test
public void testFindAllWithOptions() throws Exception {
final List<SolutionEntity> solutionsEntities = this.getSolutionsEntities();
final List<SolutionModelInterface> solutionsModels = this.getSolutionsModels(solutionsEntities);
final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
given(this.solutionsMapper.findAll()).willReturn(solutionsEntities);
given(solutionsOptions.withRelations(Mockito.anyList())).willReturn(solutionsModels);
final List<SolutionModelInterface> foundedSolutionsModels = this.solutionsService.findAll(solutionsOptions);
verify(solutionsOptions).withRelations(solutionsModels);
Assert.assertEquals(solutionsModels, foundedSolutionsModels);
}
use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.
the class SolutionsServiceTest method testSaveEntitiesList.
@Test
public void testSaveEntitiesList() throws Exception {
final SolutionModelInterface solutionModelFirst = this.createSolutionModel(1, 13, 4);
final SolutionModelInterface solutionModelSecond = this.createSolutionModel(2, 10, 3);
final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
final List<SolutionModelInterface> solutionModels = new ArrayList<>();
solutionModels.add(solutionModelFirst);
solutionModels.add(solutionModelSecond);
final SolutionsServiceInterface solutionsServiceSpy = Mockito.spy(solutionsService);
solutionsServiceSpy.save(solutionModels);
verify(solutionsServiceSpy, times(1)).save(solutionModelFirst);
verify(solutionsServiceSpy, times(1)).save(solutionModelSecond);
solutionsServiceSpy.save(solutionModels, solutionsOptions);
verify(solutionsServiceSpy, times(1)).save(solutionModelFirst, solutionsOptions);
verify(solutionsServiceSpy, times(1)).save(solutionModelSecond, solutionsOptions);
}
use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.
the class SolutionsServiceTest method mapSolutionModel.
private SolutionModelInterface mapSolutionModel(SolutionEntity solutionEntity) {
final SolutionModelInterface solutionModel = new SolutionModel();
solutionModel.map(solutionEntity);
return solutionModel;
}
use of easytests.core.models.SolutionModelInterface in project easy-tests by malinink.
the class SolutionsServiceTest method testSaveUpdatesEntity.
@Test
public void testSaveUpdatesEntity() throws Exception {
final SolutionModelInterface solutionModel = this.createSolutionModel(1, 10, 1);
this.solutionsService.save(solutionModel);
verify(this.solutionsMapper, times(1)).update(this.mapSolutionEntity(solutionModel));
}
Aggregations