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;
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.
54 final Random rand = new Random();
55 testMatchCase = rand.nextInt(4);
56 name = "Event0" + rand.nextInt(2) + "00";
57 testTemperature = rand.nextDouble() * 1000;
60 public String getNameSpace() {
65 public void setNameSpace(String nameSpace) {
66 this.nameSpace = nameSpace;
69 public String getName() {
73 public void setName(String name) {
77 public String getVersion() {
81 public void setVersion(String version) {
82 this.version = version;
85 public String getSource() {
89 public void setSource(String source) {
93 public String getTarget() {
98 public void setTarget(String target) {
102 public String getTestSlogan() {
106 public void setTestSlogan(String testSlogan) {
107 this.testSlogan = testSlogan;
110 public int getTestMatchCase() {
111 return testMatchCase;
114 public void setTestMatchCase(int testMatchCase) {
115 this.testMatchCase = testMatchCase;
118 public long getTestTimestamp() {
119 return testTimestamp;
122 public void setTestTimestamp(long testTimestamp) {
123 this.testTimestamp = testTimestamp;
126 public double getTestTemperature() {
127 return testTemperature;
130 public void setTestTemperature(double testTemperature) {
131 this.testTemperature = testTemperature;
135 * Get a JSON representation of the input event.
137 * @return the event in JSON format
139 public String asJson() {
140 return new GsonBuilder().setPrettyPrinting().create().toJson(this);