Search in sources :

Example 31 with SolutionModelInterface

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

the class SolutionsServiceTest method testDeleteIdentifiedModel.

@Test
public void testDeleteIdentifiedModel() throws Exception {
    final SolutionModelInterface solutionModel = this.createSolutionModel(1, 10, 1);
    this.solutionsService.delete(solutionModel);
    verify(this.solutionsMapper, times(1)).delete(this.mapSolutionEntity(solutionModel));
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 32 with SolutionModelInterface

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

the class PointsOptionsTest method testWithRelationsOnModelsList.

@Test
public void testWithRelationsOnModelsList() throws Exception {
    final PointModelInterface pointModelFirst = Mockito.mock(PointModelInterface.class);
    final PointModelInterface pointModelSecond = Mockito.mock(PointModelInterface.class);
    pointModelFirst.setId(1);
    pointModelSecond.setId(2);
    given(pointModelFirst.getQuiz()).willReturn(new QuizModelEmpty(1));
    given(pointModelSecond.getQuiz()).willReturn(new QuizModelEmpty(2));
    given(pointModelFirst.getQuestion()).willReturn(new QuestionModelEmpty(1));
    given(pointModelSecond.getQuestion()).willReturn(new QuestionModelEmpty(2));
    final List<PointModelInterface> pointsModels = new ArrayList<>();
    pointsModels.add(pointModelFirst);
    pointsModels.add(pointModelSecond);
    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);
    pointsOptions.withQuestion(questionOptions);
    pointsOptions.withSolutions(solutionsOptions);
    final QuizModelInterface quizModelFirst = Mockito.mock(QuizModelInterface.class);
    final QuizModelInterface quizModelSecond = Mockito.mock(QuizModelInterface.class);
    given(quizzesService.find(1, quizOptions)).willReturn(quizModelFirst);
    given(quizzesService.find(2, quizOptions)).willReturn(quizModelSecond);
    final QuestionModelInterface questionModelFirst = Mockito.mock(QuestionModelInterface.class);
    final QuestionModelInterface questionModelSecond = Mockito.mock(QuestionModelInterface.class);
    given(questionsService.find(1, questionOptions)).willReturn(questionModelFirst);
    given(questionsService.find(2, questionOptions)).willReturn(questionModelSecond);
    final List<SolutionModelInterface> solutionsModelsFirst = new ArrayList<>();
    solutionsModelsFirst.add(Mockito.mock(SolutionModelInterface.class));
    final List<SolutionModelInterface> solutionsModelsSecond = new ArrayList<>();
    solutionsModelsSecond.add(Mockito.mock(SolutionModelInterface.class));
    solutionsModelsSecond.add(Mockito.mock(SolutionModelInterface.class));
    given(solutionsService.findByPoint(pointModelFirst, solutionsOptions)).willReturn(solutionsModelsFirst);
    given(solutionsService.findByPoint(pointModelSecond, solutionsOptions)).willReturn(solutionsModelsSecond);
    final List<PointModelInterface> pointsModelsWithRelations = pointsOptions.withRelations(pointsModels);
    Assert.assertEquals(pointsModels, pointsModelsWithRelations);
    verify(quizzesService).find(1, quizOptions);
    verify(questionsService).find(1, questionOptions);
    verify(solutionsService).findByPoint(pointModelFirst, solutionsOptions);
    verify(pointsModels.get(0)).setQuiz(quizModelFirst);
    verify(pointsModels.get(0)).setQuestion(questionModelFirst);
    verify(pointsModels.get(0)).setSolutions(solutionsModelsFirst);
    verify(pointsModels.get(0)).setSolutions(Mockito.anyList());
    verify(quizzesService).find(2, quizOptions);
    verify(questionsService).find(2, questionOptions);
    verify(solutionsService).findByPoint(pointModelSecond, solutionsOptions);
    verify(pointsModels.get(1)).setQuiz(quizModelSecond);
    verify(pointsModels.get(1)).setQuestion(questionModelSecond);
    verify(pointsModels.get(1)).setSolutions(solutionsModelsSecond);
    verify(pointsModels.get(1)).setSolutions(Mockito.anyList());
}
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 33 with SolutionModelInterface

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

the class SolutionsOptionsTest method testWithRelationsOnNull.

@Test
public void testWithRelationsOnNull() throws Exception {
    final SolutionsOptionsInterface solutionsOptions = Mockito.mock(SolutionsOptionsInterface.class);
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
    solutionsOptions.setPointsService(pointsService);
    solutionsOptions.setAnswersService(answersService);
    final SolutionModelInterface nullSolutionModel = null;
    final SolutionModelInterface solutionModelWithRelations = solutionsOptions.withRelations(nullSolutionModel);
    Assert.assertNull(solutionModelWithRelations);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) PointsServiceInterface(easytests.core.services.PointsServiceInterface) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) Test(org.junit.Test)

Example 34 with SolutionModelInterface

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

the class SolutionsOptionsTest method testSaveWithRelations.

@Test
public void testSaveWithRelations() throws Exception {
    final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
    final SolutionsOptionsInterface solutionsOptions = new SolutionsOptions();
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    final SolutionsServiceInterface solutionsService = Mockito.mock(SolutionsServiceInterface.class);
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
    solutionsOptions.setSolutionsService(solutionsService);
    solutionsOptions.setPointsService(pointsService);
    solutionsOptions.withPoint(pointsOptions);
    solutionsOptions.setAnswersService(answersService);
    solutionsOptions.withAnswer(answersOptions);
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    solutionModel.setPoint(pointModel);
    solutionModel.setAnswer(answerModel);
    final InOrder inOrder = Mockito.inOrder(solutionsService, pointsService, answersService);
    solutionsOptions.saveWithRelations(solutionModel);
    inOrder.verify(solutionsService).save(solutionModel);
    inOrder.verify(pointsService).save(solutionModel.getPoint(), pointsOptions);
    inOrder.verify(answersService).save(solutionModel.getAnswer(), answersOptions);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) InOrder(org.mockito.InOrder) PointsServiceInterface(easytests.core.services.PointsServiceInterface) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) PointModelInterface(easytests.core.models.PointModelInterface) SolutionsServiceInterface(easytests.core.services.SolutionsServiceInterface) Test(org.junit.Test)

Example 35 with SolutionModelInterface

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

the class SolutionsOptionsTest method testDeleteWithRelations.

@Test
public void testDeleteWithRelations() throws Exception {
    final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
    final SolutionsOptionsInterface solutionsOptions = new SolutionsOptions();
    final PointsOptionsInterface pointsOptions = Mockito.mock(PointsOptionsInterface.class);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    final SolutionsServiceInterface solutionsService = Mockito.mock(SolutionsServiceInterface.class);
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
    solutionsOptions.setSolutionsService(solutionsService);
    solutionsOptions.setPointsService(pointsService);
    solutionsOptions.withPoint(pointsOptions);
    solutionsOptions.setAnswersService(answersService);
    solutionsOptions.withAnswer(answersOptions);
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    solutionModel.setPoint(pointModel);
    solutionModel.setAnswer(answerModel);
    final InOrder inOrder = Mockito.inOrder(pointsService, answersService, solutionsService);
    solutionsOptions.deleteWithRelations(solutionModel);
    inOrder.verify(pointsService).delete(solutionModel.getPoint(), pointsOptions);
    // inOrder.verify(answersService).delete(solutionModel.getAnswer(), answersOptions);
    inOrder.verify(solutionsService).delete(solutionModel);
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) InOrder(org.mockito.InOrder) PointsServiceInterface(easytests.core.services.PointsServiceInterface) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) PointModelInterface(easytests.core.models.PointModelInterface) SolutionsServiceInterface(easytests.core.services.SolutionsServiceInterface) Test(org.junit.Test)

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