Search in sources :

Example 26 with AnswerModelInterface

use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.

the class AnswerEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer id = 3;
    final String txt = "Text";
    final Integer questionId = 5;
    final Integer serialNumber = 3;
    final Boolean right = true;
    final QuestionModelInterface questionModel = Mockito.mock(QuestionModelInterface.class);
    Mockito.when(questionModel.getId()).thenReturn(questionId);
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    Mockito.when(answerModel.getId()).thenReturn(id);
    Mockito.when(answerModel.getTxt()).thenReturn(txt);
    Mockito.when(answerModel.getQuestion()).thenReturn(questionModel);
    Mockito.when(answerModel.getSerialNumber()).thenReturn(serialNumber);
    Mockito.when(answerModel.getRight()).thenReturn(right);
    final AnswerEntity answerEntity = new AnswerEntity();
    answerEntity.map(answerModel);
    Assert.assertEquals(id, answerEntity.getId());
    Assert.assertEquals(txt, answerEntity.getTxt());
    Assert.assertEquals(questionId, answerEntity.getQuestionId());
    Assert.assertEquals(serialNumber, answerEntity.getSerialNumber());
    Assert.assertEquals(right, answerEntity.getRight());
}
Also used : QuestionModelInterface(easytests.core.models.QuestionModelInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) Test(org.junit.Test)

Example 27 with AnswerModelInterface

use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.

the class SolutionEntityTest method testMap.

@Test
public void testMap() throws Exception {
    final Integer id = 1;
    final Integer answerId = 10;
    final Integer pointId = 3;
    final AnswerModelInterface answerModel = Mockito.mock(AnswerModelInterface.class);
    Mockito.when(answerModel.getId()).thenReturn(answerId);
    final PointModelInterface pointModel = Mockito.mock(PointModelInterface.class);
    Mockito.when(pointModel.getId()).thenReturn(pointId);
    final SolutionModelInterface solutionModel = Mockito.mock(SolutionModelInterface.class);
    Mockito.when(solutionModel.getId()).thenReturn(id);
    Mockito.when(solutionModel.getAnswer()).thenReturn(answerModel);
    Mockito.when(solutionModel.getPoint()).thenReturn(pointModel);
    final SolutionEntity solutionEntity = new SolutionEntity();
    solutionEntity.map(solutionModel);
    assertEquals(id, solutionEntity.getId());
    assertEquals(answerId, solutionEntity.getAnswerId());
    assertEquals(pointId, solutionEntity.getPointId());
}
Also used : SolutionModelInterface(easytests.core.models.SolutionModelInterface) AnswerModelInterface(easytests.core.models.AnswerModelInterface) PointModelInterface(easytests.core.models.PointModelInterface) Test(org.junit.Test)

Example 28 with AnswerModelInterface

use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.

the class AnswerListDto method map.

public void map(QuestionModelInterface questionModel) {
    final List<AnswerModelInterface> answers = questionModel.getAnswers();
    final List<AnswerDto> answerDtoList = new ArrayList<>(answers.size());
    for (AnswerModelInterface answer : answers) {
        final AnswerDto answerDto = new AnswerDto();
        answerDto.map(answer);
        answerDtoList.add(answerDto);
    }
    this.setAnswersList(answerDtoList);
    if (answerDtoList == null) {
        this.setAnswersList(new ArrayList<>());
    }
}
Also used : ArrayList(java.util.ArrayList) AnswerModelInterface(easytests.core.models.AnswerModelInterface)

Example 29 with AnswerModelInterface

use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.

the class AnswersService method map.

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

Example 30 with AnswerModelInterface

use of easytests.core.models.AnswerModelInterface in project easy-tests by malinink.

the class AnswersServiceTest method testFindAbsentModel.

@Test
public void testFindAbsentModel() throws Exception {
    final Integer id = 10;
    given(this.answersMapper.find(id)).willReturn(null);
    final AnswerModelInterface answerModel = this.answersService.find(id);
    Assert.assertEquals(null, answerModel);
}
Also used : AnswerModelInterface(easytests.core.models.AnswerModelInterface)

Aggregations

AnswerModelInterface (easytests.core.models.AnswerModelInterface)36 AnswerEntity (easytests.core.entities.AnswerEntity)10 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 AnswersServiceInterface (easytests.core.services.AnswersServiceInterface)7 AnswerModel (easytests.core.models.AnswerModel)6 QuestionModelInterface (easytests.core.models.QuestionModelInterface)6 AnswersOptionsInterface (easytests.core.options.AnswersOptionsInterface)6 PointModelInterface (easytests.core.models.PointModelInterface)5 SolutionModelInterface (easytests.core.models.SolutionModelInterface)5 TopicModelInterface (easytests.core.models.TopicModelInterface)4 TopicsServiceInterface (easytests.core.services.TopicsServiceInterface)4 InOrder (org.mockito.InOrder)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 PointsServiceInterface (easytests.core.services.PointsServiceInterface)3 QuestionTypeModelInterface (easytests.core.models.QuestionTypeModelInterface)2 QuestionTypeModelEmpty (easytests.core.models.empty.QuestionTypeModelEmpty)2 TopicModelEmpty (easytests.core.models.empty.TopicModelEmpty)2 QuestionTypesServiceInterface (easytests.core.services.QuestionTypesServiceInterface)2 QuestionsServiceInterface (easytests.core.services.QuestionsServiceInterface)2