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
24 import java.util.Calendar
28 object MessagePrioritizationSample {
30 fun samplePrioritizationConfiguration(): PrioritizationConfiguration {
31 return PrioritizationConfiguration().apply {
32 inputTopicSelector = "prioritize-input"
33 outputTopic = "prioritize-output-topic"
34 expiredTopic = "prioritize-expired-topic"
35 expiryConfiguration = ExpiryConfiguration().apply {
36 frequencyMilli = 10000L
39 shutDownConfiguration = ShutDownConfiguration().apply {
42 cleanConfiguration = CleanConfiguration().apply {
43 frequencyMilli = 10000L
44 expiredRecordsHoldDays = 5
49 private fun currentDatePlusDays(days: Int): Date {
50 val calender = Calendar.getInstance()
51 calender.add(Calendar.DATE, days)
55 fun sampleMessages(messageState: String, count: Int): List<MessagePrioritization> {
56 return sampleMessages("sample-group", messageState, count)
59 fun sampleMessages(groupName: String, messageState: String, count: Int): List<MessagePrioritization> {
60 val messages: MutableList<MessagePrioritization> = arrayListOf()
62 val backPressureMessage = createMessage(
63 groupName, messageState,
66 messages.add(backPressureMessage)
71 fun sampleMessageWithSameCorrelation(groupName: String, messageState: String, count: Int): List<MessagePrioritization> {
72 val messages: MutableList<MessagePrioritization> = arrayListOf()
74 val backPressureMessage = createMessage(
75 groupName, messageState, "sample-type",
76 "key1=value1,key2=value2"
78 messages.add(backPressureMessage)
83 fun sampleMessageWithDifferentTypeSameCorrelation(
87 ): List<MessagePrioritization> {
88 val messages: MutableList<MessagePrioritization> = arrayListOf()
90 val backPressureMessage = createMessage(
91 groupName, messageState, "type-$it",
92 "key1=value1,key2=value2"
94 messages.add(backPressureMessage)
101 messageState: String,
103 messageCorrelationId: String?
104 ): MessagePrioritization {
106 return MessagePrioritization().apply {
107 id = UUID.randomUUID().toString()
112 correlationId = messageCorrelationId
113 message = "I am the Message"
116 expiryDate = currentDatePlusDays(3)