Search in sources :

Example 1 with PointsOptionsInterface

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

the class PointsServiceTest method testDeleteModelsListWithOptions.

@Test
public void testDeleteModelsListWithOptions() throws Exception {
    final ArgumentCaptor<PointModelInterface> pointModelCaptor = ArgumentCaptor.forClass(PointModelInterface.class);
    final List<PointModelInterface> pointsModels = this.getPointsFixturesModels();
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    this.pointsService.delete(pointsModels, pointsOptions);
    this.assertServicesSet(pointsOptions, pointsModels.size());
    verify(pointsOptions, times(pointsModels.size())).deleteWithRelations(pointModelCaptor.capture());
    this.pointsSupport.assertModelsListEquals(pointsModels, pointModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.pointsMapper);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) PointModelInterface(easytests.core.models.PointModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with PointsOptionsInterface

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

the class PointsServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final Integer questionId = 1;
    final Integer quizId = 2;
    final PointEntity pointEntity = Entities.createPointEntityMock(4, questionId, quizId);
    final PointModelInterface pointModel = this.mapPointModel(pointEntity);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    given(this.pointsMapper.find(id)).willReturn(pointEntity);
    given(pointsOptions.withRelations(pointModel)).willReturn(pointModel);
    final PointModelInterface foundPointModel = this.pointsService.find(id, pointsOptions);
    verify(pointsOptions).withRelations(pointModel);
    Assert.assertEquals(pointModel, foundPointModel);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) PointEntity(easytests.core.entities.PointEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with PointsOptionsInterface

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

the class PointsServiceTest method testDeleteModelsList.

@Test
@Ignore
public void testDeleteModelsList() throws Exception {
    final PointModelInterface pointModelFirst = Models.createPointModel(2, 2, 2);
    final PointModelInterface pointModelSecond = Models.createPointModel(3, 3, 3);
    final List<PointModelInterface> pointsModels = new ArrayList<>();
    pointsModels.add(pointModelFirst);
    pointsModels.add(pointModelSecond);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    final PointsServiceInterface pointsServiceSpy = Mockito.spy(pointsService);
    pointsServiceSpy.delete(pointsModels);
    verify(pointsServiceSpy, times(1)).delete(pointModelFirst);
    verify(pointsServiceSpy, times(1)).delete(pointModelSecond);
    pointsServiceSpy.delete(pointsModels);
    verify(pointsServiceSpy, times(1)).delete(pointModelFirst, pointsOptions);
    verify(pointsServiceSpy, times(1)).delete(pointModelSecond, pointsOptions);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) ArrayList(java.util.ArrayList) Ignore(org.junit.Ignore) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with PointsOptionsInterface

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

the class PointsServiceTest method testDeleteWithOptions.

@Test
public void testDeleteWithOptions() throws Exception {
    final PointModelInterface pointModel = Models.createPointModel(null, 1, 1);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    this.pointsService.delete(pointModel, pointsOptions);
    verify(pointsOptions).deleteWithRelations(pointModel);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with PointsOptionsInterface

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

the class PointsServiceTest method testFindAllWithOptions.

@Test
public void testFindAllWithOptions() throws Exception {
    final List<PointEntity> pointsEntities = this.getPointsEntities();
    final List<PointModelInterface> pointsModels = this.getPointsModels();
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    given(this.pointsMapper.findAll()).willReturn(pointsEntities);
    given(pointsOptions.withRelations(Mockito.anyList())).willReturn(pointsModels);
    final List<PointModelInterface> foundPointsModels = this.pointsService.findAll(pointsOptions);
    verify(pointsOptions).withRelations(foundPointsModels);
    Assert.assertEquals(pointsModels, foundPointsModels);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) PointEntity(easytests.core.entities.PointEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

PointsOptionsInterface (easytests.core.options.PointsOptionsInterface)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 Test (org.junit.Test)6 PointEntity (easytests.core.entities.PointEntity)3 PointModelInterface (easytests.core.models.PointModelInterface)3 ArrayList (java.util.ArrayList)2 Ignore (org.junit.Ignore)2