mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-04 04:07:16 +02:00
749aa5e7ed
* adding step for writing metrics to InfluxDB including dependencies * added documentation * incorporated PR feedback
43 lines
1.6 KiB
Groovy
43 lines
1.6 KiB
Groovy
package com.sap.piper
|
|
|
|
import org.junit.Assert
|
|
import org.junit.Test
|
|
|
|
class ConfigurationMergerTest {
|
|
|
|
@Test
|
|
void testMerge(){
|
|
Map defaults = [dockerImage: 'mvn']
|
|
Map parameters = [goals: 'install', flags: '']
|
|
List parameterKeys = ['flags']
|
|
Map configuration = [flags: '-B']
|
|
List configurationKeys = ['flags']
|
|
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, configuration, configurationKeys, defaults)
|
|
Assert.assertEquals('mvn', merged.dockerImage)
|
|
Assert.assertNull(merged.goals)
|
|
Assert.assertEquals('', merged.flags)
|
|
}
|
|
|
|
@Test
|
|
void testMergeParameterWithDefault(){
|
|
Map defaults = [nonErpDestinations: []]
|
|
Map parameters = [nonErpDestinations: null]
|
|
List parameterKeys = ['nonErpDestinations']
|
|
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, defaults)
|
|
Assert.assertEquals([], merged.nonErpDestinations)
|
|
}
|
|
|
|
@Test
|
|
void testMergeCustomPipelineValues(){
|
|
Map defaults = [dockerImage: 'mvn']
|
|
Map parameters = [goals: 'install', flags: '']
|
|
List parameterKeys = ['flags']
|
|
Map configuration = [flags: '-B']
|
|
List configurationKeys = ['flags']
|
|
Map pipelineDataMap = [artifactVersion: '1.2.3', flags: 'test']
|
|
Map merged = ConfigurationMerger.mergeWithPipelineData(parameters, parameterKeys, pipelineDataMap, configuration, configurationKeys, defaults)
|
|
Assert.assertEquals('', merged.flags)
|
|
Assert.assertEquals('1.2.3', merged.artifactVersion)
|
|
}
|
|
}
|