2 * Copyright © 2019 IBM.
3 * Modifications Copyright © 2021 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.cds.blueprintsprocessor.selfservice.api
20 import io.micrometer.core.instrument.MeterRegistry
21 import io.mockk.coEvery
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
39 @RunWith(SpringRunner::class)
40 @ContextConfiguration(
42 BluePrintMessageLibConfiguration::class, SelfServiceApiTestConfiguration::class,
43 BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class, ErrorCatalogTestConfiguration::class
46 @TestPropertySource(locations = ["classpath:application-test.properties"])
47 class BluePrintProcessingKafkaConsumerTest {
50 lateinit var meterRegistry: MeterRegistry
53 lateinit var bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService
56 fun testExecutionInputMessageConsumer() {
59 bluePrintMessageLibPropertyService,
60 "failed to initialise bluePrintMessageLibPropertyService"
63 val executionServiceHandle = mockk<ExecutionServiceHandler>()
65 coEvery { executionServiceHandle.doProcess(any()) } returns mockk()
67 val bluePrintProcessingKafkaConsumer = BluePrintProcessingKafkaConsumer(
68 bluePrintMessageLibPropertyService,
69 executionServiceHandle,
74 bluePrintProcessingKafkaConsumer.setupMessageListener()
77 bluePrintProcessingKafkaConsumer.shutdownMessageListener()