Search in sources :

Example 11 with QuestionEntity

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

the class QuestionsServiceTest method testFindByTopicPresentList.

@Test
public void testFindByTopicPresentList() throws Exception {
    final TopicModelInterface topicModel = this.topicsSupport.getModelFixtureMock(0);
    final List<QuestionEntity> questionEntities = this.getQuestionsFixturesEntities();
    when(this.questionsMapper.findByTopicId(topicModel.getId())).thenReturn(questionEntities);
    final List<QuestionModelInterface> questionsFoundedModels = this.questionsService.findByTopic(topicModel);
    this.questionsSupport.assertModelsListEquals(this.getQuestionsFixturesModels(), questionsFoundedModels);
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) QuestionModelInterface(easytests.core.models.QuestionModelInterface) TopicModelInterface(easytests.core.models.TopicModelInterface)

Example 12 with QuestionEntity

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

the class QuestionsMapperTest method testFindAll.

@Test
public void testFindAll() throws Exception {
    final List<QuestionEntity> questionsFoundedEntities = this.questionsMapper.findAll();
    Assert.assertEquals(3, questionsFoundedEntities.size());
    Integer index = 0;
    for (QuestionEntity questionEntity : questionsFoundedEntities) {
        final QuestionEntity questionFixtureEntity = this.questionsSupport.getEntityFixtureMock(index);
        this.questionsSupport.assertEquals(questionFixtureEntity, questionEntity);
        index++;
    }
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) Test(org.junit.Test)

Example 13 with QuestionEntity

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

the class QuestionsService method save.

@Override
public void save(QuestionModelInterface questionModel) {
    final QuestionEntity questionEntity = this.map(questionModel);
    if (questionEntity.getId() == null) {
        this.questionsMapper.insert(questionEntity);
        questionModel.setId(questionEntity.getId());
        return;
    }
    this.questionsMapper.update(questionEntity);
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity)

Example 14 with QuestionEntity

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

the class QuestionsService method delete.

@Override
public void delete(QuestionModelInterface questionModel) {
    final QuestionEntity questionEntity = this.map(questionModel);
    if (questionEntity.getId() == null) {
        throw new DeleteUnidentifiedModelException();
    }
    this.questionsMapper.delete(questionEntity);
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) DeleteUnidentifiedModelException(easytests.core.services.exceptions.DeleteUnidentifiedModelException)

Example 15 with QuestionEntity

use of easytests.core.entities.QuestionEntity 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);
}
Also used : QuestionEntity(easytests.core.entities.QuestionEntity) QuestionModelInterface(easytests.core.models.QuestionModelInterface) QuestionsOptionsInterface(easytests.core.options.QuestionsOptionsInterface)

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