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.Gson;
25 import com.google.gson.GsonBuilder;
26 import com.google.gson.annotations.SerializedName;
27 import java.util.Random;
32 * This class is a POJO representing an input event for load testing.
36 public class InputEvent {
37 private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
39 private String nameSpace = "org.onap.policy.apex.sample.events";
41 private String version = "0.0.1";
42 private String source = "EventGenerator";
43 private String target = "Apex";
45 @SerializedName(value = "TestSlogan")
46 private String testSlogan;
48 @SerializedName(value = "TestMatchCase")
49 private int testMatchCase;
51 @SerializedName(value = "TestTimestamp")
52 private long testTimestamp = System.nanoTime();
54 @SerializedName(value = "TestTemperature")
55 private double testTemperature;
58 * Constructor, assign default values to fields.
62 * This is not used for encryption/security, thus disabling sonar.
64 final Random rand = new Random(); // NOSONAR
66 testMatchCase = rand.nextInt(4);
67 name = "Event0" + rand.nextInt(2) + "00";
68 testTemperature = rand.nextDouble() * 1000;
72 * Get a JSON representation of the input event.
74 * @return the event in JSON format
76 public String asJson() {
77 return gson.toJson(this);