2 * Copyright © 2017-2018 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
19 import org.junit.runner.RunWith
20 import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
21 import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
22 import org.onap.ccsdk.apps.blueprintsprocessor.rest.BluePrintRestLibConfiguration
23 import org.springframework.beans.factory.annotation.Autowired
24 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
25 import org.springframework.boot.test.context.SpringBootTest
26 import org.springframework.test.context.ContextConfiguration
27 import org.springframework.test.context.TestPropertySource
28 import org.springframework.test.context.junit4.SpringRunner
29 import org.springframework.web.bind.annotation.GetMapping
30 import org.springframework.web.bind.annotation.RequestMapping
31 import org.springframework.web.bind.annotation.RestController
32 import kotlin.test.Test
33 import kotlin.test.assertNotNull
35 @EnableAutoConfiguration
36 @RunWith(SpringRunner::class)
37 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
38 @ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class,
39 SampleController::class, BluePrintProperties::class])
40 @TestPropertySource(properties =
42 "blueprintsprocessor.restclient.sample.type=basic-auth",
43 "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:9111",
44 "blueprintsprocessor.restclient.sample.userId=sampleuser",
45 "blueprintsprocessor.restclient.sample.token=sampletoken"])
46 class RestClientServiceTest {
49 lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
54 val restClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
55 val headers = mutableMapOf<String, String>()
56 headers["X-Transaction-Id"] = "1234"
57 val response = restClientService.getResource("/sample/name", headers, String::class.java)
58 assertNotNull(response, "failed to get response")
64 @RequestMapping("/sample")
65 open class SampleController {
67 fun getName(): String = "Sample Controller"