github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/test/groovy/TransportRequestUploadSOLMANTest.groovy (about) 1 import org.junit.Before 2 import org.junit.Ignore 3 import org.junit.Rule 4 import org.junit.Test 5 import org.junit.rules.ExpectedException 6 import org.junit.rules.RuleChain 7 import org.yaml.snakeyaml.parser.ParserException 8 9 import hudson.AbortException 10 import util.BasePiperTest 11 import util.JenkinsDockerExecuteRule 12 import util.JenkinsLoggingRule 13 import util.JenkinsReadYamlRule 14 import util.JenkinsShellCallRule 15 import util.JenkinsStepRule 16 import util.JenkinsWriteFileRule 17 import util.Rules 18 19 import static org.junit.Assert.assertThat 20 import static org.hamcrest.Matchers.containsString 21 import static org.hamcrest.Matchers.hasItem 22 23 public class TransportRequestUploadSOLMANTest extends BasePiperTest { 24 25 private JenkinsStepRule stepRule = new JenkinsStepRule(this) 26 private JenkinsReadYamlRule readYamlRule = new JenkinsReadYamlRule(this) 27 28 @Rule 29 public RuleChain ruleChain = Rules 30 .getCommonRules(this) 31 .around(stepRule) 32 .around(readYamlRule) 33 34 @Test 35 void testCallGoWrapper() { 36 37 def calledWithParameters, 38 calledWithStepName, 39 calledWithMetadata, 40 calledWithCredentials 41 42 helper.registerAllowedMethod( 43 'piperExecuteBin', 44 [Map, String, String, List], 45 { 46 params, stepName, metaData, creds -> 47 calledWithParameters = params 48 calledWithStepName = stepName 49 calledWithMetadata = metaData 50 calledWithCredentials = creds 51 } 52 ) 53 54 stepRule.step.transportRequestUploadSOLMAN(script: nullScript, abc: 'CF') 55 56 assert calledWithParameters.size() == 2 57 assert calledWithParameters.script == nullScript 58 assert calledWithParameters.abc == 'CF' 59 60 assert calledWithStepName == 'transportRequestUploadSOLMAN' 61 assert calledWithMetadata == 'metadata/transportRequestUploadSOLMAN.yaml' 62 assert calledWithCredentials[0].size() == 3 63 } 64 }