Search in sources :

Example 6 with QuestionEntity

use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.

the class QuestionsServiceTest method mapQuestionEntity.

private QuestionEntity mapQuestionEntity(QuestionModelInterface questionModel) {
    final QuestionEntity questionEntity = new QuestionEntity();
    questionEntity.map(questionModel);
    return questionEntity;
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity)

Example 7 with QuestionEntity

use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.

the class QuestionsServiceTest method testSaveCreatesEntity.

@Test
public void testSaveCreatesEntity() throws Exception {
    final QuestionModelInterface questionModel = Models.createQuestionModel(null, "Text", 1, 1);
    doAnswer(invocation -> {
        final QuestionEntity questionEntity = (QuestionEntity) invocation.getArguments()[0];
        questionEntity.setId(5);
        return null;
    }).when(this.questionsMapper).insert(Mockito.any(QuestionEntity.class));
    this.questionsService.save(questionModel);
    verify(this.questionsMapper, times(1)).insert(this.mapQuestionEntity(questionModel));
    Assert.assertEquals((Integer) 5, questionModel.getId());
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) QuestionModelInterface(easytests.core.models.QuestionModelInterface)

Example 8 with QuestionEntity

use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.

the class QuestionsServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final Integer id = 1;
    final QuestionEntity questionEntity = Entities.createQuestionEntityMock(id, "NewText", 1, 1);
    given(this.questionsMapper.find(id)).willReturn(questionEntity);
    final QuestionModelInterface questionModel = this.questionsService.find(id);
    Assert.assertEquals(this.mapQuestionModel(questionEntity), questionModel);
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) QuestionModelInterface(easytests.core.models.QuestionModelInterface)

Example 9 with QuestionEntity

use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.

the class QuestionsServiceTest method getQuestionsEntities.

private List<QuestionEntity> getQuestionsEntities() {
    final List<QuestionEntity> questionsEntities = new ArrayList<>(2);
    final QuestionEntity questionEntityFirst = Entities.createQuestionEntityMock(1, "test1", 1, 1);
    final QuestionEntity questionEntitySecond = Entities.createQuestionEntityMock(2, "test2", 2, 1);
    questionsEntities.add(questionEntityFirst);
    questionsEntities.add(questionEntitySecond);
    return questionsEntities;
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) ArrayList(java.util.ArrayList)

Example 10 with QuestionEntity

use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.

the class QuestionsServiceTest method testSaveUpdateEntityIdOnCreation.

@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
    final Integer id = 7;
    final QuestionModelInterface questionModel = this.questionsSupport.getModelAdditionalMock(0);
    doAnswer(invocation -> {
        final QuestionEntity questionEntity = (QuestionEntity) invocation.getArguments()[0];
        questionEntity.setId(id);
        return null;
    }).when(this.questionsMapper).insert(any());
    this.questionsService.save(questionModel);
    verify(questionModel, times(1)).setId(id);
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) QuestionModelInterface(easytests.core.models.QuestionModelInterface)

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