github.com/ouraigua/jenkins-library@v0.0.0-20231028010029-fbeaf2f3aa9b/pkg/cpi/mockingUtils.go (about)

     1  //go:build !release
     2  // +build !release
     3  
     4  package cpi
     5  
     6  import (
     7  	"bytes"
     8  	"io"
     9  	"net/http"
    10  	"strings"
    11  
    12  	"github.com/pkg/errors"
    13  )
    14  
    15  // GetCPIFunctionMockResponse -Generate mock response payload for different CPI functions
    16  func GetCPIFunctionMockResponse(functionName, testType string) (*http.Response, error) {
    17  	switch functionName {
    18  	case "IntegrationArtifactDeploy", "PositiveAndUnDeployIntegrationDesigntimeArtifact":
    19  		return GetEmptyHTTPResponseBodyAndErrorNil()
    20  	case "FailIntegrationDesigntimeArtifactDeployment", "FailedIntegrationRuntimeArtifactUnDeployment":
    21  		return GetNegativeCaseHTTPResponseBodyAndErrorNil()
    22  	case "IntegrationArtifactUpdateConfiguration":
    23  		if testType == "Positive" {
    24  			return GetEmptyHTTPResponseBodyAndErrorNil()
    25  		}
    26  		if testType == "Negative_With_ResponseBody" {
    27  			return GetNegativeCaseHTTPResponseBodyAndErrorNil()
    28  		}
    29  		return GetParameterKeyMissingResponseBody()
    30  	case "IntegrationArtifactGetMplStatus", "APIKeyValueMapDownload", "APIProviderDownload":
    31  		return GetIntegrationArtifactGetMplStatusCommandMockResponse(testType)
    32  	case "IntegrationArtifactGetServiceEndpoint":
    33  		return GetIntegrationArtifactGetServiceEndpointCommandMockResponse(testType)
    34  	case "IntegrationArtifactDownload", "APIProxyDownload":
    35  		return IntegrationArtifactDownloadCommandMockResponse(testType)
    36  	case "GetIntegrationDesigntimeArtifact":
    37  		return GetIntegrationDesigntimeArtifactMockResponse(testType)
    38  	case "UploadIntegrationDesigntimeArtifact":
    39  		return GetIntegrationDesigntimeArtifactMockResponse(testType)
    40  	case "UploadIntegrationDesigntimeArtifactNegative":
    41  		return GetRespBodyHTTPStatusServiceErrorResponse()
    42  	case "UpdateIntegrationDesigntimeArtifactNegative":
    43  		return GetRespBodyHTTPStatusServiceErrorResponse()
    44  	case "UpdateIntegrationDesigntimeArtifact":
    45  		return UpdateIntegrationDesigntimeArtifactMockResponse(testType)
    46  	case "IntegrationDesigntimeArtifactUpdate":
    47  		return IntegrationDesigntimeArtifactUpdateMockResponse(testType)
    48  	case "GetIntegrationArtifactDeployStatus":
    49  		return GetIntegrationArtifactDeployStatusMockResponse(testType)
    50  	case "GetIntegrationArtifactDeployErrorDetails":
    51  		return GetIntegrationArtifactDeployErrorDetailsMockResponse(testType)
    52  	case "TriggerIntegrationTest":
    53  		return TriggerIntegrationTestMockResponse(testType)
    54  	case "IntegrationArtifactGetMplStatusError":
    55  		return GetIntegrationArtifactDeployErrorStatusMockResponseBody()
    56  	case "IntegrationArtifactResourceCreate", "ApiKeyValueMapUpload":
    57  		if testType == "Negative" {
    58  			return GetRespBodyHTTPStatusServiceErrorResponse()
    59  		}
    60  		if testType == "HttpResponseNotAccepted" {
    61  			return GetEmptyHTTPResponseBodyAndErrorNil()
    62  		}
    63  		if testType == "NilHttpResponse" {
    64  			return nil, errors.New("invalid payalod")
    65  		}
    66  		return GetRespBodyHTTPStatusCreated()
    67  	case "IntegrationArtifactResourceUpdate", "IntegrationArtifactResourceDelete", "ApiProxyUpload":
    68  		return GetRespBodyHTTPStatusOK()
    69  	default:
    70  		res := http.Response{
    71  			StatusCode: 404,
    72  			Body:       io.NopCloser(bytes.NewReader([]byte(``))),
    73  		}
    74  		return &res, errors.New("Service not Found")
    75  	}
    76  }
    77  
    78  // GetEmptyHTTPResponseBodyAndErrorNil -Empty http respose body
    79  func GetEmptyHTTPResponseBodyAndErrorNil() (*http.Response, error) {
    80  	res := http.Response{
    81  		StatusCode: 202,
    82  		Body:       io.NopCloser(bytes.NewReader([]byte(``))),
    83  	}
    84  	return &res, nil
    85  }
    86  
    87  // GetParameterKeyMissingResponseBody -Parameter key missing http respose body
    88  func GetParameterKeyMissingResponseBody() (*http.Response, error) {
    89  	res := http.Response{
    90  		StatusCode: 404,
    91  		Body: io.NopCloser(bytes.NewReader([]byte(`{
    92  					"code": "Not Found",
    93  					"message": {
    94  					"@lang": "en",
    95  					"#text": "Parameter key 'Parameter1' not found."
    96  					}
    97  				}`))),
    98  	}
    99  	return &res, errors.New("Not found - either wrong version for the given Id or wrong parameter key")
   100  }
   101  
   102  // GetNegativeCaseHTTPResponseBodyAndErrorNil -Negative case http respose body
   103  func GetNegativeCaseHTTPResponseBodyAndErrorNil() (*http.Response, error) {
   104  	res := http.Response{
   105  		StatusCode: 400,
   106  		Body: io.NopCloser(bytes.NewReader([]byte(`{
   107  					"code": "Bad Request",
   108  					"message": {
   109  					"@lang": "en",
   110  					"#text": "Wrong body format for the expected parameter value"
   111  					}
   112  				}`))),
   113  	}
   114  	return &res, nil
   115  }
   116  
   117  // GetIntegrationArtifactGetMplStatusCommandMockResponse -Provide http respose body
   118  func GetIntegrationArtifactGetMplStatusCommandMockResponse(testType string) (*http.Response, error) {
   119  	if testType == "Positive" {
   120  		res := http.Response{
   121  			StatusCode: 200,
   122  			Body: io.NopCloser(bytes.NewReader([]byte(`{
   123  				"d": {
   124  					"results": [
   125  						{
   126  							"__metadata": {
   127  								"id": "https://roverpoc.it-accd002.cfapps.sap.hana.ondemand.com:443/api/v1/MessageProcessingLogs('AGAS1GcWkfBv-ZtpS6j7TKjReO7t')",
   128  								"uri": "https://roverpoc.it-accd002.cfapps.sap.hana.ondemand.com:443/api/v1/MessageProcessingLogs('AGAS1GcWkfBv-ZtpS6j7TKjReO7t')",
   129  								"type": "com.sap.hci.api.MessageProcessingLog"
   130  							},
   131  							"MessageGuid": "AGAS1GcWkfBv-ZtpS6j7TKjReO7t",
   132  							"CorrelationId": "AGAS1GevYrPodxieoYf4YSY4jd-8",
   133  							"ApplicationMessageId": null,
   134  							"ApplicationMessageType": null,
   135  							"LogStart": "/Date(1611846759005)/",
   136  							"LogEnd": "/Date(1611846759032)/",
   137  							"Sender": null,
   138  							"Receiver": null,
   139  							"IntegrationFlowName": "flow1",
   140  							"Status": "COMPLETED",
   141  							"LogLevel": "INFO",
   142  							"CustomStatus": "COMPLETED",
   143  							"TransactionId": "aa220151116748eeae69db3e88f2bbc8"
   144  						}
   145  					]
   146  				}
   147  			}`))),
   148  		}
   149  		return &res, nil
   150  	}
   151  	res := http.Response{
   152  		StatusCode: 400,
   153  		Body: io.NopCloser(bytes.NewReader([]byte(`{
   154  					"code": "Bad Request",
   155  					"message": {
   156  					"@lang": "en",
   157  					"#text": "Invalid order by expression"
   158  					}
   159  				}`))),
   160  	}
   161  	return &res, errors.New("Unable to get integration flow MPL status, Response Status code:400")
   162  }
   163  
   164  // GetIntegrationArtifactGetServiceEndpointCommandMockResponse -Provide http respose body
   165  func GetIntegrationArtifactGetServiceEndpointCommandMockResponse(testCaseType string) (*http.Response, error) {
   166  	if testCaseType == "PositiveAndGetetIntegrationArtifactGetServiceResBody" {
   167  		return GetIntegrationArtifactGetServiceEndpointPositiveCaseRespBody()
   168  	}
   169  	res := http.Response{
   170  		StatusCode: 400,
   171  		Body: io.NopCloser(bytes.NewReader([]byte(`{
   172  					"code": "Bad Request",
   173  					"message": {
   174  					"@lang": "en",
   175  					"#text": "invalid service endpoint query"
   176  					}
   177  				}`))),
   178  	}
   179  	return &res, errors.New("Unable to get integration flow service endpoint, Response Status code:400")
   180  }
   181  
   182  // TriggerIntegrationTestMockResponse
   183  func TriggerIntegrationTestMockResponse(testCaseType string) (*http.Response, error) {
   184  	if testCaseType == "Positive" {
   185  		return &http.Response{
   186  			StatusCode: 200,
   187  			Body: io.NopCloser(bytes.NewReader([]byte(`{
   188  					"code": "Good Request",
   189  					"message": {
   190  						"@lang": "en",
   191  						"#text": "valid"
   192  					}
   193  				}`))),
   194  			Header: map[string][]string{
   195  				"test": []string{"this is a test"},
   196  			},
   197  		}, nil
   198  	}
   199  	res := http.Response{
   200  		StatusCode: 400,
   201  		Body: io.NopCloser(bytes.NewReader([]byte(`{
   202  					"code": "Bad Request",
   203  					"message": {
   204  					"@lang": "en",
   205  					"#text": "invalid"
   206  					}
   207  				}`))),
   208  	}
   209  	return &res, errors.New("Unable to trigger integration test, Response Status code:400")
   210  }
   211  
   212  // GetIntegrationArtifactGetServiceEndpointPositiveCaseRespBody -Provide http respose body for positive case
   213  func GetIntegrationArtifactGetServiceEndpointPositiveCaseRespBody() (*http.Response, error) {
   214  
   215  	resp := http.Response{
   216  		StatusCode: 200,
   217  		Body: io.NopCloser(bytes.NewReader([]byte(`{
   218  			"d": {
   219  				"results": [
   220  					{
   221  						"__metadata": {
   222  							"id": "https://demo.cfapps.sap.hana.ondemand.com:443/api/v1/ServiceEndpoints('CPI_IFlow_Call_using_Cert%24endpointAddress%3Dtestwithcert')",
   223  							"uri": "https://demo.cfapps.sap.hana.ondemand.com:443/api/v1/ServiceEndpoints('CPI_IFlow_Call_using_Cert%24endpointAddress%3Dtestwithcert')",
   224  							"type": "com.sap.hci.api.ServiceEndpoint"
   225  						},
   226  						"Name": "CPI_IFlow_Call_using_Cert",
   227  						"Id": "CPI_IFlow_Call_using_Cert$endpointAddress=testwithcert",
   228  						"EntryPoints": {
   229  							"results": [
   230  								{
   231  									"__metadata": {
   232  										"id": "https://demo.cfapps.sap.hana.ondemand.com:443/api/v1/EntryPoints('https%3A%2F%2Froverpoc.it-accd002-rt.cfapps.sap.hana.ondemand.com%2Fhttp%2Ftestwithcert')",
   233  										"uri": "https://demo.cfapps.sap.hana.ondemand.com:443/api/v1/EntryPoints('https%3A%2F%2Froverpoc.it-accd002-rt.cfapps.sap.hana.ondemand.com%2Fhttp%2Ftestwithcert')",
   234  										"type": "com.sap.hci.api.EntryPoint"
   235  									},
   236  									"Name": "CPI_IFlow_Call_using_Cert",
   237  									"Url": "https://demo.cfapps.sap.hana.ondemand.com/http/testwithcert",
   238  									"Type": "PROD",
   239  									"AdditionalInformation": ""
   240  								}
   241  							]
   242  						}
   243  					}
   244  				]
   245  			}
   246  		}`))),
   247  	}
   248  	return &resp, nil
   249  }
   250  
   251  // GetRespBodyHTTPStatusOK -Provide http respose body for Http StatusOK
   252  func GetRespBodyHTTPStatusOK() (*http.Response, error) {
   253  
   254  	resp := http.Response{
   255  		StatusCode: 200,
   256  		Body:       io.NopCloser(bytes.NewReader([]byte(``))),
   257  	}
   258  	return &resp, nil
   259  }
   260  
   261  // GetRespBodyHTTPStatusCreated -Provide http respose body for Http StatusOK
   262  func GetRespBodyHTTPStatusCreated() (*http.Response, error) {
   263  
   264  	resp := http.Response{
   265  		StatusCode: 201,
   266  		Body:       io.NopCloser(bytes.NewReader([]byte(``))),
   267  	}
   268  	return &resp, nil
   269  }
   270  
   271  // GetRespBodyHTTPStatusServiceNotFound -Provide http respose body for Http URL not Found
   272  func GetRespBodyHTTPStatusServiceNotFound() (*http.Response, error) {
   273  
   274  	resp := http.Response{
   275  		StatusCode: 404,
   276  		Body:       io.NopCloser(bytes.NewReader([]byte(``))),
   277  	}
   278  	return &resp, errors.New("Integration Package not found")
   279  }
   280  
   281  // GetRespBodyHTTPStatusServiceErrorResponse -Provide http respose body for server error
   282  func GetRespBodyHTTPStatusServiceErrorResponse() (*http.Response, error) {
   283  
   284  	resp := http.Response{
   285  		StatusCode: 500,
   286  		Body:       io.NopCloser(bytes.NewReader([]byte(``))),
   287  	}
   288  	return &resp, errors.New("401 Unauthorized")
   289  }
   290  
   291  // IntegrationArtifactDownloadCommandMockResponse -Provide http respose body
   292  func IntegrationArtifactDownloadCommandMockResponse(testType string) (*http.Response, error) {
   293  
   294  	return GetMockResponseByTestTypeAndMockFunctionName("IntegrationArtifactDownloadCommandMockResponse", testType)
   295  }
   296  
   297  // GetIntegrationDesigntimeArtifactMockResponse -Provide http respose body
   298  func GetIntegrationDesigntimeArtifactMockResponse(testType string) (*http.Response, error) {
   299  
   300  	return GetMockResponseByTestTypeAndMockFunctionName("GetIntegrationDesigntimeArtifactMockResponse", testType)
   301  }
   302  
   303  // IntegrationDesigntimeArtifactUpdateMockResponse -Provide http respose body
   304  func IntegrationDesigntimeArtifactUpdateMockResponse(testType string) (*http.Response, error) {
   305  
   306  	return GetMockResponseByTestTypeAndMockFunctionName("IntegrationDesigntimeArtifactUpdateMockResponse", testType)
   307  }
   308  
   309  // GetMockResponseByTestTypeAndMockFunctionName - Get mock response by testtype and mock function name
   310  func GetMockResponseByTestTypeAndMockFunctionName(mockFuntionName, testType string) (*http.Response, error) {
   311  
   312  	response, error := GetPositiveCaseResponseByTestType(testType)
   313  
   314  	if response == nil && error == nil {
   315  
   316  		switch mockFuntionName {
   317  
   318  		case "IntegrationDesigntimeArtifactUpdateMockResponse":
   319  
   320  			return NegtiveResForIntegrationArtifactGenericCommandMockResponse("Unable to get status of integration artifact, Response Status code:400")
   321  
   322  		case "GetIntegrationDesigntimeArtifactMockResponse":
   323  
   324  			return NegtiveResForIntegrationArtifactGenericCommandMockResponse("Unable to get status of integration artifact, Response Status code:400")
   325  
   326  		case "IntegrationArtifactDownloadCommandMockResponse":
   327  
   328  			return NegtiveResForIntegrationArtifactGenericCommandMockResponse("Unable to download integration artifact, Response Status code:400")
   329  
   330  		case "GetIntegrationArtifactDeployStatusMockResponse":
   331  
   332  			res := http.Response{
   333  				StatusCode: 400,
   334  				Body: io.NopCloser(bytes.NewReader([]byte(`{
   335  							"code": "Bad Request",
   336  							"message": {
   337  							"@lang": "en",
   338  							"#text": "Bad request"
   339  							}
   340  						}`))),
   341  			}
   342  			return &res, errors.New("Unable to get integration artifact deploy status, Response Status code:400")
   343  
   344  		case "GetIntegrationArtifactDeployErrorDetailsMockResponse":
   345  			res := http.Response{
   346  				StatusCode: 500,
   347  				Body: io.NopCloser(bytes.NewReader([]byte(`{
   348  							"code": "Internal Server Error",
   349  							"message": {
   350  							"@lang": "en",
   351  							"#text": "Internal Processing Error"
   352  							}
   353  						}`))),
   354  			}
   355  			return &res, errors.New("Unable to get integration artifact deploy error status, Response Status code:400")
   356  		}
   357  	}
   358  	return response, error
   359  }
   360  
   361  // NegtiveResForIntegrationArtifactGenericCommandMockResponse -Nagative Case http response body
   362  func NegtiveResForIntegrationArtifactGenericCommandMockResponse(message string) (*http.Response, error) {
   363  
   364  	res := http.Response{
   365  		StatusCode: 400,
   366  		Body: io.NopCloser(bytes.NewReader([]byte(`{
   367  					"code": "Bad Request",
   368  					"message": {
   369  					"@lang": "en",
   370  					"#text": "invalid request"
   371  					}
   372  				}`))),
   373  	}
   374  	return &res, errors.New(message)
   375  }
   376  
   377  // UpdateIntegrationDesigntimeArtifactMockResponse -Provide http respose body
   378  func UpdateIntegrationDesigntimeArtifactMockResponse(testType string) (*http.Response, error) {
   379  
   380  	response, error := GetRespBodyHTTPStatusCreated()
   381  
   382  	if response == nil && error == nil {
   383  
   384  		res := http.Response{
   385  			StatusCode: 400,
   386  			Body: io.NopCloser(bytes.NewReader([]byte(`{
   387  					"code": "Bad Request",
   388  					"message": {
   389  					"@lang": "en",
   390  					"#text": "invalid request"
   391  					}
   392  				}`))),
   393  		}
   394  		return &res, errors.New("Unable to get status of integration artifact, Response Status code:400")
   395  	}
   396  	return response, error
   397  }
   398  
   399  // IntegrationArtifactDownloadCommandMockResponsePositiveCaseRespBody -Provide http respose body for positive case
   400  func IntegrationArtifactDownloadCommandMockResponsePositiveCaseRespBody() (*http.Response, error) {
   401  	header := make(http.Header)
   402  	headerValue := "attachment; filename=flow1.zip"
   403  	header.Add("Content-Disposition", headerValue)
   404  	resp := http.Response{
   405  		StatusCode: 200,
   406  		Header:     header,
   407  		Body:       io.NopCloser(bytes.NewReader([]byte(`UEsDBBQACAgIADQ2clAAAAAAAAAAAAAAAAAUAAQATU`))),
   408  	}
   409  	return &resp, nil
   410  }
   411  
   412  // GetPositiveCaseResponseByTestType - get postive response by test case type
   413  func GetPositiveCaseResponseByTestType(testType string) (*http.Response, error) {
   414  	switch testType {
   415  	case "PositiveAndGetetIntegrationArtifactDownloadResBody":
   416  		return IntegrationArtifactDownloadCommandMockResponsePositiveCaseRespBody()
   417  	case "PositiveAndCreateIntegrationDesigntimeArtifactResBody":
   418  		return GetRespBodyHTTPStatusOK()
   419  	case "NegativeAndCreateIntegrationDesigntimeArtifactResBody":
   420  		return GetRespBodyHTTPStatusOK()
   421  	case "PositiveAndUpdateIntegrationDesigntimeArtifactResBody":
   422  		return GetRespBodyHTTPStatusServiceNotFound()
   423  	case "NegativeAndUpdateIntegrationDesigntimeArtifactResBody":
   424  		return GetRespBodyHTTPStatusServiceNotFound()
   425  	case "PositiveAndDeployIntegrationDesigntimeArtifactResBody":
   426  		return GetIntegrationArtifactDeployStatusMockResponseBody()
   427  	case "PositiveAndGetDeployedIntegrationDesigntimeArtifactErrorResBody":
   428  		return GetIntegrationArtifactDeployErrorStatusMockResponseBody()
   429  	case "NegativeAndDeployIntegrationDesigntimeArtifactResBody":
   430  		return GetIntegrationArtifactDeployStatusErrorMockResponseBody()
   431  	default:
   432  		return nil, nil
   433  	}
   434  }
   435  
   436  // GetCPIFunctionNameByURLCheck - get postive response by test case type
   437  func GetCPIFunctionNameByURLCheck(url, method, testType string) string {
   438  	switch url {
   439  	case "https://demo/api/v1/IntegrationDesigntimeArtifacts(Id='flow4',Version='1.0.4')":
   440  		return GetFunctionNameByTestTypeAndMethod(method, testType)
   441  
   442  	case "https://demo/api/v1/IntegrationDesigntimeArtifacts(Id='flow4',Version='Active')":
   443  		return GetFunctionNameByTestTypeAndMethod(method, testType)
   444  
   445  	case "https://demo/api/v1/IntegrationDesigntimeArtifacts":
   446  		return GetFunctionNameByTestTypeAndMethod(method, testType)
   447  	case "https://demo/api/v1/DeployIntegrationDesigntimeArtifact?Id='flow1'&Version='Active'":
   448  		return GetFunctionNameByTestTypeAndMethod(method, testType)
   449  	case "https://demo/api/v1/BuildAndDeployStatus(TaskId='')":
   450  		return "GetIntegrationArtifactDeployStatus"
   451  	case "https://demo/api/v1/IntegrationRuntimeArtifacts('flow1')/ErrorInformation/$value":
   452  		return "GetIntegrationArtifactDeployErrorDetails"
   453  	default:
   454  		return ""
   455  	}
   456  }
   457  
   458  // GetFunctionNameByTestTypeAndMethod -get function name by test tyep
   459  func GetFunctionNameByTestTypeAndMethod(method, testType string) string {
   460  
   461  	switch testType {
   462  
   463  	case "PositiveAndCreateIntegrationDesigntimeArtifactResBody":
   464  		return GetFunctionNamePositiveAndCreateIntegrationDesigntimeArtifactResBody(method)
   465  
   466  	case "PositiveAndUpdateIntegrationDesigntimeArtifactResBody":
   467  		return GetFunctionNamePositiveAndUpdateIntegrationDesigntimeArtifactResBody(method)
   468  	case "NegativeAndGetIntegrationDesigntimeArtifactResBody":
   469  		if method == "GET" {
   470  			return "GetIntegrationDesigntimeArtifact"
   471  		}
   472  
   473  	case "NegativeAndCreateIntegrationDesigntimeArtifactResBody":
   474  		if method == "GET" {
   475  			return "GetIntegrationDesigntimeArtifact"
   476  		}
   477  		if method == "PUT" {
   478  			return "UploadIntegrationDesigntimeArtifactNegative"
   479  		}
   480  	case "NegativeAndUpdateIntegrationDesigntimeArtifactResBody":
   481  		if method == "GET" {
   482  			return "GetIntegrationDesigntimeArtifact"
   483  		}
   484  		if method == "POST" {
   485  			return "UpdateIntegrationDesigntimeArtifactNegative"
   486  		}
   487  
   488  	case "PositiveAndDeployIntegrationDesigntimeArtifactResBody", "NegativeAndDeployIntegrationDesigntimeArtifactResBody":
   489  		if method == "POST" {
   490  			return "IntegrationArtifactDeploy"
   491  		}
   492  	default:
   493  		return ""
   494  
   495  	}
   496  	return ""
   497  }
   498  
   499  // GetFunctionNamePositiveAndUpdateIntegrationDesigntimeArtifactResBody -Get Function Name
   500  func GetFunctionNamePositiveAndUpdateIntegrationDesigntimeArtifactResBody(method string) string {
   501  	if method == "GET" {
   502  		return "IntegrationDesigntimeArtifactUpdate"
   503  	}
   504  	if method == "POST" {
   505  		return "UpdateIntegrationDesigntimeArtifact"
   506  	}
   507  	return ""
   508  }
   509  
   510  // GetFunctionNamePositiveAndCreateIntegrationDesigntimeArtifactResBody -Get Function Name
   511  func GetFunctionNamePositiveAndCreateIntegrationDesigntimeArtifactResBody(method string) string {
   512  	if method == "GET" {
   513  		return "GetIntegrationDesigntimeArtifact"
   514  	}
   515  	if method == "PUT" {
   516  		return "UploadIntegrationDesigntimeArtifact"
   517  	}
   518  	return ""
   519  }
   520  
   521  // GetIntegrationArtifactDeployStatusMockResponse -Provide http respose body
   522  func GetIntegrationArtifactDeployStatusMockResponse(testType string) (*http.Response, error) {
   523  
   524  	return GetMockResponseByTestTypeAndMockFunctionName("GetIntegrationArtifactDeployStatusMockResponse", testType)
   525  }
   526  
   527  // GetIntegrationArtifactDeployErrorDetailsMockResponse -Provide http respose body
   528  func GetIntegrationArtifactDeployErrorDetailsMockResponse(testType string) (*http.Response, error) {
   529  
   530  	return GetMockResponseByTestTypeAndMockFunctionName("GetIntegrationArtifactDeployErrorDetailsMockResponse", "PositiveAndGetDeployedIntegrationDesigntimeArtifactErrorResBody")
   531  }
   532  
   533  // GetIntegrationArtifactDeployStatusMockResponseBody -Provide http respose body
   534  func GetIntegrationArtifactDeployStatusMockResponseBody() (*http.Response, error) {
   535  
   536  	resp := http.Response{
   537  		StatusCode: 200,
   538  		Body:       io.NopCloser(bytes.NewReader([]byte(GetIntegrationArtifactDeployStatusPayload("STARTED")))),
   539  	}
   540  	return &resp, nil
   541  }
   542  
   543  // GetIntegrationArtifactDeployStatusErrorMockResponseBody -Provide http respose body
   544  func GetIntegrationArtifactDeployStatusErrorMockResponseBody() (*http.Response, error) {
   545  
   546  	resp := http.Response{
   547  		StatusCode: 200,
   548  		Body:       io.NopCloser(bytes.NewReader([]byte(GetIntegrationArtifactDeployStatusPayload("FAIL")))),
   549  	}
   550  	return &resp, nil
   551  }
   552  
   553  // GetIntegrationArtifactDeployStatusPayload -Get Payload
   554  func GetIntegrationArtifactDeployStatusPayload(status string) string {
   555  
   556  	jsonByte := []byte(`{
   557  		"d": {
   558  			"__metadata": {
   559  				"id": "https://roverpoc.it-accd002.cfapps.sap.hana.ondemand.com/api/v1/IntegrationRuntimeArtifacts('smtp')",
   560  				"uri": "https://roverpoc.it-accd002.cfapps.sap.hana.ondemand.com/api/v1/IntegrationRuntimeArtifacts('smtp')",
   561  				"media_src": "https://roverpoc.it-accd002.cfapps.sap.hana.ondemand.com/api/v1/IntegrationRuntimeArtifacts('smtp')/$value",
   562  				"edit_media": "https://roverpoc.it-accd002.cfapps.sap.hana.ondemand.com/api/v1/IntegrationRuntimeArtifacts('smtp')/$value"
   563  			},
   564  			"Id": "smtp",
   565  			"Version": "2.0",
   566  			"Name": "smtp",
   567  			"Status": "StatusValue",
   568  			"ErrorInformation": {
   569  				"__deferred": {
   570  					"uri": "https://roverpoc.it-accd002.cfapps.sap.hana.ondemand.com/api/v1/IntegrationRuntimeArtifacts('smtp')/ErrorInformation"
   571  				}
   572  			}
   573  		}
   574  	}`)
   575  	return strings.Replace(string(jsonByte), "StatusValue", status, 1)
   576  }
   577  
   578  // GetIntegrationArtifactDeployErrorStatusMockResponseBody -Provide http respose body
   579  func GetIntegrationArtifactDeployErrorStatusMockResponseBody() (*http.Response, error) {
   580  
   581  	resp := http.Response{
   582  		StatusCode: 200,
   583  		Body:       io.NopCloser(bytes.NewReader([]byte(`{"message": "java.lang.IllegalStateException: No credentials for 'smtp' found"}`))),
   584  	}
   585  	return &resp, nil
   586  }