Search in sources :

Example 1 with QuestionModelEmpty

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

the class AnswersSupport method getModelMock.

private AnswerModelInterface getModelMock(Integer id, String txt, Integer questionId, Integer serialNumber, Boolean right) {
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    Mockito.when(answerModel.getId()).thenReturn(id);
    Mockito.when(answerModel.getTxt()).thenReturn(txt);
    Mockito.when(answerModel.getQuestion()).thenReturn(new QuestionModelEmpty(questionId));
    Mockito.when(answerModel.getSerialNumber()).thenReturn(serialNumber);
    Mockito.when(answerModel.getRight()).thenReturn(right);
    return answerModel;
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) AnswerModelInterface(easytests.core.models.AnswerModelInterface)

Example 2 with QuestionModelEmpty

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

the class PointsSupport method getModelMock.

private PointModelInterface getModelMock(Integer id, Integer quizId, Integer questionId) {
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    Mockito.when(pointModel.getId()).thenReturn(id);
    Mockito.when(pointModel.getQuestion()).thenReturn(new QuestionModelEmpty(questionId));
    Mockito.when(pointModel.getQuiz()).thenReturn(new QuizModelEmpty(quizId));
    Mockito.when(pointModel.getSolutions()).thenReturn(new ModelsListEmpty());
    return pointModel;
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) QuizModelEmpty(easytests.core.models.empty.QuizModelEmpty) PointModelInterface(easytests.core.models.PointModelInterface)

Example 3 with QuestionModelEmpty

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

the class PointsSupport method assertEquals.

public void assertEquals(PointEntity expected, PointModelInterface actual) {
    assertEquals(actual, expected);
    Assert.assertEquals(new QuestionModelEmpty(expected.getQuestionId()), actual.getQuestion());
    Assert.assertEquals(new ModelsListEmpty(), actual.getSolutions());
    Assert.assertEquals(new QuizModelEmpty(expected.getQuizId()), actual.getQuiz());
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) QuizModelEmpty(easytests.core.models.empty.QuizModelEmpty)

Example 4 with QuestionModelEmpty

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

the class AnswerModel method map.

public void map(AnswerEntity answerEntity) {
    this.setId(answerEntity.getId());
    this.setTxt(answerEntity.getTxt());
    this.setSerialNumber(answerEntity.getSerialNumber());
    this.setQuestion(new QuestionModelEmpty(answerEntity.getQuestionId()));
    this.setRight(answerEntity.getRight());
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty)

Example 5 with QuestionModelEmpty

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

the class PointsOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    final PointsOptionsInterface pointsOptions = new PointsOptions();
    pointModel.setId(1);
    given(pointModel.getQuiz()).willReturn(new QuizModelEmpty(1));
    given(pointModel.getQuestion()).willReturn(new QuestionModelEmpty(1));
    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 quizModel = Mockito.mock(QuizModelInterface.class);
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    final List<SolutionModelInterface> solutionsModels = new ArrayList<>();
    solutionsModels.add(Mockito.mock(SolutionModelInterface.class));
    given(quizzesService.find(pointModel.getQuiz().getId(), quizOptions)).willReturn(quizModel);
    given(questionsService.find(pointModel.getQuestion().getId(), questionOptions)).willReturn(questionModel);
    given(solutionsService.findByPoint(pointModel, solutionsOptions)).willReturn(solutionsModels);
    final PointModelInterface pointModelWithRelations = pointsOptions.withRelations(pointModel);
    Assert.assertEquals(pointModel, pointModelWithRelations);
    verify(quizzesService).find(1, quizOptions);
    verify(questionsService).find(1, questionOptions);
    verify(solutionsService).findByPoint(pointModel, solutionsOptions);
    verify(pointModel).setQuiz(quizModel);
    verify(pointModel).setQuestion(questionModel);
    verify(pointModel).setSolutions(solutionsModels);
}
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)

Aggregations

QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)13 Test (org.junit.Test)7 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)4 PointModelInterface (easytests.core.models.PointModelInterface)3 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)3 ArrayList (java.util.ArrayList)3 QuestionModelInterface (easytests.core.models.QuestionModelInterface)2 QuizModelInterface (easytests.core.models.QuizModelInterface)2 SolutionModelInterface (easytests.core.models.SolutionModelInterface)2 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)2 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)2 AnswerEntity (easytests.core.entities.AnswerEntity)1 PointEntity (easytests.core.entities.PointEntity)1 AnswerModelInterface (easytests.core.models.AnswerModelInterface)1