2 * Copyright © 2017-2018 AT&T Intellectual Property.
3 * Modifications Copyright © 2019 Bell Canada.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
21 import com.google.protobuf.util.JsonFormat
22 import io.grpc.testing.GrpcServerRule
23 import org.junit.Ignore
26 import org.junit.runner.RunWith
27 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
28 import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
29 import org.onap.ccsdk.apps.controllerblueprints.processing.api.CommonHeader
30 import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
31 import org.springframework.beans.factory.annotation.Autowired
32 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
33 import org.springframework.context.annotation.ComponentScan
34 import org.springframework.test.annotation.DirtiesContext
35 import org.springframework.test.context.TestPropertySource
36 import org.springframework.test.context.junit4.SpringRunner
37 import kotlin.test.BeforeTest
40 @RunWith(SpringRunner::class)
42 @EnableAutoConfiguration
43 @ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
44 @TestPropertySource(locations = ["classpath:application-test.properties"])
45 class BluePrintProcessingGRPCHandlerTest {
48 val grpcServerRule = GrpcServerRule().directExecutor()
51 lateinit var bluePrintProcessingGRPCHandler: BluePrintProcessingGRPCHandler
55 // Create a server, add service, start, and register for automatic graceful shutdown.
56 grpcServerRule.serviceRegistry.addService(bluePrintProcessingGRPCHandler)
60 fun testSelfServiceGRPCHandler() {
62 val blockingStub = BluePrintProcessingServiceGrpc.newBlockingStub(grpcServerRule.channel)
64 val commonHeader = CommonHeader.newBuilder()
65 .setTimestamp("2012-04-23T18:25:43.511Z")
66 .setOriginatorId("System")
68 .setSubRequestId("1234-56").build()
70 val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json")
71 val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
72 JsonFormat.parser().merge(jsonContent, payloadBuilder)
74 val input = ExecutionServiceInput.newBuilder()
75 .setCommonHeader(commonHeader)
76 .setPayload(payloadBuilder.build())
79 // val response = blockingStub.process(input)
80 // assertNotNull(response, "Response is null")