aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap
diff options
context:
space:
mode:
authorottero <rodrigo.ottero@est.tech>2019-03-17 19:38:32 +0000
committerottero <rodrigo.ottero@est.tech>2019-03-17 19:38:32 +0000
commit1b5d34c4a9c62de7aee833529e9df160315c5f8f (patch)
tree89f576232913076e4632c1603f27dc9be013d218 /ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap
parent593e3233ffff0b82a8bdf687ca051666688296a7 (diff)
Adding custom headers capability to REST client
For YANG PATCH requests to ODL to work, they need to have a Content- type header of application/yang.patch+json and should not have Accept as application/json Current REST client inserts a default header to the requests with this content: Content-Type: application/json Accept: application/json The solution was to add the possibility of sending custom headers alon- gside the other parameters. Change-Id: I2cf0cd2ef7b87f4f5a246d427dffafe266cb33f7 Issue-ID: CCSDK-926 Signed-off-by: ottero <rodrigo.ottero@est.tech>
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap')
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt14
1 files changed, 14 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
index 4fa82df2..0390550c 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright (C) 2019 Nordix Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,6 +13,8 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
*/
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
@@ -29,9 +32,11 @@ import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import org.springframework.web.bind.annotation.GetMapping
+import org.springframework.web.bind.annotation.PatchMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import kotlin.test.Test
+import kotlin.test.assertEquals
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@@ -58,6 +63,13 @@ class RestClientServiceTest {
assertNotNull(response, "failed to get response")
}
+ @Test
+ fun testPatch() {
+ val restClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
+ val response = restClientService.exchangeResource(HttpMethod.PATCH.name, "/sample/name", "")
+ assertEquals("Patch request successful", response, "failed to get patch response")
+ }
+
}
@RestController
@@ -65,5 +77,7 @@ class RestClientServiceTest {
open class SampleController {
@GetMapping("/name")
fun getName(): String = "Sample Controller"
+ @PatchMapping("/name")
+ fun patchName(): String = "Patch request successful"
}