@Test public void testValidateFieldValueRequired() { assertTrue(fieldStateValidator.validateFieldValueRequired(labelField, "cc")); assertFalse(fieldStateValidator.validateFieldValueRequired(labelField, "")); assertFalse(fieldStateValidator.validateFieldValueRequired(labelField, null)); ArrayList<String> nonEmptyArrayList = new ArrayList<>(); nonEmptyArrayList.add("something"); ArrayList<String> emptyArrayList = new ArrayList<>(); assertTrue(fieldStateValidator.validateFieldValueRequired(labelField, nonEmptyArrayList)); assertFalse(fieldStateValidator.validateFieldValueRequired(labelField, emptyArrayList)); }
protected boolean validateFieldValueRequired(FormField field, Object value) { String message = translationService.getTranslation(ProcessingEngineConstants.FieldStateValidatorImplFieldIsRequired); if (value == null) { field.showError(message); return false; } if (validators.containsKey(value.getClass())) { Predicate predicate = validators.get(value.getClass()); if (!predicate.test(value)) { field.showError(message); return false; } } return true; }
FieldStateValidatorImpl implements FieldStateValidator { protected boolean validateFieldValueRequired(FormField field, Object value) { String message = translationService.getTranslation(ProcessingEngineConstants.FieldStateValidatorImplFieldIsRequired); if (value == null) { field.showError(message); return false; } if (validators.containsKey(value.getClass())) { Predicate predicate = validators.get(value.getClass()); if (!predicate.test(value)) { field.showError(message); return false; } } return true; } }
FieldStateValidatorImpl implements FieldStateValidator { protected boolean validateFieldValueRequired(FormField field, Object value) { String message = translationService.getTranslation(ProcessingEngineConstants.FieldStateValidatorImplFieldIsRequired); if (value == null) { field.showError(message); return false; } if (validators.containsKey(value.getClass())) { Predicate predicate = validators.get(value.getClass()); if (!predicate.test(value)) { field.showError(message); return false; } } return true; } @Inject  FieldStateValidatorImpl(TranslationService translationService); }
FieldStateValidatorImpl implements FieldStateValidator { protected boolean validateFieldValueRequired(FormField field, Object value) { String message = translationService.getTranslation(ProcessingEngineConstants.FieldStateValidatorImplFieldIsRequired); if (value == null) { field.showError(message); return false; } if (validators.containsKey(value.getClass())) { Predicate predicate = validators.get(value.getClass()); if (!predicate.test(value)) { field.showError(message); return false; } } return true; } @Inject  FieldStateValidatorImpl(TranslationService translationService); @PostConstruct void initialize(); @Override boolean validate(Collection<FormField> fields); @Override boolean validate(FormField field); }
FieldStateValidatorImpl implements FieldStateValidator { protected boolean validateFieldValueRequired(FormField field, Object value) { String message = translationService.getTranslation(ProcessingEngineConstants.FieldStateValidatorImplFieldIsRequired); if (value == null) { field.showError(message); return false; } if (validators.containsKey(value.getClass())) { Predicate predicate = validators.get(value.getClass()); if (!predicate.test(value)) { field.showError(message); return false; } } return true; } @Inject  FieldStateValidatorImpl(TranslationService translationService); @PostConstruct void initialize(); @Override boolean validate(Collection<FormField> fields); @Override boolean validate(FormField field);  }