2017-12-06 13:03:06 +02:00
|
|
|
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)
|
|
|
|
}
|
2018-01-24 10:55:38 +02:00
|
|
|
|
|
|
|
@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)
|
|
|
|
}
|
2018-02-01 13:16:21 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void testMergeDeepStructure(){
|
|
|
|
Map defaults = [fruits: [apples: 1, oranges: 10, bananaaas: 0]]
|
|
|
|
Map configuration = [fruits: [bananaaas: 50, cucumbers: 1000]]
|
2018-02-07 13:01:46 +02:00
|
|
|
List configurationKeys = ['fruits']
|
|
|
|
Map parameters = [fruits: [apples: 18], veggie: []]
|
|
|
|
List parameterKeys = ['fruits']
|
2018-02-05 21:31:30 +02:00
|
|
|
Map merged = ConfigurationMerger.merge(parameters, parameterKeys, configuration, configurationKeys, defaults)
|
2018-02-01 13:16:21 +02:00
|
|
|
Assert.assertEquals(50, merged.fruits.bananaaas)
|
|
|
|
Assert.assertEquals(18, merged.fruits.apples)
|
2018-02-05 20:54:04 +02:00
|
|
|
Assert.assertEquals(10, merged.fruits.oranges)
|
2018-02-07 13:01:46 +02:00
|
|
|
Assert.assertEquals(1000, merged.fruits.cucumbers)
|
|
|
|
Assert.assertEquals(null, merged.veggie)
|
2018-02-01 13:16:21 +02:00
|
|
|
}
|
2017-12-06 13:03:06 +02:00
|
|
|
}
|