Use lombok in apex-pdp #4
[policy/apex-pdp.git] / testsuites / performance / performance-benchmark-test / src / main / java / org / onap / policy / apex / testsuites / performance / benchmark / eventgenerator / events / InputEvent.java
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.Gson;
25 import com.google.gson.GsonBuilder;
26 import com.google.gson.annotations.SerializedName;
27 import java.util.Random;
28 import lombok.Getter;
29 import lombok.Setter;
30
31 /**
32  * This class is a POJO representing an input event for load testing.
33  */
34 @Getter
35 @Setter
36 public class InputEvent {
37     private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
38
39     private String nameSpace = "org.onap.policy.apex.sample.events";
40     private String name;
41     private String version = "0.0.1";
42     private String source = "EventGenerator";
43     private String target = "Apex";
44
45     @SerializedName(value = "TestSlogan")
46     private String testSlogan;
47
48     @SerializedName(value = "TestMatchCase")
49     private int testMatchCase;
50
51     @SerializedName(value = "TestTimestamp")
52     private long testTimestamp = System.nanoTime();
53
54     @SerializedName(value = "TestTemperature")
55     private double testTemperature;
56
57     /**
58      * Constructor, assign default values to fields.
59      */
60     public InputEvent() {
61         /*
62          * This is not used for encryption/security, thus disabling sonar.
63          */
64         final Random rand = new Random();   // NOSONAR
65
66         testMatchCase = rand.nextInt(4);
67         name = "Event0" + rand.nextInt(2) + "00";
68         testTemperature = rand.nextDouble() * 1000;
69     }
70
71     /**
72      * Get a JSON representation of the input event.
73      *
74      * @return the event in JSON format
75      */
76     public String asJson() {
77         return gson.toJson(this);
78     }
79 }