jenkinsci/jenkins — pull request #976 by sghill (2013-10-16 20:19:45+00:00)
Title: Adding ParametersAction#merge(ParametersAction) method with tests.

I propose we build atop the `ParametersAction#createUpdated(Collection)` method by creating `ParametersAction#merge(ParametersAction)`.

I'd like to be able to use this functionality in the build-pipeline-plugin, which currently has its own ([tested][mergeParamsTests]) method: [`BuildUtil#mergeParameters(ParametersAction, ParametersAction)`][mergeParams].

After creating tests that verified:
* overriding parameters replaced original parameters
* a new instance of `ParametersAction` was always returned
* null and empty parameters were handled gracefully

I refactored `ParametersAction#createUpdated(Collection)` a bit:
* using a for each loop while iterating both collections
* using `ParametersAction#getName()` instead of `ParametersAction#name`
* initializing the new list of parameters with all overrides, instead of adding them all at the end

[mergeParams]: https://github.com/jenkinsci/build-pipeline-plugin/blob/62852159b3a8ce8b5a346ed7eaee5ce6897558f3/src/main/java/au/com/centrumsystems/hudson/plugin/util/BuildUtil.java#L120-144
[mergeParamsTests]: https://github.com/jenkinsci/build-pipeline-plugin/blob/62852159b3a8ce8b5a346ed7eaee5ce6897558f3/src/test/java/au/com/centrumsystems/hudson/plugin/util/BuildUtilTest.java#L164-183