Search in sources :

Example 26 with PointModelInterface

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

the class SolutionEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer id = 1;
    final Integer answerId = 10;
    final Integer pointId = 3;
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    Mockito.when(answerModel.getId()).thenReturn(answerId);
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    Mockito.when(pointModel.getId()).thenReturn(pointId);
    final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
    Mockito.when(solutionModel.getId()).thenReturn(id);
    Mockito.when(solutionModel.getAnswer()).thenReturn(answerModel);
    Mockito.when(solutionModel.getPoint()).thenReturn(pointModel);
    final SolutionEntity solutionEntity = new SolutionEntity();
    solutionEntity.map(solutionModel);
    assertEquals(id, solutionEntity.getId());
    assertEquals(answerId, solutionEntity.getAnswerId());
    assertEquals(pointId, solutionEntity.getPointId());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test)

Example 27 with PointModelInterface

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

the class SolutionsServiceTest method testFindByPointPresentModel.

@Test
public void testFindByPointPresentModel() throws Exception {
    Integer pointId = 1;
    final List<SolutionEntity> solutionEntities = new ArrayList<>(2);
    solutionEntities.add(this.createSolutionEntityMock(1, 10, pointId));
    solutionEntities.add(this.createSolutionEntityMock(2, 20, pointId));
    given(this.solutionsMapper.findByPointId(pointId)).willReturn(solutionEntities);
    final PointModelInterface pointModel = mock(PointModelInterface.class);
    when(pointModel.getId()).thenReturn(pointId);
    final List<SolutionModelInterface> solutionModels = this.solutionsService.findByPoint(pointModel);
    Assert.assertNotNull(solutionModels);
    Assert.assertEquals(solutionEntities.size(), solutionModels.size());
    for (int i = 0; i < solutionEntities.size(); i++) {
        Assert.assertEquals(solutionModels.get(i), this.mapSolutionModel(solutionEntities.get(i)));
    }
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionEntity(easytests.core.entities.SolutionEntity) ArrayList(java.util.ArrayList) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 28 with PointModelInterface

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

the class PointsOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() throws Exception {
    final PointModelInterface pointModelFirst = Mockito.mock(PointModelInterface.class);
    final PointModelInterface pointModelSecond = Mockito.mock(PointModelInterface.class);
    pointModelFirst.setId(1);
    pointModelSecond.setId(2);
    given(pointModelFirst.getQuiz()).willReturn(new QuizModelEmpty(1));
    given(pointModelSecond.getQuiz()).willReturn(new QuizModelEmpty(2));
    given(pointModelFirst.getQuestion()).willReturn(new QuestionModelEmpty(1));
    given(pointModelSecond.getQuestion()).willReturn(new QuestionModelEmpty(2));
    final List<PointModelInterface> pointsModels = new ArrayList<>();
    pointsModels.add(pointModelFirst);
    pointsModels.add(pointModelSecond);
    final PointsOptionsInterface pointsOptions = new PointsOptions();
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
    final SolutionsServiceInterface solutionsService = Mockito.mock(SolutionsServiceInterface.class);
    pointsOptions.setQuizzesService(quizzesService);
    pointsOptions.setQuestionsService(questionsService);
    pointsOptions.setSolutionsService(solutionsService);
    final QuizzesOptionsInterface quizOptions = Mockito.mock(QuizzesOptionsInterface.class);
    final QuestionsOptionsInterface questionOptions = Mockito.mock(QuestionsOptionsInterface.class);
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    pointsOptions.withQuiz(quizOptions);
    pointsOptions.withQuestion(questionOptions);
    pointsOptions.withSolutions(solutionsOptions);
    final QuizModelInterface quizModelFirst = Mockito.mock(QuizModelInterface.class);
    final QuizModelInterface quizModelSecond = Mockito.mock(QuizModelInterface.class);
    given(quizzesService.find(1, quizOptions)).willReturn(quizModelFirst);
    given(quizzesService.find(2, quizOptions)).willReturn(quizModelSecond);
    final QuestionModelInterface questionModelFirst = Mockito.mock(QuestionModelInterface.class);
    final QuestionModelInterface questionModelSecond = Mockito.mock(QuestionModelInterface.class);
    given(questionsService.find(1, questionOptions)).willReturn(questionModelFirst);
    given(questionsService.find(2, questionOptions)).willReturn(questionModelSecond);
    final List<SolutionModelInterface> solutionsModelsFirst = new ArrayList<>();
    solutionsModelsFirst.add(Mockito.mock(SolutionModelInterface.class));
    final List<SolutionModelInterface> solutionsModelsSecond = new ArrayList<>();
    solutionsModelsSecond.add(Mockito.mock(SolutionModelInterface.class));
    solutionsModelsSecond.add(Mockito.mock(SolutionModelInterface.class));
    given(solutionsService.findByPoint(pointModelFirst, solutionsOptions)).willReturn(solutionsModelsFirst);
    given(solutionsService.findByPoint(pointModelSecond, solutionsOptions)).willReturn(solutionsModelsSecond);
    final List<PointModelInterface> pointsModelsWithRelations = pointsOptions.withRelations(pointsModels);
    Assert.assertEquals(pointsModels, pointsModelsWithRelations);
    verify(quizzesService).find(1, quizOptions);
    verify(questionsService).find(1, questionOptions);
    verify(solutionsService).findByPoint(pointModelFirst, solutionsOptions);
    verify(pointsModels.get(0)).setQuiz(quizModelFirst);
    verify(pointsModels.get(0)).setQuestion(questionModelFirst);
    verify(pointsModels.get(0)).setSolutions(solutionsModelsFirst);
    verify(pointsModels.get(0)).setSolutions(Mockito.anyList());
    verify(quizzesService).find(2, quizOptions);
    verify(questionsService).find(2, questionOptions);
    verify(solutionsService).findByPoint(pointModelSecond, solutionsOptions);
    verify(pointsModels.get(1)).setQuiz(quizModelSecond);
    verify(pointsModels.get(1)).setQuestion(questionModelSecond);
    verify(pointsModels.get(1)).setSolutions(solutionsModelsSecond);
    verify(pointsModels.get(1)).setSolutions(Mockito.anyList());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) QuestionModelInterface(easytests.core.models.QuestionModelInterface) ArrayList(java.util.ArrayList) PointModelInterface(easytests.core.models.PointModelInterface) QuizModelInterface(easytests.core.models.QuizModelInterface) QuestionsServiceInterface(easytests.core.services.QuestionsServiceInterface) QuizModelEmpty(easytests.core.models.empty.QuizModelEmpty) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) SolutionsServiceInterface(easytests.core.services.SolutionsServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 29 with PointModelInterface

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

the class QuizzesOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    quizModel.setId(1);
    given(quizModel.getIssue()).willReturn(new IssueModelEmpty(1));
    final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final TesteesServiceInterface testeeService = Mockito.mock(TesteesServiceInterface.class);
    final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    final TesteesOptionsInterface testeeOptions = Mockito.mock(TesteesOptionsInterface.class);
    final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
    quizzesOptions.setPointsService(pointsService);
    quizzesOptions.setIssuesService(issuesService);
    quizzesOptions.setTesteesService(testeeService);
    quizzesOptions.withTestee(testeeOptions);
    quizzesOptions.withPoints(pointsOptions);
    quizzesOptions.withIssue(issuesOptions);
    final List<PointModelInterface> pointsModels = new ArrayList<>();
    pointsModels.add(Mockito.mock(PointModelInterface.class));
    final IssueModelInterface issueModel = Mockito.mock(IssueModelInterface.class);
    final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
    given(testeeService.findByQuiz(quizModel, testeeOptions)).willReturn(testeeModel);
    given(pointsService.findByQuiz(quizModel, pointsOptions)).willReturn(pointsModels);
    given(issuesService.find(quizModel.getIssue().getId(), issuesOptions)).willReturn(issueModel);
    final QuizModelInterface quizModelWithRelations = quizzesOptions.withRelations(quizModel);
    Assert.assertEquals(quizModel, quizModelWithRelations);
    verify(testeeService).findByQuiz(quizModel, testeeOptions);
    verify(pointsService).findByQuiz(quizModel, pointsOptions);
    verify(issuesService).find(1, issuesOptions);
    verify(quizModel).setTestee(testeeModel);
    verify(quizModel).setPoints(pointsModels);
    verify(quizModel).setIssue(issueModel);
}
Also used : IssuesServiceInterface(easytests.core.services.IssuesServiceInterface) ArrayList(java.util.ArrayList) PointModelInterface(easytests.core.models.PointModelInterface) IssueModelEmpty(easytests.core.models.empty.IssueModelEmpty) QuizModelInterface(easytests.core.models.QuizModelInterface) PointsServiceInterface(easytests.core.services.PointsServiceInterface) TesteesServiceInterface(easytests.core.services.TesteesServiceInterface) IssueModelInterface(easytests.core.models.IssueModelInterface) TesteeModelInterface(easytests.core.models.TesteeModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 30 with PointModelInterface

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

the class PointEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer pointId = 3;
    final Integer questionId = 1;
    final Integer quizId = 2;
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    Mockito.when(questionModel.getId()).thenReturn(questionId);
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    Mockito.when(quizModel.getId()).thenReturn(quizId);
    Mockito.when(pointModel.getId()).thenReturn(pointId);
    Mockito.when(pointModel.getQuestion()).thenReturn(questionModel);
    Mockito.when(pointModel.getQuiz()).thenReturn(quizModel);
    final PointEntity pointEntity = new PointEntity();
    pointEntity.map(pointModel);
    Assert.assertEquals(pointId, pointEntity.getId());
    Assert.assertEquals(questionId, pointEntity.getQuestionId());
    Assert.assertEquals(quizId, pointEntity.getQuizId());
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) QuestionModelInterface(easytests.core.models.QuestionModelInterface) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test)

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