Search in sources :

Example 1 with QuizModelInterface

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

use of easytests.core.models.QuizModelInterface 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 3 with QuizModelInterface

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

the class QuizzesServiceTest method testSaveModelsListWithOptions.

@Test
public void testSaveModelsListWithOptions() throws Exception {
    final ArgumentCaptor<QuizModelInterface> quizModelCaptor = ArgumentCaptor.forClass(QuizModelInterface.class);
    final List<QuizModelInterface> quizzesModels = this.getQuizzesFixturesModels();
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    this.quizzesService.save(quizzesModels, quizzesOptions);
    this.assertServicesSet(quizzesOptions, quizzesModels.size());
    verify(quizzesOptions, times(quizzesModels.size())).saveWithRelations(quizModelCaptor.capture());
    this.quizzesSupport.assertModelsListEquals(quizzesModels, quizModelCaptor.getAllValues());
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) QuizzesOptionsInterface(easytests.core.options.QuizzesOptionsInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with QuizModelInterface

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

the class QuizzesServiceTest method testFindByIssuePresentList.

@Test
public void testFindByIssuePresentList() throws Exception {
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    final List<QuizEntity> quizzesEntities = this.getQuizzesFixturesEntities();
    when(this.quizzesMapper.findByIssueId(issueModel.getId())).thenReturn(quizzesEntities);
    final List<QuizModelInterface> quizzesModels = this.getQuizzesFixturesModels();
    final List<QuizModelInterface> quizzesFoundedModels = this.quizzesService.findByIssue(issueModel);
    this.quizzesSupport.assertModelsListEquals(quizzesModels, quizzesFoundedModels);
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) QuizModelInterface(easytests.core.models.QuizModelInterface) IssueModelInterface(easytests.core.models.IssueModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with QuizModelInterface

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

the class QuizzesServiceTest method testSaveUpdateEntityIdOnCreation.

@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
    final QuizModelInterface quizAdditionalModel = this.quizzesSupport.getModelAdditionalMock(0);
    doAnswer(invocation -> {
        final QuizEntity quizEntity = (QuizEntity) invocation.getArguments()[0];
        quizEntity.setId(5);
        return null;
    }).when(this.quizzesMapper).insert(Mockito.any(QuizEntity.class));
    this.quizzesService.save(quizAdditionalModel);
    verify(quizAdditionalModel, times(1)).setId(5);
}
Also used : QuizEntity(easytests.core.entities.QuizEntity) QuizModelInterface(easytests.core.models.QuizModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

QuizModelInterface (easytests.core.models.QuizModelInterface)48 Test (org.junit.Test)42 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)42 ArrayList (java.util.ArrayList)17 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)15 IssueModelInterface (easytests.core.models.IssueModelInterface)11 PointModelInterface (easytests.core.models.PointModelInterface)11 TesteeModelInterface (easytests.core.models.TesteeModelInterface)11 QuizzesOptionsInterface (easytests.core.options.QuizzesOptionsInterface)9 InOrder (org.mockito.InOrder)8 QuizEntity (easytests.core.entities.QuizEntity)7 PointsServiceInterface (easytests.core.services.PointsServiceInterface)7 TesteesServiceInterface (easytests.core.services.TesteesServiceInterface)7 IssuesServiceInterface (easytests.core.services.IssuesServiceInterface)6 SolutionModelInterface (easytests.core.models.SolutionModelInterface)4 IssueModelEmpty (easytests.core.models.empty.IssueModelEmpty)4 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)4 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)4 QuestionModelInterface (easytests.core.models.QuestionModelInterface)3 QuizModel (easytests.core.models.QuizModel)2