Search in sources :

Example 6 with QuizModelEmpty

use of easytests.core.models.empty.QuizModelEmpty 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)

Example 7 with QuizModelEmpty

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

the class TesteesOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
    final TesteesOptionsInterface testeesOptions = new TesteesOptions();
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    final Integer quizId = 3;
    Mockito.when(testeeModel.getQuiz()).thenReturn(new QuizModelEmpty(quizId));
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    Mockito.when(quizModel.getId()).thenReturn(quizId);
    given(quizzesService.find(quizId, quizzesOptions)).willReturn(quizModel);
    final TesteeModelInterface testeeModelWithoutRelations = testeesOptions.withRelations(testeeModel);
    verify(quizzesService, times(0)).find(quizId, quizzesOptions);
    Assert.assertEquals(testeeModel, testeeModelWithoutRelations);
    verify(testeeModel, times(0)).setQuiz(quizModel);
    testeesOptions.setQuizzesService(quizzesService);
    testeesOptions.withQuiz(quizzesOptions);
    final TesteeModelInterface testeeModelWithRelations = testeesOptions.withRelations(testeeModel);
    verify(quizzesService, times(1)).find(quizId, quizzesOptions);
    Assert.assertEquals(testeeModel, testeeModelWithRelations);
    verify(testeeModel, times(1)).setQuiz(quizModel);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) QuizModelEmpty(easytests.core.models.empty.QuizModelEmpty) TesteeModelInterface(easytests.core.models.TesteeModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with QuizModelEmpty

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

the class PointModelTest method testMap.

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

Example 9 with QuizModelEmpty

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

the class TesteesSupport method assertEquals.

public void assertEquals(TesteeEntity expected, TesteeModelInterface actual) {
    assertEquals(actual, expected);
    Assert.assertEquals(new QuizModelEmpty(expected.getQuizId()), actual.getQuiz());
}
Also used : QuizModelEmpty(easytests.core.models.empty.QuizModelEmpty)

Example 10 with QuizModelEmpty

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

the class PointModel method map.

public void map(PointEntity pointEntity) {
    this.setId(pointEntity.getId());
    this.setQuestion(new QuestionModelEmpty(pointEntity.getQuestionId()));
    this.setQuiz(new QuizModelEmpty(pointEntity.getQuizId()));
    this.setSolutions(new ModelsListEmpty());
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) QuizModelEmpty(easytests.core.models.empty.QuizModelEmpty)

Aggregations

QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)13 Test (org.junit.Test)7 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 QuizModelInterface (easytests.core.models.QuizModelInterface)4 TesteeModelInterface (easytests.core.models.TesteeModelInterface)4 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)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 SolutionModelInterface (easytests.core.models.SolutionModelInterface)2 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)2 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)2 PointEntity (easytests.core.entities.PointEntity)1 TesteeEntity (easytests.core.entities.TesteeEntity)1