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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events;
24 import com.google.gson.GsonBuilder;
25 import com.google.gson.annotations.SerializedName;
26 import java.util.Random;
29 * This class is a POJO representing an input event for load testing.
31 public class InputEvent {
32 private String nameSpace = "org.onap.policy.apex.sample.events";
34 private String version = "0.0.1";
35 private String source = "EventGenerator";
36 private String target = "Apex";
38 @SerializedName(value = "TestSlogan")
39 private String testSlogan;
41 @SerializedName(value = "TestMatchCase")
42 private int testMatchCase;
44 @SerializedName(value = "TestTimestamp")
45 private long testTimestamp = System.nanoTime();
47 @SerializedName(value = "TestTemperature")
48 private double testTemperature;
51 * Constructor, assign default values to fields.
55 * This is not used for encryption/security, thus disabling sonar.
57 final Random rand = new Random(); // NOSONAR
59 testMatchCase = rand.nextInt(4);
60 name = "Event0" + rand.nextInt(2) + "00";
61 testTemperature = rand.nextDouble() * 1000;
64 public String getNameSpace() {
69 public void setNameSpace(String nameSpace) {
70 this.nameSpace = nameSpace;
73 public String getName() {
77 public void setName(String name) {
81 public String getVersion() {
85 public void setVersion(String version) {
86 this.version = version;
89 public String getSource() {
93 public void setSource(String source) {
97 public String getTarget() {
102 public void setTarget(String target) {
103 this.target = target;
106 public String getTestSlogan() {
110 public void setTestSlogan(String testSlogan) {
111 this.testSlogan = testSlogan;
114 public int getTestMatchCase() {
115 return testMatchCase;
118 public void setTestMatchCase(int testMatchCase) {
119 this.testMatchCase = testMatchCase;
122 public long getTestTimestamp() {
123 return testTimestamp;
126 public void setTestTimestamp(long testTimestamp) {
127 this.testTimestamp = testTimestamp;
130 public double getTestTemperature() {
131 return testTemperature;
134 public void setTestTemperature(double testTemperature) {
135 this.testTemperature = testTemperature;
139 * Get a JSON representation of the input event.
141 * @return the event in JSON format
143 public String asJson() {
144 return new GsonBuilder().setPrettyPrinting().create().toJson(this);