Search in sources :

Example 1 with SolutionsServiceInterface

use of easytests.core.services.SolutionsServiceInterface 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 2 with SolutionsServiceInterface

use of easytests.core.services.SolutionsServiceInterface in project easy-tests by malinink.

the class PointsOptionsTest method testWithRelationsOnNull.

@Test
public void testWithRelationsOnNull() throws Exception {
    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).withQuestion(questionOptions).withSolutions(solutionsOptions);
    final PointModelInterface nullPointModel = null;
    final PointModelInterface pointModelWithRelations = pointsOptions.withRelations(nullPointModel);
    Assert.assertNull(pointModelWithRelations);
}
Also used : QuestionsServiceInterface(easytests.core.services.QuestionsServiceInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) PointModelInterface(easytests.core.models.PointModelInterface) SolutionsServiceInterface(easytests.core.services.SolutionsServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with SolutionsServiceInterface

use of easytests.core.services.SolutionsServiceInterface in project easy-tests by malinink.

the class PointsOptionsTest method testDeleteWithRelations.

@Test
public void testDeleteWithRelations() throws Exception {
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final PointsOptionsInterface pointsOptions = new PointsOptions();
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final SolutionsServiceInterface solutionsService = Mockito.mock(SolutionsServiceInterface.class);
    pointsOptions.setPointsService(pointsService);
    pointsOptions.setQuizzesService(quizzesService);
    pointsOptions.setSolutionsService(solutionsService);
    final QuizzesOptionsInterface quizOptions = Mockito.mock(QuizzesOptionsInterface.class);
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    pointsOptions.withQuiz(quizOptions);
    pointsOptions.withSolutions(solutionsOptions);
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    final List<SolutionModelInterface> solutionsModels = new ArrayList<>();
    solutionsModels.add(Mockito.mock(SolutionModelInterface.class));
    given(pointModel.getQuiz()).willReturn(quizModel);
    given(pointModel.getSolutions()).willReturn(solutionsModels);
    final InOrder inOrder = Mockito.inOrder(solutionsService, pointsService, quizzesService);
    pointsOptions.deleteWithRelations(pointModel);
    inOrder.verify(solutionsService).delete(solutionsModels, solutionsOptions);
    inOrder.verify(pointsService).delete(pointModel);
    inOrder.verify(quizzesService).delete(quizModel, quizOptions);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) InOrder(org.mockito.InOrder) ArrayList(java.util.ArrayList) PointModelInterface(easytests.core.models.PointModelInterface) QuizModelInterface(easytests.core.models.QuizModelInterface) PointsServiceInterface(easytests.core.services.PointsServiceInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) SolutionsServiceInterface(easytests.core.services.SolutionsServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with SolutionsServiceInterface

use of easytests.core.services.SolutionsServiceInterface in project easy-tests by malinink.

the class PointsOptionsTest method testSaveWithRelations.

@Test
public void testSaveWithRelations() throws Exception {
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final PointsOptionsInterface pointsOptions = new PointsOptions();
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final SolutionsServiceInterface solutionsService = Mockito.mock(SolutionsServiceInterface.class);
    pointsOptions.setPointsService(pointsService);
    pointsOptions.setQuizzesService(quizzesService);
    pointsOptions.setSolutionsService(solutionsService);
    final QuizzesOptionsInterface quizOptions = Mockito.mock(QuizzesOptionsInterface.class);
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    pointsOptions.withQuiz(quizOptions);
    pointsOptions.withSolutions(solutionsOptions);
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    final List<SolutionModelInterface> solutionsModels = new ArrayList<>();
    solutionsModels.add(Mockito.mock(SolutionModelInterface.class));
    given(pointModel.getQuiz()).willReturn(quizModel);
    given(pointModel.getSolutions()).willReturn(solutionsModels);
    final InOrder inOrder = Mockito.inOrder(quizzesService, pointsService, solutionsService);
    pointsOptions.saveWithRelations(pointModel);
    inOrder.verify(quizzesService).save(quizModel, quizOptions);
    inOrder.verify(pointsService).save(pointModel);
    inOrder.verify(solutionsService).save(solutionsModels, solutionsOptions);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) InOrder(org.mockito.InOrder) ArrayList(java.util.ArrayList) PointModelInterface(easytests.core.models.PointModelInterface) QuizModelInterface(easytests.core.models.QuizModelInterface) PointsServiceInterface(easytests.core.services.PointsServiceInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) SolutionsServiceInterface(easytests.core.services.SolutionsServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with SolutionsServiceInterface

use of easytests.core.services.SolutionsServiceInterface in project easy-tests by malinink.

the class SolutionsOptionsTest method testSaveDeleteWithPoint.

@Test
public void testSaveDeleteWithPoint() {
    final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
    final SolutionsOptionsInterface solutionsOptions = new SolutionsOptions();
    final SolutionsServiceInterface solutionsService = Mockito.mock(SolutionsServiceInterface.class);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
    solutionsOptions.setSolutionsService(solutionsService);
    solutionsOptions.setPointsService(pointsService);
    solutionsOptions.withPoint(pointsOptions);
    solutionsOptions.setAnswersService(answersService);
    solutionsOptions.withAnswer(answersOptions);
    final SolutionsOptionsInterface solutionsOptionsSpy = Mockito.spy(solutionsOptions);
    solutionsOptionsSpy.deleteWithRelations(solutionModel);
    verify(pointsOptions, times(1)).deleteWithRelations(solutionModel.getPoint());
/*        solutionsOptionsSpy.saveWithRelations(solutionModel);
        verify(pointsOptions, times(1)).saveWithRelations(solutionModel.getPoint());*/
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) PointsServiceInterface(easytests.core.services.PointsServiceInterface) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) SolutionsServiceInterface(easytests.core.services.SolutionsServiceInterface) Test(org.junit.Test)

Aggregations

SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)8 Test (org.junit.Test)8 PointModelInterface (easytests.core.models.PointModelInterface)7 SolutionModelInterface (easytests.core.models.SolutionModelInterface)7 PointsServiceInterface (easytests.core.services.PointsServiceInterface)5 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 QuizModelInterface (easytests.core.models.QuizModelInterface)4 ArrayList (java.util.ArrayList)4 InOrder (org.mockito.InOrder)4 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)3 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)3 AnswerModelInterface (easytests.core.models.AnswerModelInterface)2 QuestionModelInterface (easytests.core.models.QuestionModelInterface)2 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)2 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)2