Search in sources :

Example 6 with PointModelInterface

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

the class PointsSupport method getModelMock.

private PointModelInterface getModelMock(Integer id, Integer quizId, Integer questionId) {
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    Mockito.when(pointModel.getId()).thenReturn(id);
    Mockito.when(pointModel.getQuestion()).thenReturn(new QuestionModelEmpty(questionId));
    Mockito.when(pointModel.getQuiz()).thenReturn(new QuizModelEmpty(quizId));
    Mockito.when(pointModel.getSolutions()).thenReturn(new ModelsListEmpty());
    return pointModel;
}
Also used : QuestionModelEmpty(easytests.core.models.empty.QuestionModelEmpty) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) QuizModelEmpty(easytests.core.models.empty.QuizModelEmpty) PointModelInterface(easytests.core.models.PointModelInterface)

Example 7 with PointModelInterface

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

the class SolutionsServiceTest method testFindByPointAbsentModel.

@Test
public void testFindByPointAbsentModel() throws Exception {
    Integer pointId = 10;
    given(this.solutionsMapper.findByPointId(pointId)).willReturn(new ArrayList<>(0));
    final PointModelInterface pointModel = mock(PointModelInterface.class);
    when(pointModel.getId()).thenReturn(pointId);
    final List<SolutionModelInterface> solutionModels = this.solutionsService.findByPoint(pointModel);
    Assert.assertNotNull(solutionModels);
    Assert.assertEquals(0, solutionModels.size());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with PointModelInterface

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

the class SolutionsServiceTest method createSolutionModel.

private SolutionModelInterface createSolutionModel(Integer id, Integer answerId, Integer pointId) {
    final SolutionModelInterface solutionModel = new SolutionModel();
    final AnswerModelInterface answerModel = mock(AnswerModelInterface.class);
    when(answerModel.getId()).thenReturn(answerId);
    final PointModelInterface pointModel = mock(PointModelInterface.class);
    when(pointModel.getId()).thenReturn(pointId);
    solutionModel.setId(id);
    solutionModel.setAnswer(answerModel);
    solutionModel.setPoint(pointModel);
    return solutionModel;
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) SolutionModel(easytests.core.models.SolutionModel) AnswerModelInterface(easytests.core.models.AnswerModelInterface) PointModelInterface(easytests.core.models.PointModelInterface)

Example 9 with PointModelInterface

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

the class PointsOptionsTest method testSaveDeleteWithQuiz.

@Test
public void testSaveDeleteWithQuiz() {
    final PointsOptionsInterface pointsOptions = new PointsOptions();
    final PointsServiceInterface pointsService = Mockito.mock(PointsServiceInterface.class);
    pointsOptions.setPointsService(pointsService);
    final QuizzesServiceInterface quizzesService = Mockito.mock(QuizzesServiceInterface.class);
    pointsOptions.setQuizzesService(quizzesService);
    final QuizzesOptionsInterface quizzesOptions = Mockito.mock(QuizzesOptionsInterface.class);
    pointsOptions.withQuiz(quizzesOptions);
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    final PointsOptionsInterface pointsOptionsSpy = Mockito.spy(pointsOptions);
    pointsOptionsSpy.deleteWithRelations(pointModel);
    verify(quizzesService, times(1)).delete(pointModel.getQuiz(), quizzesOptions);
    pointsOptionsSpy.saveWithRelations(pointModel);
    verify(quizzesService, times(1)).save(pointModel.getQuiz(), quizzesOptions);
}
Also used : PointsServiceInterface(easytests.core.services.PointsServiceInterface) QuizzesServiceInterface(easytests.core.services.QuizzesServiceInterface) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 10 with PointModelInterface

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

the class PointsOptionsTest method testWithRelationsOnSingleModel.

@Test
public void testWithRelationsOnSingleModel() throws Exception {
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    final PointsOptionsInterface pointsOptions = new PointsOptions();
    pointModel.setId(1);
    given(pointModel.getQuiz()).willReturn(new QuizModelEmpty(1));
    given(pointModel.getQuestion()).willReturn(new QuestionModelEmpty(1));
    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 quizModel = Mockito.mock(QuizModelInterface.class);
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    final List<SolutionModelInterface> solutionsModels = new ArrayList<>();
    solutionsModels.add(Mockito.mock(SolutionModelInterface.class));
    given(quizzesService.find(pointModel.getQuiz().getId(), quizOptions)).willReturn(quizModel);
    given(questionsService.find(pointModel.getQuestion().getId(), questionOptions)).willReturn(questionModel);
    given(solutionsService.findByPoint(pointModel, solutionsOptions)).willReturn(solutionsModels);
    final PointModelInterface pointModelWithRelations = pointsOptions.withRelations(pointModel);
    Assert.assertEquals(pointModel, pointModelWithRelations);
    verify(quizzesService).find(1, quizOptions);
    verify(questionsService).find(1, questionOptions);
    verify(solutionsService).findByPoint(pointModel, solutionsOptions);
    verify(pointModel).setQuiz(quizModel);
    verify(pointModel).setQuestion(questionModel);
    verify(pointModel).setSolutions(solutionsModels);
}
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)

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