2 * Copyright © 2019 IBM.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
19 import io.micrometer.core.instrument.MeterRegistry
20 import io.mockk.coEvery
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
38 @RunWith(SpringRunner::class)
39 @ContextConfiguration(
41 BlueprintMessageLibConfiguration::class, SelfServiceApiTestConfiguration::class,
42 BlueprintPropertyConfiguration::class, BlueprintPropertiesService::class, ErrorCatalogTestConfiguration::class
45 @TestPropertySource(locations = ["classpath:application-test.properties"])
46 class BlueprintProcessingKafkaConsumerTest {
49 lateinit var meterRegistry: MeterRegistry
52 lateinit var bluePrintMessageLibPropertyService: BlueprintMessageLibPropertyService
55 fun testExecutionInputMessageConsumer() {
58 bluePrintMessageLibPropertyService,
59 "failed to initialise bluePrintMessageLibPropertyService"
62 val executionServiceHandle = mockk<ExecutionServiceHandler>()
64 coEvery { executionServiceHandle.doProcess(any()) } returns mockk()
66 val bluePrintProcessingKafkaConsumer = BlueprintProcessingKafkaConsumer(
67 bluePrintMessageLibPropertyService,
68 executionServiceHandle
72 bluePrintProcessingKafkaConsumer.setupMessageListener()
75 bluePrintProcessingKafkaConsumer.shutdownMessageListener()