@Bean public TaskletStep masterStep() { return this.masterStepBuilderFactory.get("masterStep") .<Integer, Integer>chunk(3) .reader(itemReader()) .outputChannel(requests()) .inputChannel(replies()) .build(); }
@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 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 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 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 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 }
.stream(stream) .keyGenerator(Object::hashCode) .build();
@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 }