Search in sources :

Example 11 with SolutionModelInterface

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

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

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

use of easytests.core.models.SolutionModelInterface 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 15 with SolutionModelInterface

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

the class SolutionsServiceTest method testFindByPointAbsentList.

@Test
public void testFindByPointAbsentList() throws Exception {
    final PointModelInterface pointModel = this.pointsSupport.getModelFixtureMock(0);
    when(this.solutionsMapper.findByPointId(pointModel.getId())).thenReturn(new ArrayList<>(0));
    final List<SolutionModelInterface> solutionsFoundedModels = this.solutionsService.findByPoint(pointModel);
    Assert.assertEquals(0, solutionsFoundedModels.size());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) PointModelInterface(easytests.core.models.PointModelInterface)

Aggregations

SolutionModelInterface (easytests.core.models.SolutionModelInterface)35 Test (org.junit.Test)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 PointModelInterface (easytests.core.models.PointModelInterface)14 SolutionEntity (easytests.core.entities.SolutionEntity)9 SolutionsOptionsInterface (easytests.core.options.SolutionsOptionsInterface)8 PointsServiceInterface (easytests.core.services.PointsServiceInterface)7 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)7 ArrayList (java.util.ArrayList)7 AnswerModelInterface (easytests.core.models.AnswerModelInterface)5 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)5 QuizModelInterface (easytests.core.models.QuizModelInterface)4 QuizzesServiceInterface (easytests.core.services.QuizzesServiceInterface)4 InOrder (org.mockito.InOrder)4 SolutionModel (easytests.core.models.SolutionModel)3 QuestionModelInterface (easytests.core.models.QuestionModelInterface)2 AnswerModelEmpty (easytests.core.models.empty.AnswerModelEmpty)2 PointModelEmpty (easytests.core.models.empty.PointModelEmpty)2 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)2 QuizModelEmpty (easytests.core.models.empty.QuizModelEmpty)2