@Test void testValidateNotNullConstraintDecimal() { String attributeName = "attr"; Attribute attribute = when(mock(Attribute.class).getDataType()).thenReturn(DECIMAL).getMock(); when(attribute.getName()).thenReturn(attributeName); EntityType entityType = when(mock(EntityType.class).getAtomicAttributes()) .thenReturn(singletonList(attribute)) .getMock(); Entity entity = mock(Entity.class); when(entity.getEntityType()).thenReturn(entityType); when(entity.getDouble(attribute)).thenReturn(null); Errors errors = mock(Errors.class); entityValidator.validate(entity, errors); verify(errors).rejectValue(attributeName, "constraints.NotNull", null, null); }
@Override public void validate(@Nonnull Object target, @Nonnull Errors errors) { Entity entity = (Entity) target; entity .getEntityType() .getAtomicAttributes() .forEach(attribute -> validate(entity, attribute, errors)); }
EntityValidator implements Validator { @Override public void validate(@Nonnull Object target, @Nonnull Errors errors) { Entity entity = (Entity) target; entity .getEntityType() .getAtomicAttributes() .forEach(attribute -> validate(entity, attribute, errors)); } }
EntityValidator implements Validator { @Override public void validate(@Nonnull Object target, @Nonnull Errors errors) { Entity entity = (Entity) target; entity .getEntityType() .getAtomicAttributes() .forEach(attribute -> validate(entity, attribute, errors)); } EntityValidator(ExpressionValidator expressionValidator); }
EntityValidator implements Validator { @Override public void validate(@Nonnull Object target, @Nonnull Errors errors) { Entity entity = (Entity) target; entity .getEntityType() .getAtomicAttributes() .forEach(attribute -> validate(entity, attribute, errors)); } EntityValidator(ExpressionValidator expressionValidator); @Override boolean supports(@Nonnull Class<?> clazz); @Override void validate(@Nonnull Object target, @Nonnull Errors errors); }
EntityValidator implements Validator { @Override public void validate(@Nonnull Object target, @Nonnull Errors errors) { Entity entity = (Entity) target; entity .getEntityType() .getAtomicAttributes() .forEach(attribute -> validate(entity, attribute, errors)); } EntityValidator(ExpressionValidator expressionValidator); @Override boolean supports(@Nonnull Class<?> clazz); @Override void validate(@Nonnull Object target, @Nonnull Errors errors);  }