2 * ============LICENSE_START=======================================================
3 * Copyright (C) 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
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.integration.common.testclasses;
24 import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 import static org.junit.Assert.assertEquals;
27 import org.junit.Test;
28 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
31 * Test the ping test class.
33 public class TestPingClassTest {
35 public void testPingClass() throws ApexException {
36 PingTestClass ptc = new PingTestClass();
39 assertEquals("Hello", ptc.getName());
41 ptc.setDescription("Good Day");
42 assertEquals("Good Day", ptc.getDescription());
45 assertEquals(0, ptc.getPingTime());
48 assertEquals(-1, ptc.getPongTime());
49 assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
50 .hasMessageContaining("TestPing is not valid, name does not start with \"Rose\"");
53 assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
54 .hasMessageContaining("TestPing is not valid, name length null or less than 4");
57 assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
58 .hasMessageContaining("TestPing is not valid, name length null or less than 4");
61 assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
62 .hasMessageContaining("TestPing is not valid, description length null or less than 44");
64 ptc.setDescription(null);
65 assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
66 .hasMessageContaining("TestPing is not valid, description length null or less than 44");
68 ptc.setDescription("A rose by any other name would smell as swee");
69 assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
70 .hasMessageContaining("TestPing is not valid, description length null or less than 44");
72 ptc.setDescription("A rose by any other name would smell as swell");
73 assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
74 .hasMessageContaining("TestPing is not valid, description is incorrect");
76 ptc.setDescription("A rose by any other name would smell as sweet");
77 assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
78 .hasMessageContaining("TestPing is not valid, pong time -1 is less than ping time 0");
81 assertThatThrownBy(() -> ptc.verify()).isInstanceOf(ApexException.class)
82 .hasMessageContaining("TestPing is not valid, pong time -2 is less than ping time 0");
88 "PingTestClass(id=0, name=Rose, "
89 + "description=A rose by any other name would smell as sweet, pingTime=0, pongTime=1)",