Search in sources :

Example 6 with QuizzesServiceInterface

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

Example 7 with QuizzesServiceInterface

use of easytests.core.services.QuizzesServiceInterface 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 8 with QuizzesServiceInterface

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

the class QuizzesOptionsTest method testSaveDeleteWithIssue.

@Test
public void testSaveDeleteWithIssue() {
    final QuizzesOptionsInterface quizzesOptions = new QuizzesOptions();
    final IssuesOptionsInterface issuesOptions = Mockito.mock(IssuesOptionsInterface.class);
    final IssuesServiceInterface issuesService = Mockito.mock(IssuesServiceInterface.class);
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    quizzesOptions.setQuizzesService(quizzesService);
    quizzesOptions.setIssuesService(issuesService);
    quizzesOptions.withIssue(issuesOptions);
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    final QuizzesOptionsInterface quizzesOptionsSpy = Mockito.spy(quizzesOptions);
    quizzesOptionsSpy.deleteWithRelations(quizModel);
    verify(issuesService, times(1)).delete(quizModel.getIssue(), issuesOptions);
    quizzesOptionsSpy.saveWithRelations(quizModel);
    verify(issuesService, times(1)).save(quizModel.getIssue(), issuesOptions);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) IssuesServiceInterface(easytests.core.services.IssuesServiceInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with QuizzesServiceInterface

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

the class TesteesOptionsTest method testSaveWithRelations.

@Test
public void testSaveWithRelations() throws Exception {
    final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
    final TesteesOptionsInterface testeesOptions = new TesteesOptions();
    final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    final Integer quizId = 3;
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    Mockito.when(quizModel.getId()).thenReturn(quizId);
    Mockito.when(testeeModel.getQuiz()).thenReturn(quizModel);
    testeesOptions.setTesteesService(testeesService);
    testeesOptions.setQuizzesService(quizzesService);
    testeesOptions.withQuiz(quizzesOptions);
    final InOrder inOrder = Mockito.inOrder(quizzesService, testeesService);
    testeesOptions.saveWithRelations(testeeModel);
    inOrder.verify(quizzesService, times(1)).save(testeeModel.getQuiz(), quizzesOptions);
    inOrder.verify(testeesService, times(1)).save(testeeModel);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) InOrder(org.mockito.InOrder) 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 10 with QuizzesServiceInterface

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

the class TesteesOptionsTest method testDeleteWithRelations.

@Test
public void testDeleteWithRelations() throws Exception {
    final TesteeModelInterface testeeModel = Mockito.mock(TesteeModelInterface.class);
    final TesteesOptionsInterface testeesOptions = new TesteesOptions();
    final TesteesServiceInterface testeesService = Mockito.mock(TesteesServiceInterface.class);
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    final Integer quizId = 3;
    final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
    Mockito.when(quizModel.getId()).thenReturn(quizId);
    Mockito.when(testeeModel.getQuiz()).thenReturn(quizModel);
    testeesOptions.setTesteesService(testeesService);
    testeesOptions.setQuizzesService(quizzesService);
    testeesOptions.withQuiz(quizzesOptions);
    final InOrder inOrder = Mockito.inOrder(quizzesService, testeesService);
    testeesOptions.deleteWithRelations(testeeModel);
    inOrder.verify(quizzesService, times(1)).delete(testeeModel.getQuiz(), quizzesOptions);
    inOrder.verify(testeesService, times(1)).delete(testeeModel);
}
Also used : QuizModelInterface(easytests.core.models.QuizModelInterface) InOrder(org.mockito.InOrder) 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

QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)19 Test (org.junit.Test)19 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)19 QuizModelInterface (easytests.core.models.QuizModelInterface)15 ArrayList (java.util.ArrayList)11 PointModelInterface (easytests.core.models.PointModelInterface)8 InOrder (org.mockito.InOrder)8 TesteeModelInterface (easytests.core.models.TesteeModelInterface)7 IssueModelInterface (easytests.core.models.IssueModelInterface)5 PointsServiceInterface (easytests.core.services.PointsServiceInterface)5 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)5 SolutionModelInterface (easytests.core.models.SolutionModelInterface)4 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)4 TesteesServiceInterface (easytests.core.services.TesteesServiceInterface)4 IssuesServiceInterface (easytests.core.services.IssuesServiceInterface)3 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)3 SubjectsServiceInterface (easytests.core.services.SubjectsServiceInterface)3 QuestionModelInterface (easytests.core.models.QuestionModelInterface)2 SubjectModelInterface (easytests.core.models.SubjectModelInterface)2 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)2