Search in sources :

Example 11 with PointModelInterface

use of easytests.core.models.PointModelInterface 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 12 with PointModelInterface

use of easytests.core.models.PointModelInterface 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 13 with PointModelInterface

use of easytests.core.models.PointModelInterface 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 14 with PointModelInterface

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

the class QuizzesOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() throws Exception {
    final QuizModelInterface quizModelFirst = Mockito.mock(QuizModelInterface.class);
    quizModelFirst.setId(1);
    given(quizModelFirst.getIssue()).willReturn(new IssueModelEmpty(1));
    final QuizModelInterface quizModelSecond = Mockito.mock(QuizModelInterface.class);
    quizModelSecond.setId(2);
    given(quizModelSecond.getIssue()).willReturn(new IssueModelEmpty(2));
    final List<QuizModelInterface> quizzesModels = new ArrayList<>(2);
    quizzesModels.add(quizModelFirst);
    quizzesModels.add(quizModelSecond);
    final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
    final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
    final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
    final IssuesOptionsInterface issueOptions = Mockito.mock(IssuesOptionsInterface.class);
    quizzesOptions.setTesteesService(testeesService);
    quizzesOptions.setPointsService(pointsService);
    quizzesOptions.setIssuesService(issuesService);
    quizzesOptions.withTestee(testeesOptions);
    quizzesOptions.withPoints(pointsOptions);
    quizzesOptions.withIssue(issueOptions);
    final List<PointModelInterface> pointsModelsFirst = new ArrayList<>();
    pointsModelsFirst.add(Mockito.mock(PointModelInterface.class));
    final List<PointModelInterface> pointsModelsSecond = new ArrayList<>();
    pointsModelsSecond.add(Mockito.mock(PointModelInterface.class));
    pointsModelsSecond.add(Mockito.mock(PointModelInterface.class));
    given(pointsService.findByQuiz(quizModelFirst, pointsOptions)).willReturn(pointsModelsFirst);
    given(pointsService.findByQuiz(quizModelSecond, pointsOptions)).willReturn(pointsModelsSecond);
    final IssueModelInterface issueModelFirst = Mockito.mock(IssueModelInterface.class);
    final IssueModelInterface issueModelSecond = Mockito.mock(IssueModelInterface.class);
    given(issuesService.find(1, issueOptions)).willReturn(issueModelFirst);
    given(issuesService.find(2, issueOptions)).willReturn(issueModelSecond);
    final TesteeModelInterface testeeModelFirst = Mockito.mock(TesteeModelInterface.class);
    final TesteeModelInterface testeeModelSecond = Mockito.mock(TesteeModelInterface.class);
    given(testeesService.findByQuiz(quizModelFirst, testeesOptions)).willReturn(testeeModelFirst);
    given(testeesService.findByQuiz(quizModelSecond, testeesOptions)).willReturn(testeeModelSecond);
    final List<QuizModelInterface> quizzesModelsWithRelations = quizzesOptions.withRelations(quizzesModels);
    Assert.assertEquals(quizzesModelsWithRelations, quizzesModels);
    verify(testeesService).findByQuiz(quizModelFirst, testeesOptions);
    verify(pointsService).findByQuiz(quizModelFirst, pointsOptions);
    verify(issuesService).find(1, issueOptions);
    verify(quizzesModels.get(0)).setPoints(pointsModelsFirst);
    verify(quizzesModels.get(0)).setPoints(Mockito.anyList());
    verify(quizzesModels.get(0)).setIssue(issueModelFirst);
    verify(quizzesModels.get(0)).setTestee(testeeModelFirst);
    verify(testeesService).findByQuiz(quizModelSecond, testeesOptions);
    verify(pointsService).findByQuiz(quizModelSecond, pointsOptions);
    verify(issuesService).find(2, issueOptions);
    verify(quizzesModels.get(1)).setPoints(pointsModelsSecond);
    verify(quizzesModels.get(1)).setPoints(Mockito.anyList());
    verify(quizzesModels.get(1)).setIssue(issueModelSecond);
    verify(quizzesModels.get(1)).setTestee(testeeModelSecond);
}
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 15 with PointModelInterface

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

the class QuizzesOptionsTest method testSaveWithRelations.

@Test
public void testSaveWithRelations() throws Exception {
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
    final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    quizzesOptions.setTesteesService(testeesService);
    quizzesOptions.setQuizzesService(quizzesService);
    quizzesOptions.setPointsService(pointsService);
    quizzesOptions.withTestee(testeesOptions);
    quizzesOptions.withPoints(pointsOptions);
    final List<PointModelInterface> pointsModels = new ArrayList<>();
    quizModel.setPoints(pointsModels);
    final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
    quizModel.setTestee(testeeModel);
    final InOrder inOrder = Mockito.inOrder(quizzesService, testeesService, pointsService);
    quizzesOptions.saveWithRelations(quizModel);
    inOrder.verify(quizzesService).save(quizModel);
    inOrder.verify(testeesService).save(quizModel.getTestee(), testeesOptions);
    inOrder.verify(pointsService).save(quizModel.getPoints(), pointsOptions);
}
Also used : InOrder(org.mockito.InOrder) ArrayList(java.util.ArrayList) PointModelInterface(easytests.core.models.PointModelInterface) QuizModelInterface(easytests.core.models.QuizModelInterface) PointsServiceInterface(easytests.core.services.PointsServiceInterface) TesteesServiceInterface(easytests.core.services.TesteesServiceInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) TesteeModelInterface(easytests.core.models.TesteeModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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