1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-18 05:18:24 +02:00
This commit is contained in:
Marcus Holl 2018-06-20 11:45:42 +02:00
parent 7ce0c85fe9
commit c29fb02dd9
2 changed files with 37 additions and 2 deletions

View File

@ -0,0 +1,35 @@
import org.junit.Rule;
import org.junit.Test
import org.junit.rules.RuleChain;
import com.sap.piper.DefaultValueCache
import util.BasePiperTest
import util.JenkinsStepRule;
import util.Rules
public class PrepareDefaultValuesTest extends BasePiperTest {
private JenkinsStepRule jsr = new JenkinsStepRule(this)
@Rule
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(jsr)
@Test
public void testMerge() {
helper.registerAllowedMethod("libraryResource", [String], { fileName-> return fileName })
helper.registerAllowedMethod("readYaml", [Map], { m ->
switch(m.text) {
case 'default_pipeline_environment.yml': return [a: 'x']
default: return [the:'end']
}
})
jsr.step.call(script: nullScript)
println DefaultValueCache.getInstance().getDefaultValues()
}
}

View File

@ -19,8 +19,8 @@ def call(Map parameters = [:]) {
for (def configFileName : configurationFiles){
def configuration = readYaml text: libraryResource(configFileName)
defaultValues = MapUtils.merge(
MapUtils.pruneNull(defaultValues),
MapUtils.pruneNull(configuration))
MapUtils.pruneNulls(defaultValues),
MapUtils.pruneNulls(configuration))
}
DefaultValueCache.createInstance(defaultValues)
}