Remove some deprecated APIs from tests
The following deprecated APIs are not in use anymore in the project's tests: - `org.junit.rules.ExpectedException#none` - `org.mockito.MockitoAnnotations#initMocks` - `org.mockito.Mockito#verifyZeroInteractions` Issue #3838
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
7242f8fe77
commit
24422b5163
@@ -20,9 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.batch.core.ChunkListener;
|
||||
@@ -62,6 +60,7 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.interceptor.DefaultTransactionAttribute;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -75,9 +74,6 @@ import static org.mockito.Mockito.when;
|
||||
@ContextConfiguration(classes = {RemoteChunkingManagerStepBuilderTest.BatchConfiguration.class})
|
||||
public class RemoteChunkingManagerStepBuilderTest {
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Autowired
|
||||
private JobRepository jobRepository;
|
||||
@Autowired
|
||||
@@ -90,76 +86,66 @@ public class RemoteChunkingManagerStepBuilderTest {
|
||||
@Test
|
||||
public void inputChannelMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("inputChannel must not be null");
|
||||
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.inputChannel(null);
|
||||
|
||||
// when
|
||||
TaskletStep step = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.inputChannel(null)
|
||||
.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("inputChannel must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outputChannelMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("outputChannel must not be null");
|
||||
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.outputChannel(null);
|
||||
|
||||
// when
|
||||
TaskletStep step = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.outputChannel(null)
|
||||
.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("outputChannel must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void messagingTemplateMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("messagingTemplate must not be null");
|
||||
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.messagingTemplate(null);
|
||||
|
||||
// when
|
||||
TaskletStep step = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.messagingTemplate(null)
|
||||
.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("messagingTemplate must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maxWaitTimeoutsMustBeGreaterThanZero() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("maxWaitTimeouts must be greater than zero");
|
||||
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.maxWaitTimeouts(-1);
|
||||
|
||||
// when
|
||||
TaskletStep step = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.maxWaitTimeouts(-1)
|
||||
.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("maxWaitTimeouts must be greater than zero");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void throttleLimitMustNotBeGreaterThanZero() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("throttleLimit must be greater than zero");
|
||||
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.throttleLimit(-1L);
|
||||
|
||||
// when
|
||||
TaskletStep step = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.throttleLimit(-1L)
|
||||
.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("throttleLimit must be greater than zero");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -167,14 +153,11 @@ public class RemoteChunkingManagerStepBuilderTest {
|
||||
// given
|
||||
RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<>("step");
|
||||
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("An InputChannel must be provided");
|
||||
|
||||
// when
|
||||
TaskletStep step = builder.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("An InputChannel must be provided");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -185,37 +168,32 @@ public class RemoteChunkingManagerStepBuilderTest {
|
||||
.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();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalStateException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("You must specify either an outputChannel or a messagingTemplate but not both.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsupportedOperationExceptionWhenSpecifyingAnItemWriter() {
|
||||
// given
|
||||
this.expectedException.expect(UnsupportedOperationException.class);
|
||||
this.expectedException.expectMessage("When configuring a manager " +
|
||||
"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 RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
final RemoteChunkingManagerStepBuilder<String, String> builder = new RemoteChunkingManagerStepBuilder<String, String>("step")
|
||||
.reader(this.itemReader)
|
||||
.writer(items -> { })
|
||||
.repository(this.jobRepository)
|
||||
.transactionManager(this.transactionManager)
|
||||
.inputChannel(this.inputChannel)
|
||||
.outputChannel(this.outputChannel)
|
||||
.build();
|
||||
.outputChannel(this.outputChannel);
|
||||
|
||||
// when
|
||||
final Exception expectedException = Assert.assertThrows(UnsupportedOperationException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("When configuring a manager " +
|
||||
"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.");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
package org.springframework.batch.integration.chunk;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.batch.item.ItemProcessor;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
@@ -26,75 +24,66 @@ import org.springframework.batch.item.support.PassThroughItemProcessor;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class RemoteChunkingWorkerBuilderTest {
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
private ItemProcessor<String, String> itemProcessor = new PassThroughItemProcessor<>();
|
||||
private ItemWriter<String> itemWriter = items -> { };
|
||||
|
||||
@Test
|
||||
public void itemProcessorMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("itemProcessor must not be null");
|
||||
final RemoteChunkingWorkerBuilder<String, String> builder = new RemoteChunkingWorkerBuilder<String, String>()
|
||||
.itemProcessor(null);
|
||||
|
||||
// when
|
||||
IntegrationFlow integrationFlow = new RemoteChunkingWorkerBuilder<String, String>()
|
||||
.itemProcessor(null)
|
||||
.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("itemProcessor must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itemWriterMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("itemWriter must not be null");
|
||||
final RemoteChunkingWorkerBuilder<String, String> builder = new RemoteChunkingWorkerBuilder<String, String>()
|
||||
.itemWriter(null);
|
||||
|
||||
// when
|
||||
IntegrationFlow integrationFlow = new RemoteChunkingWorkerBuilder<String, String>()
|
||||
.itemWriter(null)
|
||||
.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("itemWriter must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void inputChannelMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("inputChannel must not be null");
|
||||
final RemoteChunkingWorkerBuilder<String, String> builder = new RemoteChunkingWorkerBuilder<String, String>()
|
||||
.inputChannel(null);
|
||||
|
||||
// when
|
||||
IntegrationFlow integrationFlow = new RemoteChunkingWorkerBuilder<String, String>()
|
||||
.inputChannel(null)
|
||||
.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("inputChannel must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outputChannelMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("outputChannel must not be null");
|
||||
final RemoteChunkingWorkerBuilder<String, String> builder = new RemoteChunkingWorkerBuilder<String, String>()
|
||||
.outputChannel(null);
|
||||
|
||||
// when
|
||||
IntegrationFlow integrationFlow = new RemoteChunkingWorkerBuilder<String, String>()
|
||||
.outputChannel(null)
|
||||
.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("outputChannel must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -102,14 +91,11 @@ public class RemoteChunkingWorkerBuilderTest {
|
||||
// given
|
||||
RemoteChunkingWorkerBuilder<String, String> builder = new RemoteChunkingWorkerBuilder<>();
|
||||
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("An ItemWriter must be provided");
|
||||
|
||||
// when
|
||||
builder.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("An ItemWriter must be provided");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,14 +104,11 @@ public class RemoteChunkingWorkerBuilderTest {
|
||||
RemoteChunkingWorkerBuilder<String, String> builder = new RemoteChunkingWorkerBuilder<String, String>()
|
||||
.itemWriter(items -> { });
|
||||
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("An InputChannel must be provided");
|
||||
|
||||
// when
|
||||
builder.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("An InputChannel must be provided");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -135,14 +118,12 @@ public class RemoteChunkingWorkerBuilderTest {
|
||||
.itemWriter(items -> { })
|
||||
.inputChannel(new DirectChannel());
|
||||
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("An OutputChannel must be provided");
|
||||
|
||||
// when
|
||||
builder.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("An OutputChannel must be provided");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
package org.springframework.batch.integration.partition;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -37,6 +35,7 @@ import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.test.util.ReflectionTestUtils.getField;
|
||||
|
||||
/**
|
||||
@@ -46,75 +45,72 @@ import static org.springframework.test.util.ReflectionTestUtils.getField;
|
||||
@ContextConfiguration(classes = {RemotePartitioningMasterStepBuilderTests.BatchConfiguration.class})
|
||||
public class RemotePartitioningMasterStepBuilderTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Autowired
|
||||
private JobRepository jobRepository;
|
||||
|
||||
@Test
|
||||
public void inputChannelMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("inputChannel must not be null");
|
||||
final RemotePartitioningMasterStepBuilder builder = new RemotePartitioningMasterStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningMasterStepBuilder("step").inputChannel(null);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
|
||||
() -> builder.inputChannel(null));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("inputChannel must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outputChannelMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("outputChannel must not be null");
|
||||
final RemotePartitioningMasterStepBuilder builder = new RemotePartitioningMasterStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningMasterStepBuilder("step").outputChannel(null);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
|
||||
() -> builder.outputChannel(null));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("outputChannel must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void messagingTemplateMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("messagingTemplate must not be null");
|
||||
final RemotePartitioningMasterStepBuilder builder = new RemotePartitioningMasterStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningMasterStepBuilder("step").messagingTemplate(null);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
|
||||
() -> builder.messagingTemplate(null));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("messagingTemplate must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jobExplorerMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("jobExplorer must not be null");
|
||||
final RemotePartitioningMasterStepBuilder builder = new RemotePartitioningMasterStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningMasterStepBuilder("step").jobExplorer(null);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
|
||||
() -> builder.jobExplorer(null));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("jobExplorer must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollIntervalMustBeGreaterThanZero() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("The poll interval must be greater than zero");
|
||||
final RemotePartitioningMasterStepBuilder builder = new RemotePartitioningMasterStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningMasterStepBuilder("step").pollInterval(-1);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class,
|
||||
() -> builder.pollInterval(-1));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("The poll interval must be greater than zero");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,32 +120,30 @@ public class RemotePartitioningMasterStepBuilderTests {
|
||||
.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
|
||||
Step step = builder.build();
|
||||
final Exception expectedException = Assert.assertThrows(IllegalStateException.class,
|
||||
builder::build);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("You must specify either an outputChannel or a messagingTemplate but not both.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsupportedOperationExceptionWhenSpecifyingPartitionHandler() {
|
||||
// given
|
||||
PartitionHandler partitionHandler = Mockito.mock(PartitionHandler.class);
|
||||
this.expectedException.expect(UnsupportedOperationException.class);
|
||||
this.expectedException.expectMessage("When configuring a master step " +
|
||||
final RemotePartitioningMasterStepBuilder builder = new RemotePartitioningMasterStepBuilder("step");
|
||||
|
||||
// when
|
||||
final Exception expectedException = Assert.assertThrows(UnsupportedOperationException.class,
|
||||
() -> builder.partitionHandler(partitionHandler));
|
||||
|
||||
// then
|
||||
assertThat(expectedException).hasMessage("When configuring a master step " +
|
||||
"for remote partitioning using the RemotePartitioningMasterStepBuilder, " +
|
||||
"the partition handler will be automatically set to an instance " +
|
||||
"of MessageChannelPartitionHandler. The partition handler must " +
|
||||
"not be provided in this case.");
|
||||
|
||||
// when
|
||||
new RemotePartitioningMasterStepBuilder("step").partitionHandler(partitionHandler);
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,117 +16,107 @@
|
||||
|
||||
package org.springframework.batch.integration.partition;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class RemotePartitioningWorkerStepBuilderTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@Mock
|
||||
private Tasklet tasklet;
|
||||
|
||||
@Test
|
||||
public void inputChannelMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("inputChannel must not be null");
|
||||
final RemotePartitioningWorkerStepBuilder builder = new RemotePartitioningWorkerStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningWorkerStepBuilder("step").inputChannel(null);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, () -> builder.inputChannel(null));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("inputChannel must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outputChannelMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("outputChannel must not be null");
|
||||
final RemotePartitioningWorkerStepBuilder builder = new RemotePartitioningWorkerStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningWorkerStepBuilder("step").outputChannel(null);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, () -> builder.outputChannel(null));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("outputChannel must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jobExplorerMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("jobExplorer must not be null");
|
||||
final RemotePartitioningWorkerStepBuilder builder = new RemotePartitioningWorkerStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningWorkerStepBuilder("step").jobExplorer(null);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, () -> builder.jobExplorer(null));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("jobExplorer must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stepLocatorMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("stepLocator must not be null");
|
||||
final RemotePartitioningWorkerStepBuilder builder = new RemotePartitioningWorkerStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningWorkerStepBuilder("step").stepLocator(null);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, () -> builder.stepLocator(null));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("stepLocator must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanFactoryMustNotBeNull() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("beanFactory must not be null");
|
||||
final RemotePartitioningWorkerStepBuilder builder = new RemotePartitioningWorkerStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningWorkerStepBuilder("step").beanFactory(null);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, () -> builder.beanFactory(null));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("beanFactory must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMandatoryInputChannel() {
|
||||
// given
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("An InputChannel must be provided");
|
||||
final RemotePartitioningWorkerStepBuilder builder = new RemotePartitioningWorkerStepBuilder("step");
|
||||
|
||||
// when
|
||||
new RemotePartitioningWorkerStepBuilder("step").tasklet(this.tasklet);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, () -> builder.tasklet(this.tasklet));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("An InputChannel must be provided");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMandatoryJobExplorer() {
|
||||
// given
|
||||
DirectChannel inputChannel = new DirectChannel();
|
||||
this.expectedException.expect(IllegalArgumentException.class);
|
||||
this.expectedException.expectMessage("A JobExplorer must be provided");
|
||||
final RemotePartitioningWorkerStepBuilder builder = new RemotePartitioningWorkerStepBuilder("step")
|
||||
.inputChannel(inputChannel);
|
||||
|
||||
// when
|
||||
new RemotePartitioningWorkerStepBuilder("step")
|
||||
.inputChannel(inputChannel)
|
||||
.tasklet(this.tasklet);
|
||||
final Exception expectedException = Assert.assertThrows(IllegalArgumentException.class, () -> builder.tasklet(this.tasklet));
|
||||
|
||||
// then
|
||||
// expected exception
|
||||
assertThat(expectedException).hasMessage("A JobExplorer must be provided");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user