Refactored to add a way to copy JobParameters into another via builder
In a previous commit, the JobParametersBuilder was updated to include some code from Spring Boot that handled the incrementing of JobParameters for a previous job. That commit brought over a private `merge` method that is actually useful for general consumption. This commit adds a `addJobParameters` method to the builder providing the same functionality the `merge` method did in a public method.
This commit is contained in:
@@ -64,6 +64,28 @@ public class JobParametersBuilderTests {
|
||||
this.parametersBuilder = new JobParametersBuilder(this.jobExplorer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddingExistingJobParameters() {
|
||||
JobParameters params1 = new JobParametersBuilder()
|
||||
.addString("foo", "bar")
|
||||
.addString("bar", "baz")
|
||||
.toJobParameters();
|
||||
|
||||
JobParameters params2 = new JobParametersBuilder()
|
||||
.addString("foo", "baz")
|
||||
.toJobParameters();
|
||||
|
||||
JobParameters finalParams = new JobParametersBuilder()
|
||||
.addString("baz", "quix")
|
||||
.addJobParameters(params1)
|
||||
.addJobParameters(params2)
|
||||
.toJobParameters();
|
||||
|
||||
assertEquals(finalParams.getString("foo"), "baz");
|
||||
assertEquals(finalParams.getString("bar"), "baz");
|
||||
assertEquals(finalParams.getString("baz"), "quix");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonIdentifyingParameters() {
|
||||
this.parametersBuilder.addDate("SCHEDULE_DATE", date, false);
|
||||
|
||||
Reference in New Issue
Block a user