Add junit coverage for three classes
[appc.git] / appc-config / appc-flow-controller / provider / src / test / java / org / onap / appc / flow / controller / data / PrecheckOptionTest.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP : APPC\r
4  * ================================================================================\r
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.\r
6  * =============================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  *\r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  *\r
19  * ============LICENSE_END=========================================================\r
20  */\r
21 \r
22 package org.onap.appc.flow.controller.data;\r
23 \r
24 import static org.junit.Assert.assertTrue;\r
25 import static org.junit.Assert.assertFalse;\r
26 import static org.junit.Assert.assertEquals;\r
27 import static org.junit.Assert.assertNotNull;\r
28 \r
29 \r
30 import org.junit.Before;\r
31 import org.junit.Test;\r
32 \r
33 public class PrecheckOptionTest {\r
34     \r
35     private PrecheckOption precheckoption;\r
36     private PrecheckOption precheckoption1;\r
37     private PrecheckOption precheckoption2;\r
38 \r
39     @Before\r
40     public void SetUp() {\r
41         precheckoption = new PrecheckOption();\r
42         precheckoption1 = new PrecheckOption();\r
43         precheckoption2 = new PrecheckOption();\r
44     }\r
45 \r
46     @Test\r
47     public void testSetpTransactionID() {\r
48         precheckoption.setpTransactionID(1);\r
49         assertNotNull(precheckoption.getpTransactionID());\r
50         assertEquals(precheckoption.getpTransactionID(),1);\r
51     }\r
52 \r
53     @Test\r
54     public void testSetParamName() {\r
55         precheckoption.setParamName("abc");\r
56         assertNotNull(precheckoption.getParamName());\r
57         assertEquals(precheckoption.getParamName(),"abc");\r
58     }\r
59 \r
60     @Test\r
61     public void testSetParamValue() {\r
62         precheckoption.setParamValue("def");\r
63         assertNotNull(precheckoption.getParamValue());\r
64         assertEquals(precheckoption.getParamValue(),"def");\r
65     }\r
66 \r
67     @Test\r
68     public void testToString() {\r
69         precheckoption.setParamName("abc");\r
70         precheckoption.setParamValue("ghi");\r
71         precheckoption.setpTransactionID(1);\r
72         precheckoption.setRule("jkl");\r
73         String ret = precheckoption.toString();\r
74         assertFalse("toString is not empty", ret.isEmpty());\r
75     }\r
76 \r
77     @Test\r
78     public void testSetRule() {\r
79         precheckoption.setRule("abc");\r
80         assertNotNull(precheckoption.getRule());\r
81         assertEquals(precheckoption.getRule(),"abc");\r
82     }\r
83 \r
84     @Test\r
85     public void testHashCode_Print() {\r
86         precheckoption.setpTransactionID(2);\r
87         precheckoption.setParamName("abc");\r
88         precheckoption.setParamValue("def");\r
89         precheckoption.setRule("jkl");\r
90         System.out.println("precheckoption hashcode is " + precheckoption.hashCode());\r
91     }\r
92 \r
93     @Test\r
94     public void testEqualsObject() {\r
95         assertTrue(precheckoption1.equals(precheckoption2) && precheckoption2.equals(precheckoption1));\r
96         assertTrue(precheckoption1.equals(precheckoption1));\r
97         assertFalse(precheckoption1.equals(null));\r
98     }\r
99 }\r