@Bean public TaskletStep masterStep() { return this.masterStepBuilderFactory.get("masterStep") .<Integer, Integer>chunk(3) .reader(itemReader()) .outputChannel(requests()) .inputChannel(replies()) .build(); }
@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 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); }
@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 }
.transactionManager(this.transactionManager) .transactionAttribute(transactionAttribute) .inputChannel(this.inputChannel) .outputChannel(this.outputChannel) .listener(annotatedListener)
@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 }