diff --git a/test/groovy/TransportRequestUploadFileTest.groovy b/test/groovy/TransportRequestUploadFileTest.groovy index 54db440c1..6f63c7331 100644 --- a/test/groovy/TransportRequestUploadFileTest.groovy +++ b/test/groovy/TransportRequestUploadFileTest.groovy @@ -246,7 +246,19 @@ public class TransportRequestUploadFileTest extends BasePiperTest { @Test public void uploadFileToTransportRequestRFCSuccessTest() { - def cmUtilsReceivedParams + def calledWithParameters, + calledWithStepName, + calledWithMetadata, + calledWithCredentials + + helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], { + params, stepName, metaData, creds -> + calledWithParameters = params + calledWithStepName = stepName + calledWithMetadata = metaData + calledWithCredentials = creds + } + ) nullScript.commonPipelineEnvironment.configuration = [general: @@ -257,42 +269,6 @@ public class TransportRequestUploadFileTest extends BasePiperTest { ] ] - def cm = new ChangeManagement(nullScript) { - - void uploadFileToTransportRequestRFC( - Map docker, - String transportRequestId, - String applicationId, - String applicationURL, - String endpoint, - String credentialsId, - String developmentInstance, - String developmentClient, - String applicationDescription, - String abapPackage, - String codePage, - boolean acceptUnixStyleLineEndings, - boolean failUploadOnWarning, - boolean verbose) { - - cmUtilsReceivedParams = [ - docker: docker, - transportRequestId: transportRequestId, - applicationName: applicationId, - applicationURL: applicationURL, - endpoint: endpoint, - credentialsId: credentialsId, - developmentInstance: developmentInstance, - developmentClient: developmentClient, - applicationDescription: applicationDescription, - abapPackage: abapPackage, - codePage: codePage, - acceptUnixStyleLineEndings: acceptUnixStyleLineEndings, - failUploadOnWarning: failUploadOnWarning, - ] - } - } - stepRule.step.transportRequestUploadFile(script: nullScript, applicationUrl: 'http://example.org/blobstore/xyz.zip', codePage: 'UTF-9', @@ -308,29 +284,22 @@ public class TransportRequestUploadFileTest extends BasePiperTest { applicationName: '42', applicationDescription: 'Lorem ipsum', abapPackage: 'XYZ', - cmUtils: cm,) + credentialsId: 'CM' + ) - assert cmUtilsReceivedParams == - [ - docker: [ - image: 'rfc', - options: [], - envVars: [:], - pullImage: true - ], - transportRequestId: '123456', - applicationName: '42', - applicationURL: 'http://example.org/blobstore/xyz.zip', - endpoint: 'https://example.org/rfc', - credentialsId: 'CM', - developmentInstance: '001', - developmentClient: '002', - applicationDescription: 'Lorem ipsum', - abapPackage:'XYZ', - codePage: 'UTF-9', - acceptUnixStyleLineEndings: true, - failUploadOnWarning: true, - ] + assertThat(calledWithStepName, is('transportRequestUploadRFC')) + assertThat(calledWithParameters.applicationName, is('42')) + assertThat(calledWithParameters.applicationUrl, is('http://example.org/blobstore/xyz.zip')) + assertThat(calledWithParameters.endpoint, is('https://example.org/rfc')) + assertThat(calledWithParameters.uploadCredentialsId, is('CM')) + assertThat(calledWithParameters.instance, is('001')) + assertThat(calledWithParameters.client, is('002')) + assertThat(calledWithParameters.applicationDescription, is('Lorem ipsum')) + assertThat(calledWithParameters.abapPackage, is('XYZ')) + assertThat(calledWithParameters.codePage, is('UTF-9')) + assertThat(calledWithParameters.acceptUnixStyleLineEndings, is(true)) + assertThat(calledWithParameters.failUploadOnWarning, is(true)) + assertThat(calledWithParameters.transportRequestId, is('123456')) } @Test @@ -339,26 +308,10 @@ public class TransportRequestUploadFileTest extends BasePiperTest { thrown.expect(AbortException) thrown.expectMessage('upload failed') - def cm = new ChangeManagement(nullScript) { - - void uploadFileToTransportRequestRFC( - Map docker, - String transportRequestId, - String applicationId, - String applicationURL, - String endpoint, - String credentialsId, - String developmentInstance, - String developmentClient, - String applicationDescription, - String abapPackage, - String codePage, - boolean acceptUnixStyleLineEndings, - boolean failOnUploadWarning, - boolean verbose) { - throw new ChangeManagementException('upload failed') + helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], { + throw new AbortException('upload failed') } - } + ) stepRule.step.transportRequestUploadFile(script: nullScript, applicationUrl: 'http://example.org/blobstore/xyz.zip', @@ -381,7 +334,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest { applicationName: '42', applicationDescription: 'Lorem ipsum', abapPackage: 'XYZ', - cmUtils: cm,) + credentialsId: 'CM' + ) } @Test diff --git a/vars/transportRequestUploadFile.groovy b/vars/transportRequestUploadFile.groovy index 15f822623..bb6ca0219 100644 --- a/vars/transportRequestUploadFile.groovy +++ b/vars/transportRequestUploadFile.groovy @@ -276,22 +276,20 @@ void call(Map parameters = [:]) { case BackendType.RFC: echo "[INFO] Uploading file '${configuration.applicationUrl}' to transport request '${configuration.transportRequestId}'." - - cm.uploadFileToTransportRequestRFC( - configuration.changeManagement.rfc.docker ?: [:], - configuration.transportRequestId, - configuration.applicationName, - configuration.applicationUrl, - configuration.changeManagement.endpoint, - configuration.changeManagement.credentialsId, - configuration.changeManagement.rfc.developmentInstance, - configuration.changeManagement.rfc.developmentClient, - configuration.applicationDescription, - configuration.abapPackage, - configuration.codePage, - configuration.acceptUnixStyleLineEndings, - configuration.failOnWarning, - configuration.verbose + transportRequestUploadRFC(script: script, + transportRequestId: configuration.transportRequestId, + applicationName: configuration.applicationName, + applicationUrl: configuration.applicationUrl, + endpoint: configuration.changeManagement.endpoint, + uploadCredentialsId: configuration.changeManagement.credentialsId, + instance: configuration.changeManagement.rfc.developmentInstance, + client: configuration.changeManagement.rfc.developmentClient, + applicationDescription: configuration.applicationDescription, + abapPackage: configuration.abapPackage, + codePage: configuration.codePage, + acceptUnixStyleLineEndings: configuration.acceptUnixStyleLineEndings, + failUploadOnWarning: configuration.failOnWarning, + verbose: configuration.verbose ) echo "[INFO] File 'configuration.applicationUrl' has been successfully uploaded to transport request '${configuration.transportRequestId}'."