diff options
author | Oleg Mitsura <oleg.mitsura@amdocs.com> | 2019-05-13 15:49:03 -0400 |
---|---|---|
committer | Oleg Mitsura <oleg.mitsura@amdocs.com> | 2019-05-15 16:26:34 -0400 |
commit | 9eb8b8a88bfac860a94b62b203b00c64330a1be7 (patch) | |
tree | 1e7403f7a53599f7708d172ae61b3dbc0e1b55ac /ms/blueprintsprocessor/functions/resource-resolution/src/test | |
parent | 250b5b2a4ad4020df9c0dd053743d28616e28485 (diff) |
BlueprintWebClientService: added return status
Issue-ID: CCSDK-1331
Change-Id: I8dab8ad4eaebf1863f11c4d38c52cf7f64b0a4d5
Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/test')
2 files changed, 14 insertions, 10 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt index c6ca41351..fede7be7b 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt @@ -61,17 +61,17 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient mockServer.close() } - override fun exchangeResource(method: String, path: String, payload: String): String { + override fun exchangeResource(method: String, path: String, payload: String): BlueprintWebClientService.WebClientResponse<String> { val header = arrayOf(BasicHeader(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION])) return when (method) { "POST" -> { - post(path, payload, header) + post(path, payload, header, String::class.java) } "PUT" -> { - put(path, payload, header) + put(path, payload, header, String::class.java) } else -> { - get(path, header) + get(path, header, String::class.java) } } } @@ -121,4 +121,4 @@ class MockBlueprintWebClientService(private var restClientProperties: RestClient return Base64.getEncoder().encodeToString( credentialsString.toByteArray(Charset.defaultCharset())) } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt index 2c481dca3..eb2a7a7ed 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt @@ -80,11 +80,15 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe val restClientService = blueprintWebClientService(executionRequest) val response = restClientService.exchangeResource(verb, urlPath, payload) - if (response.isEmpty()) { - logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)") - } else { - populateResource(executionRequest, sourceProperties, response, path) + val responseStatusCode = response.status + val responseBody = response.body + if (responseStatusCode in 200..299 && !responseBody.isBlank()) { + populateResource(executionRequest, sourceProperties, responseBody, path) restClientService.tearDown() + } else { + val errMsg = "Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath) response_code: ($responseStatusCode)" + logger.warn(errMsg) + throw BluePrintProcessorException(errMsg) } } } catch (e: Exception) { @@ -156,4 +160,4 @@ class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertySe } } } -}
\ No newline at end of file +} |