2 * ============LICENSE_START=======================================================
3 * Copyright (C) 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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.testsuites.integration.common.testclasses;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.fail;
26 import org.junit.Test;
27 import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
30 * Test the ping test class.
32 public class TestPingClassTest {
34 public void testPingClass() {
35 PingTestClass ptc = new PingTestClass();
38 assertEquals("Hello", ptc.getName());
40 ptc.setDescription("Good Day");
41 assertEquals("Good Day", ptc.getDescription());
44 assertEquals(0, ptc.getPingTime());
47 assertEquals(-1, ptc.getPongTime());
51 fail("test should throw an exception");
52 } catch (ApexException ae) {
53 assertEquals("TestPing is not valid, name does not start with \"Rose\"", ae.getMessage());
59 fail("test should throw an exception");
60 } catch (ApexException ae) {
61 assertEquals("TestPing is not valid, name length null or less than 4", ae.getMessage());
67 fail("test should throw an exception");
68 } catch (ApexException ae) {
69 assertEquals("TestPing is not valid, name length null or less than 4", ae.getMessage());
75 fail("test should throw an exception");
76 } catch (ApexException ae) {
77 assertEquals("TestPing is not valid, description length null or less than 44", ae.getMessage());
80 ptc.setDescription(null);
83 fail("test should throw an exception");
84 } catch (ApexException ae) {
85 assertEquals("TestPing is not valid, description length null or less than 44", ae.getMessage());
88 ptc.setDescription("A rose by any other name would smell as swee");
91 fail("test should throw an exception");
92 } catch (ApexException ae) {
93 assertEquals("TestPing is not valid, description length null or less than 44", ae.getMessage());
96 ptc.setDescription("A rose by any other name would smell as swell");
99 fail("test should throw an exception");
100 } catch (ApexException ae) {
101 assertEquals("TestPing is not valid, description is incorrect", ae.getMessage());
104 ptc.setDescription("A rose by any other name would smell as sweet");
107 fail("test should throw an exception");
108 } catch (ApexException ae) {
109 assertEquals("TestPing is not valid, pong time is not greater than ping time", ae.getMessage());
115 fail("test should throw an exception");
116 } catch (ApexException ae) {
117 assertEquals("TestPing is not valid, pong time is not greater than ping time", ae.getMessage());
123 } catch (ApexException ae) {
124 fail("test should not throw an exception");
127 assertEquals("TestPing [name=Rose, description=A rose by any other name would smell as sweet, "
128 + "pingTime=0, pongTime=1]", ptc.toString());