Search in sources :

Example 21 with QuestionEntity

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());
}
Also used : TopicModelEmpty(easytests.core.models.empty.TopicModelEmpty) QuestionEntity(easytests.core.entities.QuestionEntity) ModelsListEmpty(easytests.core.models.empty.ModelsListEmpty) QuestionTypeModelEmpty(easytests.core.models.empty.QuestionTypeModelEmpty) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 22 with QuestionEntity

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());
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) Test(org.junit.Test)

Aggregations

QuestionEntity (easytests.core.entities.QuestionEntity)22 QuestionModelInterface (easytests.core.models.QuestionModelInterface)8 Test (org.junit.Test)7 TopicModelInterface (easytests.core.models.TopicModelInterface)3 QuestionsOptionsInterface (easytests.core.options.QuestionsOptionsInterface)3 ArrayList (java.util.ArrayList)3 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)1 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)1 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)1 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1