Search in sources :

Example 21 with AnswerEntity

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

the class AnswersService method map.

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

Example 22 with AnswerEntity

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

the class AnswersServiceTest method createAnswerEntityMock.

private AnswerEntity createAnswerEntityMock(Integer id, String txt, Integer questionId, Integer serialNumber, boolean right) {
    final AnswerEntity answerEntity = Mockito.mock(AnswerEntity.class);
    Mockito.when(answerEntity.getId()).thenReturn(id);
    Mockito.when(answerEntity.getTxt()).thenReturn(txt);
    Mockito.when(answerEntity.getQuestionId()).thenReturn(questionId);
    Mockito.when(answerEntity.getSerialNumber()).thenReturn(serialNumber);
    Mockito.when(answerEntity.getRight()).thenReturn(right);
    return answerEntity;
}
Also used : AnswerEntity(easytests.core.entities.AnswerEntity)

Example 23 with AnswerEntity

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

the class AnswersServiceTest method testFindAllPresentList.

@Test
public void testFindAllPresentList() throws Exception {
    final List<AnswerEntity> answersEntities = new ArrayList<>(2);
    final AnswerEntity answerEntityFirst = this.createAnswerEntityMock(1, "Answer1", 1, 1, true);
    final AnswerEntity answerEntitySecond = this.createAnswerEntityMock(2, "Answer2", 2, 2, false);
    answersEntities.add(answerEntityFirst);
    answersEntities.add(answerEntitySecond);
    given(this.answersMapper.findAll()).willReturn(answersEntities);
    final List<AnswerModelInterface> answersModels = this.answersService.findAll();
    Assert.assertEquals(2, answersModels.size());
    Assert.assertEquals(answersModels.get(0), this.mapAnswerModel(answerEntityFirst));
    Assert.assertEquals(answersModels.get(1), this.mapAnswerModel(answerEntitySecond));
}
Also used : ArrayList(java.util.ArrayList) 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