@Test public void testValidateSuccess() { PojoBean bean = PojoBean.makeValidate(); MethodInvocationInfo methodInvocationInfo = new MethodInvocationInfo(null, new Object[] {bean}, null, null, null); try { beanValidatorInvokerInterceptor.beforeInvoke(methodInvocationInfo); } catch (Exception e) { System.out.println(e.getMessage()); Assert.fail(e.getMessage()); } }
@Override public void beforeInvoke(MethodInvocationInfo methodInvocationInfo) { if (formatter == null) { throw new IllegalArgumentException("'property' formatter is null"); } Object[] args = methodInvocationInfo.getArgs(); if (args == null || args.length == 0) { return; } boolean voilationFound = false; Set<ConstraintViolation<Object>> results = new HashSet<ConstraintViolation<Object>>(); for (Object o : args) { Set<ConstraintViolation<Object>> result = validator.validate(o); if (result == null || result.isEmpty()) { continue; } voilationFound = true; results.addAll(result); } if (voilationFound) { String message = formatter.format(results); throw new RuntimeException(message); } }
BeanValidatorInvokerInterceptor implements InvokerInterceptor { @Override public void beforeInvoke(MethodInvocationInfo methodInvocationInfo) { if (formatter == null) { throw new IllegalArgumentException("'property' formatter is null"); } Object[] args = methodInvocationInfo.getArgs(); if (args == null || args.length == 0) { return; } boolean voilationFound = false; Set<ConstraintViolation<Object>> results = new HashSet<ConstraintViolation<Object>>(); for (Object o : args) { Set<ConstraintViolation<Object>> result = validator.validate(o); if (result == null || result.isEmpty()) { continue; } voilationFound = true; results.addAll(result); } if (voilationFound) { String message = formatter.format(results); throw new RuntimeException(message); } } }
BeanValidatorInvokerInterceptor implements InvokerInterceptor { @Override public void beforeInvoke(MethodInvocationInfo methodInvocationInfo) { if (formatter == null) { throw new IllegalArgumentException("'property' formatter is null"); } Object[] args = methodInvocationInfo.getArgs(); if (args == null || args.length == 0) { return; } boolean voilationFound = false; Set<ConstraintViolation<Object>> results = new HashSet<ConstraintViolation<Object>>(); for (Object o : args) { Set<ConstraintViolation<Object>> result = validator.validate(o); if (result == null || result.isEmpty()) { continue; } voilationFound = true; results.addAll(result); } if (voilationFound) { String message = formatter.format(results); throw new RuntimeException(message); } }  }
BeanValidatorInvokerInterceptor implements InvokerInterceptor { @Override public void beforeInvoke(MethodInvocationInfo methodInvocationInfo) { if (formatter == null) { throw new IllegalArgumentException("'property' formatter is null"); } Object[] args = methodInvocationInfo.getArgs(); if (args == null || args.length == 0) { return; } boolean voilationFound = false; Set<ConstraintViolation<Object>> results = new HashSet<ConstraintViolation<Object>>(); for (Object o : args) { Set<ConstraintViolation<Object>> result = validator.validate(o); if (result == null || result.isEmpty()) { continue; } voilationFound = true; results.addAll(result); } if (voilationFound) { String message = formatter.format(results); throw new RuntimeException(message); } }  void setFormatter(ConstraintViolationsFormatter formatter); @Override void beforeInvoke(MethodInvocationInfo methodInvocationInfo); @Override Object process(MethodInvocationInfo methodInvocationInfo); void afterProcess(); }
BeanValidatorInvokerInterceptor implements InvokerInterceptor { @Override public void beforeInvoke(MethodInvocationInfo methodInvocationInfo) { if (formatter == null) { throw new IllegalArgumentException("'property' formatter is null"); } Object[] args = methodInvocationInfo.getArgs(); if (args == null || args.length == 0) { return; } boolean voilationFound = false; Set<ConstraintViolation<Object>> results = new HashSet<ConstraintViolation<Object>>(); for (Object o : args) { Set<ConstraintViolation<Object>> result = validator.validate(o); if (result == null || result.isEmpty()) { continue; } voilationFound = true; results.addAll(result); } if (voilationFound) { String message = formatter.format(results); throw new RuntimeException(message); } }  void setFormatter(ConstraintViolationsFormatter formatter); @Override void beforeInvoke(MethodInvocationInfo methodInvocationInfo); @Override Object process(MethodInvocationInfo methodInvocationInfo); void afterProcess();  }