MoveTargetsValidator extends AbstractBaseValidator { public void validate(Object comm, Errors errors) { MoveTargetsCommand command = (MoveTargetsCommand) comm; if(MoveTargetsCommand.ACTION_MOVE_TARGETS.equals(command.getActionCmd())) { if((command.getParentOids() == null || command.getParentOids().length == 0) && command.getSelectedCount() == 0) { errors.reject("target.errors.addparents.must_select"); } } }  boolean supports(Class clazz); void validate(Object comm, Errors errors);  }
@Test public final void testValidate() { try { MoveTargetsCommand cmd = new MoveTargetsCommand(); Errors errors = new BindException(cmd, "MoveTargetsCommand"); cmd.setActionCmd(MoveTargetsCommand.ACTION_MOVE_TARGETS); testInstance.validate(cmd, errors); assertEquals("Expecting 1 errors", 1, errors.getErrorCount()); assertEquals("Expecting error[0]", true, errors.getAllErrors().toArray()[0].toString().contains("target.errors.addparents.must_select")); } catch (Exception e) { String message = e.getClass().toString() + " - " + e.getMessage(); log.debug(message); fail(message); } }