Optimize spring data JPA UT.
[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.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(
40             NamedParameterJdbcTemplate(dataSource)
41         )
42     }
43 }
44
45 @Service(MessagePrioritizationConstants.PROCESSOR_PRIORITIZE)
46 open class TestMessagePrioritizeProcessor : MessagePrioritizeProcessor() {
47
48     override fun getGroupCorrelationTypes(messagePrioritization: MessagePrioritization): List<String>? {
49         return when (messagePrioritization.group) {
50             "group-typed" -> arrayListOf("type-0", "type-1", "type-2")
51             else -> null
52         }
53     }
54 }
55
56 @Service(MessagePrioritizationConstants.PROCESSOR_AGGREGATE)
57 open class DefaultMessageAggregateProcessor() : MessageAggregateProcessor()
58
59 @Service(MessagePrioritizationConstants.PROCESSOR_OUTPUT)
60 open class DefaultMessageOutputProcessor : MessageOutputProcessor()