2 * Copyright © 2018-2019 AT&T Intellectual Property.
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.functions.message.prioritization
19 import org.onap.ccsdk.cds.blueprintsprocessor.db.PrimaryDBLibGenericService
20 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.db.MessagePrioritization
21 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.topology.MessageAggregateProcessor
22 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.topology.MessageOutputProcessor
23 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.topology.MessagePrioritizeProcessor
24 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BluePrintMessageLibPropertyService
25 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
26 import org.springframework.context.annotation.Bean
27 import org.springframework.context.annotation.ComponentScan
28 import org.springframework.context.annotation.Configuration
29 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
30 import org.springframework.stereotype.Service
31 import javax.sql.DataSource
34 @ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.db"])
35 @EnableAutoConfiguration
36 open class TestDatabaseConfiguration {
38 @Bean("primaryDBLibGenericService")
39 open fun primaryDBLibGenericService(dataSource: DataSource): PrimaryDBLibGenericService {
40 return PrimaryDBLibGenericService(
41 NamedParameterJdbcTemplate(dataSource)
46 /* Sample Prioritization Listener, used during Application startup
48 open class SamplePrioritizationListeners(private val defaultMessagePrioritizationConsumer: MessagePrioritizationConsumer) {
50 private val log = logger(SamplePrioritizationListeners::class)
52 @EventListener(ApplicationReadyEvent::class)
53 open fun init() = runBlocking {
54 log.info("Starting PrioritizationListeners...")
55 defaultMessagePrioritizationConsumer
56 .startConsuming(MessagePrioritizationSample.samplePrioritizationConfiguration())
60 open fun destroy() = runBlocking {
61 log.info("Shutting down PrioritizationListeners...")
62 defaultMessagePrioritizationConsumer.shutDown()
68 open class SampleMessagePrioritizationConsumer(
69 bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService
70 ) : MessagePrioritizationConsumer(bluePrintMessageLibPropertyService)
72 @Service(MessagePrioritizationConstants.PROCESSOR_PRIORITIZE)
73 open class SampleMessagePrioritizeProcessor : MessagePrioritizeProcessor() {
74 override fun getGroupCorrelationTypes(messagePrioritization: MessagePrioritization): List<String>? {
75 return when (messagePrioritization.group) {
76 "group-typed" -> arrayListOf("type-0", "type-1", "type-2")
82 @Service(MessagePrioritizationConstants.PROCESSOR_AGGREGATE)
83 open class SampleMessageAggregateProcessor() : MessageAggregateProcessor()
85 @Service(MessagePrioritizationConstants.PROCESSOR_OUTPUT)
86 open class SampleMessageOutputProcessor : MessageOutputProcessor()