use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsServiceTest method mapQuestionEntity.
private QuestionEntity mapQuestionEntity(QuestionModelInterface questionModel) {
final QuestionEntity questionEntity = new QuestionEntity();
questionEntity.map(questionModel);
return questionEntity;
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsServiceTest method testSaveCreatesEntity.
@Test
public void testSaveCreatesEntity() throws Exception {
final QuestionModelInterface questionModel = Models.createQuestionModel(null, "Text", 1, 1);
doAnswer(invocation -> {
final QuestionEntity questionEntity = (QuestionEntity) invocation.getArguments()[0];
questionEntity.setId(5);
return null;
}).when(this.questionsMapper).insert(Mockito.any(QuestionEntity.class));
this.questionsService.save(questionModel);
verify(this.questionsMapper, times(1)).insert(this.mapQuestionEntity(questionModel));
Assert.assertEquals((Integer) 5, questionModel.getId());
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsServiceTest method testFindPresentModel.
@Test
public void testFindPresentModel() throws Exception {
final Integer id = 1;
final QuestionEntity questionEntity = Entities.createQuestionEntityMock(id, "NewText", 1, 1);
given(this.questionsMapper.find(id)).willReturn(questionEntity);
final QuestionModelInterface questionModel = this.questionsService.find(id);
Assert.assertEquals(this.mapQuestionModel(questionEntity), questionModel);
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsServiceTest method getQuestionsEntities.
private List<QuestionEntity> getQuestionsEntities() {
final List<QuestionEntity> questionsEntities = new ArrayList<>(2);
final QuestionEntity questionEntityFirst = Entities.createQuestionEntityMock(1, "test1", 1, 1);
final QuestionEntity questionEntitySecond = Entities.createQuestionEntityMock(2, "test2", 2, 1);
questionsEntities.add(questionEntityFirst);
questionsEntities.add(questionEntitySecond);
return questionsEntities;
}
use of easytests.core.entities.QuestionEntity in project easy-tests by malinink.
the class QuestionsServiceTest method testSaveUpdateEntityIdOnCreation.
@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
final Integer id = 7;
final QuestionModelInterface questionModel = this.questionsSupport.getModelAdditionalMock(0);
doAnswer(invocation -> {
final QuestionEntity questionEntity = (QuestionEntity) invocation.getArguments()[0];
questionEntity.setId(id);
return null;
}).when(this.questionsMapper).insert(any());
this.questionsService.save(questionModel);
verify(questionModel, times(1)).setId(id);
}
Aggregations