Search in sources :

Example 21 with PointModelInterface

use of easytests.core.models.PointModelInterface 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 22 with PointModelInterface

use of easytests.core.models.PointModelInterface in project easy-tests by malinink.

the class PointsServiceTest method testSaveUpdateEntityIdOnCreation.

@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
    final Integer id = 5;
    final PointModelInterface pointModel = this.pointsSupport.getModelAdditionalMock(0);
    doAnswer(invocation -> {
        final PointEntity answerEntity = (PointEntity) invocation.getArguments()[0];
        answerEntity.setId(id);
        return null;
    }).when(this.pointsMapper).insert(any());
    this.pointsService.save(pointModel);
    verify(pointModel, times(1)).setId(id);
}
Also used : PointEntity(easytests.core.entities.PointEntity) PointModelInterface(easytests.core.models.PointModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 23 with PointModelInterface

use of easytests.core.models.PointModelInterface in project easy-tests by malinink.

the class PointsServiceTest method testFindAbsentModel.

@Test
public void testFindAbsentModel() throws Exception {
    final Integer absentId = 10;
    when(this.pointsMapper.find(absentId)).thenReturn(null);
    final PointModelInterface pointFoundedModel = this.pointsService.find(absentId);
    Assert.assertNull(pointFoundedModel);
}
Also used : PointModelInterface(easytests.core.models.PointModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 24 with PointModelInterface

use of easytests.core.models.PointModelInterface in project easy-tests by malinink.

the class SolutionsServiceTest method testFindByPointAbsentList.

@Test
public void testFindByPointAbsentList() throws Exception {
    final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
    when(this.solutionsMapper.findByPointId(pointModel.getId())).thenReturn(new ArrayList<>(0));
    final List<SolutionModelInterface> solutionsFoundedModels = this.solutionsService.findByPoint(pointModel);
    Assert.assertEquals(0, solutionsFoundedModels.size());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) PointModelInterface(easytests.core.models.PointModelInterface)

Example 25 with PointModelInterface

use of easytests.core.models.PointModelInterface in project easy-tests by malinink.

the class SolutionsServiceTest method testFindByPointPresentList.

@Test
public void testFindByPointPresentList() throws Exception {
    final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
    final List<SolutionEntity> solutionsEntities = this.getSolutionsFixturesEntities();
    when(this.solutionsMapper.findByPointId(pointModel.getId())).thenReturn(solutionsEntities);
    final List<SolutionModelInterface> solutionsFoundedModels = this.solutionsService.findByPoint(pointModel);
    this.solutionsSupport.assertModelsListEquals(this.getSolutionsFixturesModels(), solutionsFoundedModels);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) PointModelInterface(easytests.core.models.PointModelInterface)

Aggregations

PointModelInterface (easytests.core.models.PointModelInterface)32 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)21 Test (org.junit.Test)17 SolutionModelInterface (easytests.core.models.SolutionModelInterface)14 QuizModelInterface (easytests.core.models.QuizModelInterface)11 PointsServiceInterface (easytests.core.services.PointsServiceInterface)10 ArrayList (java.util.ArrayList)10 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)8 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)7 InOrder (org.mockito.InOrder)6 AnswerModelInterface (easytests.core.models.AnswerModelInterface)5 TesteeModelInterface (easytests.core.models.TesteeModelInterface)4 TesteesServiceInterface (easytests.core.services.TesteesServiceInterface)4 PointEntity (easytests.core.entities.PointEntity)3 SolutionEntity (easytests.core.entities.SolutionEntity)3 QuestionModelInterface (easytests.core.models.QuestionModelInterface)3 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)3 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)3 PointsOptionsInterface (easytests.core.options.PointsOptionsInterface)3 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)3