Search in sources :

Example 1 with SolutionModelInterface

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

the class SolutionsServiceTest method testSaveModelsListWithOptions.

@Test
public void testSaveModelsListWithOptions() 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.save(solutionsModels, solutionsOptions);
    this.assertServicesSet(solutionsOptions, solutionsModels.size());
    verify(solutionsOptions, times(solutionsModels.size())).saveWithRelations(solutionModelCaptor.capture());
    this.solutionsSupport.assertModelsListEquals(solutionsModels, solutionModelCaptor.getAllValues());
    verifyNoMoreInteractions(this.solutionsMapper);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface)

Example 2 with SolutionModelInterface

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

the class SolutionsServiceTest method testFindByPointWithOptions.

@Test
public void testFindByPointWithOptions() throws Exception {
    final ArgumentCaptor<List> listCaptor = ArgumentCaptor.forClass(List.class);
    final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
    final List<SolutionEntity> solutionsEntities = this.getSolutionsFixturesEntities();
    when(this.solutionsMapper.findByPointId(pointModel.getId())).thenReturn(solutionsEntities);
    final List<SolutionModelInterface> solutionsModels = this.getSolutionsFixturesModels();
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    when(solutionsOptions.withRelations(listCaptor.capture())).thenReturn(solutionsModels);
    final List<SolutionModelInterface> solutionsFoundedModels = this.solutionsService.findByPoint(pointModel, solutionsOptions);
    this.assertServicesSet(solutionsOptions);
    this.solutionsSupport.assertModelsListEquals(solutionsModels, listCaptor.getValue());
    Assert.assertSame(solutionsModels, solutionsFoundedModels);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) ArrayList(java.util.ArrayList) List(java.util.List) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface) PointModelInterface(easytests.core.models.PointModelInterface)

Example 3 with SolutionModelInterface

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

the class SolutionsServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    Integer id = 1;
    final SolutionEntity solutionEntity = this.createSolutionEntityMock(id, 2, 3);
    given(this.solutionsMapper.find(id)).willReturn(solutionEntity);
    final SolutionModelInterface solutionModel = this.solutionsService.find(id);
    Assert.assertNotNull(solutionModel);
    Assert.assertEquals(solutionModel, this.mapSolutionModel(solutionEntity));
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with SolutionModelInterface

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

the class SolutionsServiceTest method testDeleteWithOptions.

@Test
public void testDeleteWithOptions() throws Exception {
    final SolutionModelInterface solutionModel = this.createSolutionModel(1, 1, 1);
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    this.solutionsService.delete(solutionModel, solutionsOptions);
    verify(solutionsOptions).deleteWithRelations(solutionModel);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with SolutionModelInterface

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

the class SolutionsServiceTest method testFindByPointAbsentModel.

@Test
public void testFindByPointAbsentModel() throws Exception {
    Integer pointId = 10;
    given(this.solutionsMapper.findByPointId(pointId)).willReturn(new ArrayList<>(0));
    final PointModelInterface pointModel = mock(PointModelInterface.class);
    when(pointModel.getId()).thenReturn(pointId);
    final List<SolutionModelInterface> solutionModels = this.solutionsService.findByPoint(pointModel);
    Assert.assertNotNull(solutionModels);
    Assert.assertEquals(0, solutionModels.size());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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