use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method createAnswerModel.
private AnswerModelInterface createAnswerModel(Integer id, String txt, Integer questionId, Integer serialNumber, Boolean right) {
final AnswerModelInterface answerModel = new AnswerModel();
answerModel.setId(id);
answerModel.setTxt(txt);
answerModel.setSerialNumber(serialNumber);
answerModel.setRight(true);
final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
Mockito.when(questionModel.getId()).thenReturn(questionId);
answerModel.setQuestion(questionModel);
return answerModel;
}
use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.
the class AnswersServiceTest method createAnswerModel.
private AnswerModelInterface createAnswerModel(Integer id, String txt, QuestionModelInterface question, Integer serialNumber, boolean right) {
final AnswerModelInterface answerModel = new AnswerModel();
answerModel.setId(id);
answerModel.setTxt(txt);
answerModel.setQuestion(question);
answerModel.setSerialNumber(serialNumber);
answerModel.setRight(right);
return answerModel;
}
use of easytests.core.models.AnswerModelInterface 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);
}
use of easytests.core.models.AnswerModelInterface 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);
}
use of easytests.core.models.AnswerModelInterface 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);
}
Aggregations