Search in sources :

Example 1 with PointModelInterface

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

the class PointsServiceTest method testFindByQuizAbsentList.

@Test
public void testFindByQuizAbsentList() throws Exception {
    final QuizModelInterface quizModel = this.quizzesSupport.getModelFixtureMock(0);
    when(this.pointsMapper.findByQuizId(quizModel.getId())).thenReturn(new ArrayList<>(0));
    final List<PointModelInterface> pointFoundedModels = this.pointsService.findByQuiz(quizModel);
    Assert.assertEquals(0, pointFoundedModels.size());
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) PointModelInterface(easytests.core.models.PointModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with PointModelInterface

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

the class PointsServiceTest method testDeleteModelsListWithOptions.

@Test
public void testDeleteModelsListWithOptions() 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.delete(pointsModels, pointsOptions);
    this.assertServicesSet(pointsOptions, pointsModels.size());
    verify(pointsOptions, times(pointsModels.size())).deleteWithRelations(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 3 with PointModelInterface

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

the class PointsServiceTest method testFindByQuizPresentList.

@Test
public void testFindByQuizPresentList() throws Exception {
    final QuizModelInterface quizModel = this.quizzesSupport.getModelFixtureMock(0);
    final List<PointEntity> pointsEntities = this.getPointsFixturesEntities();
    when(this.pointsMapper.findByQuizId(quizModel.getId())).thenReturn(pointsEntities);
    final List<PointModelInterface> pointsFoundedModels = this.pointsService.findByQuiz(quizModel);
    this.pointsSupport.assertModelsListEquals(this.getPointsFixturesModels(), pointsFoundedModels);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) PointEntity(easytests.core.entities.PointEntity) PointModelInterface(easytests.core.models.PointModelInterface) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with PointModelInterface

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

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

the class PointsSupport method assertModelsListEquals.

public void assertModelsListEquals(List<PointModelInterface> expected, List<PointModelInterface> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Integer i = 0;
    for (PointModelInterface pointModel : expected) {
        this.assertEquals(pointModel, actual.get(i));
        i++;
    }
}
Also used : 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