diff options
author | Singal, Kapil (ks220y) <ks220y@att.com> | 2019-11-22 18:06:08 -0500 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2019-11-26 21:32:38 +0000 |
commit | 341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch) | |
tree | 113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/modules/inbounds/health-api-common | |
parent | d274e5fc552cf9ae25500f504f0434981cf3accf (diff) |
Formatting Code base with ktlint
No Business logic change, just the code format.
Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3
To format run: mvn process-sources -P format
Issue-ID: CCSDK-1947
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/health-api-common')
18 files changed, 85 insertions, 112 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml b/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml index 2bd6782a7..3b3fec4d1 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml @@ -27,7 +27,7 @@ <artifactId>health-api-common</artifactId> <packaging>jar</packaging> - <name>Blueprints Processor Health API common </name> + <name>Blueprints Processor Health API common</name> <description>checking system check health endpoints</description> <dependencies> @@ -36,7 +36,6 @@ <artifactId>rest-lib</artifactId> </dependency> - <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt index 0c6099a1a..ead1f3b78 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt @@ -45,5 +45,4 @@ open class BasicAuthRestClientServiceConfiguration(private val securityConfigura open fun getBasicAuthRestClientService(): BasicAuthRestClientService { return BasicAuthRestClientService(getBasicAuthRestClientProperties()) } - } diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt index c63952d80..080a26e6f 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt @@ -54,7 +54,6 @@ open class HealthCheckProperties { open fun getCDSListenerServiceInformation(): List<ServiceEndpoint> { val serviceName = ServiceName.BLUEPRINT return getListOfServiceEndPoints(cdsListenerServiceMapping, serviceName) - } private fun getListOfServiceEndPoints(serviceMapping: List<String>?, serviceName: ServiceName): MutableList<ServiceEndpoint> { @@ -67,7 +66,7 @@ open class HealthCheckProperties { return serviceEndpoints } - private fun fillListOfService(serviceName: ServiceName , element: String, listOfCDSListenerServiceEndpoint: MutableList<ServiceEndpoint>) { + private fun fillListOfService(serviceName: ServiceName, element: String, listOfCDSListenerServiceEndpoint: MutableList<ServiceEndpoint>) { val serviceEndpointInfo = element.split(",/") val serviceEndpoint = getServiceEndpoint(serviceEndpointInfo) if (serviceName.equals(ServiceName.CDSLISTENER)) @@ -77,16 +76,15 @@ open class HealthCheckProperties { listOfCDSListenerServiceEndpoint.add(serviceEndpoint) } - private fun getServiceEndpoint(serviceEndpointInfo: List<String>): ServiceEndpoint { - return ServiceEndpoint(removeSpecialCharacter(serviceEndpointInfo.get(0)) - , removeSpecialCharacter(serviceEndpointInfo.get(1)) + return ServiceEndpoint( + removeSpecialCharacter(serviceEndpointInfo.get(0)), removeSpecialCharacter(serviceEndpointInfo.get(1)) ) } - private fun removeSpecialCharacter(value:String):String{ - return value.replaceFirst(",[","") - .replace("[","") - .replace("]","") + private fun removeSpecialCharacter(value: String): String { + return value.replaceFirst(",[", "") + .replace("[", "") + .replace("]", "") } } diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt index 94021207a..8b319fc43 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt @@ -16,17 +16,15 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration - import org.apache.commons.net.util.Base64 import org.springframework.stereotype.Component -import org.springframework.stereotype.Service import javax.crypto.Cipher import javax.crypto.spec.IvParameterSpec import javax.crypto.spec.SecretKeySpec - @Component class SecurityEncryptionConfiguration { + private val key = "aesEncryptionKey" private val initVector = "encryptionIntVec" diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt index f66e8774c..f6ce829c1 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt @@ -21,5 +21,3 @@ import org.springframework.boot.actuate.health.Status data class ApplicationHealth(val status: Status?, val details: Map<String, Any>?) { constructor() : this(null, HashMap()) } - - diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt index 61d8120d4..285dc0878 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt @@ -16,8 +16,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain - -data class HealthApiResponse(val status: HealthCheckStatus, val checks: List<ServicesCheckResponse> +data class HealthApiResponse( + val status: HealthCheckStatus, + val checks: List<ServicesCheckResponse> ) - - diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt index d9f1c79d4..ceb92d1b4 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt @@ -16,7 +16,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain - data class Metrics(val names: ArrayList<Any>?) { constructor() : this(ArrayList()) } diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt index b3796c91a..f58a31e8c 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt @@ -16,6 +16,4 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain -data class MetricsResponse(val maps: HashMap<String, String>) { - -} +data class MetricsResponse(val maps: HashMap<String, String>) diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt index ce95a5c0c..badd772c4 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt @@ -15,5 +15,4 @@ */ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain - data class ServiceEndpoint(val serviceName: String, var serviceLink: String) diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt index 1a78a5d10..3e984b3b6 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt @@ -17,5 +17,5 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain enum class ServiceName(s: String) { - BLUEPRINT("Blue Print service"),CDSLISTENER("CDS Listener service") + BLUEPRINT("Blue Print service"), CDSLISTENER("CDS Listener service") } diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt index 391d7f38a..908007523 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt @@ -16,7 +16,4 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain - data class ServicesCheckResponse(val name: String, val status: HealthCheckStatus) - - diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt index 03e864a9d..1e7e670b5 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt @@ -18,5 +18,4 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService -data class WebClientEnpointResponse (val response:BlueprintWebClientService.WebClientResponse<String>?) { -} +data class WebClientEnpointResponse(val response: BlueprintWebClientService.WebClientResponse<String>?) diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt index 72fa6c849..9f526251e 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt @@ -16,7 +16,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service - import com.fasterxml.jackson.databind.ObjectMapper import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ApplicationHealth import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint @@ -35,8 +34,10 @@ import org.springframework.stereotype.Service * @version 1.0 */ @Service -open class EndPointExecution(private val basicAuthRestClientService: BasicAuthRestClientService - , private val restClientProperties: BasicAuthRestClientProperties) { +open class EndPointExecution( + private val basicAuthRestClientService: BasicAuthRestClientService, + private val restClientProperties: BasicAuthRestClientProperties +) { private var logger = LoggerFactory.getLogger(EndPointExecution::class.java) @@ -46,25 +47,21 @@ open class EndPointExecution(private val basicAuthRestClientService: BasicAuthRe val result = basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "") if (result.status == 200) return WebClientEnpointResponse(result) - } catch (e: Exception) { logger.error("service name ${serviceEndpoint.serviceName} is down ${e.message}") } - return WebClientEnpointResponse(BlueprintWebClientService.WebClientResponse(500,"")) + return WebClientEnpointResponse(BlueprintWebClientService.WebClientResponse(500, "")) } private fun addClientPropertiesConfiguration(serviceEndpoint: ServiceEndpoint) { restClientProperties.url = serviceEndpoint.serviceLink } - open fun getHealthFromWebClientEnpointResponse(webClientEnpointResponse: WebClientEnpointResponse): ApplicationHealth? { return mappingMetricsToDTO(webClientEnpointResponse?.response?.body.toString()) - } private fun mappingMetricsToDTO(body: String): ApplicationHealth { return ObjectMapper().readValue(body, ApplicationHealth::class.java) } } - diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt index f793754e3..6d49ebe65 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt @@ -16,7 +16,11 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health -import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.* +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServicesCheckResponse +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.WebClientEnpointResponse import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution import org.slf4j.LoggerFactory @@ -27,7 +31,7 @@ import org.slf4j.LoggerFactory * @author Shaaban Ebrahim * @version 1.0 */ -abstract class AbstractHealthCheck (private val endPointExecution: EndPointExecution) { +abstract class AbstractHealthCheck(private val endPointExecution: EndPointExecution) { private var logger = LoggerFactory.getLogger(BluePrintProcessorHealthCheck::class.java) @@ -45,10 +49,8 @@ abstract class AbstractHealthCheck (private val endPointExecution: EndPointExec } healthApiResponse = HealthApiResponse(systemStatus, listOfResponse) return healthApiResponse - } - private fun retrieveServiceStatus(serviceEndpoint: ServiceEndpoint): HealthCheckStatus { var serviceStatus: HealthCheckStatus = HealthCheckStatus.UP try { @@ -59,16 +61,13 @@ abstract class AbstractHealthCheck (private val endPointExecution: EndPointExec } catch (e: Exception) { logger.error("service name ${serviceEndpoint.serviceName} is down ${e.message}") serviceStatus = HealthCheckStatus.DOWN - } return serviceStatus } - open fun retrieveEndpointExecutionStatus(): HealthApiResponse { return retrieveSystemStatus(setupServiceEndpoint()) } abstract fun setupServiceEndpoint(): List<ServiceEndpoint> - } diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt index d661b32b5..dddad52e2 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt @@ -28,9 +28,11 @@ import org.springframework.stereotype.Service * @version 1.0 */ @Service -open class BluePrintProcessorHealthCheck(private val endPointExecution: EndPointExecution - , private val healthCheckProperties: HealthCheckProperties) - : AbstractHealthCheck(endPointExecution) { +open class BluePrintProcessorHealthCheck( + private val endPointExecution: EndPointExecution, + private val healthCheckProperties: HealthCheckProperties +) : + AbstractHealthCheck(endPointExecution) { override fun setupServiceEndpoint(): List<ServiceEndpoint> { return healthCheckProperties.getBluePrintServiceInformation() diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt index 0a7c5e092..aa0d4d5f2 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt @@ -17,14 +17,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties -import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse -import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint -import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServicesCheckResponse import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution -import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service /** @@ -34,13 +28,13 @@ import org.springframework.stereotype.Service * @version 1.0 */ @Service -open class SDCListenerHealthCheck (private val endPointExecution: EndPointExecution - ,private val healthCheckProperties: HealthCheckProperties) - : AbstractHealthCheck(endPointExecution) { +open class SDCListenerHealthCheck( + private val endPointExecution: EndPointExecution, + private val healthCheckProperties: HealthCheckProperties +) : + AbstractHealthCheck(endPointExecution) { override fun setupServiceEndpoint(): List<ServiceEndpoint> { return healthCheckProperties.getCDSListenerServiceInformation() } - - } diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt index c4a8d1235..e3ba72428 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt @@ -16,25 +16,18 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi +import org.junit.Assert import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull -import org.mockito.ArgumentMatchers.any -import org.mockito.ArgumentMatchers.eq -import org.mockito.Mockito.anyString -import org.mockito.Mockito.mock - -import java.util.Arrays -import org.junit.Assert import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.mockito.ArgumentMatchers import org.mockito.InjectMocks import org.mockito.Mock import org.mockito.Mockito +import org.mockito.Mockito.anyString import org.mockito.junit.MockitoJUnitRunner import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties -import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution @@ -42,8 +35,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health.BluePrint import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService -import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService.WebClientResponse -import org.springframework.http.HttpMethod +import java.util.Arrays @RunWith(MockitoJUnitRunner::class) class HealthCheckServiceTest { @@ -62,106 +54,113 @@ class HealthCheckServiceTest { private var bluePrintProcessorHealthCheck: BluePrintProcessorHealthCheck? = null - @Before fun setup() { endPointExecution = Mockito.spy(endPointExecution!!) - Mockito.`when`(healthCheckProperties!!.getBluePrintServiceInformation()).thenReturn(Arrays.asList( + Mockito.`when`(healthCheckProperties!!.getBluePrintServiceInformation()).thenReturn( + Arrays.asList( ServiceEndpoint("Execution service ", "http://cds-blueprints-processor-http:8080/api/v1/execution-service/health-check"), - ServiceEndpoint("Resources service", "http://cds-blueprints-processor-http:8080/api/v1/resources/health-check"), ServiceEndpoint("Template service", "http://cds-blueprints-processor-http:8080/api/v1/template/health-check") - )) + ServiceEndpoint("Resources service", "http://cds-blueprints-processor-http:8080/api/v1/resources/health-check"), + ServiceEndpoint("Template service", "http://cds-blueprints-processor-http:8080/api/v1/template/health-check") + ) + ) bluePrintProcessorHealthCheck = BluePrintProcessorHealthCheck(endPointExecution!!, healthCheckProperties) } - @Test + @Test fun testSystemIsCompletelyDown() { - Mockito.`when`(basicAuthRestClientService!!.exchangeResource( - anyString(), - anyString(), - anyString())).thenThrow(RuntimeException()) + Mockito.`when`( + basicAuthRestClientService!!.exchangeResource( + anyString(), + anyString(), + anyString() + ) + ).thenThrow(RuntimeException()) val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus() assertNotNull(healthApiResponse) Assert.assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status) healthApiResponse.checks.forEach { serviceEndpoint -> assertNotNull(serviceEndpoint) assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status) - } - } @Test fun testSystemIsUPAndRunning() { - Mockito.`when`(basicAuthRestClientService!! - .exchangeResource( - anyString(), - anyString(), - anyString())).thenReturn(BlueprintWebClientService.WebClientResponse(200, "Success")) + Mockito.`when`( + basicAuthRestClientService!! + .exchangeResource( + anyString(), + anyString(), + anyString() + ) + ).thenReturn(BlueprintWebClientService.WebClientResponse(200, "Success")) val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus() assertNotNull(healthApiResponse) assertEquals(HealthCheckStatus.UP, healthApiResponse.status) healthApiResponse.checks.forEach { serviceEndpoint -> assertNotNull(serviceEndpoint) assertEquals(HealthCheckStatus.UP, serviceEndpoint.status) - } - } @Test fun testServiceIsNotFound() { - Mockito.`when`(basicAuthRestClientService!!.exchangeResource( - anyString(), - anyString(), - anyString())).thenReturn(BlueprintWebClientService.WebClientResponse(404, "failure")) + Mockito.`when`( + basicAuthRestClientService!!.exchangeResource( + anyString(), + anyString(), + anyString() + ) + ).thenReturn(BlueprintWebClientService.WebClientResponse(404, "failure")) val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus() assertNotNull(healthApiResponse) assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status) healthApiResponse.checks.forEach { serviceEndpoint -> assertNotNull(serviceEndpoint) assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status) - } - } - @Test fun testServiceInternalServerError() { - Mockito.`when`(basicAuthRestClientService!!.exchangeResource( - anyString(), - anyString(), - anyString())) - .thenReturn(BlueprintWebClientService.WebClientResponse(500, "failure")) + Mockito.`when`( + basicAuthRestClientService!!.exchangeResource( + anyString(), + anyString(), + anyString() + ) + ) + .thenReturn(BlueprintWebClientService.WebClientResponse(500, "failure")) val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus() assertNotNull(healthApiResponse) assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status) healthApiResponse.checks.forEach { serviceEndpoint -> assertNotNull(serviceEndpoint) assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status) - } - } @Test fun testServiceIsRedirected() { - Mockito.`when`(basicAuthRestClientService!!. - exchangeResource( - anyString(), - anyString(), - anyString())) - .thenReturn(BlueprintWebClientService.WebClientResponse(300, "failure")) + Mockito.`when`( + basicAuthRestClientService!! + .exchangeResource( + anyString(), + anyString(), + anyString() + ) + ) + .thenReturn(BlueprintWebClientService.WebClientResponse(300, "failure")) val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus() assertNotNull(healthApiResponse) assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status) healthApiResponse.checks.forEach { serviceEndpoint -> assertNotNull(serviceEndpoint) assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status) - } } } diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt index e1f7abdb7..54becbadf 100644 --- a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt @@ -20,7 +20,6 @@ import org.junit.Assert import org.junit.Test import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.SecurityEncryptionConfiguration - class SecurityConfigurationTest { @Test |