2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events;
23 import com.google.gson.GsonBuilder;
24 import com.google.gson.annotations.SerializedName;
25 import java.util.Random;
28 * This class is a POJO representing an input event for load testing.
30 public class InputEvent {
31 private String nameSpace = "org.onap.policy.apex.sample.events";
33 private String version = "0.0.1";
34 private String source = "EventGenerator";
35 private String target = "Apex";
37 @SerializedName(value = "TestSlogan")
38 private String testSlogan;
40 @SerializedName(value = "TestMatchCase")
41 private int testMatchCase;
43 @SerializedName(value = "TestTimestamp")
44 private long testTimestamp = System.nanoTime();
46 @SerializedName(value = "TestTemperature")
47 private double testTemperature;
50 * Constructor, assign default values to fields.
53 final Random rand = new Random();
54 testMatchCase = rand.nextInt(4);
55 name = "Event0" + rand.nextInt(2) + "00";
56 testTemperature = rand.nextDouble() * 1000;
59 public String getNameSpace() {
64 public void setNameSpace(String nameSpace) {
65 this.nameSpace = nameSpace;
68 public String getName() {
72 public void setName(String name) {
76 public String getVersion() {
80 public void setVersion(String version) {
81 this.version = version;
84 public String getSource() {
88 public void setSource(String source) {
92 public String getTarget() {
97 public void setTarget(String target) {
101 public String getTestSlogan() {
105 public void setTestSlogan(String testSlogan) {
106 this.testSlogan = testSlogan;
109 public int getTestMatchCase() {
110 return testMatchCase;
113 public void setTestMatchCase(int testMatchCase) {
114 this.testMatchCase = testMatchCase;
117 public long getTestTimestamp() {
118 return testTimestamp;
121 public void setTestTimestamp(long testTimestamp) {
122 this.testTimestamp = testTimestamp;
125 public double getTestTemperature() {
126 return testTemperature;
129 public void setTestTemperature(double testTemperature) {
130 this.testTemperature = testTemperature;
134 * Get a JSON representation of the input event.
136 * @return the event in JSON format
138 public String asJson() {
139 return new GsonBuilder().setPrettyPrinting().create().toJson(this);