1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/test/groovy/com/sap/piper/ConfigurationHelperTest.groovy

39 lines
1.4 KiB
Groovy
Raw Normal View History

package com.sap.piper
import groovy.test.GroovyAssert
import org.junit.Assert
import org.junit.Test
class ConfigurationHelperTest {
private static getConfiguration() {
Map configuration = [dockerImage: 'maven:3.2-jdk-8-onbuild']
return configuration
}
@Test
void testGetProperty() {
def configuration = new ConfigurationHelper(getConfiguration())
Assert.assertEquals('maven:3.2-jdk-8-onbuild', configuration.getConfigProperty('dockerImage'))
Assert.assertEquals('default', configuration.getConfigProperty('something', 'default'))
Assert.assertTrue(configuration.isPropertyDefined('dockerImage'))
Assert.assertFalse(configuration.isPropertyDefined('something'))
}
@Test
void testIsPropertyDefined() {
def configuration = new ConfigurationHelper(getConfiguration())
Assert.assertTrue(configuration.isPropertyDefined('dockerImage'))
Assert.assertFalse(configuration.isPropertyDefined('something'))
}
@Test
void testGetMandatoryProperty() {
def configuration = new ConfigurationHelper(getConfiguration())
Assert.assertEquals('maven:3.2-jdk-8-onbuild', configuration.getMandatoryProperty('dockerImage'))
Assert.assertEquals('default', configuration.getMandatoryProperty('something', 'default'))
GroovyAssert.shouldFail { configuration.getMandatoryProperty('something') }
}
}