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