280227d06887ac2744aa16e9f0ad1faf5b52ee50
[ccsdk/cds.git] /
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  * Modifications Copyright © 2019 Bell Canada.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
19
20
21 import com.google.protobuf.util.JsonFormat
22 import io.grpc.testing.GrpcServerRule
23 import org.junit.Ignore
24 import org.junit.Rule
25 import org.junit.Test
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
38
39 @Ignore
40 @RunWith(SpringRunner::class)
41 @DirtiesContext
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 {
46
47     @get:Rule
48     val grpcServerRule = GrpcServerRule().directExecutor()
49
50     @Autowired
51     lateinit var bluePrintProcessingGRPCHandler: BluePrintProcessingGRPCHandler
52
53     @BeforeTest
54     fun init() {
55         // Create a server, add service, start, and register for automatic graceful shutdown.
56         grpcServerRule.serviceRegistry.addService(bluePrintProcessingGRPCHandler)
57     }
58
59     @Test
60     fun testSelfServiceGRPCHandler() {
61
62         val blockingStub = BluePrintProcessingServiceGrpc.newBlockingStub(grpcServerRule.channel)
63
64         val commonHeader = CommonHeader.newBuilder()
65                 .setTimestamp("2012-04-23T18:25:43.511Z")
66                 .setOriginatorId("System")
67                 .setRequestId("1234")
68                 .setSubRequestId("1234-56").build()
69
70         val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json")
71         val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
72         JsonFormat.parser().merge(jsonContent, payloadBuilder)
73
74         val input = ExecutionServiceInput.newBuilder()
75                 .setCommonHeader(commonHeader)
76                 .setPayload(payloadBuilder.build())
77                 .build()
78
79 //        val response = blockingStub.process(input)
80 //        assertNotNull(response, "Response is null")
81     }
82
83 }