caf6e2ffd4442a24fc3932e7fb03c3ad6a46dfc8
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-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
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
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.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.apps.uservice.test.adapt.jms;
22
23 import java.io.Serializable;
24
25 import org.onap.policy.apex.service.engine.event.ApexEventException;
26
27 /**
28  * @author Liam Fallon (liam.fallon@ericsson.com)
29  */
30 public class TestPing implements Serializable {
31     private static final long serialVersionUID = -3400711508992955886L;
32
33     private String name = "Rose";
34     private String description = "A rose by any other name would smell as sweet";
35     private long pingTime = System.currentTimeMillis();
36     private long pongTime = -1;
37
38     public String getName() {
39         return name;
40     }
41
42     public void setName(final String name) {
43         this.name = name;
44     }
45
46     public String getDescription() {
47         return description;
48     }
49
50     public void setDescription(final String description) {
51         this.description = description;
52     }
53
54     public long getPingTime() {
55         return pingTime;
56     }
57
58     public void setPingTime(final long pingTime) {
59         this.pingTime = pingTime;
60     }
61
62     public long getPongTime() {
63         return pongTime;
64     }
65
66     public void setPongTime(final long pongTime) {
67         this.pongTime = pongTime;
68     }
69
70     @Override
71     public String toString() {
72         return "TestPing [name=" + name + ", description=" + description + ", pingTime=" + pingTime + ", pongTime="
73                 + pongTime + "]";
74     }
75
76     public void verify() throws ApexEventException {
77         if (!name.startsWith("Rose")) {
78             throw new ApexEventException("TestPing is not valid");
79         }
80
81         if (name.length() <= 4) {
82             throw new ApexEventException("TestPing is not valid");
83         }
84
85         if (!description.startsWith("A rose by any other name would smell as sweet")) {
86             throw new ApexEventException("TestPing is not valid");
87         }
88
89         if (description.length() <= 44) {
90             throw new ApexEventException("TestPing is not valid");
91         }
92
93         if (pongTime <= pingTime) {
94             throw new ApexEventException("TestPing is not valid");
95         }
96     }
97 }