Search in sources :

Example 1 with AnswerEntity

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

the class AnswersServiceTest method testFindByPresentQuestion.

@Test
public void testFindByPresentQuestion() throws Exception {
    final List<AnswerModelInterface> answersModels = getAnswersFixturesModels();
    final List<AnswerEntity> answersEntities = getAnswersFixturesEntities();
    when(this.answersMapper.findByQuestionId(answersModels.get(0).getQuestion().getId())).thenReturn(answersEntities);
    final List<AnswerModelInterface> answersFoundedModels = this.answersService.findByQuestion(answersModels.get(0).getQuestion());
    Integer index = 0;
    for (AnswerModelInterface answerModel1 : answersFoundedModels) {
        this.answersSupport.assertEquals(answerModel1, answersEntities.get(index));
        index++;
    }
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswerEntity(easytests.core.entities.AnswerEntity)

Example 2 with AnswerEntity

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

the class AnswersMapperTest method testFindAll.

@Test
public void testFindAll() throws Exception {
    final List<AnswerEntity> answersFoundedEntities = this.answersMapper.findAll();
    Assert.assertEquals(3, answersFoundedEntities.size());
    Integer index = 0;
    for (AnswerEntity answerEntity : answersFoundedEntities) {
        final AnswerEntity answerFixtureEntity = this.answersSupport.getEntityFixtureMock(index);
        this.answersSupport.assertEquals(answerFixtureEntity, answerEntity);
        index++;
    }
}
Also used : AnswerEntity(easytests.core.entities.AnswerEntity) Test(org.junit.Test)

Example 3 with AnswerEntity

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

the class AnswersServiceTest method testFindWithOptions.

@Test
public void testFindWithOptions() throws Exception {
    final Integer id = 1;
    final AnswerEntity answerEntity = this.createAnswerEntityMock(id, "NewAnswer", 1, 1, true);
    final AnswerModelInterface answerModel = this.mapAnswerModel(answerEntity);
    final AnswersOptionsInterface answersOptions = Mockito.mock(AnswersOptionsInterface.class);
    given(this.answersMapper.find(id)).willReturn(answerEntity);
    given(answersOptions.withRelations(answerModel)).willReturn(answerModel);
    final AnswerModelInterface foundedAnswerModel = this.answersService.find(id, answersOptions);
    verify(answersOptions).withRelations(answerModel);
    Assert.assertNotNull(foundedAnswerModel);
    Assert.assertEquals(answerModel, foundedAnswerModel);
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswerEntity(easytests.core.entities.AnswerEntity) AnswersOptionsInterface(easytests.core.options.AnswersOptionsInterface)

Example 4 with AnswerEntity

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

the class AnswersServiceTest method mapAnswerEntity.

private AnswerEntity mapAnswerEntity(AnswerModelInterface answerModel) {
    final AnswerEntity answerEntity = new AnswerEntity();
    answerEntity.map(answerModel);
    return answerEntity;
}
Also used : AnswerEntity(easytests.core.entities.AnswerEntity)

Example 5 with AnswerEntity

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

the class AnswersServiceTest method testFindPresentModel.

@Test
public void testFindPresentModel() throws Exception {
    final Integer id = 1;
    final AnswerEntity answerEntity = this.createAnswerEntityMock(id, "NewAnswer", 1, 1, true);
    given(this.answersMapper.find(id)).willReturn(answerEntity);
    final AnswerModelInterface answerModel = this.answersService.find(id);
    Assert.assertEquals(this.mapAnswerModel(answerEntity), answerModel);
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface) AnswerEntity(easytests.core.entities.AnswerEntity)

Aggregations

AnswerEntity (easytests.core.entities.AnswerEntity)23 AnswerModelInterface (easytests.core.models.AnswerModelInterface)10 Test (org.junit.Test)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 AnswersOptionsInterface (easytests.core.options.AnswersOptionsInterface)3 ArrayList (java.util.ArrayList)3 List (java.util.List)2 QuestionModelInterface (easytests.core.models.QuestionModelInterface)1 QuestionModelEmpty (easytests.core.models.empty.QuestionModelEmpty)1 DeleteUnidentifiedModelException (easytests.core.services.exceptions.DeleteUnidentifiedModelException)1