Merge "Add New Junit Tests For ONAP-XACML"
[policy/engine.git] / ONAP-XACML / src / test / java / org / onap / policy / xacml / test / std / pap / StdPDPGroupStatusTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-XACML
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.policy.xacml.test.std.pap;
21
22 import static org.junit.Assert.*;
23
24 import java.util.HashSet;
25 import java.util.Set;
26
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.policy.common.logging.flexlogger.FlexLogger;
30 import org.onap.policy.common.logging.flexlogger.Logger;
31 import org.onap.policy.xacml.std.pap.StdPDP;
32 import org.onap.policy.xacml.std.pap.StdPDPGroupStatus;
33 import org.onap.policy.xacml.std.pap.StdPDPPIPConfig;
34
35 public class StdPDPGroupStatusTest {
36
37         private static Logger logger = FlexLogger.getLogger(StdPDPGroupStatus.class);
38         
39         private StdPDPGroupStatus stdPDPGroupStatus;
40         
41         @Before
42         public void setUp(){
43         
44                 try {
45                         stdPDPGroupStatus = new StdPDPGroupStatus();
46                 } catch (Exception e) {
47                         logger.error(e);
48                 } 
49         }
50
51         @Test
52         public void tesGgetStatus() {
53                 try {
54                         assertTrue(stdPDPGroupStatus.getStatus() != null);
55                 } catch (Exception e) {
56                         logger.error(e);
57                 }
58         }
59
60         @Test
61         public void testGetFailedPIPConfigs() {
62                 try {
63                         assertTrue(stdPDPGroupStatus.getFailedPIPConfigs() != null);
64                 } catch (Exception e) {
65                         logger.error(e);
66                 }
67         }
68
69         @Test
70         public void testGetUnknownPDPs() {
71                 try {
72                         assertTrue(stdPDPGroupStatus.getUnknownPDPs() != null);
73                 } catch (Exception e) {
74                         logger.error(e);
75                 }
76         }
77
78         @Test
79         public void testGetLoadErrors() {
80                 try {
81                         stdPDPGroupStatus.setLoadErrors(new HashSet<String>());
82                         assertTrue(stdPDPGroupStatus.getLoadErrors() != null);
83                 } catch (Exception e) {
84                         logger.error(e);
85                 }
86         }
87
88         @Test
89         public void testGetLoadWarnings() {
90                 try {
91                         stdPDPGroupStatus.setLoadWarnings(new HashSet<>());
92                         assertTrue(stdPDPGroupStatus.getLoadWarnings() != null);
93                 } catch (Exception e) {
94                         logger.error(e);
95                 }
96         }
97
98         @Test
99         public void testGetLoadedPolicies() {
100                 try {
101                         stdPDPGroupStatus.setLoadedPolicies(new HashSet<>());
102                         assertTrue(stdPDPGroupStatus.getLoadedPolicies() != null);
103                 } catch (Exception e) {
104                         logger.error(e);
105                 }
106         }
107
108         @Test
109         public void testGetFailedPolicies() {
110                 try {
111                         stdPDPGroupStatus.setFailedPolicies(new HashSet<>());
112                         assertTrue(stdPDPGroupStatus.getFailedPolicies() != null);
113                 } catch (Exception e) {
114                         logger.error(e);
115                 }
116         }
117
118         @Test
119         public void testGetLoadedPipConfigs() {
120                 try {
121                         stdPDPGroupStatus.addLoadedPipConfig(new StdPDPPIPConfig());
122                         assertTrue(stdPDPGroupStatus.getLoadedPipConfigs() != null);
123                 } catch (Exception e) {
124                         logger.error(e);
125                 }
126         }
127
128         @Test
129         public void testGetFailedPipConfigs() {
130                 try {
131                         stdPDPGroupStatus.addFailedPipConfig(new StdPDPPIPConfig());
132                         assertTrue(stdPDPGroupStatus.getFailedPipConfigs() != null);
133                 } catch (Exception e) {
134                         logger.error(e);
135                 }
136         }
137
138         @Test
139         public void testGetInSynchPDPs() {
140                 try {
141                         stdPDPGroupStatus.addInSynchPDP(new StdPDP());
142                         assertTrue(stdPDPGroupStatus.getInSynchPDPs() != null);
143                 } catch (Exception e) {
144                         logger.error(e);
145                 }
146         }
147
148         @Test
149         public void testGetOutOfSynchPDPs() {
150                 try {
151                         stdPDPGroupStatus.addOutOfSynchPDP(new StdPDP());
152                         assertTrue(stdPDPGroupStatus.getOutOfSynchPDPs() != null);
153                 } catch (Exception e) {
154                         logger.error(e);
155                 }
156         }
157
158         @Test
159         public void testGetFailedPDPs() {
160                 try {
161                         stdPDPGroupStatus.addFailedPDP(new StdPDP());
162                         assertTrue(stdPDPGroupStatus.getFailedPDPs() != null);
163                 } catch (Exception e) {
164                         logger.error(e);
165                 }
166         }
167
168         @Test
169         public void testGetUpdatingPDPs() {
170                 try {
171                         stdPDPGroupStatus.addUpdatingPDP(new StdPDP());
172                         assertTrue(stdPDPGroupStatus.getUpdatingPDPs() != null);
173                 } catch (Exception e) {
174                         logger.error(e);
175                 }
176         }
177
178         @Test
179         public void testGetLastUpdateFailedPDPs() {
180                 try {
181                         stdPDPGroupStatus.addLastUpdateFailedPDP(new StdPDP());
182                         assertTrue(stdPDPGroupStatus.getLastUpdateFailedPDPs() != null);
183                 } catch (Exception e) {
184                         logger.error(e);
185                 }
186         }
187
188         @Test
189         public void testGetUnknownStatusPDPs() {
190                 try {
191                         stdPDPGroupStatus.addUnknownPDP(new StdPDP());
192                         assertTrue(stdPDPGroupStatus.getUnknownStatusPDPs() != null);
193                 } catch (Exception e) {
194                         logger.error(e);
195                 }
196         }
197
198         @Test
199         public void testIsGroupOk() {
200                 try {
201                         stdPDPGroupStatus.policiesOK();
202                         assertTrue(stdPDPGroupStatus.isGroupOk() == false);
203                 } catch (Exception e) {
204                         logger.error(e);
205                 }
206         }
207
208 }