Reformat ONAP-XACML test cases 44/78544/1
authorkaihlavi <l.kaihlavirt@partner.samsung.com>
Fri, 15 Feb 2019 09:33:20 +0000 (11:33 +0200)
committerkaihlavi <l.kaihlavirt@partner.samsung.com>
Fri, 15 Feb 2019 09:33:20 +0000 (11:33 +0200)
Reformat test cases to follow ONAP style
https://wiki.onap.org/display/DW/Java+code+style

Format changes mainly consist of conversions of tabs and
2 spaces to 4 spaces

Samsung modifications copyrights added and updated

Change-Id: I1da3f7e0d032ba00721f16ae9c7dd8baca3299b4
Issue-ID: POLICY-1506
Signed-off-by: kaihlavi <l.kaihlavirt@partner.samsung.com>
15 files changed:
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/api/XACMLErrorConstantsTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineFactoryTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupStatusTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPItemSetChangeNotifierTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPIPConfigTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPolicyTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPStatusTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pip/engines/OperationHistoryEngineTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/AAFEngineTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/MetricsUtilTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyScannerTest.java
ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyWriterTest.java

index 2214817..0166a12 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -28,11 +30,13 @@ 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();
-       }
+    @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();
+    }
 }
index 2e0a0de..6ab9790 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -21,58 +23,55 @@ package org.onap.policy.xacml.test.std.pap;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
 import java.io.IOException;
 import java.util.Properties;
-
 import org.junit.Test;
 import org.onap.policy.xacml.std.pap.StdEngineFactory;
-
 import com.att.research.xacml.api.pap.PAPException;
 import com.att.research.xacml.std.pap.StdEngine;
 import com.att.research.xacml.util.FactoryException;
 
 public class StdEngineFactoryTest {
-  @Test
-  public void testStdEngineFactory() throws FactoryException, PAPException, IOException {
-    StdEngineFactory stdFactory = new StdEngineFactory();
-    System.setProperty("xacml.pap.pdps", "src/test/resources/pdps");
-    assertTrue(stdFactory.newEngine() != null);
-    Properties properties = new Properties();
-    properties.setProperty("xacml.pap.pdps", "src/test/resources/pdps");
-    assertTrue(stdFactory.newEngine(properties) != null);
+    @Test
+    public void testStdEngineFactory() throws FactoryException, PAPException, IOException {
+        StdEngineFactory stdFactory = new StdEngineFactory();
+        System.setProperty("xacml.pap.pdps", "src/test/resources/pdps");
+        assertTrue(stdFactory.newEngine() != null);
+        Properties properties = new Properties();
+        properties.setProperty("xacml.pap.pdps", "src/test/resources/pdps");
+        assertTrue(stdFactory.newEngine(properties) != null);
 
-    StdEngineFactory stdFactoryNew = new StdEngineFactory();
-    System.setProperty("xacml.pap.pdps", "src/test/resources/pdpstest");
-    assertTrue(stdFactoryNew.newEngine() != null);
-  }
+        StdEngineFactory stdFactoryNew = new StdEngineFactory();
+        System.setProperty("xacml.pap.pdps", "src/test/resources/pdpstest");
+        assertTrue(stdFactoryNew.newEngine() != null);
+    }
 
-  @Test
-  public void testNegativeCase() throws Exception {
-    // Setup test data
-    Properties props = new Properties();
-    String tmpdir = System.getProperty("java.io.tmpdir");
-    props.setProperty(StdEngine.PROP_PAP_REPO, tmpdir);
+    @Test
+    public void testNegativeCase() throws Exception {
+        // Setup test data
+        Properties props = new Properties();
+        String tmpdir = System.getProperty("java.io.tmpdir");
+        props.setProperty(StdEngine.PROP_PAP_REPO, tmpdir);
 
-    // Set the system property temporarily
-    String systemKey = StdEngine.PROP_PAP_REPO;
-    String oldProperty = System.getProperty(systemKey);
-    System.setProperty(systemKey, tmpdir);
+        // Set the system property temporarily
+        String systemKey = StdEngine.PROP_PAP_REPO;
+        String oldProperty = System.getProperty(systemKey);
+        System.setProperty(systemKey, tmpdir);
 
-    // Test factory failure cases
-    try {
-      StdEngineFactory factory = new StdEngineFactory();
-      factory.newEngine();
-      factory.newEngine(props);
-    } catch (Exception ex) {
-      fail("Not expecting any exceptions: " + ex);
-    }
+        // Test factory failure cases
+        try {
+            StdEngineFactory factory = new StdEngineFactory();
+            factory.newEngine();
+            factory.newEngine(props);
+        } catch (Exception ex) {
+            fail("Not expecting any exceptions: " + ex);
+        }
 
-    // Restore the original system property
-    if (oldProperty != null) {
-      System.setProperty(systemKey, oldProperty);
-    } else {
-      System.clearProperty(systemKey);
+        // Restore the original system property
+        if (oldProperty != null) {
+            System.setProperty(systemKey, oldProperty);
+        } else {
+            System.clearProperty(systemKey);
+        }
     }
-  }
 }
index f0ee8dd..79b43b1 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -52,16 +54,20 @@ public class StdEngineTest {
     private Path repository;
     Properties properties = new Properties();
     StdEngine stdEngine = null;
-    
+
     @Rule
     public ExpectedException expectedException = ExpectedException.none();
-    
+
     @BeforeClass
-    public static void setUpClass() throws IOException{
+    public static void setUpClass() throws IOException {
         new File("target/test/resources/pdps").mkdirs();
         new File("target/test/resources/emptyPapGroupsDefault").mkdirs();
-        Files.copy(Paths.get("src/test/resources/pdps/xacml.properties"), Paths.get("target/test/resources/pdps/xacml.properties"), StandardCopyOption.REPLACE_EXISTING);
-        Files.copy(Paths.get("src/test/resources/emptyPapGroupsDefault/xacml.properties"), Paths.get("target/test/resources/emptyPapGroupsDefault/xacml.properties"), StandardCopyOption.REPLACE_EXISTING);
+        Files.copy(Paths.get("src/test/resources/pdps/xacml.properties"),
+                Paths.get("target/test/resources/pdps/xacml.properties"),
+                StandardCopyOption.REPLACE_EXISTING);
+        Files.copy(Paths.get("src/test/resources/emptyPapGroupsDefault/xacml.properties"),
+                Paths.get("target/test/resources/emptyPapGroupsDefault/xacml.properties"),
+                StandardCopyOption.REPLACE_EXISTING);
     }
 
     @Before
@@ -100,47 +106,53 @@ public class StdEngineTest {
     public void testNoRepository() throws PAPException, IOException {
         expectedException.expect(PAPException.class);
         expectedException.expectMessage("No repository specified.");
-        new StdEngine((Path)null);
+        new StdEngine((Path) null);
     }
-    
+
     @Test
     public void testRepositoryDoesNotExist() throws PAPException, IOException {
         repository = Paths.get("target/test/resources/nonExisting");
         new StdEngine(repository);
-        
-        assertTrue(Files.exists(Paths.get("target/test/resources/nonExisting/default/xacml.pip.properties")));
-        assertTrue(Files.exists(Paths.get("target/test/resources/nonExisting/default/xacml.policy.properties")));
+
+        assertTrue(Files.exists(
+                Paths.get("target/test/resources/nonExisting/default/xacml.pip.properties")));
+        assertTrue(Files.exists(
+                Paths.get("target/test/resources/nonExisting/default/xacml.policy.properties")));
         assertTrue(Files.exists(Paths.get("target/test/resources/nonExisting/xacml.properties")));
         FileUtils.deleteDirectory(repository.toFile());
     }
-    
+
     @Test
     public void testEmptyPapGroupsDefault() throws PAPException, IOException {
         System.setProperty("xacml.pap.groups.default", "");
         repository = Paths.get("target/test/resources/emptyPapGroupsDefault");
         new StdEngine(repository);
-        
-        assertTrue(Files.exists(Paths.get("target/test/resources/emptyPapGroupsDefault/default/xacml.pip.properties")));
-        assertTrue(Files.exists(Paths.get("target/test/resources/emptyPapGroupsDefault/default/xacml.policy.properties")));
-        assertTrue(Files.exists(Paths.get("target/test/resources/emptyPapGroupsDefault/xacml.properties")));
+
+        assertTrue(Files.exists(Paths
+                .get("target/test/resources/emptyPapGroupsDefault/default/xacml.pip.properties")));
+        assertTrue(Files.exists(Paths.get(
+                "target/test/resources/emptyPapGroupsDefault/default/xacml.policy.properties")));
+        assertTrue(Files
+                .exists(Paths.get("target/test/resources/emptyPapGroupsDefault/xacml.properties")));
     }
-    
+
     @Test
-    public void testNewGroupAndRemoveGroup() throws NullPointerException, PAPException, IOException {
+    public void testNewGroupAndRemoveGroup()
+            throws NullPointerException, PAPException, IOException {
         OnapPDPGroup newGroup = createGroup("newGroup", "Description of new group");
         assertNotNull(newGroup);
 
         stdEngine.removeGroup(stdEngine.getGroup("newGroup"), null);
         assertNull(stdEngine.getGroup("newGroup"));
     }
-    
+
     @Test
     public void testRemoveGroupNull() throws NullPointerException, PAPException, IOException {
         expectedException.expect(NullPointerException.class);
         stdEngine.removeGroup(null, null);
         assertNull(stdEngine.getGroup("newGroup"));
     }
-    
+
     @Test
     public void testRemoveGroupUnknown() throws NullPointerException, PAPException, IOException {
         OnapPDPGroup unknownGroup = new StdPDPGroup("unknownId", null);
@@ -149,7 +161,7 @@ public class StdEngineTest {
         expectedException.expectMessage("The group 'unknownId' does not exist");
         stdEngine.removeGroup(unknownGroup, null);
     }
-    
+
     @Test
     public void testRemoveGroupDefault() throws NullPointerException, PAPException, IOException {
         OnapPDPGroup defaultGroup = stdEngine.getDefaultGroup();
@@ -158,141 +170,145 @@ public class StdEngineTest {
         expectedException.expectMessage("You cannot delete the default group.");
         stdEngine.removeGroup(defaultGroup, null);
     }
-    
+
     @Test
     public void testSetDefaultGroup() throws NullPointerException, PAPException, IOException {
         OnapPDPGroup newGroup = createGroup("newGroup", "Description of new group");
         assertNotNull(newGroup);
-        
+
         OnapPDPGroup defaultGroup = stdEngine.getDefaultGroup();
         assertEquals("default", defaultGroup.getName());
         stdEngine.setDefaultGroup(newGroup);
         assertEquals(newGroup, stdEngine.getDefaultGroup());
-        
+
         stdEngine.setDefaultGroup(defaultGroup);
         stdEngine.removeGroup(stdEngine.getGroup("newGroup"), null);
     }
-    
+
     @Test
-    public void testPdps() throws NullPointerException, PAPException{
+    public void testPdps() throws NullPointerException, PAPException {
         OnapPDPGroup group1 = createGroup("newGroup", "Description of new group");
         assertEquals(0, group1.getPdps().size());
-        
+
         stdEngine.newPDP("newPdp", group1, "newPdpName", "A new pdp", 1);
         assertEquals(1, group1.getPdps().size());
         assertEquals("newPdp", group1.getPdps().iterator().next().getId());
         assertEquals("newPdpName", group1.getPdps().iterator().next().getName());
         assertEquals("A new pdp", group1.getPdps().iterator().next().getDescription());
-        
+
         OnapPDPGroup group2 = createGroup("anotherNewGroup", "Description of new group");
         assertEquals(0, group2.getPdps().size());
-        
+
         stdEngine.movePDP(group1.getOnapPdps().iterator().next(), group2);
         assertEquals(0, group1.getPdps().size());
         assertEquals(1, group2.getPdps().size());
-        
+
         OnapPDP pdp = group2.getOnapPdps().iterator().next();
         pdp.setName("AnUpdatedName");;
         pdp.setDescription("An updated description");
         stdEngine.updatePDP(pdp);
         assertEquals("AnUpdatedName", group2.getPdps().iterator().next().getName());
         assertEquals("An updated description", group2.getPdps().iterator().next().getDescription());
-        
+
         stdEngine.removePDP(group2.getOnapPdps().iterator().next());
         assertEquals(0, group1.getPdps().size());
         assertEquals(0, group2.getPdps().size());
     }
-    
+
     @Test
-    public void testNewPdpNullGroup() throws NullPointerException, PAPException{
+    public void testNewPdpNullGroup() throws NullPointerException, PAPException {
         expectedException.expect(PAPException.class);
         expectedException.expectMessage("You must specify which group the PDP will belong to.");
         stdEngine.newPDP("newPdp", null, "newPdpName", "A new pdp", 1);
     }
-    
+
     @Test
-    public void testNewPdpUnknownGroup() throws NullPointerException, PAPException{
+    public void testNewPdpUnknownGroup() throws NullPointerException, PAPException {
         OnapPDPGroup unknownGroup = new StdPDPGroup("unknownId", null);
 
         expectedException.expect(PAPException.class);
         expectedException.expectMessage("Unknown group, not in our list.");
         stdEngine.newPDP("newPdp", unknownGroup, "newPdpName", "A new pdp", 1);
     }
-    
+
     @Test
-    public void testNewPdpAlreadyExistingPdp() throws NullPointerException, PAPException{
+    public void testNewPdpAlreadyExistingPdp() throws NullPointerException, PAPException {
         OnapPDPGroup group1 = createGroup("newGroup", "Description of new group");
         assertEquals(0, group1.getPdps().size());
-        
+
         stdEngine.newPDP("newPdp", group1, "newPdpName", "A new pdp", 1);
         assertEquals(1, group1.getPdps().size());
-        
+
         expectedException.expect(PAPException.class);
         expectedException.expectMessage("A PDP with this ID exists.");
         stdEngine.newPDP("newPdp", group1, "newPdpName", "A new pdp", 1);
     }
-    
+
     @Test
-    public void testRemoveGroupWithPdps() throws NullPointerException, PAPException{
+    public void testRemoveGroupWithPdps() throws NullPointerException, PAPException {
         OnapPDPGroup group1 = createGroup("newGroup", "Description of new group");
-        
+
         stdEngine.newPDP("newPdp", group1, "newPdpName", "A new pdp", 1);
         assertEquals(1, group1.getPdps().size());
-        
+
         OnapPDPGroup group2 = createGroup("anotherNewGroup", "Description of new group");
         assertEquals(0, group2.getPdps().size());
-        
+
         stdEngine.removeGroup(group1, group2);
         assertNull(stdEngine.getGroup("newGroup"));
         assertEquals(1, group2.getPdps().size());
     }
-    
+
     @Test
-    public void testRemoveGroupWithPdpsNoTarget() throws NullPointerException, PAPException{
+    public void testRemoveGroupWithPdpsNoTarget() throws NullPointerException, PAPException {
         OnapPDPGroup group1 = createGroup("newGroup", "Description of new group");
-        
+
         stdEngine.newPDP("newPdp", group1, "newPdpName", "A new pdp", 1);
         assertEquals(1, group1.getPdps().size());
-        
+
         OnapPDPGroup group2 = createGroup("anotherNewGroup", "Description of new group");
         assertEquals(0, group2.getPdps().size());
-        
+
         expectedException.expect(NullPointerException.class);
-        expectedException.expectMessage("Group targeted for deletion has PDPs, you must provide a new group for them.");
+        expectedException.expectMessage(
+                "Group targeted for deletion has PDPs, you must provide a new group for them.");
         stdEngine.removeGroup(group1, null);
     }
-    
+
     @Test
     public void testUpdateGroupName() throws NullPointerException, PAPException, IOException {
         OnapPDPGroup newGroup = createGroup("newGroup", "Description of new group");
-        
+
         OnapPDPGroup updatedGroup = new StdPDPGroup(newGroup);
         updatedGroup.setName("AnUpdatedName");
         stdEngine.updateGroup(updatedGroup);
         assertNull(stdEngine.getGroup("newGroup"));
         assertNotNull(stdEngine.getGroup("AnUpdatedName"));
         assertEquals("AnUpdatedName", stdEngine.getGroup("AnUpdatedName").getName());
-        assertEquals("Description of new group", stdEngine.getGroup("AnUpdatedName").getDescription());
+        assertEquals("Description of new group",
+                stdEngine.getGroup("AnUpdatedName").getDescription());
     }
-    
+
     @Test
-    public void testUpdateGroupDescription() throws NullPointerException, PAPException, IOException {
+    public void testUpdateGroupDescription()
+            throws NullPointerException, PAPException, IOException {
         OnapPDPGroup newGroup = createGroup("newGroup", "Description of new group");
-                
-        OnapPDPGroup updatedGroup = new StdPDPGroup(newGroup.getId(), newGroup.getName(), "An updated description", Paths.get("target/test/resources/pdps/newGroup"));
+
+        OnapPDPGroup updatedGroup = new StdPDPGroup(newGroup.getId(), newGroup.getName(),
+                "An updated description", Paths.get("target/test/resources/pdps/newGroup"));
         updatedGroup.setDescription("An updated description");
         stdEngine.updateGroup(updatedGroup);
         assertEquals("newGroup", stdEngine.getGroup("newGroup").getName());
         assertEquals("An updated description", stdEngine.getGroup("newGroup").getDescription());
     }
-    
+
     @Test
     public void testUpdateGroupNull() throws NullPointerException, PAPException, IOException {
         expectedException.expect(PAPException.class);
         expectedException.expectMessage("Group or id is null");
         stdEngine.updateGroup(null);
     }
-    
+
     @Test
     public void testUpdateGroupIdNull() throws NullPointerException, PAPException, IOException {
         StdPDPGroup group = new StdPDPGroup(null, null);
@@ -300,7 +316,7 @@ public class StdEngineTest {
         expectedException.expectMessage("Group or id is null");
         stdEngine.updateGroup(group);
     }
-    
+
     @Test
     public void testUpdateGroupNameNull() throws NullPointerException, PAPException, IOException {
         StdPDPGroup group = new StdPDPGroup("groupId", null);
@@ -308,15 +324,16 @@ public class StdEngineTest {
         expectedException.expectMessage("New name for group cannot be null or blank");
         stdEngine.updateGroup(group);
     }
-    
+
     @Test
-    public void testUpdateGroupNameEmptyString() throws NullPointerException, PAPException, IOException {
+    public void testUpdateGroupNameEmptyString()
+            throws NullPointerException, PAPException, IOException {
         StdPDPGroup group = new StdPDPGroup("groupId", "", "description", null);
         expectedException.expect(PAPException.class);
         expectedException.expectMessage("New name for group cannot be null or blank");
         stdEngine.updateGroup(group);
     }
-    
+
     @Test
     public void testUpdateGroupUnknown() throws NullPointerException, PAPException, IOException {
         StdPDPGroup group = new StdPDPGroup("groupId", "groupName", "description", null);
@@ -324,69 +341,77 @@ public class StdEngineTest {
         expectedException.expectMessage("Update found no existing group with id 'groupId'");
         stdEngine.updateGroup(group);
     }
-    
+
     @Test
-    public void testPublishAndRemovePolicy() throws NullPointerException, PAPException, FileNotFoundException{
+    public void testPublishAndRemovePolicy()
+            throws NullPointerException, PAPException, FileNotFoundException {
         OnapPDPGroup newGroup = createGroup("newGroup", "Description of new group");
-        InputStream inputStream = new FileInputStream("src/test/resources/pdps/default/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml");
-        stdEngine.publishPolicy("com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml", "Config_BRMS_Param_BRMSParamvFWDemoPolicy", true, inputStream, newGroup);
+        InputStream inputStream = new FileInputStream(
+                "src/test/resources/pdps/default/com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml");
+        stdEngine.publishPolicy("com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml",
+                "Config_BRMS_Param_BRMSParamvFWDemoPolicy", true, inputStream, newGroup);
         PDPPolicy policy = newGroup.getPolicy("com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml");
         assertNotNull(policy);
-        
+
         stdEngine.removePolicy(policy, newGroup);
         assertNull(newGroup.getPolicy("com.Config_BRMS_Param_BRMSParamvFWDemoPolicy.1.xml"));
     }
-    
+
     @Test
-    public void testPublishPolicyNull() throws NullPointerException, PAPException, FileNotFoundException{
+    public void testPublishPolicyNull()
+            throws NullPointerException, PAPException, FileNotFoundException {
         expectedException.expect(NullPointerException.class);
         stdEngine.publishPolicy(null, null, true, null, null);
     }
-    
+
     @Test
-    public void testPublishPolicyUnknownGroup() throws NullPointerException, PAPException, FileNotFoundException{
+    public void testPublishPolicyUnknownGroup()
+            throws NullPointerException, PAPException, FileNotFoundException {
         OnapPDPGroup unknownGroup = new StdPDPGroup("unknownId", null);
 
         expectedException.expect(PAPException.class);
         expectedException.expectMessage("Unknown PDP Group: unknownId");
         stdEngine.publishPolicy(null, null, true, null, unknownGroup);
     }
-    
+
     @Test
-    public void testRemovePolicyNull() throws NullPointerException, PAPException, FileNotFoundException{
+    public void testRemovePolicyNull()
+            throws NullPointerException, PAPException, FileNotFoundException {
         expectedException.expect(NullPointerException.class);
         stdEngine.removePolicy(null, null);
     }
-    
+
     @Test
-    public void testRemovePolicyUnknownGroup() throws NullPointerException, PAPException, FileNotFoundException{
+    public void testRemovePolicyUnknownGroup()
+            throws NullPointerException, PAPException, FileNotFoundException {
         OnapPDPGroup unknownGroup = new StdPDPGroup("unknownId", null);
 
         expectedException.expect(PAPException.class);
         expectedException.expectMessage("Unknown PDP Group: unknownId");
         stdEngine.removePolicy(null, unknownGroup);
     }
-    
-    private OnapPDPGroup createGroup(final String name, final String description) throws NullPointerException, PAPException{
+
+    private OnapPDPGroup createGroup(final String name, final String description)
+            throws NullPointerException, PAPException {
         ensureGroupDoesntExist(name);
         stdEngine.newGroup(name, description);
         return stdEngine.getGroup(name);
     }
-    
+
     @After
-    public void tearDown() throws PAPException{
+    public void tearDown() throws PAPException {
         ensureGroupDoesntExist("newGroup");
         ensureGroupDoesntExist("anotherNewGroup");
         ensureGroupDoesntExist("AnUpdatedName");
     }
-    
-    private void ensureGroupDoesntExist(final String groupName) throws PAPException{
+
+    private void ensureGroupDoesntExist(final String groupName) throws PAPException {
         OnapPDPGroup group = stdEngine.getGroup(groupName);
-        if (group != null){
-            for (OnapPDP pdp: group.getOnapPdps()){
+        if (group != null) {
+            for (OnapPDP pdp : group.getOnapPdps()) {
                 stdEngine.removePDP(pdp);
             }
-            stdEngine.removeGroup(group, null);       
-       }
+            stdEngine.removeGroup(group, null);
+        }
     }
 }
index 3e1d815..55413d8 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -223,35 +225,35 @@ public class StdPDPGroupStatusTest {
         stdPDPGroupStatus.addFailedPipConfig(new StdPDPPIPConfig());
         assertFalse(stdPDPGroupStatus.pipConfigOK());
     }
-    
+
     @Test
     public void testPdpsOKOutOfSyncPdp() {
         assertTrue(stdPDPGroupStatus.pdpsOK());
         stdPDPGroupStatus.addOutOfSynchPDP(new StdPDP());
         assertFalse(stdPDPGroupStatus.pdpsOK());
     }
-    
+
     @Test
     public void testPdpsOKFailedPdp() {
         assertTrue(stdPDPGroupStatus.pdpsOK());
         stdPDPGroupStatus.addFailedPDP(new StdPDP());
         assertFalse(stdPDPGroupStatus.pdpsOK());
     }
-    
+
     @Test
     public void testPdpsOKLastUpdateFailedPdp() {
         assertTrue(stdPDPGroupStatus.pdpsOK());
         stdPDPGroupStatus.addLastUpdateFailedPDP(new StdPDP());
         assertFalse(stdPDPGroupStatus.pdpsOK());
     }
-    
+
     @Test
     public void testPdpsOKUnknownPdp() {
         assertTrue(stdPDPGroupStatus.pdpsOK());
         stdPDPGroupStatus.addUnknownPDP(new StdPDP());
         assertFalse(stdPDPGroupStatus.pdpsOK());
     }
-    
+
     @Test
     public void testIsGroupOkFailedPolicy() {
         stdPDPGroupStatus.setStatus(Status.OK);
@@ -259,7 +261,7 @@ public class StdPDPGroupStatusTest {
         stdPDPGroupStatus.addFailedPolicy(new StdPDPPolicy());
         assertFalse(stdPDPGroupStatus.isGroupOk());
     }
-    
+
     @Test
     public void testIsGroupOkFailedPipConfig() {
         stdPDPGroupStatus.setStatus(Status.OK);
@@ -267,30 +269,30 @@ public class StdPDPGroupStatusTest {
         stdPDPGroupStatus.addFailedPipConfig(new StdPDPPIPConfig());
         assertFalse(stdPDPGroupStatus.isGroupOk());
     }
-    
+
     @Test
     public void testIsGroupOkFailedPdp() {
         stdPDPGroupStatus.setStatus(Status.OK);
         assertTrue(stdPDPGroupStatus.isGroupOk());
         stdPDPGroupStatus.addLastUpdateFailedPDP(new StdPDP());
         assertFalse(stdPDPGroupStatus.isGroupOk());
-    }  
-    
+    }
+
     @Test
     public void testIsGroupOkLoadErrors() {
         stdPDPGroupStatus.setStatus(Status.OK);
         assertTrue(stdPDPGroupStatus.isGroupOk());
         stdPDPGroupStatus.addLoadError("A load error");
         assertFalse(stdPDPGroupStatus.isGroupOk());
-    }  
-    
+    }
+
     @Test
     public void testIsGroupOkStatusOutOfSynch() {
         stdPDPGroupStatus.setStatus(Status.OK);
         assertTrue(stdPDPGroupStatus.isGroupOk());
         stdPDPGroupStatus.setStatus(Status.OUT_OF_SYNCH);
         assertFalse(stdPDPGroupStatus.isGroupOk());
-    }  
+    }
 
     @Test
     public void testConstructor() {
@@ -477,5 +479,4 @@ public class StdPDPGroupStatusTest {
     public void testEqualsInstanceOfDiffClass() {
         assertFalse(stdPDPGroupStatus.equals(""));
     }
-
 }
index 323b034..e5e058a 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
 package org.onap.policy.xacml.test.std.pap;
 
 import static org.junit.Assert.assertTrue;
-
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.HashSet;
 import java.util.Set;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -36,194 +36,191 @@ import org.onap.policy.xacml.std.pap.StdPDPGroup;
 public class StdPDPGroupTest {
 
 
-       private static Logger logger = FlexLogger.getLogger(StdPDPGroupTest.class);
-       
-       private StdPDPGroup stdPDPGroup;
-       private Path repository;
-       private StdPDP testPdp = new StdPDP();
-       private StdPDP testPdp1 = new StdPDP();
-       
-       @Before
-       public void setUp(){
-       
-               try {
-                       stdPDPGroup = new StdPDPGroup();
-                       repository = Paths.get("src/test/resources/pdps");
-                       testPdp1.setId("100");
-                       
-               } catch (Exception e) {
-                       logger.error(e);
-               } 
-       }
-
-
-       @Test
-       public void testGetStatus() {
-               try {
-                       assertTrue(stdPDPGroup.getStatus() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetId() {
-               try {
-                       stdPDPGroup.setId("testId");
-                       assertTrue(stdPDPGroup.getId() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testIsDefaultGroup() {
-               try {
-                       stdPDPGroup.setDefaultGroup(true);
-                       assertTrue(stdPDPGroup.isDefaultGroup() == true);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetName() {
-               try {
-                       stdPDPGroup.setName("testing");
-                       assertTrue(stdPDPGroup.getName() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetDescription() {
-               try {
-                       stdPDPGroup.setDescription("description");
-                       assertTrue(stdPDPGroup.getDescription() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }       
-       }
-
-       @Test
-       public void testGetDirectory() {
-               try {
-                       stdPDPGroup.setDirectory(repository);
-                       assertTrue(stdPDPGroup.getDirectory() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetSelectedPolicies() {
-               try {
-                       assertTrue(stdPDPGroup.getSelectedPolicies() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetOperation() {
-               try {
-                       stdPDPGroup.setOperation("test");
-                       assertTrue(stdPDPGroup.getOperation() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetPdps() {
-               try {
-                       stdPDPGroup.setOnapPdps(new HashSet<>());
-                       assertTrue(stdPDPGroup.getPdps() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetOnapPdps() {
-               try {
-                       stdPDPGroup.setOnapPdps(new HashSet<>());
-                       assertTrue(stdPDPGroup.getOnapPdps() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testAddPDP() {
-               try {
-                       assertTrue(stdPDPGroup.addPDP(testPdp) == true);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testRemovePDP() {
-               try {
-                       assertTrue(stdPDPGroup.removePDP(testPdp) == false);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetPolicies() {
-               try {
-                       stdPDPGroup.setPolicies(new HashSet());
-                       assertTrue(stdPDPGroup.getPolicies() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetPolicy() {
-               try {
-                       assertTrue(stdPDPGroup.getPolicy("wrongId") == null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-
-       @Test
-       public void testGetPipConfigs() {
-               try {
-                       stdPDPGroup.setPipConfigs(new HashSet());
-                       assertTrue(stdPDPGroup.getPipConfigs() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetPipConfig() {
-               try {
-                       Set pipConfigs = new HashSet();                 
-                       StdPDP testPdp = new StdPDP();
-                       testPdp.setId("20");
-                       pipConfigs.add(testPdp);                        
-                       stdPDPGroup.setId("testId");
-                       assertTrue(stdPDPGroup.getPipConfig("222") == null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
-       @Test
-       public void testGetPipConfigProperties() {
-               try {
-                       assertTrue(stdPDPGroup.getPipConfigProperties() != null);
-               } catch (Exception e) {
-                       logger.error(e);
-               }
-       }
-
+    private static Logger logger = FlexLogger.getLogger(StdPDPGroupTest.class);
+
+    private StdPDPGroup stdPDPGroup;
+    private Path repository;
+    private StdPDP testPdp = new StdPDP();
+    private StdPDP testPdp1 = new StdPDP();
+
+    @Before
+    public void setUp() {
+
+        try {
+            stdPDPGroup = new StdPDPGroup();
+            repository = Paths.get("src/test/resources/pdps");
+            testPdp1.setId("100");
+
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetStatus() {
+        try {
+            assertTrue(stdPDPGroup.getStatus() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetId() {
+        try {
+            stdPDPGroup.setId("testId");
+            assertTrue(stdPDPGroup.getId() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testIsDefaultGroup() {
+        try {
+            stdPDPGroup.setDefaultGroup(true);
+            assertTrue(stdPDPGroup.isDefaultGroup() == true);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetName() {
+        try {
+            stdPDPGroup.setName("testing");
+            assertTrue(stdPDPGroup.getName() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetDescription() {
+        try {
+            stdPDPGroup.setDescription("description");
+            assertTrue(stdPDPGroup.getDescription() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetDirectory() {
+        try {
+            stdPDPGroup.setDirectory(repository);
+            assertTrue(stdPDPGroup.getDirectory() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetSelectedPolicies() {
+        try {
+            assertTrue(stdPDPGroup.getSelectedPolicies() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetOperation() {
+        try {
+            stdPDPGroup.setOperation("test");
+            assertTrue(stdPDPGroup.getOperation() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetPdps() {
+        try {
+            stdPDPGroup.setOnapPdps(new HashSet<>());
+            assertTrue(stdPDPGroup.getPdps() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetOnapPdps() {
+        try {
+            stdPDPGroup.setOnapPdps(new HashSet<>());
+            assertTrue(stdPDPGroup.getOnapPdps() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testAddPDP() {
+        try {
+            assertTrue(stdPDPGroup.addPDP(testPdp) == true);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testRemovePDP() {
+        try {
+            assertTrue(stdPDPGroup.removePDP(testPdp) == false);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetPolicies() {
+        try {
+            stdPDPGroup.setPolicies(new HashSet());
+            assertTrue(stdPDPGroup.getPolicies() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetPolicy() {
+        try {
+            assertTrue(stdPDPGroup.getPolicy("wrongId") == null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetPipConfigs() {
+        try {
+            stdPDPGroup.setPipConfigs(new HashSet());
+            assertTrue(stdPDPGroup.getPipConfigs() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetPipConfig() {
+        try {
+            Set pipConfigs = new HashSet();
+            StdPDP testPdp = new StdPDP();
+            testPdp.setId("20");
+            pipConfigs.add(testPdp);
+            stdPDPGroup.setId("testId");
+            assertTrue(stdPDPGroup.getPipConfig("222") == null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetPipConfigProperties() {
+        try {
+            assertTrue(stdPDPGroup.getPipConfigProperties() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
 }
index 1be34ee..cea7c32 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -28,16 +30,16 @@ import org.onap.policy.xacml.std.pap.StdPDPItemSetChangeNotifier;
 import org.onap.policy.xacml.std.pap.StdPDPItemSetChangeNotifier.StdItemSetChangeListener;
 
 public class StdPDPItemSetChangeNotifierTest {
-  @Test
-  public void testNotifier() {
-    StdPDPItemSetChangeNotifier notifier = new StdPDPItemSetChangeNotifier();
-    StdItemSetChangeListener listener = Mockito.mock(StdItemSetChangeListener.class);
-    notifier.addItemSetChangeListener(listener);
-    notifier.removeItemSetChangeListener(listener);
-    notifier.fireChanged();
-    OnapPDP pdp = Mockito.mock(OnapPDP.class);
-    notifier.firePDPChanged(pdp);
-    OnapPDPGroup group = Mockito.mock(OnapPDPGroup.class);
-    notifier.firePDPGroupChanged(group);
-  }
+    @Test
+    public void testNotifier() {
+        StdPDPItemSetChangeNotifier notifier = new StdPDPItemSetChangeNotifier();
+        StdItemSetChangeListener listener = Mockito.mock(StdItemSetChangeListener.class);
+        notifier.addItemSetChangeListener(listener);
+        notifier.removeItemSetChangeListener(listener);
+        notifier.fireChanged();
+        OnapPDP pdp = Mockito.mock(OnapPDP.class);
+        notifier.firePDPChanged(pdp);
+        OnapPDPGroup group = Mockito.mock(OnapPDPGroup.class);
+        notifier.firePDPGroupChanged(group);
+    }
 }
index 05b8ae7..b5713d3 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -32,76 +34,76 @@ import org.junit.Test;
 import org.onap.policy.xacml.std.pap.StdPDPPIPConfig;
 
 public class StdPDPPIPConfigTest {
-  @Test
-  public void testConfig() {
-    // Setup test data
-    String id = "testID";
-    String value = "testVal";
-    Properties props = new Properties();
-    props.setProperty(id + ".classname", value);
-    Map<String, String> map = new HashMap<String, String>();
-    map.put(id, value);
+    @Test
+    public void testConfig() {
+        // Setup test data
+        String id = "testID";
+        String value = "testVal";
+        Properties props = new Properties();
+        props.setProperty(id + ".classname", value);
+        Map<String, String> map = new HashMap<String, String>();
+        map.put(id, value);
 
-    // Test constructors
-    StdPDPPIPConfig config = new StdPDPPIPConfig();
-    assertNotNull(config);
-    StdPDPPIPConfig config2 = new StdPDPPIPConfig(id);
-    assertNotNull(config2);
-    StdPDPPIPConfig config3 = new StdPDPPIPConfig(id, value, value);
-    assertNotNull(config3);
-    StdPDPPIPConfig config4 = new StdPDPPIPConfig(id, props);
-    assertNotNull(config4);
-    StdPDPPIPConfig config5 = new StdPDPPIPConfig(id, props);
-    assertNotNull(config5);
+        // Test constructors
+        StdPDPPIPConfig config = new StdPDPPIPConfig();
+        assertNotNull(config);
+        StdPDPPIPConfig config2 = new StdPDPPIPConfig(id);
+        assertNotNull(config2);
+        StdPDPPIPConfig config3 = new StdPDPPIPConfig(id, value, value);
+        assertNotNull(config3);
+        StdPDPPIPConfig config4 = new StdPDPPIPConfig(id, props);
+        assertNotNull(config4);
+        StdPDPPIPConfig config5 = new StdPDPPIPConfig(id, props);
+        assertNotNull(config5);
 
-    // Test set and get
-    config.setId(value);
-    assertEquals(value, config.getId());
-    config.setName(value);
-    assertEquals(value, config.getName());
-    config.setDescription(value);
-    assertEquals(value, config.getDescription());
-    config.setClassname(value);
-    assertEquals(value, config.getClassname());
-    config.setValues(map);
-    assertEquals(map, config.getConfiguration());
-    assertEquals(true, config.isConfigured());
-    config.setConfig(map);
-    assertEquals(map, config.getConfig());
+        // Test set and get
+        config.setId(value);
+        assertEquals(value, config.getId());
+        config.setName(value);
+        assertEquals(value, config.getName());
+        config.setDescription(value);
+        assertEquals(value, config.getDescription());
+        config.setClassname(value);
+        assertEquals(value, config.getClassname());
+        config.setValues(map);
+        assertEquals(map, config.getConfiguration());
+        assertEquals(true, config.isConfigured());
+        config.setConfig(map);
+        assertEquals(map, config.getConfig());
 
-    // Test equals combinations
-    assertEquals(true, config4.equals(config5));
-    assertEquals(true, config4.equals(config4));
-    assertEquals(false, config4.equals(null));
-    assertEquals(false, config4.equals(value));
-    config4.setClassname(null);
-    config5.setClassname(value);
-    assertEquals(false, config4.equals(config5));
-    config4.setClassname(id);
-    assertEquals(false, config4.equals(config5));
-    config4.setClassname(value);
-    config5.setConfig(map);
-    assertEquals(false, config4.equals(config5));
-    config4.setConfig(null);
-    assertEquals(false, config4.equals(config5));
-    config4.setConfig(map);
-    config5.setDescription(value);
-    assertEquals(false, config4.equals(config5));
-    config4.setDescription(id);
-    assertEquals(false, config4.equals(config5));
-    config4.setDescription(value);
-    config4.setId(null);
-    assertEquals(false, config4.equals(config5));
-    config4.setId(value);
-    assertEquals(false, config4.equals(config5));
-    config4.setId(id);
-    config5.setName(value);
-    assertEquals(false, config4.equals(config5));
-    config4.setName(id);
-    assertEquals(false, config4.equals(config5));
-    assertThat(config.hashCode(), is(not(0)));
+        // Test equals combinations
+        assertEquals(true, config4.equals(config5));
+        assertEquals(true, config4.equals(config4));
+        assertEquals(false, config4.equals(null));
+        assertEquals(false, config4.equals(value));
+        config4.setClassname(null);
+        config5.setClassname(value);
+        assertEquals(false, config4.equals(config5));
+        config4.setClassname(id);
+        assertEquals(false, config4.equals(config5));
+        config4.setClassname(value);
+        config5.setConfig(map);
+        assertEquals(false, config4.equals(config5));
+        config4.setConfig(null);
+        assertEquals(false, config4.equals(config5));
+        config4.setConfig(map);
+        config5.setDescription(value);
+        assertEquals(false, config4.equals(config5));
+        config4.setDescription(id);
+        assertEquals(false, config4.equals(config5));
+        config4.setDescription(value);
+        config4.setId(null);
+        assertEquals(false, config4.equals(config5));
+        config4.setId(value);
+        assertEquals(false, config4.equals(config5));
+        config4.setId(id);
+        config5.setName(value);
+        assertEquals(false, config4.equals(config5));
+        config4.setName(id);
+        assertEquals(false, config4.equals(config5));
+        assertThat(config.hashCode(), is(not(0)));
 
-    // Test toString
-    assertThat(config.toString().length(), is(not(0)));
-  }
+        // Test toString
+        assertThat(config.toString().length(), is(not(0)));
+    }
 }
index 26af008..7aaa381 100644 (file)
@@ -3,14 +3,15 @@
  * ONAP-XACML
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
  * ================================================================================
  * 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.
@@ -36,129 +37,114 @@ import org.onap.policy.xacml.std.pap.StdPDPPolicy;
 import com.att.research.xacml.api.pap.PAPException;
 import org.onap.policy.xacml.std.pap.StdPDPPolicyParams;
 
-
 public class StdPDPPolicyTest {
-  @Test
-  public void testPolicy() throws URISyntaxException, IOException, PAPException {
-    // Set up test data
-    String value = "testVal";
-    URI uri = new URI("http://localhost/");
-    int[] array = {1, 1};
+    @Test
+    public void testPolicy() throws URISyntaxException, IOException, PAPException {
+        // Set up test data
+        String value = "testVal";
+        URI uri = new URI("http://localhost/");
+        int[] array = {1, 1};
 
-    // Test constructors
-    StdPDPPolicy policy = new StdPDPPolicy(value, true);
-    assertNotNull(policy);
-    StdPDPPolicy policy2 = new StdPDPPolicy(value, true, value);
-    assertNotNull(policy2);
-    StdPDPPolicy policy4 = new StdPDPPolicy();
-    assertNotNull(policy4);
+        // Test constructors
+        StdPDPPolicy policy = new StdPDPPolicy(value, true);
+        assertNotNull(policy);
+        StdPDPPolicy policy2 = new StdPDPPolicy(value, true, value);
+        assertNotNull(policy2);
+        StdPDPPolicy policy4 = new StdPDPPolicy();
+        assertNotNull(policy4);
 
-    StdPDPPolicy policy5 = new StdPDPPolicy(StdPDPPolicyParams.builder()
-            .id(value)
-            .isRoot(true)
-            .name(value)
-            .location(uri)
-            .isValid(false)
-            .policyId(value)
-            .description(value)
-            .version("1")
-            .build());
-    assertNotNull(policy5);
-    StdPDPPolicy policy6 = new StdPDPPolicy(value, true, value, uri, false);
-    assertNotNull(policy6);
-    StdPDPPolicy policy8 = new StdPDPPolicy(value, true, value, uri, false);
-    assertNotNull(policy8);
+        StdPDPPolicy policy5 = new StdPDPPolicy(
+                StdPDPPolicyParams.builder().id(value).isRoot(true).name(value).location(uri)
+                        .isValid(false).policyId(value).description(value).version("1").build());
+        assertNotNull(policy5);
+        StdPDPPolicy policy6 = new StdPDPPolicy(value, true, value, uri, false);
+        assertNotNull(policy6);
+        StdPDPPolicy policy8 = new StdPDPPolicy(value, true, value, uri, false);
+        assertNotNull(policy8);
 
-    // Test set and get
-    policy.setId(value);
-    assertEquals(value, policy.getId());
-    policy.setName(value);
-    assertEquals(value, policy.getName());
-    policy.setPolicyId(value);
-    assertEquals(value, policy.getPolicyId());
-    policy.setDescription(value);
-    assertEquals(value, policy.getDescription());
-    policy.setVersion("1");
-    assertEquals("1", policy.getVersion());
-    assertEquals(1, policy.getVersionInts()[0]);
-    assertEquals(true, policy.isRoot());
-    policy.setValid(true);
-    assertEquals(true, policy.isValid());
-    assertEquals(uri, policy5.getLocation());
-    policy.setRoot(false);
-    assertEquals(false, policy.isRoot());
-    policy.setLocation(uri);
-    assertEquals(uri, policy.getLocation());
+        // Test set and get
+        policy.setId(value);
+        assertEquals(value, policy.getId());
+        policy.setName(value);
+        assertEquals(value, policy.getName());
+        policy.setPolicyId(value);
+        assertEquals(value, policy.getPolicyId());
+        policy.setDescription(value);
+        assertEquals(value, policy.getDescription());
+        policy.setVersion("1");
+        assertEquals("1", policy.getVersion());
+        assertEquals(1, policy.getVersionInts()[0]);
+        assertEquals(true, policy.isRoot());
+        policy.setValid(true);
+        assertEquals(true, policy.isValid());
+        assertEquals(uri, policy5.getLocation());
+        policy.setRoot(false);
+        assertEquals(false, policy.isRoot());
+        policy.setLocation(uri);
+        assertEquals(uri, policy.getLocation());
 
-    // Test equals combinations
-    assertThat(policy.hashCode(), is(not(0)));
-    assertEquals(true, policy.equals(policy));
-    assertEquals(false, policy.equals(null));
-    assertEquals(false, policy.equals(value));
-    assertEquals(true, policy6.equals(policy8));
-    policy6.setId("1");
-    assertEquals(false, policy6.equals(policy8));
-    policy6.setId(null);
-    assertEquals(false, policy6.equals(policy8));
-    policy8.setId(null);
-    assertEquals(true, policy6.equals(policy8));
-    policy8.setPolicyId(value);
-    assertEquals(false, policy6.equals(policy8));
-    policy6.setPolicyId("1");
-    policy8.setPolicyId("2");
-    assertEquals(false, policy6.equals(policy8));
-    policy8.setPolicyId("1");
-    policy6.setVersion("1");
-    policy8.setVersion("2");
-    assertEquals(false, policy6.equals(policy8));
+        // Test equals combinations
+        assertThat(policy.hashCode(), is(not(0)));
+        assertEquals(true, policy.equals(policy));
+        assertEquals(false, policy.equals(null));
+        assertEquals(false, policy.equals(value));
+        assertEquals(true, policy6.equals(policy8));
+        policy6.setId("1");
+        assertEquals(false, policy6.equals(policy8));
+        policy6.setId(null);
+        assertEquals(false, policy6.equals(policy8));
+        policy8.setId(null);
+        assertEquals(true, policy6.equals(policy8));
+        policy8.setPolicyId(value);
+        assertEquals(false, policy6.equals(policy8));
+        policy6.setPolicyId("1");
+        policy8.setPolicyId("2");
+        assertEquals(false, policy6.equals(policy8));
+        policy8.setPolicyId("1");
+        policy6.setVersion("1");
+        policy8.setVersion("2");
+        assertEquals(false, policy6.equals(policy8));
 
-    // Test toString
-    assertThat(policy.toString().length(), is(not(0)));
-    assertEquals("1.1", StdPDPPolicy.versionArrayToString(array));
-    assertEquals("", StdPDPPolicy.versionArrayToString(null));
-    assertEquals(0, StdPDPPolicy.versionStringToArray(null).length);
-  }
+        // Test toString
+        assertThat(policy.toString().length(), is(not(0)));
+        assertEquals("1.1", StdPDPPolicy.versionArrayToString(array));
+        assertEquals("", StdPDPPolicy.versionArrayToString(null));
+        assertEquals(0, StdPDPPolicy.versionStringToArray(null).length);
+    }
 
-  @Test(expected = ConnectException.class)
-  public void negTestStream() throws URISyntaxException, IOException, PAPException {
-    // Set up test data
-    String value = "testVal";
-    URI uri = new URI("http://localhost:54287");
-    StdPDPPolicy policy = new StdPDPPolicy(StdPDPPolicyParams.builder()
-            .id(value)
-            .isRoot(true)
-            .name(value)
-            .location(uri)
-            .isValid(false)
-            .policyId(value)
-            .description(value)
-            .version("1")
-            .build());
+    @Test(expected = ConnectException.class)
+    public void negTestStream() throws URISyntaxException, IOException, PAPException {
+        // Set up test data
+        String value = "testVal";
+        URI uri = new URI("http://localhost:54287");
+        StdPDPPolicy policy = new StdPDPPolicy(
+                StdPDPPolicyParams.builder().id(value).isRoot(true).name(value).location(uri)
+                        .isValid(false).policyId(value).description(value).version("1").build());
 
-    // Negative test stream
-    policy.getStream();
-  }
+        // Negative test stream
+        policy.getStream();
+    }
 
-  @Test(expected = ConnectException.class)
-  public void negTestConstructor1() throws URISyntaxException, IOException {
-    // Set up test data
-    String value = "testVal";
-    URI uri = new URI("http://localhost:54287");
+    @Test(expected = ConnectException.class)
+    public void negTestConstructor1() throws URISyntaxException, IOException {
+        // Set up test data
+        String value = "testVal";
+        URI uri = new URI("http://localhost:54287");
 
-    // Test constructor
-    StdPDPPolicy policy = new StdPDPPolicy(value, true, value, uri);
-    assertNotNull(policy);
-  }
+        // Test constructor
+        StdPDPPolicy policy = new StdPDPPolicy(value, true, value, uri);
+        assertNotNull(policy);
+    }
 
-  @Test(expected = ConnectException.class)
-  public void negTestConstructor2() throws URISyntaxException, IOException {
-    // Set up test data
-    String value = "testVal";
-    URI uri = new URI("http://localhost:54287");
-    Properties props = new Properties();
+    @Test(expected = ConnectException.class)
+    public void negTestConstructor2() throws URISyntaxException, IOException {
+        // Set up test data
+        String value = "testVal";
+        URI uri = new URI("http://localhost:54287");
+        Properties props = new Properties();
 
-    // Test constructor
-    StdPDPPolicy policy = new StdPDPPolicy(value, true, uri, props);
-    assertNotNull(policy);
-  }
+        // Test constructor
+        StdPDPPolicy policy = new StdPDPPolicy(value, true, uri, props);
+        assertNotNull(policy);
+    }
 }
index c99eef8..dfdbf5f 100644 (file)
@@ -2,12 +2,14 @@
  * ============LICENSE_START=======================================================
  * Copyright (C) 2018 Ericsson. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -132,33 +134,33 @@ public class StdPDPStatusTest {
         stdPDPStatus.setStatus(Status.OUT_OF_SYNCH);
         assertFalse(stdPDPStatus.isOk());
     }
-    
+
     @Test
     public void testAddLoadError() {
         stdPDPStatus.addLoadError("An error");
         assertEquals("An error", stdPDPStatus.getLoadErrors().iterator().next());
     }
-    
+
     @Test
     public void testAddLoadWarning() {
         stdPDPStatus.addLoadWarning("A warning");
         assertEquals("A warning", stdPDPStatus.getLoadWarnings().iterator().next());
     }
-    
+
     @Test
     public void testAddLoadedPolicy() {
         PDPPolicy policy = new StdPDPPolicy();
         stdPDPStatus.addLoadedPolicy(policy);
         assertEquals(policy, stdPDPStatus.getLoadedPolicies().iterator().next());
     }
-    
+
     @Test
     public void testAddRootPolicy() {
         PDPPolicy policy = new StdPDPPolicy();
         stdPDPStatus.addRootPolicy(policy);
         assertEquals(policy, stdPDPStatus.getLoadedRootPolicies().iterator().next());
     }
-    
+
     @Test
     public void testAddAllLoadedRootPolicy() {
         Set<PDPPolicy> policies = new HashSet<>();
@@ -167,9 +169,9 @@ public class StdPDPStatusTest {
         stdPDPStatus.addAllLoadedRootPolicies(policies);
         assertEquals(policies, stdPDPStatus.getLoadedRootPolicies());
     }
-    
+
     @Test
-    public void testAddLoadedPipConfig(){
+    public void testAddLoadedPipConfig() {
         PDPPIPConfig pipConfig = new StdPDPPIPConfig();
         stdPDPStatus.addLoadedPipConfig(pipConfig);
         assertEquals(pipConfig, stdPDPStatus.getLoadedPipConfigs().iterator().next());
@@ -214,12 +216,16 @@ public class StdPDPStatusTest {
         assertEquals(loadedPIPConfigs, stdPDPStatus1.getLoadedPipConfigs());
         assertEquals(failedPIPConfigs, stdPDPStatus1.getFailedPipConfigs());
 
-        assertEquals("StdPDPStatus [status=UP_TO_DATE, loadErrors=[An error], loadWarnings=[An error], loadedPolicies=[StdPDPPolicy " 
-                        + "[id=null, name=null, policyId=null, description=null, version=, isRoot=false, isValid=false, location=null]], "
-                        + "loadedRootPolicies=[StdPDPPolicy [id=null, name=null, policyId=null, description=null, version=, isRoot=false, "
-                        + "isValid=false, location=null]], failedPolicies=[StdPDPPolicy [id=null, name=null, policyId=null, description=null, "
-                        + "version=, isRoot=false, isValid=false, location=null]], loadedPIPConfigs=[StdPDPPIPConfig [id=null, name=null, "
-                        + "description=null, classname=null, config={}]], failedPIPConfigs=[StdPDPPIPConfig [id=null, name=null, description=null, classname=null, config={}]]]",
+        assertEquals(
+                "StdPDPStatus [status=UP_TO_DATE, loadErrors=[An error], loadWarnings=[An error],"
+                        + " loadedPolicies=[StdPDPPolicy [id=null, name=null, policyId=null, description=null,"
+                        + " version=, isRoot=false, isValid=false, location=null]],"
+                        + " loadedRootPolicies=[StdPDPPolicy [id=null, name=null, policyId=null, description=null,"
+                        + " version=, isRoot=false, isValid=false, location=null]],"
+                        + " failedPolicies=[StdPDPPolicy [id=null, name=null, policyId=null, description=null,"
+                        + " version=, isRoot=false, isValid=false, location=null]], loadedPIPConfigs=[StdPDPPIPConfig"
+                        + " [id=null, name=null, description=null, classname=null, config={}]], failedPIPConfigs="
+                        + "[StdPDPPIPConfig [id=null, name=null, description=null, classname=null, config={}]]]",
                 stdPDPStatus1.toString());
     }
 
index e62f1fd..0beb282 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -40,132 +42,132 @@ import com.att.research.xacml.api.pap.PDPPolicy;
 
 public class StdPDPTest {
 
-  private static Logger logger = FlexLogger.getLogger(StdPDPTest.class);
+    private static Logger logger = FlexLogger.getLogger(StdPDPTest.class);
 
-  private StdPDP stdPDP;
+    private StdPDP stdPDP;
 
-  @Before
-  public void setUp() {
+    @Before
+    public void setUp() {
 
-    try {
-      stdPDP = new StdPDP();
-    } catch (Exception e) {
-      logger.error(e);
+        try {
+            stdPDP = new StdPDP();
+        } catch (Exception e) {
+            logger.error(e);
+        }
     }
-  }
-
-  @Test
-  public void testGetId() {
-    try {
-      stdPDP.setId("testId");
-      assertTrue(stdPDP.getId() != null);
-    } catch (Exception e) {
-      logger.error(e);
+
+    @Test
+    public void testGetId() {
+        try {
+            stdPDP.setId("testId");
+            assertTrue(stdPDP.getId() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
     }
-  }
-
-  @Test
-  public void testGetName() {
-    try {
-      stdPDP.setName("abc");
-      assertTrue(stdPDP.getName() != null);
-    } catch (Exception e) {
-      logger.error(e);
+
+    @Test
+    public void testGetName() {
+        try {
+            stdPDP.setName("abc");
+            assertTrue(stdPDP.getName() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
     }
-  }
-
-  @Test
-  public void testGetDescription() {
-    try {
-      stdPDP.setDescription("somee here");
-      assertTrue(stdPDP.getDescription() != null);
-    } catch (Exception e) {
-      logger.error(e);
+
+    @Test
+    public void testGetDescription() {
+        try {
+            stdPDP.setDescription("somee here");
+            assertTrue(stdPDP.getDescription() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
     }
-  }
-
-  @Test
-  public void testGetStatus() {
-    try {
-      stdPDP.setStatus(new StdPDPStatus());
-      assertTrue(stdPDP.getStatus() != null);
-    } catch (Exception e) {
-      logger.error(e);
+
+    @Test
+    public void testGetStatus() {
+        try {
+            stdPDP.setStatus(new StdPDPStatus());
+            assertTrue(stdPDP.getStatus() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
     }
-  }
-
-  @Test
-  public void testGetPipConfigs() {
-    try {
-      assertTrue(stdPDP.getPipConfigs() != null);
-    } catch (Exception e) {
-      logger.error(e);
+
+    @Test
+    public void testGetPipConfigs() {
+        try {
+            assertTrue(stdPDP.getPipConfigs() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
+    }
+
+    @Test
+    public void testGetJmxPort() {
+        try {
+            stdPDP.setJmxPort(123);
+            assertTrue(stdPDP.getJmxPort() != null);
+        } catch (Exception e) {
+            logger.error(e);
+        }
     }
-  }
-
-  @Test
-  public void testGetJmxPort() {
-    try {
-      stdPDP.setJmxPort(123);
-      assertTrue(stdPDP.getJmxPort() != null);
-    } catch (Exception e) {
-      logger.error(e);
+
+    @Test
+    public void testPDP() {
+        // Set up test data
+        String id = "testID";
+        String value = "testVal";
+        Properties props = new Properties();
+        props.setProperty(id + ".name", value);
+        props.setProperty(id + ".description", value);
+        props.setProperty(id + ".jmxport", "0");
+        Set<PDPPIPConfig> pipConfigs = new HashSet<PDPPIPConfig>();
+        Set<PDPPolicy> policies = new HashSet<PDPPolicy>();
+
+        // Test constructors
+        StdPDP pdp = new StdPDP(id, 0);
+        assertNotNull(pdp);
+        StdPDP pdp2 = new StdPDP(id, value, 0);
+        assertNotNull(pdp2);
+        StdPDP pdp3 = new StdPDP(id, value, value, 0);
+        assertNotNull(pdp3);
+        StdPDP pdp4 = new StdPDP(id, props);
+        assertNotNull(pdp4);
+        StdPDP pdp5 = new StdPDP(id, props);
+        assertNotNull(pdp5);
+
+        // Test set and get
+        pdp.setPipConfigs(pipConfigs);
+        assertEquals(pipConfigs, pdp.getPipConfigs());
+        pdp.setPolicies(policies);
+        assertEquals(policies, pdp.getPolicies());
+
+        // Test equals combinations
+        assertEquals(true, pdp4.equals(pdp5));
+        assertEquals(true, pdp4.equals(pdp4));
+        assertEquals(false, pdp4.equals(null));
+        assertEquals(false, pdp4.equals(value));
+        pdp4.setId(null);
+        assertEquals(false, pdp4.equals(value));
+        pdp5.setId(id);
+        assertEquals(false, pdp4.equals(pdp5));
+        pdp4.setId(value);
+        assertEquals(false, pdp4.equals(pdp5));
+        assertThat(pdp.hashCode(), is(not(0)));
+
+        // Test compare
+        assertEquals(-1, pdp4.compareTo(null));
+        assertEquals(0, pdp4.compareTo(pdp4));
+        pdp5.setName(null);
+        assertEquals(-1, pdp4.compareTo(pdp5));
+        pdp4.setName(null);
+        pdp5.setName(value);
+        assertEquals(1, pdp4.compareTo(pdp5));
+
+        // Test toString
+        assertThat(pdp.toString().length(), is(not(0)));
     }
-  }
-
-  @Test
-  public void testPDP() {
-    // Set up test data
-    String id = "testID";
-    String value = "testVal";
-    Properties props = new Properties();
-    props.setProperty(id + ".name", value);
-    props.setProperty(id + ".description", value);
-    props.setProperty(id + ".jmxport", "0");
-    Set<PDPPIPConfig> pipConfigs = new HashSet<PDPPIPConfig>();
-    Set<PDPPolicy> policies = new HashSet<PDPPolicy>();
-
-    // Test constructors
-    StdPDP pdp = new StdPDP(id, 0);
-    assertNotNull(pdp);
-    StdPDP pdp2 = new StdPDP(id, value, 0);
-    assertNotNull(pdp2);
-    StdPDP pdp3 = new StdPDP(id, value, value, 0);
-    assertNotNull(pdp3);
-    StdPDP pdp4 = new StdPDP(id, props);
-    assertNotNull(pdp4);
-    StdPDP pdp5 = new StdPDP(id, props);
-    assertNotNull(pdp5);
-
-    // Test set and get
-    pdp.setPipConfigs(pipConfigs);
-    assertEquals(pipConfigs, pdp.getPipConfigs());
-    pdp.setPolicies(policies);
-    assertEquals(policies, pdp.getPolicies());
-
-    // Test equals combinations
-    assertEquals(true, pdp4.equals(pdp5));
-    assertEquals(true, pdp4.equals(pdp4));
-    assertEquals(false, pdp4.equals(null));
-    assertEquals(false, pdp4.equals(value));
-    pdp4.setId(null);
-    assertEquals(false, pdp4.equals(value));
-    pdp5.setId(id);
-    assertEquals(false, pdp4.equals(pdp5));
-    pdp4.setId(value);
-    assertEquals(false, pdp4.equals(pdp5));
-    assertThat(pdp.hashCode(), is(not(0)));
-
-    // Test compare
-    assertEquals(-1, pdp4.compareTo(null));
-    assertEquals(0, pdp4.compareTo(pdp4));
-    pdp5.setName(null);
-    assertEquals(-1, pdp4.compareTo(pdp5));
-    pdp4.setName(null);
-    pdp5.setName(value);
-    assertEquals(1, pdp4.compareTo(pdp5));
-
-    // Test toString
-    assertThat(pdp.toString().length(), is(not(0)));
-  }
 }
index bc9a674..2b43ce7 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -32,17 +34,17 @@ import com.att.research.xacml.std.StdMutableAttribute;
 import com.att.research.xacml.std.pip.StdPIPRequest;
 
 public class OperationHistoryEngineTest {
-       @Test
-       public void testBaseNegativeCase() throws PIPException {
-               OperationHistoryEngine engine = new OperationHistoryEngine();
-               Collection<PIPRequest> required = engine.attributesRequired();
-               assertEquals(required.size(), 0);
-               Collection<PIPRequest> provided = engine.attributesProvided();
-               assertEquals(provided.size(), 0);
-               
-               Attribute attribute = new StdMutableAttribute();
-               PIPRequest pipRequest = new StdPIPRequest(attribute);
-               PIPResponse response = engine.getAttributes(pipRequest, null);
-               assertEquals(response.getStatus().isOk(), true);
-       }
+    @Test
+    public void testBaseNegativeCase() throws PIPException {
+        OperationHistoryEngine engine = new OperationHistoryEngine();
+        Collection<PIPRequest> required = engine.attributesRequired();
+        assertEquals(required.size(), 0);
+        Collection<PIPRequest> provided = engine.attributesProvided();
+        assertEquals(provided.size(), 0);
+
+        Attribute attribute = new StdMutableAttribute();
+        PIPRequest pipRequest = new StdPIPRequest(attribute);
+        PIPResponse response = engine.getAttributes(pipRequest, null);
+        assertEquals(response.getStatus().isOk(), true);
+    }
 }
index f60645f..319198e 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -34,32 +36,33 @@ import com.att.research.xacml.util.XACMLProperties;
 import com.att.research.xacml.api.XACML3;
 
 public class AAFEngineTest {
-       @Test
-       public void aafEngineTest(){
-               String testId = "testId";
-               System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.properties");
-               AAFEngine aafEngine = new AAFEngine();
-               assertTrue(AAFEngine.DEFAULT_DESCRIPTION.equals("PIP for authenticating aaf attributes using the AAF REST interface"));
-               assertTrue(AAFEngine.DEFAULT_ISSUER.equals("aaf"));
-               
-               Properties props = new Properties();
-               try {
-                       aafEngine.configure(testId, props);
-                       assertEquals(aafEngine.getName(), testId);
-                       assertEquals(aafEngine.getDescription(), AAFEngine.DEFAULT_DESCRIPTION);
-                       assertEquals(aafEngine.getIssuer(), AAFEngine.DEFAULT_ISSUER);
-                       assertEquals(aafEngine.attributesProvided().size(), 2);
-                       assertEquals(aafEngine.attributesRequired().size(), 5);
-                       
-                       PIPRequest pipRequest = new StdPIPRequest(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, AAFEngine.AAF_RESPONSE_ID, XACML3.ID_DATATYPE_STRING);
-                       StdPIPFinderFactory pipFactory = new StdPIPFinderFactory();
-                       PIPFinder pipFinder = pipFactory.getFinder();
-                       assertEquals(pipFinder.getPIPEngines().size(), 0);
-                       PIPResponse pipResponse = aafEngine.getAttributes(pipRequest, pipFinder);
-                       assertEquals(pipResponse.getStatus().isOk(), true);
-               }
-               catch (Exception ex) {
-                       fail("Not expecting any exceptions");
-               }
-       }
+    @Test
+    public void aafEngineTest() {
+        String testId = "testId";
+        System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.properties");
+        AAFEngine aafEngine = new AAFEngine();
+        assertTrue(AAFEngine.DEFAULT_DESCRIPTION
+                .equals("PIP for authenticating aaf attributes using the AAF REST interface"));
+        assertTrue(AAFEngine.DEFAULT_ISSUER.equals("aaf"));
+
+        Properties props = new Properties();
+        try {
+            aafEngine.configure(testId, props);
+            assertEquals(aafEngine.getName(), testId);
+            assertEquals(aafEngine.getDescription(), AAFEngine.DEFAULT_DESCRIPTION);
+            assertEquals(aafEngine.getIssuer(), AAFEngine.DEFAULT_ISSUER);
+            assertEquals(aafEngine.attributesProvided().size(), 2);
+            assertEquals(aafEngine.attributesRequired().size(), 5);
+
+            PIPRequest pipRequest = new StdPIPRequest(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE,
+                    AAFEngine.AAF_RESPONSE_ID, XACML3.ID_DATATYPE_STRING);
+            StdPIPFinderFactory pipFactory = new StdPIPFinderFactory();
+            PIPFinder pipFinder = pipFactory.getFinder();
+            assertEquals(pipFinder.getPIPEngines().size(), 0);
+            PIPResponse pipResponse = aafEngine.getAttributes(pipRequest, pipFinder);
+            assertEquals(pipResponse.getStatus().isOk(), true);
+        } catch (Exception ex) {
+            fail("Not expecting any exceptions");
+        }
+    }
 }
index 041acde..291bae8 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
 package org.onap.policy.xacml.test.util;
 
 import static org.junit.Assert.*;
-
 import org.junit.Test;
 import org.onap.policy.xacml.util.MetricsUtil;
 
 public class MetricsUtilTest {
-       
-       @Test
-       public void metricsUtilTest(){
-               MetricsUtil.AvgLatency avgLatency = new MetricsUtil.AvgLatency();
-               avgLatency.compute(0);
-               assertTrue(avgLatency.avg() == 0);
-               avgLatency.compute(2);
-               assertTrue(avgLatency.avg() == 1);
-               avgLatency.reset();
-               assertTrue(avgLatency.avg() == 0);
-               
-               MetricsUtil.MaxLatency maxLatency = new MetricsUtil.MaxLatency();
-               maxLatency.compute(2);
-               assertTrue(maxLatency.max() == 2);
-               maxLatency.reset();
-               assertTrue(maxLatency.max() < 0);
-               
-               MetricsUtil.MinLatency minLatency = new MetricsUtil.MinLatency();
-               minLatency.compute(2);
-               assertTrue(minLatency.min() == 2);
-               minLatency.reset();
-               assertTrue(minLatency.min() > 0);
-       }
+
+    @Test
+    public void metricsUtilTest() {
+        MetricsUtil.AvgLatency avgLatency = new MetricsUtil.AvgLatency();
+        avgLatency.compute(0);
+        assertTrue(avgLatency.avg() == 0);
+        avgLatency.compute(2);
+        assertTrue(avgLatency.avg() == 1);
+        avgLatency.reset();
+        assertTrue(avgLatency.avg() == 0);
+
+        MetricsUtil.MaxLatency maxLatency = new MetricsUtil.MaxLatency();
+        maxLatency.compute(2);
+        assertTrue(maxLatency.max() == 2);
+        maxLatency.reset();
+        assertTrue(maxLatency.max() < 0);
+
+        MetricsUtil.MinLatency minLatency = new MetricsUtil.MinLatency();
+        minLatency.compute(2);
+        assertTrue(minLatency.min() == 2);
+        minLatency.reset();
+        assertTrue(minLatency.min() > 0);
+    }
 
 }
index 09dcf83..0270a89 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -21,68 +23,69 @@ package org.onap.policy.xacml.test.util;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Path;
 import java.util.List;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.junit.Before;
 import org.junit.Test;
 import org.onap.policy.xacml.util.XACMLPolicyScanner;
-
 import com.att.research.xacml.util.XACMLPolicyScanner.Callback;
 
 public class XACMLPolicyScannerTest {
 
-       private static final Log logger                         = LogFactory.getLog(XACMLPolicyScannerTest.class);
-       private static Path configPolicyPathValue;
-       private static Path actionPolicyPathValue;
-       
-       @Before
-       public void setUp() {
-               File templateFile;
-               ClassLoader classLoader = getClass().getClassLoader();
+    private static final Log logger = LogFactory.getLog(XACMLPolicyScannerTest.class);
+    private static Path configPolicyPathValue;
+    private static Path actionPolicyPathValue;
+
+    @Before
+    public void setUp() {
+        File templateFile;
+        ClassLoader classLoader = getClass().getClassLoader();
+        try {
+            templateFile =
+                    new File(classLoader.getResource("Config_SampleTest1206.1.xml").getFile());
+            configPolicyPathValue = templateFile.toPath();
+            templateFile =
+                    new File(classLoader.getResource("Action_TestActionPolicy.1.xml").getFile());
+            actionPolicyPathValue = templateFile.toPath();
+        } catch (Exception e1) {
+            logger.error("Exception Occured" + e1);
+        }
+    }
+
+    @Test
+    public void xacmlPolicyScannerTest() throws IOException {
+        Callback callback = null;
         try {
-               templateFile = new File(classLoader.getResource("Config_SampleTest1206.1.xml").getFile());
-               configPolicyPathValue = templateFile.toPath();
-               templateFile = new File(classLoader.getResource("Action_TestActionPolicy.1.xml").getFile());
-               actionPolicyPathValue = templateFile.toPath();
-               } catch (Exception e1) {
-                       logger.error("Exception Occured"+e1);
-               }
-       }
-       
-       @Test
-       public void xacmlPolicyScannerTest() throws IOException{
-               Callback callback = null;
-               try{
-                       XACMLPolicyScanner actionScanner = new XACMLPolicyScanner(actionPolicyPathValue, callback);
-                       assertTrue(actionScanner.getPolicyObject() != null);
-                       Object actionObject = actionScanner.scan();
-                       assertTrue(actionObject != null);
-                       
-                       XACMLPolicyScanner scanner = new XACMLPolicyScanner(configPolicyPathValue, callback);
-                       assertTrue(scanner.getPolicyObject() != null);
-                       Object object = scanner.scan();
-                       assertTrue(object != null);
-                       String id = XACMLPolicyScanner.getID(scanner.getPolicyObject());
-                       assertTrue(id.equals("urn:com:xacml:policy:id:0b67998b-57e2-4e25-9ea9-f9154bf18df1"));
-                       String version = XACMLPolicyScanner.getVersion(scanner.getPolicyObject());
-                       assertTrue(version.equals("1"));
-                       String versionFromPath = XACMLPolicyScanner.getVersion(configPolicyPathValue);
-                       assertTrue(versionFromPath.equals("1"));
-                       List<String> returnValue = XACMLPolicyScanner.getCreatedByModifiedBy(configPolicyPathValue);
-                       assertTrue(returnValue.get(0).equals("test"));
-                       String createdBy = XACMLPolicyScanner.getCreatedBy(configPolicyPathValue);
-                       assertTrue(createdBy.equals("test"));
-                       String modifiedBy = XACMLPolicyScanner.getModifiedBy(configPolicyPathValue);
-                       assertTrue(modifiedBy.equals("test"));
-               }catch(Exception e){
-                       fail();
-                       logger.error("Exception Occured"+e);
-               }
-       }
+            XACMLPolicyScanner actionScanner =
+                    new XACMLPolicyScanner(actionPolicyPathValue, callback);
+            assertTrue(actionScanner.getPolicyObject() != null);
+            Object actionObject = actionScanner.scan();
+            assertTrue(actionObject != null);
+
+            XACMLPolicyScanner scanner = new XACMLPolicyScanner(configPolicyPathValue, callback);
+            assertTrue(scanner.getPolicyObject() != null);
+            Object object = scanner.scan();
+            assertTrue(object != null);
+            String id = XACMLPolicyScanner.getID(scanner.getPolicyObject());
+            assertTrue(id.equals("urn:com:xacml:policy:id:0b67998b-57e2-4e25-9ea9-f9154bf18df1"));
+            String version = XACMLPolicyScanner.getVersion(scanner.getPolicyObject());
+            assertTrue(version.equals("1"));
+            String versionFromPath = XACMLPolicyScanner.getVersion(configPolicyPathValue);
+            assertTrue(versionFromPath.equals("1"));
+            List<String> returnValue =
+                    XACMLPolicyScanner.getCreatedByModifiedBy(configPolicyPathValue);
+            assertTrue(returnValue.get(0).equals("test"));
+            String createdBy = XACMLPolicyScanner.getCreatedBy(configPolicyPathValue);
+            assertTrue(createdBy.equals("test"));
+            String modifiedBy = XACMLPolicyScanner.getModifiedBy(configPolicyPathValue);
+            assertTrue(modifiedBy.equals("test"));
+        } catch (Exception e) {
+            fail();
+            logger.error("Exception Occured" + e);
+        }
+    }
 }
index 446a87d..4cf40a3 100644 (file)
@@ -1,15 +1,17 @@
-/*
+/*-
  * ============LICENSE_START=======================================================
  * ONAP-XACML
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2019 Samsung
+ * ================================================================================
  * 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.
@@ -21,73 +23,74 @@ package org.onap.policy.xacml.test.util;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.file.Path;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.junit.Before;
 import org.junit.Test;
 import org.onap.policy.xacml.util.XACMLPolicyWriter;
-
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
 
 public class XACMLPolicyWriterTest {
-  private static final Log logger = LogFactory.getLog(XACMLPolicyWriterTest.class);
-  private static Path configPolicyPathValue;
-  private static Path actionPolicyPathValue;
+    private static final Log logger = LogFactory.getLog(XACMLPolicyWriterTest.class);
+    private static Path configPolicyPathValue;
+    private static Path actionPolicyPathValue;
 
-  @Before
-  public void setUp() {
-    File templateFile;
-    ClassLoader classLoader = getClass().getClassLoader();
-    try {
-      templateFile = new File(classLoader.getResource("Config_SampleTest1206.1.xml").getFile());
-      configPolicyPathValue = templateFile.toPath();
-      templateFile = new File(classLoader.getResource("Action_TestActionPolicy.1.xml").getFile());
-      actionPolicyPathValue = templateFile.toPath();
-    } catch (Exception e1) {
-      logger.error("Exception Occured" + e1);
+    @Before
+    public void setUp() {
+        File templateFile;
+        ClassLoader classLoader = getClass().getClassLoader();
+        try {
+            templateFile =
+                    new File(classLoader.getResource("Config_SampleTest1206.1.xml").getFile());
+            configPolicyPathValue = templateFile.toPath();
+            templateFile =
+                    new File(classLoader.getResource("Action_TestActionPolicy.1.xml").getFile());
+            actionPolicyPathValue = templateFile.toPath();
+        } catch (Exception e1) {
+            logger.error("Exception Occured" + e1);
+        }
     }
-  }
 
-  @SuppressWarnings("static-access")
-  @Test
-  public void xacmlPolicyWriterTest() throws IOException {
-    XACMLPolicyWriter writer = new XACMLPolicyWriter();
-    String configResponseValue = writer.changeFileNameInXmlWhenRenamePolicy(configPolicyPathValue);
-    assertTrue(configResponseValue.equals("txt"));
-    String actionResponseValue = writer.changeFileNameInXmlWhenRenamePolicy(actionPolicyPathValue);
-    assertTrue(actionResponseValue.equals("json"));
-  }
+    @SuppressWarnings("static-access")
+    @Test
+    public void xacmlPolicyWriterTest() throws IOException {
+        XACMLPolicyWriter writer = new XACMLPolicyWriter();
+        String configResponseValue =
+                writer.changeFileNameInXmlWhenRenamePolicy(configPolicyPathValue);
+        assertTrue(configResponseValue.equals("txt"));
+        String actionResponseValue =
+                writer.changeFileNameInXmlWhenRenamePolicy(actionPolicyPathValue);
+        assertTrue(actionResponseValue.equals("json"));
+    }
+
+    @Test
+    public void testWrites() throws Exception {
+        // Set up test data
+        PolicyType policyType = new PolicyType();
+        OutputStream os = new ByteArrayOutputStream();
+        File tmpfile = File.createTempFile("foo", null);
+        Path filename = tmpfile.toPath();
+        PolicySetType policySet = new PolicySetType();
 
-  @Test
-  public void testWrites() throws Exception {
-    // Set up test data
-    PolicyType policyType = new PolicyType();
-    OutputStream os = new ByteArrayOutputStream();
-    File tmpfile = File.createTempFile("foo", null);
-    Path filename = tmpfile.toPath();
-    PolicySetType policySet = new PolicySetType();
-    
-    // delete tmp file before running the test
-    tmpfile.delete();
+        // delete tmp file before running the test
+        tmpfile.delete();
 
-    // ensure its deleted after writePolicyFile() re-creates it
-    tmpfile.deleteOnExit();
+        // ensure its deleted after writePolicyFile() re-creates it
+        tmpfile.deleteOnExit();
 
-    // Test write combinations
-    assertNotNull(XACMLPolicyWriter.writePolicyFile(filename, policySet));
-    assertNotNull(XACMLPolicyWriter.writePolicyFile(filename, policyType));
-    assertNotNull(XACMLPolicyWriter.getXmlAsInputStream(policyType));
-    XACMLPolicyWriter.writePolicyFile(os, policySet);
-    assertNotNull(os.toString());
-    XACMLPolicyWriter.writePolicyFile(os, policyType);
-    assertNotNull(os.toString());
-  }
+        // Test write combinations
+        assertNotNull(XACMLPolicyWriter.writePolicyFile(filename, policySet));
+        assertNotNull(XACMLPolicyWriter.writePolicyFile(filename, policyType));
+        assertNotNull(XACMLPolicyWriter.getXmlAsInputStream(policyType));
+        XACMLPolicyWriter.writePolicyFile(os, policySet);
+        assertNotNull(os.toString());
+        XACMLPolicyWriter.writePolicyFile(os, policyType);
+        assertNotNull(os.toString());
+    }
 }