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.junit.Assert.assertEquals;
25 import static org.junit.Assert.fail;
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() {
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());
52 fail("test should throw an exception");
53 } catch (ApexException ae) {
54 assertEquals("TestPing is not valid, name does not start with \"Rose\"", ae.getMessage());
60 fail("test should throw an exception");
61 } catch (ApexException ae) {
62 assertEquals("TestPing is not valid, name length null or less than 4", ae.getMessage());
68 fail("test should throw an exception");
69 } catch (ApexException ae) {
70 assertEquals("TestPing is not valid, name length null or less than 4", ae.getMessage());
76 fail("test should throw an exception");
77 } catch (ApexException ae) {
78 assertEquals("TestPing is not valid, description length null or less than 44", ae.getMessage());
81 ptc.setDescription(null);
84 fail("test should throw an exception");
85 } catch (ApexException ae) {
86 assertEquals("TestPing is not valid, description length null or less than 44", ae.getMessage());
89 ptc.setDescription("A rose by any other name would smell as swee");
92 fail("test should throw an exception");
93 } catch (ApexException ae) {
94 assertEquals("TestPing is not valid, description length null or less than 44", ae.getMessage());
97 ptc.setDescription("A rose by any other name would smell as swell");
100 fail("test should throw an exception");
101 } catch (ApexException ae) {
102 assertEquals("TestPing is not valid, description is incorrect", ae.getMessage());
105 ptc.setDescription("A rose by any other name would smell as sweet");
108 fail("test should throw an exception");
109 } catch (ApexException ae) {
110 assertEquals("TestPing is not valid, pong time -1 is less than ping time 0", ae.getMessage());
116 fail("test should throw an exception");
117 } catch (ApexException ae) {
118 assertEquals("TestPing is not valid, pong time -2 is less than ping time 0", ae.getMessage());
124 } catch (ApexException ae) {
125 fail("test should not throw an exception");
129 "PingTestClass(id=0, name=Rose, "
130 + "description=A rose by any other name would smell as sweet, pingTime=0, pongTime=1)",