@Test public void testMasterStepCreation() { // when TaskletStep taskletStep = new RemoteChunkingMasterStepBuilder<String, String>("step") .reader(this.itemReader) .repository(this.jobRepository) .transactionManager(this.transactionManager) .inputChannel(this.inputChannel) .outputChannel(this.outputChannel) .build(); // then Assert.assertNotNull(taskletStep); }
@Bean public TaskletStep masterStep() { return this.masterStepBuilderFactory.get("masterStep") .<Integer, Integer>chunk(3) .reader(itemReader()) .outputChannel(requests()) .inputChannel(replies()) .build(); }
/** * Creates a {@link RemoteChunkingMasterStepBuilder} and initializes its job * repository and transaction manager. * * @param name the name of the step * @param <I> type of input items * @param <O> type of output items * @return a {@link RemoteChunkingMasterStepBuilder} */ public <I, O> RemoteChunkingMasterStepBuilder<I, O> get(String name) { return new RemoteChunkingMasterStepBuilder<I, O>(name) .repository(this.jobRepository) .transactionManager(this.transactionManager); }
TaskletStep taskletStep = new RemoteChunkingMasterStepBuilder<String, String>("step") .reader(itemReader) .readerIsTransactionalQueue() .processor(itemProcessor) .repository(this.jobRepository) .transactionManager(this.transactionManager) .transactionAttribute(transactionAttribute) .inputChannel(this.inputChannel) .outputChannel(this.outputChannel) .listener(annotatedListener) .listener(skipListener) .listener(chunkListener) .listener(stepExecutionListener) .listener(itemReadListener) .listener(itemWriteListener) .listener(retryListener) .skip(Exception.class) .noSkip(RuntimeException.class) .skipLimit(10) .retry(IOException.class) .noRetry(RuntimeException.class) .retryLimit(10) .retryContextCache(retryCache) .noRollback(Exception.class) .startLimit(3) .allowStartIfComplete(true) .stepOperations(stepOperations) .chunk(3) .backOffPolicy(backOffPolicy)
@Test public void eitherOutputChannelOrMessagingTemplateMustBeProvided() { // given RemoteChunkingMasterStepBuilder<String, String> builder = new RemoteChunkingMasterStepBuilder<String, String>("step") .inputChannel(this.inputChannel) .outputChannel(new DirectChannel()) .messagingTemplate(new MessagingTemplate()); this.expectedException.expect(IllegalStateException.class); this.expectedException.expectMessage("You must specify either an outputChannel or a messagingTemplate but not both."); // when TaskletStep step = builder.build(); // then // expected exception }
@Test public void inputChannelMustNotBeNull() { // given this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("inputChannel must not be null"); // when TaskletStep step = new RemoteChunkingMasterStepBuilder<String, String>("step") .inputChannel(null) .build(); // then // expected exception }
@Test public void outputChannelMustNotBeNull() { // given this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("outputChannel must not be null"); // when TaskletStep step = new RemoteChunkingMasterStepBuilder<String, String>("step") .outputChannel(null) .build(); // then // expected exception }
@Test public void messagingTemplateMustNotBeNull() { // given this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("messagingTemplate must not be null"); // when TaskletStep step = new RemoteChunkingMasterStepBuilder<String, String>("step") .messagingTemplate(null) .build(); // then // expected exception }
@Test public void throttleLimitMustNotBeGreaterThanZero() { // given this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("throttleLimit must be greater than zero"); // when TaskletStep step = new RemoteChunkingMasterStepBuilder<String, String>("step") .throttleLimit(-1L) .build(); // then // expected exception }
@Test public void maxWaitTimeoutsMustBeGreaterThanZero() { // given this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("maxWaitTimeouts must be greater than zero"); // when TaskletStep step = new RemoteChunkingMasterStepBuilder<String, String>("step") .maxWaitTimeouts(-1) .build(); // then // expected exception }
@Test public void testMandatoryInputChannel() { // given RemoteChunkingMasterStepBuilder<String, String> builder = new RemoteChunkingMasterStepBuilder<>("step"); this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("An InputChannel must be provided"); // when TaskletStep step = builder.build(); // then // expected exception }
@Test public void testUnsupportedOperationExceptionWhenSpecifyingAnItemWriter() { // given this.expectedException.expect(UnsupportedOperationException.class); this.expectedException.expectMessage("When configuring a master " + "step for remote chunking, the item writer will be automatically " + "set to an instance of ChunkMessageChannelItemWriter. " + "The item writer must not be provided in this case."); // when TaskletStep step = new RemoteChunkingMasterStepBuilder<String, String>("step") .reader(this.itemReader) .writer(items -> { }) .repository(this.jobRepository) .transactionManager(this.transactionManager) .inputChannel(this.inputChannel) .outputChannel(this.outputChannel) .build(); // then // expected exception }