use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionModelTest 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 QuestionEntity questionEntity = Mockito.mock(QuestionEntity.class);
Mockito.when(questionEntity.getId()).thenReturn(questionId);
Mockito.when(questionEntity.getText()).thenReturn(text);
Mockito.when(questionEntity.getQuestionTypeId()).thenReturn(questionTypeId);
Mockito.when(questionEntity.getTopicId()).thenReturn(topicId);
final QuestionModel questionModel = new QuestionModel();
questionModel.map(questionEntity);
Assert.assertEquals(questionId, questionModel.getId());
Assert.assertEquals(text, questionModel.getText());
Assert.assertEquals(new QuestionTypeModelEmpty(questionEntity.getQuestionTypeId()), questionModel.getQuestionType());
Assert.assertEquals(new ModelsListEmpty(), questionModel.getAnswers());
Assert.assertEquals(new TopicModelEmpty(questionEntity.getTopicId()), questionModel.getTopic());
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsMapperTest method testUpdate.
@Test
public void testUpdate() throws Exception {
final Integer id = 1;
final String text = "text2";
final Integer questionTypeId = 2;
final Integer topicId = 2;
QuestionEntity questionEntity = this.questionsMapper.find(id);
Assert.assertNotNull(questionEntity);
Assert.assertEquals(id, questionEntity.getId());
Assert.assertNotEquals(text, questionEntity.getText());
Assert.assertNotEquals(questionTypeId, questionEntity.getQuestionTypeId());
Assert.assertNotEquals(topicId, questionEntity.getTopicId());
questionEntity = Mockito.mock(QuestionEntity.class);
Mockito.when(questionEntity.getId()).thenReturn(id);
Mockito.when(questionEntity.getText()).thenReturn(text);
Mockito.when(questionEntity.getQuestionTypeId()).thenReturn(questionTypeId);
Mockito.when(questionEntity.getTopicId()).thenReturn(topicId);
this.questionsMapper.update(questionEntity);
questionEntity = this.questionsMapper.find(id);
Assert.assertEquals(id, questionEntity.getId());
Assert.assertEquals(text, questionEntity.getText());
Assert.assertEquals(questionTypeId, questionEntity.getQuestionTypeId());
Assert.assertEquals(topicId, questionEntity.getTopicId());
}
Aggregations