use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class AnswerEntityTest 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 QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
Mockito.when(questionModel.getId()).thenReturn(questionId);
final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
Mockito.when(answerModel.getId()).thenReturn(id);
Mockito.when(answerModel.getTxt()).thenReturn(txt);
Mockito.when(answerModel.getQuestion()).thenReturn(questionModel);
Mockito.when(answerModel.getSerialNumber()).thenReturn(serialNumber);
Mockito.when(answerModel.getRight()).thenReturn(right);
final AnswerEntity answerEntity = new AnswerEntity();
answerEntity.map(answerModel);
Assert.assertEquals(id, answerEntity.getId());
Assert.assertEquals(txt, answerEntity.getTxt());
Assert.assertEquals(questionId, answerEntity.getQuestionId());
Assert.assertEquals(serialNumber, answerEntity.getSerialNumber());
Assert.assertEquals(right, answerEntity.getRight());
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionEntityTest method testMap.
@Test
public void testMap() throws Exception {
final Integer questionId = 1;
final String text = "test1";
final Integer questionTypeId = 1;
final Integer topicId = 1;
final TopicModelInterface topic = Mockito.mock(TopicModelInterface.class);
Mockito.when(topic.getId()).thenReturn(topicId);
final QuestionTypeModelInterface questionType = Mockito.mock(QuestionTypeModelInterface.class);
Mockito.when(questionType.getId()).thenReturn(questionTypeId);
final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
Mockito.when(questionModel.getId()).thenReturn(questionId);
Mockito.when(questionModel.getText()).thenReturn(text);
Mockito.when(questionModel.getQuestionType()).thenReturn(questionType);
Mockito.when(questionModel.getTopic()).thenReturn(topic);
final QuestionEntity questionEntity = new QuestionEntity();
questionEntity.map(questionModel);
Assert.assertEquals(questionId, questionEntity.getId());
Assert.assertEquals(text, questionEntity.getText());
Assert.assertEquals(questionTypeId, questionEntity.getQuestionTypeId());
Assert.assertEquals(topicId, questionEntity.getTopicId());
}
use of easytests.core.models.QuestionModelInterface 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.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testFindWithOptions.
@Test
public void testFindWithOptions() throws Exception {
final Integer id = 1;
final QuestionEntity questionEntity = Entities.createQuestionEntityMock(id, "NewText", 1, 1);
final QuestionModelInterface questionModel = this.mapQuestionModel(questionEntity);
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
given(this.questionsMapper.find(id)).willReturn(questionEntity);
given(questionsOptions.withRelations(questionModel)).willReturn(questionModel);
final QuestionModelInterface foundedQuestionModel = this.questionsService.find(id, questionsOptions);
Assert.assertEquals(questionModel, foundedQuestionModel);
verify(questionsOptions).withRelations(questionModel);
}
use of easytests.core.models.QuestionModelInterface in project easy-tests by malinink.
the class QuestionsServiceTest method testSaveWithOptions.
@Test
public void testSaveWithOptions() throws Exception {
final QuestionModelInterface questionModel = Models.createQuestionModel(null, "Text", 1, 1);
final QuestionsOptionsInterface questionsOptions = Mockito.mock(QuestionsOptionsInterface.class);
this.questionsService.save(questionModel, questionsOptions);
verify(questionsOptions).saveWithRelations(questionModel);
}
Aggregations