diff options
author | 2019-11-22 18:06:08 -0500 | |
---|---|---|
committer | 2019-11-26 21:32:38 +0000 | |
commit | 341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch) | |
tree | 113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap | |
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/commons/grpc-lib/src/test/kotlin/org/onap')
3 files changed, 105 insertions, 83 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt index 13432c043..ea17b94a1 100644 --- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt @@ -24,7 +24,11 @@ import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.grpc.* +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BasicAuthGrpcClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.BluePrintGrpcLibConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TLSAuthGrpcClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TLSAuthGrpcServerProperties +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration @@ -35,34 +39,38 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [BluePrintGrpcLibConfiguration::class, - BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]) -@TestPropertySource(properties = -["blueprintsprocessor.grpcclient.sample.type=basic-auth", - "blueprintsprocessor.grpcclient.sample.host=127.0.0.1", - "blueprintsprocessor.grpcclient.sample.port=50505", - "blueprintsprocessor.grpcclient.sample.username=sampleuser", - "blueprintsprocessor.grpcclient.sample.password=sampleuser", - - "blueprintsprocessor.grpcclient.token.type=token-auth", - "blueprintsprocessor.grpcclient.token.host=127.0.0.1", - "blueprintsprocessor.grpcclient.token.port=50505", - "blueprintsprocessor.grpcclient.token.username=sampleuser", - "blueprintsprocessor.grpcclient.token.password=sampleuser", - - "blueprintsprocessor.grpcserver.tls-sample.type=tls-auth", - "blueprintsprocessor.grpcserver.tls-sample.port=50505", - "blueprintsprocessor.grpcserver.tls-sample.certChain=server1.pem", - "blueprintsprocessor.grpcserver.tls-sample.privateKey=server1.key", - "blueprintsprocessor.grpcserver.tls-sample.trustCertCollection=ca.pem", - - "blueprintsprocessor.grpcclient.tls-sample.type=tls-auth", - "blueprintsprocessor.grpcclient.tls-sample.host=127.0.0.1", - "blueprintsprocessor.grpcclient.tls-sample.port=50505", - "blueprintsprocessor.grpcclient.tls-sample.trustCertCollection=ca.pem", - "blueprintsprocessor.grpcclient.tls-sample.clientCertChain=client.pem", - "blueprintsprocessor.grpcclient.tls-sample.clientPrivateKey=client.key" -]) +@ContextConfiguration( + classes = [BluePrintGrpcLibConfiguration::class, + BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class] +) +@TestPropertySource( + properties = + ["blueprintsprocessor.grpcclient.sample.type=basic-auth", + "blueprintsprocessor.grpcclient.sample.host=127.0.0.1", + "blueprintsprocessor.grpcclient.sample.port=50505", + "blueprintsprocessor.grpcclient.sample.username=sampleuser", + "blueprintsprocessor.grpcclient.sample.password=sampleuser", + + "blueprintsprocessor.grpcclient.token.type=token-auth", + "blueprintsprocessor.grpcclient.token.host=127.0.0.1", + "blueprintsprocessor.grpcclient.token.port=50505", + "blueprintsprocessor.grpcclient.token.username=sampleuser", + "blueprintsprocessor.grpcclient.token.password=sampleuser", + + "blueprintsprocessor.grpcserver.tls-sample.type=tls-auth", + "blueprintsprocessor.grpcserver.tls-sample.port=50505", + "blueprintsprocessor.grpcserver.tls-sample.certChain=server1.pem", + "blueprintsprocessor.grpcserver.tls-sample.privateKey=server1.key", + "blueprintsprocessor.grpcserver.tls-sample.trustCertCollection=ca.pem", + + "blueprintsprocessor.grpcclient.tls-sample.type=tls-auth", + "blueprintsprocessor.grpcclient.tls-sample.host=127.0.0.1", + "blueprintsprocessor.grpcclient.tls-sample.port=50505", + "blueprintsprocessor.grpcclient.tls-sample.trustCertCollection=ca.pem", + "blueprintsprocessor.grpcclient.tls-sample.clientCertChain=client.pem", + "blueprintsprocessor.grpcclient.tls-sample.clientPrivateKey=client.key" + ] +) class BluePrintGrpcLibPropertyServiceTest { @Autowired @@ -74,17 +82,26 @@ class BluePrintGrpcLibPropertyServiceTest { @Test fun testGrpcClientProperties() { val properties = bluePrintGrpcLibPropertyService.grpcClientProperties( - "blueprintsprocessor.grpcclient.sample") + "blueprintsprocessor.grpcclient.sample" + ) as BasicAuthGrpcClientProperties assertNotNull(properties, "failed to create property bean") - assertNotNull(properties.host, "failed to get host property" + - " in property bean") - assertNotNull(properties.port, "failed to get host property" + - " in property bean") - assertNotNull(properties.username, "failed to get host pro" + - "perty in property bean") - assertNotNull(properties.password, "failed to get host pr" + - "operty in property bean") + assertNotNull( + properties.host, "failed to get host property" + + " in property bean" + ) + assertNotNull( + properties.port, "failed to get host property" + + " in property bean" + ) + assertNotNull( + properties.username, "failed to get host pro" + + "perty in property bean" + ) + assertNotNull( + properties.password, "failed to get host pr" + + "operty in property bean" + ) } /** @@ -100,7 +117,8 @@ class BluePrintGrpcLibPropertyServiceTest { val mapper = ObjectMapper() val actualObj: JsonNode = mapper.readTree(json) val properties = bluePrintGrpcLibPropertyService.grpcClientProperties( - actualObj) as TokenAuthGrpcClientProperties + actualObj + ) as TokenAuthGrpcClientProperties assertNotNull(properties, "failed to create property bean") assertEquals(properties.host, "127.0.0.1") assertNotNull(properties.port, "50505") @@ -112,7 +130,8 @@ class BluePrintGrpcLibPropertyServiceTest { @Test fun testGrpcClientServiceBasic() { val svc = bluePrintGrpcLibPropertyService.blueprintGrpcClientService( - "sample") + "sample" + ) assertTrue(svc is BasicAuthGrpcClientService) } @@ -122,7 +141,8 @@ class BluePrintGrpcLibPropertyServiceTest { @Test fun testGrpcClientServiceToken() { val svc = bluePrintGrpcLibPropertyService.blueprintGrpcClientService( - "token") + "token" + ) assertTrue(svc is TokenAuthGrpcClientService) } @@ -141,14 +161,14 @@ class BluePrintGrpcLibPropertyServiceTest { val mapper = ObjectMapper() val actualObj: JsonNode = mapper.readTree(json) val svc = bluePrintGrpcLibPropertyService - .blueprintGrpcClientService(actualObj) + .blueprintGrpcClientService(actualObj) assertTrue(svc is BasicAuthGrpcClientService) } @Test fun testGrpcClientTLSProperties() { val properties = bluePrintGrpcLibPropertyService - .grpcClientProperties("blueprintsprocessor.grpcclient.tls-sample") as TLSAuthGrpcClientProperties + .grpcClientProperties("blueprintsprocessor.grpcclient.tls-sample") as TLSAuthGrpcClientProperties assertNotNull(properties, "failed to create property bean") assertNotNull(properties.host, "failed to get host property in property bean") assertNotNull(properties.port, "failed to get host property in property bean") @@ -166,14 +186,14 @@ class BluePrintGrpcLibPropertyServiceTest { } """.trimIndent() val jsonProperties = bluePrintGrpcLibPropertyService - .grpcClientProperties(configDsl.jsonAsJsonType()) as TLSAuthGrpcClientProperties + .grpcClientProperties(configDsl.jsonAsJsonType()) as TLSAuthGrpcClientProperties assertNotNull(jsonProperties, "failed to create property bean from json") } @Test fun testGrpcServerTLSProperties() { val properties = bluePrintGrpcLibPropertyService - .grpcServerProperties("blueprintsprocessor.grpcserver.tls-sample") as TLSAuthGrpcServerProperties + .grpcServerProperties("blueprintsprocessor.grpcserver.tls-sample") as TLSAuthGrpcServerProperties assertNotNull(properties, "failed to create property bean") assertNotNull(properties.port, "failed to get host property in property bean") assertNotNull(properties.trustCertCollection, "failed to get trustCertCollection property in property bean") @@ -189,11 +209,11 @@ class BluePrintGrpcLibPropertyServiceTest { } """.trimIndent() val jsonProperties = bluePrintGrpcLibPropertyService - .grpcServerProperties(configDsl.jsonAsJsonType()) as TLSAuthGrpcServerProperties + .grpcServerProperties(configDsl.jsonAsJsonType()) as TLSAuthGrpcServerProperties assertNotNull(jsonProperties, "failed to create property bean from json") val grpcServerService = bluePrintGrpcLibPropertyService.blueprintGrpcServerService("tls-sample") assertNotNull(grpcServerService, "failed to get grpc server service") Assert.assertEquals(TLSAuthGrpcServerService::class.java, grpcServerService.javaClass) } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcServerTest.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcServerTest.kt index 8154d3747..026fe5af5 100644 --- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcServerTest.kt +++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcServerTest.kt @@ -30,7 +30,7 @@ import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput -import java.util.* +import java.util.UUID import kotlin.test.Test import kotlin.test.assertNotNull @@ -62,14 +62,16 @@ class BluePrintGrpcServerTest { } /** TLS Client Integration testing, GRPC TLS Junit testing is not supported. */ - //@Test + // @Test fun testGrpcTLSServerIntegration() { runBlocking { val tlsAuthGrpcClientService = TLSAuthGrpcClientService(tlsAuthGrpcClientProperties) val grpcChannel = tlsAuthGrpcClientService.channel() /** Get Send and Receive Channel for bidirectional process method*/ - val (reqChannel, resChannel) = clientCallBidiStreaming(BluePrintProcessingServiceGrpc.getProcessMethod(), - grpcChannel) + val (reqChannel, resChannel) = clientCallBidiStreaming( + BluePrintProcessingServiceGrpc.getProcessMethod(), + grpcChannel + ) launch { resChannel.consumeEach { log.info("Received Response") @@ -85,25 +87,24 @@ class BluePrintGrpcServerTest { private fun getRequest(requestId: String): ExecutionServiceInput { val commonHeader = CommonHeader.newBuilder() - .setTimestamp("2012-04-23T18:25:43.511Z") - .setOriginatorId("System") - .setRequestId(requestId) - .setSubRequestId("$requestId-" + UUID.randomUUID().toString()).build() + .setTimestamp("2012-04-23T18:25:43.511Z") + .setOriginatorId("System") + .setRequestId(requestId) + .setSubRequestId("$requestId-" + UUID.randomUUID().toString()).build() val actionIdentifier = ActionIdentifiers.newBuilder() - .setActionName("SampleScript") - .setBlueprintName("sample-cba") - .setBlueprintVersion("1.0.0") - .setMode(ACTION_MODE_SYNC) - .build() + .setActionName("SampleScript") + .setBlueprintName("sample-cba") + .setBlueprintVersion("1.0.0") + .setMode(ACTION_MODE_SYNC) + .build() val jsonContent = """{ "key1" : "value1" }""" val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder JsonFormat.parser().merge(jsonContent, payloadBuilder) return ExecutionServiceInput.newBuilder() - .setCommonHeader(commonHeader) - .setActionIdentifiers(actionIdentifier) - .setPayload(payloadBuilder.build()) - .build() + .setCommonHeader(commonHeader) + .setActionIdentifiers(actionIdentifier) + .setPayload(payloadBuilder.build()) + .build() } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt index d5bc70c48..25828b15e 100644 --- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt +++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt @@ -27,7 +27,6 @@ import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessin import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput - val log = logger(MockTLSBluePrintProcessingServer::class) /** For Integration testing stat this server, Set the working path to run this method */ @@ -40,16 +39,15 @@ fun main() { privateKey = "src/test/resources/tls-manual/py-executor-key.pem" } val server = TLSAuthGrpcServerService(tlsAuthGrpcServerProperties).serverBuilder() - .intercept(GrpcServerLoggingInterceptor()) - .addService(MockTLSBluePrintProcessingServer()) - .build() + .intercept(GrpcServerLoggingInterceptor()) + .addService(MockTLSBluePrintProcessingServer()) + .build() server.start() log.info("GRPC Serve started(${server.isShutdown}) on port(${server.port})...") server.awaitTermination() } catch (e: Exception) { log.error("Failed to start tls grpc integration server", e) } - } class MockTLSBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() { @@ -57,17 +55,21 @@ class MockTLSBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrin return object : StreamObserver<ExecutionServiceInput> { override fun onNext(executionServiceInput: ExecutionServiceInput) { - log.info("Received requestId(${executionServiceInput.commonHeader.requestId}) " + - "subRequestId(${executionServiceInput.commonHeader.subRequestId})") + log.info( + "Received requestId(${executionServiceInput.commonHeader.requestId}) " + + "subRequestId(${executionServiceInput.commonHeader.subRequestId})" + ) responseObserver.onNext(buildResponse(executionServiceInput)) responseObserver.onCompleted() } override fun onError(error: Throwable) { log.debug("Fail to process message", error) - responseObserver.onError(io.grpc.Status.INTERNAL + responseObserver.onError( + io.grpc.Status.INTERNAL .withDescription(error.message) - .asException()) + .asException() + ) } override fun onCompleted() { @@ -78,13 +80,12 @@ class MockTLSBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrin private fun buildResponse(input: ExecutionServiceInput): ExecutionServiceOutput { val status = Status.newBuilder().setCode(200) - .setEventType(EventType.EVENT_COMPONENT_EXECUTED) - .build() + .setEventType(EventType.EVENT_COMPONENT_EXECUTED) + .build() return ExecutionServiceOutput.newBuilder() - .setCommonHeader(input.commonHeader) - .setActionIdentifiers(input.actionIdentifiers) - .setStatus(status) - .build() - + .setCommonHeader(input.commonHeader) + .setActionIdentifiers(input.actionIdentifiers) + .setStatus(status) + .build() } -}
\ No newline at end of file +} |