aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2019-11-22 18:06:08 -0500
committerKAPIL SINGAL <ks220y@att.com>2019-11-26 21:32:38 +0000
commit341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch)
tree113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test
parentd274e5fc552cf9ae25500f504f0434981cf3accf (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/src/test')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt99
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt1
2 files changed, 49 insertions, 51 deletions
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