From a283fe3ca39221e950a9cd97b6f9abcb40050ae0 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 6 Dec 2018 10:30:59 -0500 Subject: Add Generic Rest Configuration Change-Id: I3865eac84765ac2cbc5dd0db7a1ed0065bcaa7c5 Issue-ID: CCSDK-699 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../modules/commons/core/pom.xml | 9 +-- .../core/BluePrintCoreConfiguration.kt | 21 +++++- .../core/BluePrintProperties.kt | 29 ++++++++ .../modules/commons/db-lib/pom.xml | 54 +++++++------- ms/blueprintsprocessor/modules/commons/pom.xml | 11 +++ .../modules/commons/rest-lib/pom.xml | 34 ++++----- .../rest/BluePrintRestLibConfiguration.kt | 36 +++++++++ .../rest/BluePrintRestLibData.kt | 50 +++++++++++++ .../rest/service/BasicAuthRestClientService.kt | 40 ++++++++++ .../service/BluePrintRestLibPropertyService.kt | 87 ++++++++++++++++++++++ .../rest/service/BlueprintWebClientService.kt | 32 ++++++++ .../rest/service/DME2ProxyRestClientService.kt | 38 ++++++++++ .../rest/service/SSLBasicAuthRestClientService.kt | 38 ++++++++++ .../src/main/resources/application.properties | 16 ++++ .../RestPropertyPlaceHolderConfigurationTest.kt | 57 ++++++++++++++ .../rest-lib/src/test/resources/logback-test.xml | 35 +++++++++ 16 files changed, 536 insertions(+), 51 deletions(-) create mode 100644 ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt create mode 100644 ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt create mode 100644 ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt create mode 100644 ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt create mode 100644 ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt create mode 100644 ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt create mode 100644 ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt create mode 100644 ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt create mode 100644 ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties create mode 100644 ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt create mode 100644 ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml (limited to 'ms/blueprintsprocessor/modules/commons') diff --git a/ms/blueprintsprocessor/modules/commons/core/pom.xml b/ms/blueprintsprocessor/modules/commons/core/pom.xml index 626a27a37..5e0c966d2 100644 --- a/ms/blueprintsprocessor/modules/commons/core/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/core/pom.xml @@ -29,15 +29,10 @@ jar Blueprints Processor Core Blueprints Processor Core - - org.onap.ccsdk.apps.blueprintsprocessor - db-lib - - - org.onap.ccsdk.apps.blueprintsprocessor - rest-lib + org.springframework.boot + spring-boot-starter-webflux diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt index 3b5722d5f..07e494a1a 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt @@ -16,17 +16,34 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core +import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value +import org.springframework.boot.context.properties.bind.Binder +import org.springframework.boot.context.properties.source.ConfigurationPropertySources +import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.core.env.Environment @Configuration open class BluePrintCoreConfiguration { - @Value("\${blueprintsprocessor.blueprint-deploy-path}") + @Value("\${blueprintsprocessor.blueprintDeployPath}") lateinit var deployPath: String - @Value("\${blueprintsprocessor.blueprint-archive-path}") + @Value("\${blueprintsprocessor.blueprintArchivePath}") lateinit var archivePath: String +} + +@Configuration +open class BlueprintPropertyConfiguration { + @Autowired + lateinit var environment: Environment + + @Bean + open fun bluePrintPropertyBinder(): Binder { + val configurationPropertySource = ConfigurationPropertySources.get(environment) + return Binder(configurationPropertySource) + } } \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt new file mode 100644 index 000000000..10b8ceb5e --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt @@ -0,0 +1,29 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.core + +import org.springframework.boot.context.properties.bind.Bindable +import org.springframework.boot.context.properties.bind.Binder +import org.springframework.stereotype.Service + +@Service +open class BluePrintProperties(var bluePrintPropertyBinder: Binder) { + + fun propertyBeanType(prefix: String, type: Class): T { + return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get() + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml index 0139e74df..5f5b89de6 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/db-lib/pom.xml @@ -15,40 +15,44 @@ ~ limitations under the License. --> - 4.0.0 - - org.onap.ccsdk.apps.blueprintsprocessor - commons - 0.4.0-SNAPSHOT - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.onap.ccsdk.apps.blueprintsprocessor + commons + 0.4.0-SNAPSHOT + - db-lib - jar - Blueprints Processor DB Lib - Blueprints Processor DB Lib + db-lib + jar + Blueprints Processor DB Lib + Blueprints Processor DB Lib - + + + org.onap.ccsdk.apps.blueprintsprocessor + core + - - org.springframework.boot - spring-boot-starter-data-jpa - - - javax.validation - validation-api - + + org.springframework.boot + spring-boot-starter-data-jpa + + + javax.validation + validation-api + - - com.h2database - h2 - + + com.h2database + h2 + org.hibernate hibernate-testing test - + diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml index 7bfec58c9..f38ccabff 100644 --- a/ms/blueprintsprocessor/modules/commons/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/pom.xml @@ -38,6 +38,17 @@ org.onap.ccsdk.apps.controllerblueprints resource-dict + + + org.powermock + powermock-api-mockito2 + test + + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml index 6dfe111c5..da6194add 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml @@ -15,23 +15,23 @@ ~ limitations under the License. --> - 4.0.0 - - org.onap.ccsdk.apps.blueprintsprocessor - commons - 0.4.0-SNAPSHOT - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.onap.ccsdk.apps.blueprintsprocessor + commons + 0.4.0-SNAPSHOT + - rest-lib - jar - Blueprints Processor Rest Lib - Blueprints Processor Rest Lib - - - org.springframework.boot - spring-boot-starter-webflux - - + rest-lib + jar + Blueprints Processor Rest Lib + Blueprints Processor Rest Lib + + + org.onap.ccsdk.apps.blueprintsprocessor + core + + diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt new file mode 100644 index 000000000..50d69aee4 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt @@ -0,0 +1,36 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.rest + +import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.Configuration + +@Configuration +@ComponentScan +@EnableConfigurationProperties +open class BluePrintRestLibConfiguration + + +class RestLibConstants { + companion object { + const val TYPE_BASIC_AUTH = "basic-auth" + const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth" + const val TYPE_DME2_PROXY = "dme2-proxy" + const val TYPE_POLICY_MANAGER = "policy-manager" + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt new file mode 100644 index 000000000..faf4fd4df --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt @@ -0,0 +1,50 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.rest + +open class RestClientProperties { + lateinit var type: String + lateinit var url: String + lateinit var userId: String +} + +open class BasicAuthRestClientProperties : RestClientProperties() { + var passwd: String? = null +} + +open class SSLBasicAuthRestClientProperties : RestClientProperties() { + lateinit var sslTrust: String + lateinit var sslTrustPasswd: String + lateinit var sslKey: String + lateinit var sslKeyPasswd: String +} + +open class DME2RestClientProperties : RestClientProperties() { + lateinit var service: String + lateinit var subContext: String + lateinit var version: String + lateinit var envContext: String + lateinit var routeOffer: String + var partner: String? = null + lateinit var appId: String +} + +open class PolicyManagerRestClientProperties : RestClientProperties() { + lateinit var env: String + lateinit var clientAuth: String + lateinit var authorisation: String +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt new file mode 100644 index 000000000..b79034b43 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt @@ -0,0 +1,40 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.rest.service + +import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties +import org.springframework.web.reactive.function.client.WebClient + + +class BasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService { + + override fun webClient(): WebClient { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun getResource(path: String, responseType: Class): T { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun postResource(path: String, request: Any, responseType: Class): T { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun exchangeResource(methodType: String, path: String, request: Any, responseType: Class): T { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt new file mode 100644 index 000000000..21d080d5a --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt @@ -0,0 +1,87 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.rest.service + +import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.apps.blueprintsprocessor.rest.* +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.springframework.stereotype.Service + +@Service +open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) { + + @Throws(BluePrintProcessorException::class) + fun restClientProperties(prefix: String): RestClientProperties { + val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java) + return when (type) { + RestLibConstants.TYPE_BASIC_AUTH -> { + basicAuthRestClientProperties(prefix) + } + RestLibConstants.TYPE_SSL_BASIC_AUTH -> { + sslBasicAuthRestClientProperties(prefix) + } + RestLibConstants.TYPE_DME2_PROXY -> { + dme2ProxyClientProperties(prefix) + } + RestLibConstants.TYPE_POLICY_MANAGER -> { + policyManagerRestClientProperties(prefix) + } + else -> { + throw BluePrintProcessorException("Rest adaptor($type) is not supported") + } + } + } + + @Throws(BluePrintProcessorException::class) + fun blueprintWebClientService(selector: String): BlueprintWebClientService { + val prefix = "blueprintsprocessor.restclient.$selector" + val beanProperties = restClientProperties(prefix) + when (beanProperties) { + is BasicAuthRestClientProperties -> { + return BasicAuthRestClientService(beanProperties) + } + is SSLBasicAuthRestClientProperties -> { + return SSLBasicAuthRestClientService(beanProperties) + } + is DME2RestClientProperties -> { + return DME2ProxyRestClientService(beanProperties) + } + else -> { + throw BluePrintProcessorException("couldn't get rest service for selector($selector)") + } + } + + } + + fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties { + return bluePrintProperties.propertyBeanType(prefix, BasicAuthRestClientProperties::class.java) + } + + fun sslBasicAuthRestClientProperties(prefix: String): SSLBasicAuthRestClientProperties { + return bluePrintProperties.propertyBeanType(prefix, SSLBasicAuthRestClientProperties::class.java) + } + + fun dme2ProxyClientProperties(prefix: String): DME2RestClientProperties { + return bluePrintProperties.propertyBeanType(prefix, DME2RestClientProperties::class.java) + } + + fun policyManagerRestClientProperties(prefix: String): PolicyManagerRestClientProperties { + return bluePrintProperties.propertyBeanType(prefix, PolicyManagerRestClientProperties::class.java) + } +} + + diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt new file mode 100644 index 000000000..232f4bb00 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt @@ -0,0 +1,32 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.rest.service + +import org.springframework.web.reactive.function.client.WebClient + +interface BlueprintWebClientService { + + fun webClient(): WebClient + + fun getResource(path: String, responseType: Class): T + + fun postResource(path: String, request: Any, responseType: Class): T + + fun exchangeResource(methodType: String, path: String, request: Any, responseType: Class): T + +} + diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt new file mode 100644 index 000000000..bd46ced1b --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt @@ -0,0 +1,38 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.rest.service + +import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties +import org.springframework.web.reactive.function.client.WebClient + +class DME2ProxyRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService { + override fun webClient(): WebClient { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun getResource(path: String, responseType: Class): T { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun postResource(path: String, request: Any, responseType: Class): T { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun exchangeResource(methodType: String, path: String, request: Any, responseType: Class): T { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt new file mode 100644 index 000000000..8b4add100 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt @@ -0,0 +1,38 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.rest.service + +import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties +import org.springframework.web.reactive.function.client.WebClient + +class SSLBasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService { + override fun webClient(): WebClient { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun getResource(path: String, responseType: Class): T { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun postResource(path: String, request: Any, responseType: Class): T { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun exchangeResource(methodType: String, path: String, request: Any, responseType: Class): T { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties new file mode 100644 index 000000000..2ce871476 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties @@ -0,0 +1,16 @@ +# +# Copyright © 2017-2018 AT&T Intellectual Property. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +# + diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt new file mode 100644 index 000000000..d5e27430e --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt @@ -0,0 +1,57 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.rest.service + +import org.junit.Test +import org.junit.runner.RunWith +import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration +import org.onap.ccsdk.apps.blueprintsprocessor.rest.BluePrintRestLibConfiguration +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.TestPropertySource +import org.springframework.test.context.junit4.SpringRunner +import kotlin.test.assertNotNull + + +@RunWith(SpringRunner::class) +@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class]) +@TestPropertySource(properties = +["blueprintsprocessor.restclient.sample.type=basic-auth", + "blueprintsprocessor.restclient.sample.url=http://localhost:8080", + "blueprintsprocessor.restclient.sample.userId=sampleuser"]) + +class RestPropertyPlaceHolderConfigurationTest { + + @Autowired + lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService + + @Test + fun testRestClientProperties() { + val properties = bluePrintRestLibPropertyService.restClientProperties("blueprintsprocessor.restclient.sample") + assertNotNull(properties, "failed to create property bean") + assertNotNull(properties.url, "failed to get url property in property bean") + } + + @Test + fun testBlueprintWebClientService() { + val blueprintWebClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample") + assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService") + } + +} + diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml new file mode 100644 index 000000000..f9ec9fe57 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml @@ -0,0 +1,35 @@ + + + + + + + %d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n + + + + + + + + + + + + + -- cgit 1.2.3-korg