Search in sources :

Example 16 with SolutionModelInterface

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

the class SolutionsServiceTest method testSaveUpdateEntityIdOnCreation.

@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
    final Integer id = 5;
    final SolutionModelInterface solutionModel = this.solutionsSupport.getModelAdditionalMock(0);
    doAnswer(invocation -> {
        final SolutionEntity solutionEntity = (SolutionEntity) invocation.getArguments()[0];
        solutionEntity.setId(id);
        return null;
    }).when(this.solutionsMapper).insert(any());
    this.solutionsService.save(solutionModel);
    verify(solutionModel, times(1)).setId(id);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity)

Example 17 with SolutionModelInterface

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

the class SolutionsServiceTest method testSaveCreatesEntity.

@Test
public void testSaveCreatesEntity() throws Exception {
    final ArgumentCaptor<SolutionEntity> solutionEntityCaptor = ArgumentCaptor.forClass(SolutionEntity.class);
    final SolutionModelInterface solutionModel = this.solutionsSupport.getModelAdditionalMock(0);
    this.solutionsService.save(solutionModel);
    verify(this.solutionsMapper, times(1)).insert(solutionEntityCaptor.capture());
    this.solutionsSupport.assertEquals(this.solutionsSupport.getEntityAdditionalMock(0), solutionEntityCaptor.getValue());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity)

Example 18 with SolutionModelInterface

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

the class SolutionsServiceTest method testDeleteModelsListWithOptions.

@Test
public void testDeleteModelsListWithOptions() throws Exception {
    final ArgumentCaptor<SolutionModelInterface> solutionModelCaptor = ArgumentCaptor.forClass(SolutionModelInterface.class);
    final List<SolutionModelInterface> solutionsModels = this.getSolutionsFixturesModels();
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    this.solutionsService.delete(solutionsModels, solutionsOptions);
    this.assertServicesSet(solutionsOptions, solutionsModels.size());
    verify(solutionsOptions, times(solutionsModels.size())).deleteWithRelations(solutionModelCaptor.capture());
    this.solutionsSupport.assertModelsListEquals(solutionsModels, solutionModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.solutionsMapper);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface)

Example 19 with SolutionModelInterface

use of easytests.core.models.SolutionModelInterface 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 20 with SolutionModelInterface

use of easytests.core.models.SolutionModelInterface 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

SolutionModelInterface (easytests.core.models.SolutionModelInterface)35 Test (org.junit.Test)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 PointModelInterface (easytests.core.models.PointModelInterface)14 SolutionEntity (easytests.core.entities.SolutionEntity)9 SolutionsOptionsInterface (easytests.core.options.SolutionsOptionsInterface)8 PointsServiceInterface (easytests.core.services.PointsServiceInterface)7 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)7 ArrayList (java.util.ArrayList)7 AnswerModelInterface (easytests.core.models.AnswerModelInterface)5 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)5 QuizModelInterface (easytests.core.models.QuizModelInterface)4 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)4 InOrder (org.mockito.InOrder)4 SolutionModel (easytests.core.models.SolutionModel)3 QuestionModelInterface (easytests.core.models.QuestionModelInterface)2 AnswerModelEmpty (easytests.core.models.empty.AnswerModelEmpty)2 PointModelEmpty (easytests.core.models.empty.PointModelEmpty)2 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)2 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)2