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