Enhancement of routing test
[dcaegen2/collectors/hv-ves.git] / hv-collector-ct / src / test / kotlin / org / onap / dcae / collectors / veshv / tests / fakes / configuration.kt
1 /*
2  * ============LICENSE_START=======================================================
3  * dcaegen2-collectors-veshv
4  * ================================================================================
5  * Copyright (C) 2018 NOKIA
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.dcae.collectors.veshv.tests.fakes
21
22 import org.onap.dcae.collectors.veshv.boundary.ConfigurationProvider
23 import org.onap.dcae.collectors.veshv.model.CollectorConfiguration
24 import org.onap.dcae.collectors.veshv.model.routing
25 import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader.Domain
26 import reactor.core.publisher.FluxProcessor
27 import reactor.core.publisher.UnicastProcessor
28
29
30 const val HVRANMEAS_TOPIC = "ves_hvRanMeas"
31 const val MEASUREMENTS_FOR_VF_SCALING_TOPIC = "ves_hvMeasForVfScaling"
32
33 val basicConfiguration: CollectorConfiguration = CollectorConfiguration(
34         kafkaBootstrapServers = "localhost:9969",
35         routing = routing {
36             defineRoute {
37                 fromDomain(Domain.HVRANMEAS)
38                 toTopic(HVRANMEAS_TOPIC)
39                 withFixedPartitioning()
40             }
41         }.build()
42 )
43
44 val twoDomainsToOneTopicConfiguration: CollectorConfiguration = CollectorConfiguration(
45         kafkaBootstrapServers = "localhost:9969",
46         routing = routing {
47             defineRoute {
48                 fromDomain(Domain.HVRANMEAS)
49                 toTopic(HVRANMEAS_TOPIC)
50                 withFixedPartitioning()
51             }
52             defineRoute {
53                 fromDomain(Domain.HEARTBEAT)
54                 toTopic(HVRANMEAS_TOPIC)
55                 withFixedPartitioning()
56             }
57             defineRoute {
58                 fromDomain(Domain.MEASUREMENTS_FOR_VF_SCALING)
59                 toTopic(MEASUREMENTS_FOR_VF_SCALING_TOPIC)
60                 withFixedPartitioning()
61             }
62         }.build()
63 )
64
65
66 class FakeConfigurationProvider : ConfigurationProvider {
67     private val configStream: FluxProcessor<CollectorConfiguration, CollectorConfiguration> = UnicastProcessor.create()
68
69     fun updateConfiguration(collectorConfiguration: CollectorConfiguration) {
70         configStream.onNext(collectorConfiguration)
71     }
72
73     override fun invoke() = configStream
74 }