Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobParametersInvalidException


    final Message<JobLaunchRequest> message = MessageBuilder.withPayload(new JobLaunchRequest(new JobSupport("testJob"),
    new JobParameters())).build();

    final JobLauncher jobLauncher = mock(JobLauncher.class);
    when(jobLauncher.run(any(Job.class), any(JobParameters.class)))
      .thenThrow(new JobParametersInvalidException("This is a JobExecutionException."));

    JobLaunchingGateway jobLaunchingGateway = new JobLaunchingGateway(jobLauncher);

    try {
      jobLaunchingGateway.handleMessage(message);
View Full Code Here


    final Message<JobLaunchRequest> message = MessageBuilder.withPayload(new JobLaunchRequest(new JobSupport("testJob"),
    new JobParameters())).build();

    final JobLauncher jobLauncher = mock(JobLauncher.class);
    when(jobLauncher.run(any(Job.class), any(JobParameters.class)))
      .thenThrow(new JobParametersInvalidException("This is a JobExecutionException."));

    JobLaunchingGateway jobLaunchingGateway = new JobLaunchingGateway(jobLauncher);

    try {
      jobLaunchingGateway.handleMessage(message);
View Full Code Here

   */
  @Override
  public void validate(JobParameters parameters) throws JobParametersInvalidException {

    if (parameters == null) {
      throw new JobParametersInvalidException("The JobParameters can not be null");
    }

    Set<String> keys = parameters.getParameters().keySet();

    // If there are explicit optional keys then all keys must be in that
    // group, or in the required group.
    if (!optionalKeys.isEmpty()) {

      Collection<String> missingKeys = new HashSet<String>();
      for (String key : keys) {
        if (!optionalKeys.contains(key) && !requiredKeys.contains(key)) {
          missingKeys.add(key);
        }
      }
      if (!missingKeys.isEmpty()) {
        throw new JobParametersInvalidException(
            "The JobParameters contains keys that are not explicitly optional or required: " + missingKeys);
      }

    }

    Collection<String> missingKeys = new HashSet<String>();
    for (String key : requiredKeys) {
      if (!keys.contains(key)) {
        missingKeys.add(key);
      }
    }
    if (!missingKeys.isEmpty()) {
      throw new JobParametersInvalidException("The JobParameters do not contain required keys: " + missingKeys);
    }

  }
View Full Code Here

  @Test
  public void testSetValidator() throws Exception {
    job.setJobParametersValidator(new DefaultJobParametersValidator() {
      @Override
      public void validate(JobParameters parameters) throws JobParametersInvalidException {
        throw new JobParametersInvalidException("FOO");
      }
    });
    JobExecution execution = jobRepository.createJobExecution("job", new JobParameters());
    job.execute(execution);
    assertEquals(BatchStatus.FAILED, execution.getStatus());
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.JobParametersInvalidException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.