Tabnine Logo
ValidationException
Code IndexAdd Tabnine to your IDE (free)

How to use
ValidationException
in
org.springframework.batch.item.validator

Best Java code snippets using org.springframework.batch.item.validator.ValidationException (Showing top 10 results out of 315)

origin: spring-projects/spring-batch

  @Override
  public Trade process(Trade item) throws Exception {
    if ((failedItem == null && index++ == failure) || (failedItem != null && failedItem.equals(item))) {
      failedItem = item;
      throw new ValidationException("Some bad data for " + failedItem);
    }
    return item;
  }
}
origin: spring-projects/spring-batch

/**
 * Typical failed validation - {@link ValidationException} is thrown
 */
@Test(expected = BindException.class)
public void testValidateFailureWithErrors() throws Exception {
  try {
    validator.validate(MockSpringValidator.REJECT_VALUE);
  }
  catch (ValidationException e) {
    throw (BindException) e.getCause();
  }
}
origin: spring-projects/spring-batch

/**
 * Typical failed validation - message contains the item and names of
 * invalid fields.
 */
@Test
public void testValidateFailureWithFields() {
  try {
    validator.validate(MockSpringValidator.REJECT_MULTI_VALUE);
    fail("exception should have been thrown on invalid value");
  }
  catch (ValidationException expected) {
    assertTrue("message should contain the item#toString() value", expected.getMessage().contains(
        "TestBeanToString"));
    assertTrue("message should contain names of the invalid fields", expected.getMessage().contains("foo"));
    assertTrue("message should contain names of the invalid fields", expected.getMessage().contains("bar"));
  }
}
origin: spring-projects/spring-batch

@Override
public Exception getException(String msg) throws Exception {
  return new ValidationException(msg);
}
origin: spring-projects/spring-batch

@Override
public Exception getException(String msg, Throwable t) throws Exception {
  return new ValidationException(msg, t);
}
origin: spring-projects/spring-batch

/**
 * @see Validator#validate(Object)
 */
@Override
public void validate(T item) throws ValidationException {
  if (!validator.supports(item.getClass())) {
    throw new ValidationException("Validation failed for " + item + ": " + item.getClass().getName()
        + " class is not supported by validator.");
  }
  BeanPropertyBindingResult errors = new BeanPropertyBindingResult(item, "item");
  validator.validate(item, errors);
  if (errors.hasErrors()) {
    throw new ValidationException("Validation failed for " + item + ": " + errorsToString(errors), new BindException(errors));
  }
}
origin: spring-projects/spring-batch

  private String processFailedValidation(ValidatingItemProcessor<String> tested) {
    validator.validate(ITEM);
    when(validator).thenThrow(new ValidationException("invalid item"));

    return tested.process(ITEM);
  }
}
origin: SmartDataAnalytics/jena-sparql-api

@Override
public void validate(Quad quad) throws ValidationException {
  boolean isValid = predicate.apply(quad);
  if(!isValid) {
    throw new ValidationException("A quad failed validation: " + quad);
  }
}
origin: mminella/LearningSpringBatch

  @Override
  public void validate(Customer value) throws ValidationException {
    if(value.getFirstName().startsWith("A")) {
      throw new ValidationException("First names that begin with A are invalid: " + value);
    }
  }
}
origin: apache/servicemix-bundles

/**
 * @see Validator#validate(Object)
 */
@Override
public void validate(T item) throws ValidationException {
  if (!validator.supports(item.getClass())) {
    throw new ValidationException("Validation failed for " + item + ": " + item.getClass().getName()
        + " class is not supported by validator.");
  }
  BeanPropertyBindingResult errors = new BeanPropertyBindingResult(item, "item");
  validator.validate(item, errors);
  if (errors.hasErrors()) {
    throw new ValidationException("Validation failed for " + item + ": " + errorsToString(errors), new BindException(errors));
  }
}
org.springframework.batch.item.validatorValidationException

Javadoc

This exception should be thrown when there are validation errors.

Most used methods

  • <init>
    Create a new ValidationException based on a message and another exception.
  • getCause
  • getMessage

Popular in Java

  • Running tasks concurrently on multiple threads
  • findViewById (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (ScheduledExecutorService)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • JList (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now