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/UtilsTest.groovy

49 lines
951 B
Groovy
Raw Normal View History

2018-02-14 12:32:46 +02:00
package com.sap.piper
import org.junit.Rule
import org.junit.Before
import org.junit.Test
import org.junit.rules.ExpectedException
import com.sap.piper.Utils
class UtilsTest {
@Rule
public ExpectedException thrown = new ExpectedException().none()
private utils = new Utils()
private parameters
@Before
void setup() {
parameters = [:]
}
@Test
void noValueGetMandatoryParameterTest() {
thrown.expect(Exception)
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR test")
utils.getMandatoryParameter(parameters, 'test', null)
}
@Test
void defaultValueGetMandatoryParameterTest() {
assert utils.getMandatoryParameter(parameters, 'test', 'default') == 'default'
}
@Test
void valueGetmandatoryParameterTest() {
parameters.put('test', 'value')
assert utils.getMandatoryParameter(parameters, 'test', null) == 'value'
}
}