Add message prioritization module
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / message-prioritizaion / src / test / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / message / prioritization / TestConfiguration.kt
1 /*
2  * Copyright © 2018-2019 AT&T Intellectual Property.
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.functions.message.prioritization
18
19 import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.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.springframework.boot.autoconfigure.EnableAutoConfiguration
25 import org.springframework.context.annotation.Bean
26 import org.springframework.context.annotation.ComponentScan
27 import org.springframework.context.annotation.Configuration
28 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
29 import org.springframework.stereotype.Service
30 import javax.sql.DataSource
31
32 @Configuration
33 @ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.db"])
34 @EnableAutoConfiguration
35 open class TestDatabaseConfiguration {
36
37     @Bean("primaryDBLibGenericService")
38     open fun primaryDBLibGenericService(dataSource: DataSource): PrimaryDBLibGenericService {
39         return PrimaryDBLibGenericService(NamedParameterJdbcTemplate(dataSource))
40     }
41 }
42
43 @Service(MessagePrioritizationConstants.PROCESSOR_PRIORITIZE)
44 open class TestMessagePrioritizeProcessor : MessagePrioritizeProcessor() {
45     override fun getGroupCorrelationTypes(messagePrioritization: MessagePrioritization): List<String>? {
46         return when (messagePrioritization.group) {
47             "group-typed" -> arrayListOf("type-0", "type-1", "type-2")
48             else -> null
49         }
50     }
51 }
52
53 @Service(MessagePrioritizationConstants.PROCESSOR_AGGREGATE)
54 open class DefaultMessageAggregateProcessor() : MessageAggregateProcessor()
55
56 @Service(MessagePrioritizationConstants.PROCESSOR_OUTPUT)
57 open class DefaultMessageOutputProcessor : MessageOutputProcessor()