Unit/SONAR/Checkstyle in ONAP-REST
[policy/engine.git] / ONAP-PAP-REST / src / test / java / org / onap / policy / pap / xacml / rest / components / NotifyOtherPapsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PAP-REST
4  * ================================================================================
5  * Copyright (C) 2018-2019 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
21 package org.onap.policy.pap.xacml.rest.components;
22
23 import static org.assertj.core.api.Assertions.assertThatCode;
24
25 import com.att.research.xacml.util.XACMLProperties;
26 import java.util.ArrayList;
27 import java.util.List;
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.policy.rest.jpa.PolicyDbDaoEntity;
32
33 public class NotifyOtherPapsTest {
34     private static final String systemKey = XACMLProperties.XACML_PROPERTIES_NAME;
35     private static final String oldProperty = System.getProperty(systemKey);
36
37     @Before
38     public void setup() {
39         // Set the system property temporarily
40         System.setProperty(systemKey, "xacml.pap.properties");
41     }
42
43     @Test
44     public void negTestNotify() {
45         NotifyOtherPaps notify = new NotifyOtherPaps();
46         List<PolicyDbDaoEntity> otherServers = new ArrayList<PolicyDbDaoEntity>();
47         PolicyDbDaoEntity dbdaoEntity = new PolicyDbDaoEntity();
48         dbdaoEntity.setPolicyDbDaoUrl("http://test");
49         otherServers.add(dbdaoEntity);
50         long entityId = 0;
51         String entityType = "entityType";
52         String newGroupId = "newGroupId";
53         assertThatCode(() -> notify.startNotifyThreads(otherServers, entityId, entityType, newGroupId))
54             .doesNotThrowAnyException();
55     }
56
57     @After
58     public void cleanup() {
59         // Restore the original system property
60         if (oldProperty != null) {
61             System.setProperty(systemKey, oldProperty);
62         } else {
63             System.clearProperty(systemKey);
64         }
65     }
66 }