2cccc7dc00fa13ea379b80fa7e1c960c64e8200a
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events;
23
24 import com.google.gson.GsonBuilder;
25 import com.google.gson.annotations.SerializedName;
26 import java.util.Random;
27
28 /**
29  * This class is a POJO representing an input event for load testing.
30  */
31 public class InputEvent {
32     private String nameSpace = "org.onap.policy.apex.sample.events";
33     private String name;
34     private String version = "0.0.1";
35     private String source = "EventGenerator";
36     private String target = "Apex";
37
38     @SerializedName(value = "TestSlogan")
39     private String testSlogan;
40
41     @SerializedName(value = "TestMatchCase")
42     private int testMatchCase;
43
44     @SerializedName(value = "TestTimestamp")
45     private long testTimestamp = System.nanoTime();
46
47     @SerializedName(value = "TestTemperature")
48     private double testTemperature;
49
50     /**
51      * Constructor, assign default values to fields.
52      */
53     public InputEvent() {
54         /*
55          * This is not used for encryption/security, thus disabling sonar.
56          */
57         final Random rand = new Random();   // NOSONAR
58
59         testMatchCase = rand.nextInt(4);
60         name = "Event0" + rand.nextInt(2) + "00";
61         testTemperature = rand.nextDouble() * 1000;
62     }
63
64     public String getNameSpace() {
65         return nameSpace;
66
67     }
68
69     public void setNameSpace(String nameSpace) {
70         this.nameSpace = nameSpace;
71     }
72
73     public String getName() {
74         return name;
75     }
76
77     public void setName(String name) {
78         this.name = name;
79     }
80
81     public String getVersion() {
82         return version;
83     }
84
85     public void setVersion(String version) {
86         this.version = version;
87     }
88
89     public String getSource() {
90         return source;
91     }
92
93     public void setSource(String source) {
94         this.source = source;
95     }
96
97     public String getTarget() {
98         return target;
99     }
100
101
102     public void setTarget(String target) {
103         this.target = target;
104     }
105
106     public String getTestSlogan() {
107         return testSlogan;
108     }
109
110     public void setTestSlogan(String testSlogan) {
111         this.testSlogan = testSlogan;
112     }
113
114     public int getTestMatchCase() {
115         return testMatchCase;
116     }
117
118     public void setTestMatchCase(int testMatchCase) {
119         this.testMatchCase = testMatchCase;
120     }
121
122     public long getTestTimestamp() {
123         return testTimestamp;
124     }
125
126     public void setTestTimestamp(long testTimestamp) {
127         this.testTimestamp = testTimestamp;
128     }
129
130     public double getTestTemperature() {
131         return testTemperature;
132     }
133
134     public void setTestTemperature(double testTemperature) {
135         this.testTemperature = testTemperature;
136     }
137
138     /**
139      * Get a JSON representation of the input event.
140      *
141      * @return the event in JSON format
142      */
143     public String asJson() {
144         return new GsonBuilder().setPrettyPrinting().create().toJson(this);
145     }
146 }