Changes for checkstyle 8.32
[policy/apex-pdp.git] / testsuites / integration / integration-common / src / main / java / org / onap / policy / apex / testsuites / integration / common / testclasses / PingTestClass.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2020 Nordix Foundation.
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.integration.common.testclasses;
23
24 import java.io.Serializable;
25 import lombok.Data;
26 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
27
28 /**
29  * The Class TestPing.
30  *
31  * @author Liam Fallon (liam.fallon@ericsson.com)
32  */
33 @Data
34 public class PingTestClass implements Serializable {
35     private static final long serialVersionUID = -3400711508992955886L;
36
37     private int id = 0;
38     private String name = "Rose";
39     private String description = "A rose by any other name would smell as sweet";
40     private long pingTime = System.currentTimeMillis();
41     private long pongTime = -1;
42
43     /**
44      * Verify the class.
45      *
46      * @throws ApexException the apex event exception
47      */
48     public void verify() throws ApexException {
49         if (name == null || name.length() < 4) {
50             throw new ApexException("TestPing is not valid, name length null or less than 4");
51         }
52
53         if (!name.startsWith("Rose")) {
54             throw new ApexException("TestPing is not valid, name does not start with \"Rose\"");
55         }
56
57         if (description == null || description.length() <= 44) {
58             throw new ApexException("TestPing is not valid, description length null or less than 44");
59         }
60
61         if (!description.startsWith("A rose by any other name would smell as sweet")) {
62             throw new ApexException("TestPing is not valid, description is incorrect");
63         }
64
65         if (pongTime < pingTime) {
66             throw new ApexException(
67                     "TestPing is not valid, pong time " + pongTime + " is less than ping time " + pingTime);
68         }
69     }
70 }