2 * Copyright © 2018-2019 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
19 import com.google.protobuf.util.JsonFormat
20 import io.grpc.stub.StreamObserver
21 import kotlinx.coroutines.delay
22 import kotlinx.coroutines.runBlocking
23 import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GRPCLibConstants
24 import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties
25 import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.TokenAuthGrpcClientService
26 import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers
27 import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
28 import org.onap.ccsdk.cds.controllerblueprints.core.logger
29 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
30 import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
31 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput
32 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput
33 import org.springframework.test.context.ContextConfiguration
35 @ContextConfiguration(
36 classes = [SelfServiceApiTestConfiguration::class, ErrorCatalogTestConfiguration::class]
38 class BluePrintProcessingIntegrationTest {
40 private val log = logger(BluePrintProcessingIntegrationTest::class)
42 /** This is Integration test sample, Do not enable this test case in server build, this is for local desktop testing*/
44 fun integrationTestGrpcManagement() {
46 val tokenAuthGrpcClientProperties = TokenAuthGrpcClientProperties().apply {
49 type = GRPCLibConstants.TYPE_TOKEN_AUTH
50 token = "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw=="
52 val basicAuthGrpcClientService = TokenAuthGrpcClientService(tokenAuthGrpcClientProperties)
53 val channel = basicAuthGrpcClientService.channel()
55 val stub = BluePrintProcessingServiceGrpc.newStub(channel)
57 val requestObs = stub.process(object : StreamObserver<ExecutionServiceOutput> {
58 override fun onNext(executionServiceOuput: ExecutionServiceOutput) {
59 log.info("onNext Received {}", executionServiceOuput)
62 override fun onError(error: Throwable) {
63 log.error("Fail to process message", error)
66 override fun onCompleted() {
71 val commonHeader = CommonHeader.newBuilder()
72 .setTimestamp("2012-04-23T18:25:43.511Z")
73 .setOriginatorId("System")
74 .setRequestId("1234-$it")
75 .setSubRequestId("1234-56").build()
77 val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json")
78 val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
79 JsonFormat.parser().merge(jsonContent, payloadBuilder)
81 val actionIdentifier = ActionIdentifiers.newBuilder()
82 .setActionName("SampleScript")
83 .setBlueprintName("sample-cba")
84 .setBlueprintVersion("1.0.0")
87 val input = ExecutionServiceInput.newBuilder()
88 .setCommonHeader(commonHeader)
89 .setActionIdentifiers(actionIdentifier)
90 .setPayload(payloadBuilder.build())
93 requestObs.onNext(input)
94 requestObs.onCompleted()