summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ClosedLoopPolicyTest.java68
-rw-r--r--ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRestProperties.java5
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java13
-rw-r--r--ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopPolicyAdaptersTest.java12
-rw-r--r--ONAP-XACML/src/main/java/org/onap/policy/xacml/api/XACMLErrorConstants.java4
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/api/XACMLErrorConstantsTest.java38
6 files changed, 139 insertions, 1 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ClosedLoopPolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ClosedLoopPolicyTest.java
new file mode 100644
index 000000000..9c5f71f55
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/ClosedLoopPolicyTest.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.pap.xacml.rest.components;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+import java.io.IOException;
+import org.onap.policy.rest.adapter.PolicyRestAdapter;
+import com.att.research.xacml.api.pap.PAPException;
+import java.nio.charset.StandardCharsets;
+
+public class ClosedLoopPolicyTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testConstructor1() {
+ thrown.expect(NullPointerException.class);
+ ClosedLoopPolicy policy = new ClosedLoopPolicy();
+ policy.getCorrectPolicyDataObject();
+ }
+
+ @Test
+ public void testConstructor2() {
+ PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
+ ClosedLoopPolicy policy = new ClosedLoopPolicy(policyAdapter);
+ assertNull(policy.getCorrectPolicyDataObject());
+ }
+
+ @Test
+ public void testReadFile() throws IOException {
+ thrown.expect(IOException.class);
+ String read = ClosedLoopPolicy.readFile("/foo", StandardCharsets.UTF_8);
+ fail("Expecting an exception.");
+ }
+
+ @Test
+ public void testPrepareToSave() throws PAPException {
+ PolicyRestAdapter policyAdapter = new PolicyRestAdapter();
+ ClosedLoopPolicy policy = new ClosedLoopPolicy(policyAdapter);
+ policyAdapter.setHighestVersion(1);
+ policyAdapter.setPolicyType("Config");
+ policyAdapter.setNewFileName("foo.xml");
+ policy.prepareToSave();
+ assertEquals(policy.isPreparedToSave(), true);
+ }
+} \ No newline at end of file
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRestProperties.java b/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRestProperties.java
index 73cb0f07e..e52a4110e 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRestProperties.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRestProperties.java
@@ -452,4 +452,9 @@ public class XACMLRestProperties extends XACMLProperties {
* */
public static final String PROP_PAP_INCOMINGNOTIFICATION_TRIES = "xacml.rest.pap.incomingnotification.tries";
+
+ // Static class, hide constructor
+ private XACMLRestProperties() {
+ super();
+ }
}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java
index 419b14daa..9b4cc3ffb 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java
@@ -20,9 +20,13 @@
package org.onap.policy.rest;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -95,6 +99,13 @@ public class XACMLRestTest extends Mockito{
} catch (Exception e) {
fail();
}
-
+ }
+
+ @Test
+ public void testConstructorIsPrivate() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
+ Constructor<XACMLRestProperties> constructor = XACMLRestProperties.class.getDeclaredConstructor();
+ assertTrue(Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
}
} \ No newline at end of file
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopPolicyAdaptersTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopPolicyAdaptersTest.java
index a153efe25..320c30213 100644
--- a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopPolicyAdaptersTest.java
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ClosedLoopPolicyAdaptersTest.java
@@ -21,6 +21,10 @@ package org.onap.policy.rest.adapter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -164,4 +168,12 @@ public class ClosedLoopPolicyAdaptersTest {
assertEquals(ClosedLoopPolicyStatus.ACTIVE.toString(), "active");
assertEquals(ClosedLoopPolicyStatus.INACTIVE.toString(), "inactive");
}
+
+ @Test
+ public void testConstructorIsPrivate() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
+ Constructor<ClosedLoopPerformanceMetrics> constructor = ClosedLoopPerformanceMetrics.class.getDeclaredConstructor();
+ assertTrue(Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
}
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/api/XACMLErrorConstants.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/api/XACMLErrorConstants.java
index 77c0da401..0cbba2f19 100644
--- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/api/XACMLErrorConstants.java
+++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/api/XACMLErrorConstants.java
@@ -52,5 +52,9 @@ public class XACMLErrorConstants {
//Captures all the errors that not related to the list of above error codes
public static final String ERROR_UNKNOWN = "PE900 - Unknown Error: ";
+ // Static class, hide constructor
+ private XACMLErrorConstants() {
+ super();
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/api/XACMLErrorConstantsTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/api/XACMLErrorConstantsTest.java
new file mode 100644
index 000000000..221481723
--- /dev/null
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/api/XACMLErrorConstantsTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-XACML
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.xacml.test.api;
+
+import static org.junit.Assert.assertTrue;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
+import org.junit.Test;
+import org.onap.policy.xacml.api.XACMLErrorConstants;
+
+public class XACMLErrorConstantsTest {
+ @Test
+ public void testConstructorIsPrivate1() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
+ Constructor<XACMLErrorConstants> constructor = XACMLErrorConstants.class.getDeclaredConstructor();
+ assertTrue(Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}