Search in sources :

Example 6 with PointsOptionsInterface

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

the class PointsServiceTest method testDeleteModelWithOptions.

@Test
public void testDeleteModelWithOptions() throws Exception {
    final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    this.pointsService.delete(pointModel, pointsOptions);
    this.assertServicesSet(pointsOptions);
    verify(pointsOptions, times(1)).deleteWithRelations(pointModel);
    verifyNoMoreInteractions(this.pointsMapper);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) PointModelInterface(easytests.core.models.PointModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with PointsOptionsInterface

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

the class PointsServiceTest method testSaveModelsListWithOptions.

@Test
public void testSaveModelsListWithOptions() 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.save(pointsModels, pointsOptions);
    this.assertServicesSet(pointsOptions, pointsModels.size());
    verify(pointsOptions, times(pointsModels.size())).saveWithRelations(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 8 with PointsOptionsInterface

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

the class PointsServiceTest method testFindByQuizWithOptions.

@Test
@Ignore
public void testFindByQuizWithOptions() throws Exception {
    final Integer quizId = 5;
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    Mockito.when(quizModel.getId()).thenReturn(quizId);
    final PointEntity pointEntityFirst = Entities.createPointEntityMock(1, 1, 1);
    final PointEntity pointEntitySecond = Entities.createPointEntityMock(4, 4, 4);
    final List<PointEntity> pointsEntities = new ArrayList<>();
    pointsEntities.add(pointEntityFirst);
    pointsEntities.add(pointEntitySecond);
    given(this.pointsMapper.findByQuizId(quizId)).willReturn(pointsEntities);
    final List<PointModelInterface> pointsModels = new ArrayList<>();
    pointsModels.add(this.mapPointModel(pointEntityFirst));
    pointsModels.add(this.mapPointModel(pointEntitySecond));
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptions.class);
    given(pointsOptions.withRelations(pointsModels)).willReturn(pointsModels);
    final List<PointModelInterface> foundPointsModels = this.pointsService.findByQuiz(quizModel);
    verify(this.pointsMapper).findByQuizId(quizId);
    verify(pointsOptions).withRelations(pointsModels);
    Assert.assertEquals(pointsModels, foundPointsModels);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) ArrayList(java.util.ArrayList) PointEntity(easytests.core.entities.PointEntity) Ignore(org.junit.Ignore) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with PointsOptionsInterface

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

the class PointsServiceTest method testSaveWithOptions.

@Test
public void testSaveWithOptions() throws Exception {
    final PointModelInterface pointModel = Models.createPointModel(null, 1, 1);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    this.pointsService.save(pointModel, pointsOptions);
    verify(pointsOptions).saveWithRelations(pointModel);
}
Also used : PointsOptionsInterface(easytests.core.options.PointsOptionsInterface) 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