use of easytests.core.models.IssueStandardQuestionTypeOptionModelInterface 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.models.IssueStandardQuestionTypeOptionModelInterface 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.models.IssueStandardQuestionTypeOptionModelInterface 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());
}
use of easytests.core.models.IssueStandardQuestionTypeOptionModelInterface in project easy-tests by malinink.
the class IssueStandardQuestionTypeOptionsOptionsTest method testDeleteWithRelations.
@Test
public void testDeleteWithRelations() throws Exception {
final IssueStandardQuestionTypeOptionsOptionsInterface questionTypeOptionsOptions = new IssueStandardQuestionTypeOptionsOptions();
final IssueStandardQuestionTypeOptionsServiceInterface questionTypeOptionsService = Mockito.mock(IssueStandardQuestionTypeOptionsServiceInterface.class);
final IssueStandardsServiceInterface issueStandardsService = Mockito.mock(IssueStandardsServiceInterface.class);
final IssueStandardsOptionsInterface issueStandardsOptions = Mockito.mock(IssueStandardsOptionsInterface.class);
final Integer issueStandardId = 10;
final IssueStandardModelInterface issueStandardModel = Mockito.mock(IssueStandardModelInterface.class);
Mockito.when(issueStandardModel.getId()).thenReturn(issueStandardId);
final IssueStandardQuestionTypeOptionModelInterface questionTypeOptionModel = Mockito.mock(IssueStandardQuestionTypeOptionModelInterface.class);
Mockito.when(questionTypeOptionModel.getIssueStandard()).thenReturn(issueStandardModel);
questionTypeOptionsOptions.setQuestionTypeOptionsService(questionTypeOptionsService);
questionTypeOptionsOptions.setIssueStandardsService(issueStandardsService);
questionTypeOptionsOptions.withIssueStandard(issueStandardsOptions);
final InOrder inOrder = Mockito.inOrder(issueStandardsService, questionTypeOptionsService);
questionTypeOptionsOptions.deleteWithRelations(questionTypeOptionModel);
inOrder.verify(questionTypeOptionsService).delete(questionTypeOptionModel);
inOrder.verify(issueStandardsService).delete(questionTypeOptionModel.getIssueStandard(), issueStandardsOptions);
}
use of easytests.core.models.IssueStandardQuestionTypeOptionModelInterface in project easy-tests by malinink.
the class IssueStandardDtoValidator method validateQuestionTypeOptionDtoIdBelongsToIssueStandard.
private void validateQuestionTypeOptionDtoIdBelongsToIssueStandard(Errors errors, IssueStandardDto issueStandardDto) {
final List<IssueStandardQuestionTypeOptionModelInterface> qtoModels = this.questionTypeOptionsService.findByIssueStandard(new IssueStandardModelEmpty(issueStandardDto.getId()));
final List<Integer> qtoModelIds = new ArrayList<>(qtoModels.size());
qtoModelIds.addAll(qtoModels.stream().map(IdentityInterface::getId).collect(Collectors.toList()));
int index = 0;
for (IssueStandardQuestionTypeOptionDto qtoDto : issueStandardDto.getQuestionTypeOptions()) {
if (qtoDto.getId() != null && !qtoModelIds.contains(qtoDto.getId())) {
reject(errors, qtoField(index, "id"), "Foreign questionTypeOption id for IssueStandard entity");
}
index++;
}
}
Aggregations