Revert "Renaming Files having BluePrint to have Blueprint"
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / inbounds / selfservice-api / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / selfservice / api / BluePrintProcessingKafkaConsumerTest.kt
1 /*
2  *  Copyright © 2019 IBM.
3  *  Modifications Copyright © 2021 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.cds.blueprintsprocessor.selfservice.api
19
20 import io.micrometer.core.instrument.MeterRegistry
21 import io.mockk.coEvery
22 import io.mockk.mockk
23 import kotlinx.coroutines.delay
24 import kotlinx.coroutines.launch
25 import kotlinx.coroutines.runBlocking
26 import org.junit.runner.RunWith
27 import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
28 import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertyConfiguration
29 import org.onap.ccsdk.cds.blueprintsprocessor.message.BluePrintMessageLibConfiguration
30 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BluePrintMessageLibPropertyService
31 import org.springframework.beans.factory.annotation.Autowired
32 import org.springframework.boot.test.mock.mockito.MockBean
33 import org.springframework.test.context.ContextConfiguration
34 import org.springframework.test.context.TestPropertySource
35 import org.springframework.test.context.junit4.SpringRunner
36 import kotlin.test.Test
37 import kotlin.test.assertNotNull
38
39 @RunWith(SpringRunner::class)
40 @ContextConfiguration(
41     classes = [
42         BluePrintMessageLibConfiguration::class, SelfServiceApiTestConfiguration::class,
43         BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, ErrorCatalogTestConfiguration::class
44     ]
45 )
46 @TestPropertySource(locations = ["classpath:application-test.properties"])
47 class BluePrintProcessingKafkaConsumerTest {
48
49     @MockBean
50     lateinit var meterRegistry: MeterRegistry
51
52     @Autowired
53     lateinit var bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService
54
55     @Test
56     fun testExecutionInputMessageConsumer() {
57         runBlocking {
58             assertNotNull(
59                 bluePrintMessageLibPropertyService,
60                 "failed to initialise bluePrintMessageLibPropertyService"
61             )
62
63             val executionServiceHandle = mockk<ExecutionServiceHandler>()
64
65             coEvery { executionServiceHandle.doProcess(any()) } returns mockk()
66
67             val bluePrintProcessingKafkaConsumer = BluePrintProcessingKafkaConsumer(
68                 bluePrintMessageLibPropertyService,
69                 executionServiceHandle,
70                 meterRegistry
71             )
72
73             launch {
74                 bluePrintProcessingKafkaConsumer.setupMessageListener()
75             }
76             delay(100)
77             bluePrintProcessingKafkaConsumer.shutdownMessageListener()
78         }
79     }
80 }