You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-09-16 09:26:22 +02:00
Merge pull request #9 from alejandraferreirovidal/utilsTestGetMandatoryParameter
getMandatoryParameter() unit tests
This commit is contained in:
46
test/groovy/UtilsTest.groovy
Normal file
46
test/groovy/UtilsTest.groovy
Normal file
@@ -0,0 +1,46 @@
|
||||
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'
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user