@Test void checkRangeMinOnlyInvalid() { Entity entity = new DynamicEntity(intRangeMinMeta); entity.set("id", "123"); entity.set("intrangemin", -1); Set<ConstraintViolation> constraints = entityAttributesValidator.validate(entity, intRangeMinMeta); assertEquals(1, constraints.size()); }
public Set<ConstraintViolation> validate(Entity entity, EntityType meta) { Set<ConstraintViolation> violations = checkNullableExpressions(entity, meta); violations.addAll(checkValidationExpressions(entity, meta)); stream(meta.getAtomicAttributes()) .filter(this::isValidationAttribute) .forEach(attr -> validateAttribute(entity, meta, attr).ifPresent(violations::add)); if (entity.getIdValue() == null) { violations.add(createConstraintViolation(entity, meta.getIdAttribute(), meta, null)); } return violations; }
EntityAttributesValidator { public Set<ConstraintViolation> validate(Entity entity, EntityType meta) { Set<ConstraintViolation> violations = checkNullableExpressions(entity, meta); violations.addAll(checkValidationExpressions(entity, meta)); stream(meta.getAtomicAttributes()) .filter(this::isValidationAttribute) .forEach(attr -> validateAttribute(entity, meta, attr).ifPresent(violations::add)); if (entity.getIdValue() == null) { violations.add(createConstraintViolation(entity, meta.getIdAttribute(), meta, null)); } return violations; } }
EntityAttributesValidator { public Set<ConstraintViolation> validate(Entity entity, EntityType meta) { Set<ConstraintViolation> violations = checkNullableExpressions(entity, meta); violations.addAll(checkValidationExpressions(entity, meta)); stream(meta.getAtomicAttributes()) .filter(this::isValidationAttribute) .forEach(attr -> validateAttribute(entity, meta, attr).ifPresent(violations::add)); if (entity.getIdValue() == null) { violations.add(createConstraintViolation(entity, meta.getIdAttribute(), meta, null)); } return violations; } EntityAttributesValidator(ExpressionValidator expressionValidator); }
EntityAttributesValidator { public Set<ConstraintViolation> validate(Entity entity, EntityType meta) { Set<ConstraintViolation> violations = checkNullableExpressions(entity, meta); violations.addAll(checkValidationExpressions(entity, meta)); stream(meta.getAtomicAttributes()) .filter(this::isValidationAttribute) .forEach(attr -> validateAttribute(entity, meta, attr).ifPresent(violations::add)); if (entity.getIdValue() == null) { violations.add(createConstraintViolation(entity, meta.getIdAttribute(), meta, null)); } return violations; } EntityAttributesValidator(ExpressionValidator expressionValidator); Set<ConstraintViolation> validate(Entity entity, EntityType meta); }
EntityAttributesValidator { public Set<ConstraintViolation> validate(Entity entity, EntityType meta) { Set<ConstraintViolation> violations = checkNullableExpressions(entity, meta); violations.addAll(checkValidationExpressions(entity, meta)); stream(meta.getAtomicAttributes()) .filter(this::isValidationAttribute) .forEach(attr -> validateAttribute(entity, meta, attr).ifPresent(violations::add)); if (entity.getIdValue() == null) { violations.add(createConstraintViolation(entity, meta.getIdAttribute(), meta, null)); } return violations; } EntityAttributesValidator(ExpressionValidator expressionValidator); Set<ConstraintViolation> validate(Entity entity, EntityType meta);  }