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:
Michael Minella
2017-10-20 12:43:06 -05:00
parent 63dfe4b912
commit b2f8f7f9cd
2 changed files with 39 additions and 9 deletions

View File

@@ -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);