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.utils
19 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.CleanConfiguration
20 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.ExpiryConfiguration
21 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.PrioritizationConfiguration
22 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.ShutDownConfiguration
23 import org.onap.ccsdk.cds.blueprintsprocessor.functions.message.prioritization.db.MessagePrioritization
26 object MessagePrioritizationSample {
28 fun samplePrioritizationConfiguration(): PrioritizationConfiguration {
29 return PrioritizationConfiguration().apply {
30 inputTopicSelector = "prioritize-input"
31 outputTopic = "prioritize-output-topic"
32 expiredTopic = "prioritize-expired-topic"
33 expiryConfiguration = ExpiryConfiguration().apply {
34 frequencyMilli = 10000L
37 shutDownConfiguration = ShutDownConfiguration().apply {
40 cleanConfiguration = CleanConfiguration().apply {
41 frequencyMilli = 10000L
42 expiredRecordsHoldDays = 5
47 private fun currentDatePlusDays(days: Int): Date {
48 val calender = Calendar.getInstance()
49 calender.add(Calendar.DATE, days)
53 fun sampleMessages(messageState: String, count: Int): List<MessagePrioritization> {
54 return sampleMessages("sample-group", messageState, count)
57 fun sampleMessages(groupName: String, messageState: String, count: Int): List<MessagePrioritization> {
58 val messages: MutableList<MessagePrioritization> = arrayListOf()
60 val backPressureMessage = createMessage(groupName, messageState,
62 messages.add(backPressureMessage)
67 fun sampleMessageWithSameCorrelation(groupName: String, messageState: String, count: Int): List<MessagePrioritization> {
68 val messages: MutableList<MessagePrioritization> = arrayListOf()
70 val backPressureMessage = createMessage(groupName, messageState, "sample-type",
71 "key1=value1,key2=value2")
72 messages.add(backPressureMessage)
77 fun sampleMessageWithDifferentTypeSameCorrelation(groupName: String, messageState: String,
78 count: Int): List<MessagePrioritization> {
79 val messages: MutableList<MessagePrioritization> = arrayListOf()
81 val backPressureMessage = createMessage(groupName, messageState, "type-$it",
82 "key1=value1,key2=value2")
83 messages.add(backPressureMessage)
88 fun createMessage(groupName: String, messageState: String, messageType: String,
89 messageCorrelationId: String?): MessagePrioritization {
91 return MessagePrioritization().apply {
92 id = UUID.randomUUID().toString()
97 correlationId = messageCorrelationId
98 message = "I am the Message"
101 expiryDate = currentDatePlusDays(3)