use of easytests.core.entities.IssueStandardQuestionTypeOptionEntity in project easy-tests by malinink.
the class IssueStandardQuestionTypeOptionsService method map.
private IssueStandardQuestionTypeOptionEntity map(IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel) {
final IssueStandardQuestionTypeOptionEntity questionTypeOptionEntity = new IssueStandardQuestionTypeOptionEntity();
questionTypeOptionEntity.map(questionTypeOptionModel);
return questionTypeOptionEntity;
}
use of easytests.core.entities.IssueStandardQuestionTypeOptionEntity in project easy-tests by malinink.
the class IssueStandardQuestionTypeOptionsServiceTest method testSaveList.
@Test
public void testSaveList() throws Exception {
final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = new ArrayList<>(2);
questionTypeOptionModels.add(Models.createQuestionTypeOptionModel(1, 1, 10, 20, 60, 1));
questionTypeOptionModels.add(Models.createQuestionTypeOptionModel(null, 1, 10, 20, 60, 1));
final Integer id = 10;
doAnswer(invocations -> {
final IssueStandardQuestionTypeOptionEntity questionTypeOptionEntity = (IssueStandardQuestionTypeOptionEntity) invocations.getArguments()[0];
questionTypeOptionEntity.setId(id);
return null;
}).when(this.questionTypeOptionsMapper).insert(Mockito.any(IssueStandardQuestionTypeOptionEntity.class));
this.questionTypeOptionsService.save(questionTypeOptionModels);
verify(this.questionTypeOptionsMapper, times(1)).update(this.mapQuestionTypeOptionEntity(questionTypeOptionModels.get(0)));
verify(this.questionTypeOptionsMapper, times(1)).insert(this.mapQuestionTypeOptionEntity(questionTypeOptionModels.get(1)));
Assert.assertEquals(id, questionTypeOptionModels.get(1).getId());
}
use of easytests.core.entities.IssueStandardQuestionTypeOptionEntity in project easy-tests by malinink.
the class IssueStandardQuestionTypeOptionsServiceTest method testFindByIssueStandardWithOptions.
@Test
public void testFindByIssueStandardWithOptions() throws Exception {
final Integer issueStandardId = 5;
final List<IssueStandardQuestionTypeOptionEntity> questionTypeOptionEntities = new ArrayList<>(2);
questionTypeOptionEntities.add(Entities.createQuestionTypeOptionEntityMock(1, 1, 1, 10, null, issueStandardId));
questionTypeOptionEntities.add(Entities.createQuestionTypeOptionEntityMock(2, 2, 10, 20, 60, issueStandardId));
final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = new ArrayList<>(2);
questionTypeOptionModels.add(this.mapQuestionTypeOptionModel(questionTypeOptionEntities.get(0)));
questionTypeOptionModels.add(this.mapQuestionTypeOptionModel(questionTypeOptionEntities.get(1)));
final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = Mockito.mock(IssueStandardQuestionTypeOptionsOptionsInterface.class);
given(this.questionTypeOptionsMapper.findByIssueStandardId(issueStandardId)).willReturn(questionTypeOptionEntities);
given(questionTypeOptionsOptions.withRelations(questionTypeOptionModels)).willReturn(questionTypeOptionModels);
List<IssueStandardQuestionTypeOptionModelInterface> foundedQuestionTypeOptionModels = this.questionTypeOptionsService.findByIssueStandard(questionTypeOptionModels.get(0).getIssueStandard(), questionTypeOptionsOptions);
verify(questionTypeOptionsOptions).withRelations(questionTypeOptionModels);
Assert.assertNotNull(foundedQuestionTypeOptionModels);
Assert.assertEquals(questionTypeOptionModels, foundedQuestionTypeOptionModels);
}
use of easytests.core.entities.IssueStandardQuestionTypeOptionEntity in project easy-tests by malinink.
the class IssueStandardQuestionTypeOptionsServiceTest method testFindByIssueStandardPresentList.
@Test
public void testFindByIssueStandardPresentList() throws Exception {
final Integer issueStandardId = 5;
final List<IssueStandardQuestionTypeOptionEntity> questionTypeOptionEntities = new ArrayList<>(2);
questionTypeOptionEntities.add(Entities.createQuestionTypeOptionEntityMock(1, 1, 1, 10, null, issueStandardId));
questionTypeOptionEntities.add(Entities.createQuestionTypeOptionEntityMock(2, 2, 10, 20, 60, issueStandardId));
given(this.questionTypeOptionsMapper.findByIssueStandardId(issueStandardId)).willReturn(questionTypeOptionEntities);
final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
final List<IssueStandardQuestionTypeOptionModelInterface> questionTypeOptionModels = this.questionTypeOptionsService.findByIssueStandard(issueStandardModel);
Assert.assertNotNull(questionTypeOptionModels);
Assert.assertEquals(questionTypeOptionEntities.size(), questionTypeOptionModels.size());
for (int i = 0; i < questionTypeOptionModels.size(); i++) {
Assert.assertEquals(this.mapQuestionTypeOptionModel(questionTypeOptionEntities.get(i)), questionTypeOptionModels.get(i));
}
}
use of easytests.core.entities.IssueStandardQuestionTypeOptionEntity in project easy-tests by malinink.
the class IssueStandardQuestionTypeOptionsServiceTest method testSaveInsertsEntity.
@Test
public void testSaveInsertsEntity() throws Exception {
final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = Models.createQuestionTypeOptionModel(null, 1, 10, 20, 60, 1);
final Integer id = 10;
doAnswer(invocations -> {
final IssueStandardQuestionTypeOptionEntity questionTypeOptionEntity = (IssueStandardQuestionTypeOptionEntity) invocations.getArguments()[0];
questionTypeOptionEntity.setId(id);
return null;
}).when(this.questionTypeOptionsMapper).insert(Mockito.any(IssueStandardQuestionTypeOptionEntity.class));
this.questionTypeOptionsService.save(questionTypeOptionModel);
verify(this.questionTypeOptionsMapper, times(1)).insert(this.mapQuestionTypeOptionEntity(questionTypeOptionModel));
Assert.assertEquals(id, questionTypeOptionModel.getId());
}
Aggregations