summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-05-16 13:44:58 +0000
committerGerrit Code Review <gerrit@onap.org>2019-05-16 13:44:58 +0000
commitacbcd280dc9d04ed303ed994872a0f3ba6adbab3 (patch)
tree4110779154409b39273093932968161dffdc63d5 /ms/blueprintsprocessor/functions
parent506d2649c48d3741b3b60b0f781e06f137af13ab (diff)
parent9eb8b8a88bfac860a94b62b203b00c64330a1be7 (diff)
Merge "BlueprintWebClientService: added return status"
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt10
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt14
3 files changed, 22 insertions, 15 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index 2d726d487..7eefe954d 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -27,7 +27,6 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientSer
import org.onap.ccsdk.cds.controllerblueprints.core.*
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
@@ -86,10 +85,14 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
val restClientService = blueprintWebClientService(resourceAssignment, sourceProperties)
val response = restClientService.exchangeResource(verb, urlPath, payload)
- if (response.isBlank()) {
- logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)")
+ val responseStatusCode = response.status
+ val responseBody = response.body
+ if (responseStatusCode in 200..299 && !responseBody.isBlank()) {
+ populateResource(resourceAssignment, sourceProperties, responseBody, path)
} else {
- populateResource(resourceAssignment, sourceProperties, response, path)
+ val errMsg = "Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath) response_code: ($responseStatusCode)"
+ logger.warn(errMsg)
+ throw BluePrintProcessorException(errMsg)
}
}
// Check the value has populated for mandatory case
@@ -204,4 +207,4 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
raRuntimeService.getBluePrintError().addError(runtimeException.message!!)
}
-} \ 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/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
+}