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  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
18
19 import io.micrometer.core.instrument.MeterRegistry
20 import io.mockk.coEvery
21 import io.mockk.mockk
22 import kotlinx.coroutines.delay
23 import kotlinx.coroutines.launch
24 import kotlinx.coroutines.runBlocking
25 import org.junit.runner.RunWith
26 import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertiesService
27 import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
28 import org.onap.ccsdk.cds.blueprintsprocessor.message.BlueprintMessageLibConfiguration
29 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageLibPropertyService
30 import org.springframework.beans.factory.annotation.Autowired
31 import org.springframework.boot.test.mock.mockito.MockBean
32 import org.springframework.test.context.ContextConfiguration
33 import org.springframework.test.context.TestPropertySource
34 import org.springframework.test.context.junit4.SpringRunner
35 import kotlin.test.Test
36 import kotlin.test.assertNotNull
37
38 @RunWith(SpringRunner::class)
39 @ContextConfiguration(
40     classes = [
41         BlueprintMessageLibConfiguration::class, SelfServiceApiTestConfiguration::class,
42         BlueprintPropertyConfiguration::class, BlueprintPropertiesService::class, ErrorCatalogTestConfiguration::class
43     ]
44 )
45 @TestPropertySource(locations = ["classpath:application-test.properties"])
46 class BlueprintProcessingKafkaConsumerTest {
47
48     @MockBean
49     lateinit var meterRegistry: MeterRegistry
50
51     @Autowired
52     lateinit var bluePrintMessageLibPropertyService: BlueprintMessageLibPropertyService
53
54     @Test
55     fun testExecutionInputMessageConsumer() {
56         runBlocking {
57             assertNotNull(
58                 bluePrintMessageLibPropertyService,
59                 "failed to initialise bluePrintMessageLibPropertyService"
60             )
61
62             val executionServiceHandle = mockk<ExecutionServiceHandler>()
63
64             coEvery { executionServiceHandle.doProcess(any()) } returns mockk()
65
66             val bluePrintProcessingKafkaConsumer = BlueprintProcessingKafkaConsumer(
67                 bluePrintMessageLibPropertyService,
68                 executionServiceHandle
69             )
70
71             launch {
72                 bluePrintProcessingKafkaConsumer.setupMessageListener()
73             }
74             delay(100)
75             bluePrintProcessingKafkaConsumer.shutdownMessageListener()
76         }
77     }
78 }