Search in sources :

Example 6 with AnswersServiceInterface

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

the class QuestionsOptionsTest method testWithRelationsOnNull.

@Test
public void testWithRelationsOnNull() throws Exception {
    final QuestionModelInterface questionModel = null;
    final QuestionsOptionsInterface questionsOptions = new QuestionsOptions();
    final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
    final QuestionTypesServiceInterface questionTypesService = Mockito.mock(QuestionTypesServiceInterface.class);
    final QuestionTypesOptionsInterface questionTypesOptions = Mockito.mock(QuestionTypesOptionsInterface.class);
    questionsOptions.setAnswersService(answersService);
    questionsOptions.withAnswers(answersOptions);
    questionsOptions.setTopicsService(topicsService);
    questionsOptions.withTopic(topicsOptions);
    questionsOptions.setQuestionTypesService(questionTypesService);
    questionsOptions.withQuestionType(questionTypesOptions);
    final QuestionModelInterface questionModelWithRelations = questionsOptions.withRelations(questionModel);
    Assert.assertEquals(null, questionModelWithRelations);
}
Also used : QuestionTypesServiceInterface(easytests.core.services.QuestionTypesServiceInterface) QuestionModelInterface(easytests.core.models.QuestionModelInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 7 with AnswersServiceInterface

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

the class QuestionsOptionsTest method testSaveWithRelations.

@Test
public void testSaveWithRelations() throws Exception {
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    final QuestionsOptionsInterface questionsOptions = new QuestionsOptions();
    final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
    final AnswersServiceInterface answersService = Mockito.mock(AnswersServiceInterface.class);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    final TopicsServiceInterface topicsService = Mockito.mock(TopicsServiceInterface.class);
    final TopicsOptionsInterface topicsOptions = Mockito.mock(TopicsOptionsInterface.class);
    questionsOptions.setQuestionsService(questionsService);
    questionsOptions.setAnswersService(answersService);
    questionsOptions.withAnswers(answersOptions);
    questionsOptions.setTopicsService(topicsService);
    questionsOptions.withTopic(topicsOptions);
    final List<AnswerModelInterface> answersModels = new ArrayList<>();
    answersModels.add(Mockito.mock(AnswerModelInterface.class));
    TopicModelInterface topicModel = Mockito.mock(TopicModelInterface.class);
    given(questionModel.getAnswers()).willReturn(answersModels);
    given(questionModel.getTopic()).willReturn(topicModel);
    final InOrder inOrder = Mockito.inOrder(topicsService, questionsService, answersService);
    questionsOptions.saveWithRelations(questionModel);
    inOrder.verify(topicsService).save(topicModel, topicsOptions);
    inOrder.verify(questionsService).save(questionModel);
    inOrder.verify(answersService).save(answersModels, answersOptions);
}
Also used : InOrder(org.mockito.InOrder) QuestionModelInterface(easytests.core.models.QuestionModelInterface) ArrayList(java.util.ArrayList) AnswersServiceInterface(easytests.core.services.AnswersServiceInterface) TopicModelInterface(easytests.core.models.TopicModelInterface) QuestionsServiceInterface(easytests.core.services.QuestionsServiceInterface) TopicsServiceInterface(easytests.core.services.TopicsServiceInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with AnswersServiceInterface

use of easytests.core.services.AnswersServiceInterface 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 9 with AnswersServiceInterface

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

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

AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)10 Test (org.junit.Test)10 AnswerModelInterface (easytests.core.models.AnswerModelInterface)7 QuestionModelInterface (easytests.core.models.QuestionModelInterface)5 SolutionModelInterface (easytests.core.models.SolutionModelInterface)5 PointsServiceInterface (easytests.core.services.PointsServiceInterface)5 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)5 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 TopicModelInterface (easytests.core.models.TopicModelInterface)4 ArrayList (java.util.ArrayList)4 InOrder (org.mockito.InOrder)4 PointModelInterface (easytests.core.models.PointModelInterface)3 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)3 SolutionsServiceInterface (easytests.core.services.SolutionsServiceInterface)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)2 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)2 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)2 AnswerModelEmpty (easytests.core.models.empty.AnswerModelEmpty)1 PointModelEmpty (easytests.core.models.empty.PointModelEmpty)1