1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-20 05:19:40 +02:00

Merge branch 'master' into pr/httpsPushArtifactSetVersion

This commit is contained in:
Thorsten Duda 2019-11-14 15:15:30 +01:00 committed by GitHub
commit bd6cb9af3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -20,6 +20,12 @@ class MapUtils implements Serializable {
return result
}
/**
* Merge two maps with the second one has precedence
* @param base First map
* @param overlay Second map, takes precedence
* @return The merged map
*/
static Map merge(Map base, Map overlay) {
Map result = [:]

View File

@ -16,7 +16,7 @@ class MapUtilsTest {
}
@Test
void testMergeMapStraigtForward(){
void testMergeMapStraightForward(){
Map a = [a: '1',
c: [d: '1',
@ -31,6 +31,20 @@ class MapUtilsTest {
c: [d: 'x', e: '2']]
}
@Test
void testMergeMapWithConflict(){
Map a = [a: '1',
b: [c: 1]],
b = [a: '2',
b: [c: 2]]
Map merged = MapUtils.merge(a, b)
assert merged == [a: '2',
b: [c: 2]]
}
@Test
void testPruneNulls() {