Search in sources :

Example 1 with IssueStandardQuestionTypeOptionDto

use of easytests.personal.dto.IssueStandardQuestionTypeOptionDto 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++;
    }
}
Also used : IssueStandardQuestionTypeOptionDto(easytests.personal.dto.IssueStandardQuestionTypeOptionDto) IssueStandardQuestionTypeOptionModelInterface(easytests.core.models.IssueStandardQuestionTypeOptionModelInterface) ArrayList(java.util.ArrayList) IdentityInterface(easytests.core.models.IdentityInterface) IssueStandardModelEmpty(easytests.core.models.empty.IssueStandardModelEmpty)

Aggregations

IdentityInterface (easytests.core.models.IdentityInterface)1 IssueStandardQuestionTypeOptionModelInterface (easytests.core.models.IssueStandardQuestionTypeOptionModelInterface)1 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)1 IssueStandardQuestionTypeOptionDto (easytests.personal.dto.IssueStandardQuestionTypeOptionDto)1 ArrayList (java.util.ArrayList)1