@Test public void testNullIsValid() { assertTrue(underTest.isValid(null, context)); verify(context, never()).buildConstraintViolationWithTemplate(any(String.class)); }
@Override public boolean isValid(String value, ConstraintValidatorContext context) { context.disableDefaultConstraintViolation(); if (value == null) { return true; } if (value.isEmpty()) { ValidatorUtil.addConstraintViolation(context, "Database vendor may not be empty"); return false; } try { DatabaseVendor.fromValue(value); return true; } catch (UnsupportedOperationException e) { ValidatorUtil.addConstraintViolation(context, value + " is not a valid database vendor"); return false; } }
DatabaseVendorValidator implements ConstraintValidator<ValidDatabaseVendor, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { context.disableDefaultConstraintViolation(); if (value == null) { return true; } if (value.isEmpty()) { ValidatorUtil.addConstraintViolation(context, "Database vendor may not be empty"); return false; } try { DatabaseVendor.fromValue(value); return true; } catch (UnsupportedOperationException e) { ValidatorUtil.addConstraintViolation(context, value + " is not a valid database vendor"); return false; } } }
DatabaseVendorValidator implements ConstraintValidator<ValidDatabaseVendor, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { context.disableDefaultConstraintViolation(); if (value == null) { return true; } if (value.isEmpty()) { ValidatorUtil.addConstraintViolation(context, "Database vendor may not be empty"); return false; } try { DatabaseVendor.fromValue(value); return true; } catch (UnsupportedOperationException e) { ValidatorUtil.addConstraintViolation(context, value + " is not a valid database vendor"); return false; } }  }
DatabaseVendorValidator implements ConstraintValidator<ValidDatabaseVendor, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { context.disableDefaultConstraintViolation(); if (value == null) { return true; } if (value.isEmpty()) { ValidatorUtil.addConstraintViolation(context, "Database vendor may not be empty"); return false; } try { DatabaseVendor.fromValue(value); return true; } catch (UnsupportedOperationException e) { ValidatorUtil.addConstraintViolation(context, value + " is not a valid database vendor"); return false; } }  @Override boolean isValid(String value, ConstraintValidatorContext context); }
DatabaseVendorValidator implements ConstraintValidator<ValidDatabaseVendor, String> { @Override public boolean isValid(String value, ConstraintValidatorContext context) { context.disableDefaultConstraintViolation(); if (value == null) { return true; } if (value.isEmpty()) { ValidatorUtil.addConstraintViolation(context, "Database vendor may not be empty"); return false; } try { DatabaseVendor.fromValue(value); return true; } catch (UnsupportedOperationException e) { ValidatorUtil.addConstraintViolation(context, value + " is not a valid database vendor"); return false; } }  @Override boolean isValid(String value, ConstraintValidatorContext context);  }