mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
257308298d
* Update MapUtils.groovy * Update ConfigurationMerger.groovy * tests * forward skipNull * Fix indent in tests * More tests. * MapUtils simplified wrt deep merge and pruneNulls * Add test for isMap with null value
47 lines
1.1 KiB
Groovy
47 lines
1.1 KiB
Groovy
package com.sap.piper
|
|
|
|
import org.junit.Assert
|
|
import org.junit.Test
|
|
|
|
class MapUtilsTest {
|
|
|
|
@Test
|
|
void testIsMap(){
|
|
Assert.assertTrue('Map is not recognized as Map', MapUtils.isMap([:]))
|
|
Assert.assertTrue('String is recognized as Map', !MapUtils.isMap('I am not a Map'))
|
|
Assert.assertFalse('Null value is recognized as Map', MapUtils.isMap(null))
|
|
}
|
|
|
|
@Test
|
|
void testMergeMapStraigtForward(){
|
|
|
|
Map a = [a: '1',
|
|
c: [d: '1',
|
|
e: '2']],
|
|
b = [b: '2',
|
|
c: [d: 'x']];
|
|
|
|
Map merged = MapUtils.merge(a, b)
|
|
|
|
assert merged == [a: '1',
|
|
b: '2',
|
|
c: [d: 'x', e: '2']]
|
|
}
|
|
|
|
@Test
|
|
void testPruneNulls() {
|
|
|
|
Map m = [a: '1',
|
|
b: 2,
|
|
c: [ d: 'abc',
|
|
e: '',
|
|
n2: null],
|
|
n1: null]
|
|
|
|
assert MapUtils.pruneNulls(m) == [ a: '1',
|
|
b: 2,
|
|
c: [ d: 'abc',
|
|
e: '']]
|
|
}
|
|
}
|