Search in sources :

Example 6 with PointsServiceInterface

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

the class QuizzesOptionsTest method testDeleteWithRelations.

@Test
public void testDeleteWithRelations() 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.withPoints(pointsOptions);
    quizzesOptions.withTestee(testeesOptions);
    final List<PointModelInterface> pointsModels = new ArrayList<>();
    quizModel.setPoints(pointsModels);
    final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
    quizModel.setTestee(testeeModel);
    final InOrder inOrder = Mockito.inOrder(pointsService, quizzesService, testeesService);
    quizzesOptions.deleteWithRelations(quizModel);
    inOrder.verify(pointsService).delete(quizModel.getPoints(), pointsOptions);
    inOrder.verify(quizzesService).delete(quizModel);
    inOrder.verify(testeesService).delete(quizModel.getTestee(), testeesOptions);
}
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)

Example 7 with PointsServiceInterface

use of easytests.core.services.PointsServiceInterface 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)

Example 8 with PointsServiceInterface

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

the class SolutionsOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
    solutionModel.setId(1);
    given(solutionModel.getPoint()).willReturn(new PointModelEmpty(1));
    given(solutionModel.getAnswer()).willReturn(new AnswerModelEmpty(1));
    final SolutionsOptionsInterface solutionsOptions = new SolutionsOptions();
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    final AnswersOptionsInterface answerOptions = Mockito.mock(AnswersOptionsInterface.class);
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
    solutionsOptions.setPointsService(pointsService);
    solutionsOptions.setAnswersService(answersService);
    solutionsOptions.withPoint(pointsOptions);
    solutionsOptions.withAnswer(answerOptions);
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    given(pointsService.find(solutionModel.getPoint().getId(), pointsOptions)).willReturn(pointModel);
    given(answersService.find(solutionModel.getAnswer().getId(), answerOptions)).willReturn(answerModel);
    final SolutionModelInterface solutionModelWithRelations = solutionsOptions.withRelations(solutionModel);
    Assert.assertEquals(solutionModel, solutionModelWithRelations);
    verify(pointsService).find(solutionModel.getPoint().getId(), pointsOptions);
    verify(answersService).find(solutionModel.getAnswer().getId(), answerOptions);
    verify(solutionModel).setPoint(pointModel);
    verify(solutionModel).setAnswer(answerModel);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) AnswerModelEmpty(easytests.core.models.empty.AnswerModelEmpty) PointsServiceInterface(easytests.core.services.PointsServiceInterface) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) PointModelEmpty(easytests.core.models.empty.PointModelEmpty) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test)

Example 9 with PointsServiceInterface

use of easytests.core.services.PointsServiceInterface 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 10 with PointsServiceInterface

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

the class QuizzesOptionsTest method testWithRelationsOnNull.

@Test
public void testWithRelationsOnNull() throws Exception {
    final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
    final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
    final TesteesOptionsInterface testeesOptions = Mockito.mock(TesteesOptionsInterface.class);
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    final IssuesOptionsInterface issueOptions = Mockito.mock(IssuesOptionsInterface.class);
    quizzesOptions.setTesteesService(testeesService);
    quizzesOptions.setPointsService(pointsService);
    quizzesOptions.setIssuesService(issuesService);
    quizzesOptions.withPoints(pointsOptions).withIssue(issueOptions).withTestee(testeesOptions);
    final QuizModelInterface nullQuizModel = null;
    final QuizModelInterface quizModelWithRelations = quizzesOptions.withRelations(nullQuizModel);
    Assert.assertNull(quizModelWithRelations);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) IssuesServiceInterface(easytests.core.services.IssuesServiceInterface) PointsServiceInterface(easytests.core.services.PointsServiceInterface) TesteesServiceInterface(easytests.core.services.TesteesServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

PointsServiceInterface (easytests.core.services.PointsServiceInterface)13 Test (org.junit.Test)13 PointModelInterface (easytests.core.models.PointModelInterface)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 QuizModelInterface (easytests.core.models.QuizModelInterface)7 SolutionModelInterface (easytests.core.models.SolutionModelInterface)7 ArrayList (java.util.ArrayList)6 InOrder (org.mockito.InOrder)6 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)5 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)5 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)5 TesteesServiceInterface (easytests.core.services.TesteesServiceInterface)5 TesteeModelInterface (easytests.core.models.TesteeModelInterface)4 AnswerModelInterface (easytests.core.models.AnswerModelInterface)3 IssuesServiceInterface (easytests.core.services.IssuesServiceInterface)3 IssueModelInterface (easytests.core.models.IssueModelInterface)2 IssueModelEmpty (easytests.core.models.empty.IssueModelEmpty)2 AnswerModelEmpty (easytests.core.models.empty.AnswerModelEmpty)1 PointModelEmpty (easytests.core.models.empty.PointModelEmpty)1