From d425c6319a995402163c8868e9fe40f3d88f02ea Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Sat, 9 Nov 2019 20:35:47 -0500 Subject: Convert component functions IT to UT. Issue-ID: CCSDK-1735 Convert Netconf and Restconf Executor IT to UT. Remove duplicate BluePrintProperties. Signed-off-by: Brinda Santh Change-Id: I2eafdbabb17a4df72541ab93c46e7fc9eb0fe8d7 --- .../service/BluePrintRestLibPropertyService.kt | 59 +++++++++++----------- .../service/BluePrintRestLibPropertyServiceTest.kt | 7 +-- .../rest/service/RestClientServiceTest.kt | 6 +-- 3 files changed, 36 insertions(+), 36 deletions(-) (limited to 'ms/blueprintsprocessor/modules/commons/rest-lib') diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt index 9a7b3c303..84ba7d414 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt @@ -19,15 +19,14 @@ package org.onap.ccsdk.cds.blueprintsprocessor.rest.service import com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService import org.onap.ccsdk.cds.blueprintsprocessor.rest.* import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.springframework.stereotype.Service @Service(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY) -open class BluePrintRestLibPropertyService(private var bluePrintProperties: - BluePrintProperties) { +open class BluePrintRestLibPropertyService(private var bluePrintPropertiesService: BluePrintPropertiesService) { private var preInterceptor: PreInterceptor? = null private var postInterceptor: PostInterceptor? = null @@ -58,8 +57,8 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: } fun restClientProperties(prefix: String): RestClientProperties { - val type = bluePrintProperties.propertyBeanType( - "$prefix.type", String::class.java) + val type = bluePrintPropertiesService.propertyBeanType( + "$prefix.type", String::class.java) return when (type) { RestLibConstants.TYPE_BASIC_AUTH -> { basicAuthRestClientProperties(prefix) @@ -82,7 +81,7 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: } else -> { throw BluePrintProcessorException("Rest adaptor($type) is" + - " not supported") + " not supported") } } } @@ -112,13 +111,13 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: } else -> { throw BluePrintProcessorException( - "Rest adaptor($type) is not supported") + "Rest adaptor($type) is not supported") } } } private fun blueprintWebClientService(restClientProperties: RestClientProperties): - BlueprintWebClientService { + BlueprintWebClientService { when (restClientProperties) { is SSLRestClientProperties -> { @@ -137,53 +136,53 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: } private fun tokenRestClientProperties(prefix: String): - TokenAuthRestClientProperties { - return bluePrintProperties.propertyBeanType( - prefix, TokenAuthRestClientProperties::class.java) + TokenAuthRestClientProperties { + return bluePrintPropertiesService.propertyBeanType( + prefix, TokenAuthRestClientProperties::class.java) } private fun basicAuthRestClientProperties(prefix: String): - BasicAuthRestClientProperties { - return bluePrintProperties.propertyBeanType( - prefix, BasicAuthRestClientProperties::class.java) + BasicAuthRestClientProperties { + return bluePrintPropertiesService.propertyBeanType( + prefix, BasicAuthRestClientProperties::class.java) } private fun sslBasicAuthRestClientProperties(prefix: String): - SSLRestClientProperties { + SSLRestClientProperties { val sslProps: SSLBasicAuthRestClientProperties = - bluePrintProperties.propertyBeanType( - prefix, SSLBasicAuthRestClientProperties::class.java) + bluePrintPropertiesService.propertyBeanType( + prefix, SSLBasicAuthRestClientProperties::class.java) val basicProps: BasicAuthRestClientProperties = - bluePrintProperties.propertyBeanType( - prefix, BasicAuthRestClientProperties::class.java) + bluePrintPropertiesService.propertyBeanType( + prefix, BasicAuthRestClientProperties::class.java) sslProps.basicAuth = basicProps return sslProps } private fun sslTokenAuthRestClientProperties(prefix: String): - SSLRestClientProperties { + SSLRestClientProperties { val sslProps: SSLTokenAuthRestClientProperties = - bluePrintProperties.propertyBeanType(prefix, - SSLTokenAuthRestClientProperties::class.java) + bluePrintPropertiesService.propertyBeanType(prefix, + SSLTokenAuthRestClientProperties::class.java) val basicProps: TokenAuthRestClientProperties = - bluePrintProperties.propertyBeanType(prefix, - TokenAuthRestClientProperties::class.java) + bluePrintPropertiesService.propertyBeanType(prefix, + TokenAuthRestClientProperties::class.java) sslProps.tokenAuth = basicProps return sslProps } private fun sslNoAuthRestClientProperties(prefix: String): - SSLRestClientProperties { - return bluePrintProperties.propertyBeanType( - prefix, SSLRestClientProperties::class.java) + SSLRestClientProperties { + return bluePrintPropertiesService.propertyBeanType( + prefix, SSLRestClientProperties::class.java) } private fun policyManagerRestClientProperties(prefix: String): - PolicyManagerRestClientProperties { - return bluePrintProperties.propertyBeanType( - prefix, PolicyManagerRestClientProperties::class.java) + PolicyManagerRestClientProperties { + return bluePrintPropertiesService.propertyBeanType( + prefix, PolicyManagerRestClientProperties::class.java) } interface PreInterceptor { diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt index b617dab90..1e4518a8c 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt @@ -23,8 +23,8 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.ObjectMapper import org.junit.Test import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties -import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.rest.BluePrintRestLibConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLRestClientProperties @@ -41,7 +41,8 @@ import kotlin.test.assertFailsWith import kotlin.test.assertNotNull @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class]) +@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BluePrintPropertyConfiguration::class, + BluePrintPropertiesService::class]) @TestPropertySource(properties = ["blueprintsprocessor.restclient.sample.type=basic-auth", "blueprintsprocessor.restclient.sample.url=http://localhost:8080", diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt index 46d171b5d..05f32904a 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt @@ -27,8 +27,8 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties -import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.rest.BluePrintRestLibConfiguration import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration @@ -57,7 +57,7 @@ import kotlin.test.assertNotNull @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, SampleController::class, SecurityConfiguration::class, - BlueprintPropertyConfiguration::class, BluePrintProperties::class]) + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]) @TestPropertySource(properties = [ "server.port=8443", -- cgit 1.2.3-korg