Search in sources :

Example 6 with SolutionsOptionsInterface

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

the class SolutionsServiceTest method testSaveWithOptions.

@Test
public void testSaveWithOptions() throws Exception {
    final SolutionModelInterface solutionModel = this.solutionsSupport.getModelFixtureMock(0);
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    this.solutionsService.save(solutionModel, solutionsOptions);
    this.assertServicesSet(solutionsOptions);
    verify(solutionsOptions, times(1)).saveWithRelations(solutionModel);
    verifyNoMoreInteractions(this.solutionsMapper);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface)

Example 7 with SolutionsOptionsInterface

use of easytests.core.options.SolutionsOptionsInterface 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);
}
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 8 with SolutionsOptionsInterface

use of easytests.core.options.SolutionsOptionsInterface 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);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) ArrayList(java.util.ArrayList) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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