Search in sources :

Example 26 with SolutionModelInterface

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

the class SolutionsServiceTest method testSaveInsertsEntity.

@Test
public void testSaveInsertsEntity() throws Exception {
    final SolutionModelInterface solutionModel = this.createSolutionModel(null, 13, 4);
    final Integer id = 5;
    doAnswer(invocations -> {
        final SolutionEntity solutionEntity = (SolutionEntity) invocations.getArguments()[0];
        solutionEntity.setId(id);
        return null;
    }).when(this.solutionsMapper).insert(Mockito.any(SolutionEntity.class));
    this.solutionsService.save(solutionModel);
    verify(this.solutionsMapper, times(1)).insert(this.mapSolutionEntity(solutionModel));
    Assert.assertEquals(id, solutionModel.getId());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 27 with SolutionModelInterface

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

the class SolutionsServiceTest method testFindAllWithOptions.

@Test
public void testFindAllWithOptions() throws Exception {
    final List<SolutionEntity> solutionsEntities = this.getSolutionsEntities();
    final List<SolutionModelInterface> solutionsModels = this.getSolutionsModels(solutionsEntities);
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    given(this.solutionsMapper.findAll()).willReturn(solutionsEntities);
    given(solutionsOptions.withRelations(Mockito.anyList())).willReturn(solutionsModels);
    final List<SolutionModelInterface> foundedSolutionsModels = this.solutionsService.findAll(solutionsOptions);
    verify(solutionsOptions).withRelations(solutionsModels);
    Assert.assertEquals(solutionsModels, foundedSolutionsModels);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 28 with SolutionModelInterface

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

the class SolutionsServiceTest method testSaveEntitiesList.

@Test
public void testSaveEntitiesList() throws Exception {
    final SolutionModelInterface solutionModelFirst = this.createSolutionModel(1, 13, 4);
    final SolutionModelInterface solutionModelSecond = this.createSolutionModel(2, 10, 3);
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    final List<SolutionModelInterface> solutionModels = new ArrayList<>();
    solutionModels.add(solutionModelFirst);
    solutionModels.add(solutionModelSecond);
    final SolutionsServiceInterface solutionsServiceSpy = Mockito.spy(solutionsService);
    solutionsServiceSpy.save(solutionModels);
    verify(solutionsServiceSpy, times(1)).save(solutionModelFirst);
    verify(solutionsServiceSpy, times(1)).save(solutionModelSecond);
    solutionsServiceSpy.save(solutionModels, solutionsOptions);
    verify(solutionsServiceSpy, times(1)).save(solutionModelFirst, solutionsOptions);
    verify(solutionsServiceSpy, times(1)).save(solutionModelSecond, solutionsOptions);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) ArrayList(java.util.ArrayList) SolutionsOptionsInterface(easytests.core.options.SolutionsOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 29 with SolutionModelInterface

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

the class SolutionsServiceTest method mapSolutionModel.

private SolutionModelInterface mapSolutionModel(SolutionEntity solutionEntity) {
    final SolutionModelInterface solutionModel = new SolutionModel();
    solutionModel.map(solutionEntity);
    return solutionModel;
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionModel(easytests.core.models.SolutionModel)

Example 30 with SolutionModelInterface

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

the class SolutionsServiceTest method testSaveUpdatesEntity.

@Test
public void testSaveUpdatesEntity() throws Exception {
    final SolutionModelInterface solutionModel = this.createSolutionModel(1, 10, 1);
    this.solutionsService.save(solutionModel);
    verify(this.solutionsMapper, times(1)).update(this.mapSolutionEntity(solutionModel));
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) 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