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());
}
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());
}
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<>());
}
}
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;
}
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);
}
Aggregations