@Test public final void testValidateCase05() { try { LogReaderCommand cmd = new LogReaderCommand(); Errors errors = new BindException(cmd, "LogReaderCommand"); cmd.setFilterType(LogReaderCommand.VALUE_REGEX_MATCH); cmd.setFilter("0"); cmd.setNoOfLines(700); testInstance.validate(cmd, errors); assertEquals("Case05: Not expecting errors with newly initialised objects", 0, errors.getErrorCount()); } catch (Exception e) { String message = e.getClass().toString() + " - " + e.getMessage(); log.debug(message); fail(message); } }
public void validate(Object comm, Errors errors) { LogReaderCommand command = (LogReaderCommand) comm; ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_LINES, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_LINES), "Number of Lines is a required field"); ValidatorUtil.validateRegEx(errors, command.getNoOfLines(), "^[0-9]*$", "typeMismatch.java.lang.Integer",getObjectArrayForLabel(LogReaderCommand.PARAM_LINES),"Number of Lines must be an integer"); if(LogReaderCommand.VALUE_FROM_LINE.equals(command.getFilterType())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Line Number is a required field"); ValidatorUtil.validateRegEx(errors, command.getFilter(), "^[0-9]*$", "typeMismatch.java.lang.Integer",getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER),"Line Number must be an integer"); } if(LogReaderCommand.VALUE_TIMESTAMP.equals(command.getFilterType())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Date/Time is a required field"); } if(LogReaderCommand.VALUE_REGEX_MATCH.equals(command.getFilterType()) || LogReaderCommand.VALUE_REGEX_CONTAIN.equals(command.getFilterType()) || LogReaderCommand.VALUE_REGEX_INDENT.equals(command.getFilterType()) ) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Regular Expression is a required field"); } }
LogReaderValidator extends AbstractBaseValidator { public void validate(Object comm, Errors errors) { LogReaderCommand command = (LogReaderCommand) comm; ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_LINES, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_LINES), "Number of Lines is a required field"); ValidatorUtil.validateRegEx(errors, command.getNoOfLines(), "^[0-9]*$", "typeMismatch.java.lang.Integer",getObjectArrayForLabel(LogReaderCommand.PARAM_LINES),"Number of Lines must be an integer"); if(LogReaderCommand.VALUE_FROM_LINE.equals(command.getFilterType())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Line Number is a required field"); ValidatorUtil.validateRegEx(errors, command.getFilter(), "^[0-9]*$", "typeMismatch.java.lang.Integer",getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER),"Line Number must be an integer"); } if(LogReaderCommand.VALUE_TIMESTAMP.equals(command.getFilterType())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Date/Time is a required field"); } if(LogReaderCommand.VALUE_REGEX_MATCH.equals(command.getFilterType()) || LogReaderCommand.VALUE_REGEX_CONTAIN.equals(command.getFilterType()) || LogReaderCommand.VALUE_REGEX_INDENT.equals(command.getFilterType()) ) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Regular Expression is a required field"); } } }
LogReaderValidator extends AbstractBaseValidator { public void validate(Object comm, Errors errors) { LogReaderCommand command = (LogReaderCommand) comm; ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_LINES, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_LINES), "Number of Lines is a required field"); ValidatorUtil.validateRegEx(errors, command.getNoOfLines(), "^[0-9]*$", "typeMismatch.java.lang.Integer",getObjectArrayForLabel(LogReaderCommand.PARAM_LINES),"Number of Lines must be an integer"); if(LogReaderCommand.VALUE_FROM_LINE.equals(command.getFilterType())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Line Number is a required field"); ValidatorUtil.validateRegEx(errors, command.getFilter(), "^[0-9]*$", "typeMismatch.java.lang.Integer",getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER),"Line Number must be an integer"); } if(LogReaderCommand.VALUE_TIMESTAMP.equals(command.getFilterType())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Date/Time is a required field"); } if(LogReaderCommand.VALUE_REGEX_MATCH.equals(command.getFilterType()) || LogReaderCommand.VALUE_REGEX_CONTAIN.equals(command.getFilterType()) || LogReaderCommand.VALUE_REGEX_INDENT.equals(command.getFilterType()) ) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Regular Expression is a required field"); } }  }
LogReaderValidator extends AbstractBaseValidator { public void validate(Object comm, Errors errors) { LogReaderCommand command = (LogReaderCommand) comm; ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_LINES, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_LINES), "Number of Lines is a required field"); ValidatorUtil.validateRegEx(errors, command.getNoOfLines(), "^[0-9]*$", "typeMismatch.java.lang.Integer",getObjectArrayForLabel(LogReaderCommand.PARAM_LINES),"Number of Lines must be an integer"); if(LogReaderCommand.VALUE_FROM_LINE.equals(command.getFilterType())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Line Number is a required field"); ValidatorUtil.validateRegEx(errors, command.getFilter(), "^[0-9]*$", "typeMismatch.java.lang.Integer",getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER),"Line Number must be an integer"); } if(LogReaderCommand.VALUE_TIMESTAMP.equals(command.getFilterType())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Date/Time is a required field"); } if(LogReaderCommand.VALUE_REGEX_MATCH.equals(command.getFilterType()) || LogReaderCommand.VALUE_REGEX_CONTAIN.equals(command.getFilterType()) || LogReaderCommand.VALUE_REGEX_INDENT.equals(command.getFilterType()) ) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Regular Expression is a required field"); } }  boolean supports(Class clazz); void validate(Object comm, Errors errors); }
LogReaderValidator extends AbstractBaseValidator { public void validate(Object comm, Errors errors) { LogReaderCommand command = (LogReaderCommand) comm; ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_LINES, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_LINES), "Number of Lines is a required field"); ValidatorUtil.validateRegEx(errors, command.getNoOfLines(), "^[0-9]*$", "typeMismatch.java.lang.Integer",getObjectArrayForLabel(LogReaderCommand.PARAM_LINES),"Number of Lines must be an integer"); if(LogReaderCommand.VALUE_FROM_LINE.equals(command.getFilterType())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Line Number is a required field"); ValidatorUtil.validateRegEx(errors, command.getFilter(), "^[0-9]*$", "typeMismatch.java.lang.Integer",getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER),"Line Number must be an integer"); } if(LogReaderCommand.VALUE_TIMESTAMP.equals(command.getFilterType())) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Date/Time is a required field"); } if(LogReaderCommand.VALUE_REGEX_MATCH.equals(command.getFilterType()) || LogReaderCommand.VALUE_REGEX_CONTAIN.equals(command.getFilterType()) || LogReaderCommand.VALUE_REGEX_INDENT.equals(command.getFilterType()) ) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, LogReaderCommand.PARAM_FILTER, "required", getObjectArrayForLabel(LogReaderCommand.PARAM_FILTER), "Regular Expression is a required field"); } }  boolean supports(Class clazz); void validate(Object comm, Errors errors);  }