use of easytests.core.models.empty.QuestionModelEmpty in project easy-tests by malinink.
the class PointModelTest method testMap.
@Test
public void testMap() throws Exception {
final Integer pointId = 3;
final Integer questionId = 2;
final Integer quizId = 2;
final PointEntity pointEntity = Mockito.mock(PointEntity.class);
Mockito.when(pointEntity.getId()).thenReturn(pointId);
Mockito.when(pointEntity.getQuestionId()).thenReturn(questionId);
Mockito.when(pointEntity.getQuizId()).thenReturn(quizId);
final QuizModelInterface quizModel = Mockito.mock(QuizModelInterface.class);
Mockito.when(quizModel.getId()).thenReturn(quizId);
final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
Mockito.when(questionModel.getId()).thenReturn(questionId);
final PointModel pointModel = new PointModel();
pointModel.map(pointEntity);
Assert.assertEquals(pointId, pointModel.getId());
Assert.assertEquals(new QuestionModelEmpty(questionId), pointModel.getQuestion());
Assert.assertEquals(new QuizModelEmpty(quizId), pointModel.getQuiz());
}
use of easytests.core.models.empty.QuestionModelEmpty in project easy-tests by malinink.
the class AnswersOptionsTest method testWithRelationsOnModelsList.
@Test
public void testWithRelationsOnModelsList() throws Exception {
final AnswerModelInterface answerModelFirst = Mockito.mock(AnswerModelInterface.class);
answerModelFirst.setId(1);
given(answerModelFirst.getQuestion()).willReturn(new QuestionModelEmpty(1));
final AnswerModelInterface answerModelSecond = Mockito.mock(AnswerModelInterface.class);
answerModelSecond.setId(2);
given(answerModelSecond.getQuestion()).willReturn(new QuestionModelEmpty(2));
final List<AnswerModelInterface> answersModels = new ArrayList<>(2);
answersModels.add(answerModelFirst);
answersModels.add(answerModelSecond);
final AnswersOptionsInterface answersOptions = new AnswersOptions();
final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
final QuestionsOptionsInterface questionOptions = Mockito.mock(QuestionsOptionsInterface.class);
answersOptions.setQuestionsService(questionsService);
answersOptions.withQuestion(questionOptions);
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<AnswerModelInterface> answersModelsWithRelations = answersOptions.withRelations(answersModels);
Assert.assertEquals(answersModelsWithRelations, answersModels);
verify(questionsService).find(1, questionOptions);
verify(answersModels.get(0)).setQuestion(questionModelFirst);
verify(questionsService).find(2, questionOptions);
verify(answersModels.get(1)).setQuestion(questionModelSecond);
}
use of easytests.core.models.empty.QuestionModelEmpty in project easy-tests by malinink.
the class AnswersOptionsTest method testWithRelationsOnSingleModel.
@Test
public void testWithRelationsOnSingleModel() throws Exception {
final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
answerModel.setId(1);
given(answerModel.getQuestion()).willReturn(new QuestionModelEmpty(1));
final AnswersOptionsInterface answersOptions = new AnswersOptions();
final QuestionsServiceInterface questionsService = Mockito.mock(QuestionsServiceInterface.class);
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
answersOptions.setQuestionsService(questionsService);
answersOptions.withQuestion(questionsOptions);
final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
given(questionsService.find(answerModel.getQuestion().getId(), questionsOptions)).willReturn(questionModel);
final AnswerModelInterface answerModelWithRelations = answersOptions.withRelations(answerModel);
Assert.assertEquals(answerModel, answerModelWithRelations);
verify(questionsService).find(1, questionsOptions);
verify(answerModel).setQuestion(questionModel);
}
use of easytests.core.models.empty.QuestionModelEmpty in project easy-tests by malinink.
the class AnswerModelTest method testMap.
@Test
public void testMap() throws Exception {
final Integer id = 3;
final String txt = "Text";
final Integer questionId = 5;
final Integer serialNumber = 3;
final Boolean right = true;
final AnswerEntity answerEntity = Mockito.mock(AnswerEntity.class);
final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
Mockito.when(questionModel.getId()).thenReturn(questionId);
Mockito.when(answerEntity.getId()).thenReturn(id);
Mockito.when(answerEntity.getTxt()).thenReturn(txt);
Mockito.when(answerEntity.getQuestionId()).thenReturn(questionId);
Mockito.when(answerEntity.getSerialNumber()).thenReturn(serialNumber);
Mockito.when(answerEntity.getRight()).thenReturn(right);
final AnswerModel answerModel = new AnswerModel();
answerModel.map(answerEntity);
Assert.assertEquals(id, answerModel.getId());
Assert.assertEquals(txt, answerModel.getTxt());
Assert.assertEquals(right, answerModel.getRight());
Assert.assertEquals(serialNumber, answerModel.getSerialNumber());
Assert.assertEquals(new QuestionModelEmpty(questionId), answerModel.getQuestion());
}
use of easytests.core.models.empty.QuestionModelEmpty in project easy-tests by malinink.
the class AnswerDto method mapInto.
public void mapInto(AnswerModelInterface answerModel) {
answerModel.setId(this.getId());
answerModel.setTxt(this.getTxt());
if ("on".equals(this.right)) {
answerModel.setRight(true);
} else {
answerModel.setRight(false);
}
answerModel.setQuestion(new QuestionModelEmpty(getQuestionId()));
answerModel.setSerialNumber(this.getSerialNumber());
}
Aggregations