summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java402
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java763
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/models/PDPResponseTest.java102
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java112
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyServiceTest.java5
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyServiceTest.java133
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyServiceTest.java117
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyServiceTest.java68
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyServiceTest.java210
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyServiceTest.java103
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyServiceTest.java103
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyServiceTest.java91
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PAPServicesTest.java20
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PDPServicesTest.java258
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PolicyEngineImportServiceTest.java54
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetConfigServiceTest.java73
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java401
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/NotificationAPITest.java113
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java539
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/utils/test/PolicyApiUtilsTest.java429
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/AuthenticationServiceTest.java49
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/FilterTest.java312
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/config/PDPRestInitializerTest.java33
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPIPFinderFactoryTest.java36
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPolicyFinderFactoryTest.java89
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/DummyServerContextImpl.java7
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java45
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/RemovedTest.java26
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/test/NotificationTest.java82
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/api/XACMLErrorConstantsTest.java22
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineFactoryTest.java81
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java199
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupStatusTest.java31
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupTest.java385
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPItemSetChangeNotifierTest.java30
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPIPConfigTest.java142
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPolicyTest.java218
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPStatusTest.java36
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPTest.java242
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pip/engines/OperationHistoryEngineTest.java32
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/AAFEngineTest.java63
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/MetricsUtilTest.java53
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyScannerTest.java107
-rw-r--r--ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyWriterTest.java107
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/ManualClientEndDMAAPTest.java48
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/StdPolicyEngineTest.java1420
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientUEBTest.java294
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/DummyNotificationHandler.java182
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndTest.java20
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndUEBTest.java123
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java159
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationStoreTest.java610
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdLoadedPolicyTest.java546
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPDPNotificationTest.java532
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyChangeResponseTest.java263
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyResponseTest.java615
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdRemovedPolicyTest.java341
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdStatusTest.java2817
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/std/utils/PolicyConstantsTest.java38
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/APIPolicyConfigResponseTest.java92
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/ActionPolicyApiTest.java390
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/AttributeTypeTest.java104
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigBasePolicyTest.java553
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigFirewallPolicyTest.java430
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigRequestParametersTest.java656
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionPolicyApiTest.java329
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionRequestParametersTest.java393
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryParametersTest.java44
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/EventRequestParametersTest.java313
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigByPolicyNameTest.java63
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringMapTest.java442
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringTest.java353
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringTest.java172
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/ImportParametersTest.java721
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/LoadedPolicyTest.java77
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/MetricsRequestParametersTest.java22
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationHandlerTest.java77
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationSchemeTest.java107
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationTypeTest.java107
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PDPNotificationTest.java77
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyChangeResponseTest.java77
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigExceptionTest.java299
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTest.java77
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTypeTest.java121
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionExceptionTest.java299
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineExceptionTest.java299
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineInterfaceTest.java1185
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEventExceptionTest.java299
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyExceptionTest.java117
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseTest.java77
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/PushPolicyParametersTest.java463
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/RemovedPolicyTest.java77
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/SendEventTest.java229
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/StdDecisionResponseTest.java23
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/StdDictionaryResponseTest.java32
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/StdMetricsResponseTest.java35
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/TestRunner.java51
-rw-r--r--PolicyEngineAPI/src/test/java/org/onap/policy/test/UpdateTypeTest.java107
98 files changed, 11966 insertions, 11954 deletions
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java
index c8716c3bc..cf3ddb3b2 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java
@@ -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.
@@ -19,206 +21,218 @@
*/
package org.onap.policy.pdp.rest;
+
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
-
import org.junit.Assert;
import org.junit.Test;
import org.onap.policy.rest.XACMLRestProperties;
public class PapUrlResolverTest {
-
- @Test
- public void testPropertyModifications(){
- DateFormat df = new SimpleDateFormat();
- //first sort order
- String urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
- String failed = "-1,-1,-1,-1";
- String succeeded = "-1,-1,-1,-1";
- PapUrlResolver rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertEquals(rs.getProperties().getProperty(XACMLRestProperties.PROP_PAP_URLS),urls);
-
- rs.failed();
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- rs.succeeded();
- Assert.assertFalse(rs.hasMoreUrls());
- Properties prop = rs.getProperties();
- Assert.assertEquals(df.format(new Date())+",-1,-1,-1",prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS));
- Assert.assertEquals("-1,"+df.format(new Date())+",-1,-1",prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS));
-
- failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
- succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
- rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://two.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://three.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://four.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://one.localhost.com", rs.getUrl());
- rs.succeeded();
- rs.getNext();
- Assert.assertFalse(rs.hasMoreUrls());
- prop = rs.getProperties();
- Assert.assertEquals("-1,-1,-1,-1",prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS));
-
- failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
- succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
- rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://one.localhost.com", rs.getUrl());
- rs.succeeded();
- rs.getNext();
- Assert.assertFalse(rs.hasMoreUrls());
- prop = rs.getProperties();
- failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
- succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
- rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://one.localhost.com", rs.getUrl());
- rs.succeeded();
- rs.getNext();
- Assert.assertFalse(rs.hasMoreUrls());
- prop = rs.getProperties();
- failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
- succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
- rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://one.localhost.com", rs.getUrl());
- rs.succeeded();
- rs.getNext();
- Assert.assertFalse(rs.hasMoreUrls());
-
-
- prop = rs.getProperties();
- succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
- }
- @SuppressWarnings("unused")
- @Test
- public void testModifyUrl(){
- String newUrl = PapUrlResolver.modifyUrl("http://mypap1.com/pap?id=987654", "http://mypap2.com:45/pap/");
- int u = 8;
- }
-
- @Test
- public void testSorts(){
- long currentTime = new Date().getTime();
- DateFormat df = new SimpleDateFormat();
- //first sort order
- String urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
- String failed = df.format(new Date(currentTime-3600000))+",-1,-1,"+df.format(new Date(currentTime-3200000));
- String succeeded = "-1,8/13/15 5:41 PM,8/13/15 4:41 PM,-1";
- PapUrlResolver rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://two.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://three.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://one.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://four.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertFalse(rs.hasMoreUrls());
-
- urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
- failed = "-1,-1,-1,-1";
- succeeded = "-1,"+df.format(new Date(currentTime-3600000))+","+df.format(new Date(currentTime-6600000))+",-1";
- rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://one.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://two.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://three.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://four.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertFalse(rs.hasMoreUrls());
-
- urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
- failed = "-1,-1,-1,-1";
- succeeded = "-1,-1,-1,-1";
- rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://one.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://two.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://three.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://four.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertFalse(rs.hasMoreUrls());
-
- urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
- failed = df.format(new Date(currentTime-3900000))+","+df.format(new Date(currentTime-5600000))+","+df.format(new Date(currentTime-4600000))+","+df.format(new Date(currentTime-3600000));
- succeeded = "-1,-1,-1,-1";
- rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://two.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://three.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://one.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://four.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertFalse(rs.hasMoreUrls());
-
- urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
- failed = df.format(new Date(currentTime-(3600000*4)))+",-1,-1,-1";
- succeeded = "-1,-1,-1,-1";
- rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://two.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://three.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://four.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://one.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertFalse(rs.hasMoreUrls());
-
- urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
- failed = df.format(new Date(currentTime-(3600000*6)))+",-1,-1,-1";
- succeeded = "-1,-1,-1,-1";
- rs = PapUrlResolver.getInstance(urls, failed, succeeded);
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://one.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://two.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://three.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertTrue(rs.hasMoreUrls());
- Assert.assertEquals("http://four.localhost.com", rs.getUrl());
- rs.getNext();
- Assert.assertFalse(rs.hasMoreUrls());
- }
+ @Test
+ public void testPropertyModifications() {
+ DateFormat df = new SimpleDateFormat();
+ // first sort order
+ String urls = "http://one.localhost.com,http://two.localhost.com,"
+ + "http://three.localhost.com,http://four.localhost.com";
+ String failed = "-1,-1,-1,-1";
+ String succeeded = "-1,-1,-1,-1";
+ PapUrlResolver rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertEquals(rs.getProperties().getProperty(XACMLRestProperties.PROP_PAP_URLS),
+ urls);
+
+ rs.failed();
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ rs.succeeded();
+ Assert.assertFalse(rs.hasMoreUrls());
+ Properties prop = rs.getProperties();
+ Assert.assertEquals(df.format(new Date()) + ",-1,-1,-1",
+ prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS));
+ Assert.assertEquals("-1," + df.format(new Date()) + ",-1,-1",
+ prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS));
+
+ failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
+ succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
+ rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://two.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://three.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://four.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://one.localhost.com", rs.getUrl());
+ rs.succeeded();
+ rs.getNext();
+ Assert.assertFalse(rs.hasMoreUrls());
+ prop = rs.getProperties();
+ Assert.assertEquals("-1,-1,-1,-1",
+ prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS));
+
+ failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
+ succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
+ rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://one.localhost.com", rs.getUrl());
+ rs.succeeded();
+ rs.getNext();
+ Assert.assertFalse(rs.hasMoreUrls());
+ prop = rs.getProperties();
+ failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
+ succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
+ rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://one.localhost.com", rs.getUrl());
+ rs.succeeded();
+ rs.getNext();
+ Assert.assertFalse(rs.hasMoreUrls());
+ prop = rs.getProperties();
+ failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS);
+ succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
+ rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://one.localhost.com", rs.getUrl());
+ rs.succeeded();
+ rs.getNext();
+ Assert.assertFalse(rs.hasMoreUrls());
+
+ prop = rs.getProperties();
+ succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS);
+ }
+
+ @SuppressWarnings("unused")
+ @Test
+ public void testModifyUrl() {
+ String newUrl = PapUrlResolver.modifyUrl("http://mypap1.com/pap?id=987654",
+ "http://mypap2.com:45/pap/");
+ int u = 8;
+ }
+
+ @Test
+ public void testSorts() {
+ long currentTime = new Date().getTime();
+ DateFormat df = new SimpleDateFormat();
+ // first sort order
+ String urls =
+ "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,"
+ + "http://four.localhost.com";
+ String failed = df.format(new Date(currentTime - 3600000)) + ",-1,-1,"
+ + df.format(new Date(currentTime - 3200000));
+ String succeeded = "-1,8/13/15 5:41 PM,8/13/15 4:41 PM,-1";
+ PapUrlResolver rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://two.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://three.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://one.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://four.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertFalse(rs.hasMoreUrls());
+
+ urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
+ failed = "-1,-1,-1,-1";
+ succeeded = "-1," + df.format(new Date(currentTime - 3600000)) + ","
+ + df.format(new Date(currentTime - 6600000)) + ",-1";
+ rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://one.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://two.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://three.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://four.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertFalse(rs.hasMoreUrls());
+
+ urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
+ failed = "-1,-1,-1,-1";
+ succeeded = "-1,-1,-1,-1";
+ rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://one.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://two.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://three.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://four.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertFalse(rs.hasMoreUrls());
+
+ urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
+ failed = df.format(new Date(currentTime - 3900000)) + ","
+ + df.format(new Date(currentTime - 5600000)) + ","
+ + df.format(new Date(currentTime - 4600000)) + ","
+ + df.format(new Date(currentTime - 3600000));
+ succeeded = "-1,-1,-1,-1";
+ rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://two.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://three.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://one.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://four.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertFalse(rs.hasMoreUrls());
+
+ urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
+ failed = df.format(new Date(currentTime - (3600000 * 4))) + ",-1,-1,-1";
+ succeeded = "-1,-1,-1,-1";
+ rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://two.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://three.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://four.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://one.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertFalse(rs.hasMoreUrls());
+
+ urls = "http://one.localhost.com,http://two.localhost.com,http://three.localhost.com,http://four.localhost.com";
+ failed = df.format(new Date(currentTime - (3600000 * 6))) + ",-1,-1,-1";
+ succeeded = "-1,-1,-1,-1";
+ rs = PapUrlResolver.getInstance(urls, failed, succeeded);
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://one.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://two.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://three.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertTrue(rs.hasMoreUrls());
+ Assert.assertEquals("http://four.localhost.com", rs.getUrl());
+ rs.getNext();
+ Assert.assertFalse(rs.hasMoreUrls());
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java
index 8707ee0ff..14c231aed 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/XACMLPdpServletTest.java
@@ -28,13 +28,11 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.Random;
-
import javax.servlet.ServletConfig;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -53,433 +51,418 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletConfig;
-
import com.att.research.xacml.util.XACMLProperties;
import com.mockrunner.mock.web.MockServletInputStream;
-
import junit.framework.TestCase;
@RunWith(PowerMockRunner.class)
@PrepareForTest({IntegrityMonitor.class})
public class XACMLPdpServletTest extends TestCase {
- private static Logger LOGGER = FlexLogger.getLogger(XACMLPdpServletTest.class);
- private List<String> headers = new ArrayList<>();
-
- private HttpServletRequest httpServletRequest;
- private HttpServletResponse httpServletResponse;
- private ServletOutputStream mockOutput;
- private ServletInputStream mockInput;
- private ServletConfig servletConfig;
- private XACMLPdpServlet pdpServlet;
- private Properties properties;
- private String resourceName;
- private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
- private static final String DEFAULT_DB_USER = "sa";
- private static final String DEFAULT_DB_PWD = "";
- private StdPDPStatus status;
- private StdPDPPolicy foobarPolicy;
-
- private static final String ERROR_TEXT = "Exception occurred: ";
-
- @Override
- @Before
- public void setUp() {
- status = new StdPDPStatus();
- foobarPolicy = new StdPDPPolicy();
- foobarPolicy.setId("foobar");
- foobarPolicy.setVersion("123");
- foobarPolicy.setName("nothing");
- status.addLoadedPolicy(foobarPolicy);
-
- properties = new Properties();
- properties.put(IntegrityAuditProperties.DB_DRIVER, XACMLPdpServletTest.DEFAULT_DB_DRIVER);
- properties.put(IntegrityAuditProperties.DB_URL, "jdbc:h2:file:./sql/xacmlTest");
- properties.put(IntegrityAuditProperties.DB_USER, XACMLPdpServletTest.DEFAULT_DB_USER);
- properties.put(IntegrityAuditProperties.DB_PWD, XACMLPdpServletTest.DEFAULT_DB_PWD);
- properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
- properties.put(IntegrityAuditProperties.NODE_TYPE, "pap");
- resourceName = "siteA.pdp1";
-
- System.setProperty("com.sun.management.jmxremote.port", "9999");
-
- IntegrityMonitor im = null;
- try {
- im = IntegrityMonitor.getInstance(resourceName, properties);
- } catch (Exception e) {
- e.printStackTrace();
+ private static Logger LOGGER = FlexLogger.getLogger(XACMLPdpServletTest.class);
+ private List<String> headers = new ArrayList<>();
+
+ private HttpServletRequest httpServletRequest;
+ private HttpServletResponse httpServletResponse;
+ private ServletOutputStream mockOutput;
+ private ServletInputStream mockInput;
+ private ServletConfig servletConfig;
+ private XACMLPdpServlet pdpServlet;
+ private Properties properties;
+ private String resourceName;
+ private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
+ private static final String DEFAULT_DB_USER = "sa";
+ private static final String DEFAULT_DB_PWD = "";
+ private StdPDPStatus status;
+ private StdPDPPolicy foobarPolicy;
+
+ private static final String ERROR_TEXT = "Exception occurred: ";
+
+ @Override
+ @Before
+ public void setUp() {
+ status = new StdPDPStatus();
+ foobarPolicy = new StdPDPPolicy();
+ foobarPolicy.setId("foobar");
+ foobarPolicy.setVersion("123");
+ foobarPolicy.setName("nothing");
+ status.addLoadedPolicy(foobarPolicy);
+
+ properties = new Properties();
+ properties.put(IntegrityAuditProperties.DB_DRIVER, XACMLPdpServletTest.DEFAULT_DB_DRIVER);
+ properties.put(IntegrityAuditProperties.DB_URL, "jdbc:h2:file:./sql/xacmlTest");
+ properties.put(IntegrityAuditProperties.DB_USER, XACMLPdpServletTest.DEFAULT_DB_USER);
+ properties.put(IntegrityAuditProperties.DB_PWD, XACMLPdpServletTest.DEFAULT_DB_PWD);
+ properties.put(IntegrityAuditProperties.SITE_NAME, "SiteA");
+ properties.put(IntegrityAuditProperties.NODE_TYPE, "pap");
+ resourceName = "siteA.pdp1";
+
+ System.setProperty("com.sun.management.jmxremote.port", "9999");
+
+ IntegrityMonitor im = null;
+ try {
+ im = IntegrityMonitor.getInstance(resourceName, properties);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ httpServletRequest = Mockito.mock(HttpServletRequest.class);
+ Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
+ Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers));
+ Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers));
+ Mockito.when(httpServletRequest.getRequestURI()).thenReturn("/pdp/test");
+
+ mockOutput = Mockito.mock(ServletOutputStream.class);
+
+ httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
+
+ try {
+ Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput);
+ } catch (IOException e) {
+ fail();
+ }
+
+ servletConfig = Mockito.mock(MockServletConfig.class);
+ // servletConfig
+ Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers));
+ pdpServlet = new XACMLPdpServlet();
+ pdpServlet.setIm(im);
+
+ Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME"))
+ .thenReturn("src/test/resources/xacml.pdp.properties");
+
+ System.setProperty("xacml.properties", "src/test/resources/xacml.pdp.properties");
+ System.setProperty("xacml.rest.pdp.config", "src/test/resources/config_testing");
+ System.setProperty("xacml.rest.pdp.webapps", "src/test/resources/webapps");
+
+ System.setProperty("xacml.rest.pdp.register", "false");
+ System.setProperty("com.sun.management.jmxremote.port", "9999");
+
+ im = Mockito.mock(IntegrityMonitor.class);
+ // Need PowerMockito for mocking static method getInstance(...)
+ PowerMockito.mockStatic(IntegrityMonitor.class);
+ try {
+ // when IntegrityMonitor.getInstance is called, return the mock object
+ PowerMockito.when(IntegrityMonitor.getInstance(Mockito.anyString(), Mockito.any(Properties.class)))
+ .thenReturn(im);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ }
+
+ try {
+ Mockito.doNothing().when(im).startTransaction();
+ } catch (IntegrityMonitorException e) {
+ fail();
+ }
+ Mockito.doNothing().when(im).endTransaction();
}
- httpServletRequest = Mockito.mock(HttpServletRequest.class);
- Mockito.when(httpServletRequest.getMethod()).thenReturn("POST");
- Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers));
- Mockito.when(httpServletRequest.getAttributeNames())
- .thenReturn(Collections.enumeration(headers));
- Mockito.when(httpServletRequest.getRequestURI()).thenReturn("/pdp/test");
-
- mockOutput = Mockito.mock(ServletOutputStream.class);
-
- httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
-
- try {
- Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput);
- } catch (IOException e) {
- fail();
+ @Override
+ @After
+ public void tearDown() {
+ System.clearProperty("xacml.rest.pdp.config");
}
- servletConfig = Mockito.mock(MockServletConfig.class);
- // servletConfig
- Mockito.when(servletConfig.getInitParameterNames())
- .thenReturn(Collections.enumeration(headers));
- pdpServlet = new XACMLPdpServlet();
- pdpServlet.setIm(im);
-
- Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME"))
- .thenReturn("src/test/resources/xacml.pdp.properties");
-
- System.setProperty("xacml.properties", "src/test/resources/xacml.pdp.properties");
- System.setProperty("xacml.rest.pdp.config", "src/test/resources/config_testing");
- System.setProperty("xacml.rest.pdp.webapps", "src/test/resources/webapps");
-
- System.setProperty("xacml.rest.pdp.register", "false");
- System.setProperty("com.sun.management.jmxremote.port", "9999");
-
- im = Mockito.mock(IntegrityMonitor.class);
- // Need PowerMockito for mocking static method getInstance(...)
- PowerMockito.mockStatic(IntegrityMonitor.class);
- try {
- // when IntegrityMonitor.getInstance is called, return the mock object
- PowerMockito
- .when(IntegrityMonitor.getInstance(Mockito.anyString(), Mockito.any(Properties.class)))
- .thenReturn(im);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
+ @Test
+ public void testInit() {
+ LOGGER.info("XACMLPdpServletTest - testInit");
+ try {
+ pdpServlet.init(servletConfig);
+
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- try {
- Mockito.doNothing().when(im).startTransaction();
- } catch (IntegrityMonitorException e) {
- fail();
- }
- Mockito.doNothing().when(im).endTransaction();
- }
-
- @Override
- @After
- public void tearDown()
- {
- System.clearProperty("xacml.rest.pdp.config");
- }
-
- @Test
- public void testInit() {
- LOGGER.info("XACMLPdpServletTest - testInit");
- try {
- pdpServlet.init(servletConfig);
-
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+ @Test
+ public void testUebNotification() {
+ LOGGER.info("XACMLPdpServletTest - testUebNotification");
+ try {
- }
-
- }
-
- @Test
- public void testUebNotification() {
- LOGGER.info("XACMLPdpServletTest - testUebNotification");
- try {
-
- XACMLProperties.reloadProperties();
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,
- "src/test/resources/xacml.pdp.ueb.properties");
- XACMLProperties.getProperties();
+ XACMLProperties.reloadProperties();
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pdp.ueb.properties");
+ XACMLProperties.getProperties();
- pdpServlet.init(servletConfig);
+ pdpServlet.init(servletConfig);
- status.setStatus(com.att.research.xacml.api.pap.PDPStatus.Status.UPDATING_CONFIGURATION);
-
- XACMLPdpLoader.validatePolicies(properties, status);
- XACMLPdpLoader.sendNotification();
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+ status.setStatus(com.att.research.xacml.api.pap.PDPStatus.Status.UPDATING_CONFIGURATION);
+ XACMLPdpLoader.validatePolicies(properties, status);
+ XACMLPdpLoader.sendNotification();
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDmaapNotification() {
- LOGGER.info("XACMLPdpServletTest - testDmaapNotification");
- try {
-
- XACMLProperties.reloadProperties();
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,
- "src/test/resources/xacml.pdp.dmaap.properties");
- XACMLProperties.getProperties();
+ @Test
+ public void testDmaapNotification() {
+ LOGGER.info("XACMLPdpServletTest - testDmaapNotification");
+ try {
- pdpServlet.init(servletConfig);
+ XACMLProperties.reloadProperties();
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pdp.dmaap.properties");
+ XACMLProperties.getProperties();
- status.setStatus(com.att.research.xacml.api.pap.PDPStatus.Status.UPDATING_CONFIGURATION);
+ pdpServlet.init(servletConfig);
- XACMLPdpLoader.validatePolicies(properties, status);
- XACMLPdpLoader.sendNotification();
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+ status.setStatus(com.att.research.xacml.api.pap.PDPStatus.Status.UPDATING_CONFIGURATION);
+ XACMLPdpLoader.validatePolicies(properties, status);
+ XACMLPdpLoader.sendNotification();
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
-
- @Test
- public void testXACMLPdpRegisterThread() {
- LOGGER.info("XACMLPdpServletTest - testXACMLPdpRegisterThread");
- try {
- ONAPLoggingContext baseLoggingContext = new ONAPLoggingContext();
- baseLoggingContext.setServer("localhost");
- XACMLPdpRegisterThread regThread = new XACMLPdpRegisterThread(baseLoggingContext);
- regThread.run();
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+ @Test
+ public void testXACMLPdpRegisterThread() {
+ LOGGER.info("XACMLPdpServletTest - testXACMLPdpRegisterThread");
+ try {
+ ONAPLoggingContext baseLoggingContext = new ONAPLoggingContext();
+ baseLoggingContext.setServer("localhost");
+ XACMLPdpRegisterThread regThread = new XACMLPdpRegisterThread(baseLoggingContext);
+ regThread.run();
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoGetNoTypeError() {
- LOGGER.info("XACMLPdpServletTest - testDoGetNoTypeError");
- try {
-
- pdpServlet.init(servletConfig);
- pdpServlet.doGet(httpServletRequest, httpServletResponse);
- Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoGetNoTypeError() {
+ LOGGER.info("XACMLPdpServletTest - testDoGetNoTypeError");
+ try {
+
+ pdpServlet.init(servletConfig);
+ pdpServlet.doGet(httpServletRequest, httpServletResponse);
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoGetConfigType() {
- LOGGER.info("XACMLPdpServletTest - testDoGetConfigType");
- Mockito.when(httpServletRequest.getParameter("type")).thenReturn("config");
-
- try {
- pdpServlet.init(servletConfig);
- pdpServlet.doGet(httpServletRequest, httpServletResponse);
- Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoGetConfigType() {
+ LOGGER.info("XACMLPdpServletTest - testDoGetConfigType");
+ Mockito.when(httpServletRequest.getParameter("type")).thenReturn("config");
+
+ try {
+ pdpServlet.init(servletConfig);
+ pdpServlet.doGet(httpServletRequest, httpServletResponse);
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
+
}
- }
-
- @Test
- public void testDoGetTypeHb() {
- LOGGER.info("XACMLPdpServletTest - testDoGetTypeHb");
- try {
- Mockito.when(httpServletRequest.getParameter("type")).thenReturn("hb");
- pdpServlet.init(servletConfig);
- pdpServlet.doGet(httpServletRequest, httpServletResponse);
- Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+ @Test
+ public void testDoGetTypeHb() {
+ LOGGER.info("XACMLPdpServletTest - testDoGetTypeHb");
+ try {
+ Mockito.when(httpServletRequest.getParameter("type")).thenReturn("hb");
+ pdpServlet.init(servletConfig);
+ pdpServlet.doGet(httpServletRequest, httpServletResponse);
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoGetTypeStatus() {
- LOGGER.info("XACMLPdpServletTest - testDoGetTypeStatus");
- try {
- Mockito.when(httpServletRequest.getParameter("type")).thenReturn("Status");
- pdpServlet.init(servletConfig);
- pdpServlet.doGet(httpServletRequest, httpServletResponse);
- Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoGetTypeStatus() {
+ LOGGER.info("XACMLPdpServletTest - testDoGetTypeStatus");
+ try {
+ Mockito.when(httpServletRequest.getParameter("type")).thenReturn("Status");
+ pdpServlet.init(servletConfig);
+ pdpServlet.doGet(httpServletRequest, httpServletResponse);
+ Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoPost() {
- LOGGER.info("XACMLPdpServletTest - testDoPost");
- try {
- pdpServlet.init(servletConfig);
- pdpServlet.doPost(httpServletRequest, httpServletResponse);
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoPost() {
+ LOGGER.info("XACMLPdpServletTest - testDoPost");
+ try {
+ pdpServlet.init(servletConfig);
+ pdpServlet.doPost(httpServletRequest, httpServletResponse);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoPostToLong() {
- LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
- try {
- Mockito.when(httpServletRequest.getContentType()).thenReturn("stuff");
- Mockito.when(httpServletRequest.getContentLength()).thenReturn(32768);
-
- pdpServlet.init(servletConfig);
- pdpServlet.doPost(httpServletRequest, httpServletResponse);
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoPostToLong() {
+ LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
+ try {
+ Mockito.when(httpServletRequest.getContentType()).thenReturn("stuff");
+ Mockito.when(httpServletRequest.getContentLength()).thenReturn(32768);
+
+ pdpServlet.init(servletConfig);
+ pdpServlet.doPost(httpServletRequest, httpServletResponse);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoPostContentLengthNegative() {
- LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
- try {
- Mockito.when(httpServletRequest.getContentType()).thenReturn("stuff");
- Mockito.when(httpServletRequest.getContentLength()).thenReturn(-1);
-
- pdpServlet.init(servletConfig);
- pdpServlet.doPost(httpServletRequest, httpServletResponse);
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoPostContentLengthNegative() {
+ LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
+ try {
+ Mockito.when(httpServletRequest.getContentType()).thenReturn("stuff");
+ Mockito.when(httpServletRequest.getContentLength()).thenReturn(-1);
+
+ pdpServlet.init(servletConfig);
+ pdpServlet.doPost(httpServletRequest, httpServletResponse);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoPostContentTypeNonValid() {
- LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
- try {
- Mockito.when(httpServletRequest.getContentType()).thenReturn(";");
- Mockito.when(httpServletRequest.getContentLength()).thenReturn(30768);
-
- pdpServlet.init(servletConfig);
- pdpServlet.doPost(httpServletRequest, httpServletResponse);
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoPostContentTypeNonValid() {
+ LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
+ try {
+ Mockito.when(httpServletRequest.getContentType()).thenReturn(";");
+ Mockito.when(httpServletRequest.getContentLength()).thenReturn(30768);
+
+ pdpServlet.init(servletConfig);
+ pdpServlet.doPost(httpServletRequest, httpServletResponse);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoPostContentTypeConfigurationError() {
- LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
- try {
- Mockito.when(httpServletRequest.getContentType()).thenReturn("stuff");
- Mockito.when(httpServletRequest.getContentLength()).thenReturn(30768);
-
- pdpServlet.init(servletConfig);
- pdpServlet.doPost(httpServletRequest, httpServletResponse);
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoPostContentTypeConfigurationError() {
+ LOGGER.info("XACMLPdpServletTest - testDoPostToLong");
+ try {
+ Mockito.when(httpServletRequest.getContentType()).thenReturn("stuff");
+ Mockito.when(httpServletRequest.getContentLength()).thenReturn(30768);
+
+ pdpServlet.init(servletConfig);
+ pdpServlet.doPost(httpServletRequest, httpServletResponse);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoPutCacheEmpty() {
- LOGGER.info("XACMLPdpServletTest - testDoPutCacheEmpty");
- mockInput = Mockito.mock(ServletInputStream.class);
-
- try {
- Mockito.when(httpServletRequest.getParameter("cache")).thenReturn("cache");
- Mockito.when(httpServletRequest.getContentType()).thenReturn("text/x-java-properties");
- Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
- pdpServlet.init(servletConfig);
- pdpServlet.doPut(httpServletRequest, httpServletResponse);
- Mockito.verify(httpServletResponse).sendError(HttpServletResponse.SC_BAD_REQUEST,
- "PUT must contain at least one property");
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoPutCacheEmpty() {
+ LOGGER.info("XACMLPdpServletTest - testDoPutCacheEmpty");
+ mockInput = Mockito.mock(ServletInputStream.class);
+
+ try {
+ Mockito.when(httpServletRequest.getParameter("cache")).thenReturn("cache");
+ Mockito.when(httpServletRequest.getContentType()).thenReturn("text/x-java-properties");
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+ pdpServlet.init(servletConfig);
+ pdpServlet.doPut(httpServletRequest, httpServletResponse);
+ Mockito.verify(httpServletResponse).sendError(HttpServletResponse.SC_BAD_REQUEST,
+ "PUT must contain at least one property");
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoPutConfigPolicies() {
- LOGGER.info("XACMLPdpServletTest - testDoPutConfigPolicies");
- byte[] b = new byte[20];
- new Random().nextBytes(b);
-
- mockInput = new MockServletInputStream(b);
-
- try {
- Mockito.when(httpServletRequest.getParameter("cache")).thenReturn("policies");
- Mockito.when(httpServletRequest.getContentType()).thenReturn("text/x-java-properties");
- Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
- pdpServlet.init(servletConfig);
- pdpServlet.doPut(httpServletRequest, httpServletResponse);
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoPutConfigPolicies() {
+ LOGGER.info("XACMLPdpServletTest - testDoPutConfigPolicies");
+ byte[] b = new byte[20];
+ new Random().nextBytes(b);
+
+ mockInput = new MockServletInputStream(b);
+
+ try {
+ Mockito.when(httpServletRequest.getParameter("cache")).thenReturn("policies");
+ Mockito.when(httpServletRequest.getContentType()).thenReturn("text/x-java-properties");
+ Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput);
+ pdpServlet.init(servletConfig);
+ pdpServlet.doPut(httpServletRequest, httpServletResponse);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- public void testDoPutToLong() {
- LOGGER.info("XACMLPdpServletTest - testDoPutToLong");
- try {
- Mockito.when(httpServletRequest.getParameter("cache")).thenReturn("policies");
-
- Mockito.when(httpServletRequest.getContentType()).thenReturn("text/x-java-properties");
- Mockito.when(httpServletRequest.getContentLength()).thenReturn(1000000000);
-
- pdpServlet.init(servletConfig);
- pdpServlet.doPut(httpServletRequest, httpServletResponse);
- Mockito.verify(httpServletResponse).sendError(HttpServletResponse.SC_BAD_REQUEST,
- "Content-Length larger than server will accept.");
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ public void testDoPutToLong() {
+ LOGGER.info("XACMLPdpServletTest - testDoPutToLong");
+ try {
+ Mockito.when(httpServletRequest.getParameter("cache")).thenReturn("policies");
+
+ Mockito.when(httpServletRequest.getContentType()).thenReturn("text/x-java-properties");
+ Mockito.when(httpServletRequest.getContentLength()).thenReturn(1000000000);
+
+ pdpServlet.init(servletConfig);
+ pdpServlet.doPut(httpServletRequest, httpServletResponse);
+ Mockito.verify(httpServletResponse).sendError(HttpServletResponse.SC_BAD_REQUEST,
+ "Content-Length larger than server will accept.");
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDoPutInvalidContentType() {
- LOGGER.info("XACMLPdpServletTest - testDoPutToLong");
- try {
- Mockito.when(httpServletRequest.getParameter("cache")).thenReturn("policies");
-
- Mockito.when(httpServletRequest.getContentType()).thenReturn("text/json");
- Mockito.when(httpServletRequest.getContentLength()).thenReturn(32768);
-
- pdpServlet.init(servletConfig);
- pdpServlet.doPut(httpServletRequest, httpServletResponse);
- Mockito.verify(httpServletResponse).sendError(HttpServletResponse.SC_BAD_REQUEST,
- "Invalid cache: 'policies' or content-type: 'text/json'");
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDoPutInvalidContentType() {
+ LOGGER.info("XACMLPdpServletTest - testDoPutToLong");
+ try {
+ Mockito.when(httpServletRequest.getParameter("cache")).thenReturn("policies");
+
+ Mockito.when(httpServletRequest.getContentType()).thenReturn("text/json");
+ Mockito.when(httpServletRequest.getContentLength()).thenReturn(32768);
+
+ pdpServlet.init(servletConfig);
+ pdpServlet.doPut(httpServletRequest, httpServletResponse);
+ Mockito.verify(httpServletResponse).sendError(HttpServletResponse.SC_BAD_REQUEST,
+ "Invalid cache: 'policies' or content-type: 'text/json'");
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
-
- @Test
- public void testDestroy() {
- LOGGER.info("XACMLPdpServletTest - testDestroy");
-
- try {
- pdpServlet.init(servletConfig);
- pdpServlet.destroy();
- } catch (Exception e) {
- LOGGER.error(ERROR_TEXT + e);
- fail();
+
+ @Test
+ public void testDestroy() {
+ LOGGER.info("XACMLPdpServletTest - testDestroy");
+
+ try {
+ pdpServlet.init(servletConfig);
+ pdpServlet.destroy();
+ } catch (Exception e) {
+ LOGGER.error(ERROR_TEXT + e);
+ fail();
+ }
}
- }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/models/PDPResponseTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/models/PDPResponseTest.java
index a48791cf0..5fe9d6a78 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/models/PDPResponseTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/models/PDPResponseTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP Policy Engine
+ * ONAP-PDP-REST
* ================================================================================
* 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.
@@ -30,53 +32,53 @@ import org.onap.policy.api.PolicyResponseStatus;
import org.onap.policy.api.PolicyType;
public class PDPResponseTest {
- @Test
- public void testSetAndGet() {
- // Test values
- String message = "testMessage";
- String config = "testConfig";
- String policyName = "testPolicyName";
- String policyVersion = "1.0";
- PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
- PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_RETRIEVED;
- PolicyType type = PolicyType.JSON;
- Map<String, String> property = new HashMap<String, String>();
- PolicyDecision policyDecision = PolicyDecision.PERMIT;
+ @Test
+ public void testSetAndGet() {
+ // Test values
+ String message = "testMessage";
+ String config = "testConfig";
+ String policyName = "testPolicyName";
+ String policyVersion = "1.0";
+ PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
+ PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_RETRIEVED;
+ PolicyType type = PolicyType.JSON;
+ Map<String, String> property = new HashMap<String, String>();
+ PolicyDecision policyDecision = PolicyDecision.PERMIT;
- PDPResponse response = new PDPResponse();
+ PDPResponse response = new PDPResponse();
- response.setStatus(message, policyResponseStatus, policyConfigStatus);
- response.setConfig(config);
- assertEquals(config, response.getConfig());
- response.setType(type);
- assertEquals(type, response.getType());
- response.setPolicyConfigStatus(policyConfigStatus);
- assertEquals(policyConfigStatus, response.getPolicyConfigStatus());
- response.setPolicyConfigMessage(message);
- assertEquals(message, response.getPolicyConfigMessage());
- response.setProperty(property);
- assertEquals(property, response.getProperty());
- response.setPolicyName(policyName);
- assertEquals(policyName, response.getPolicyName());
- response.setPolicyVersion(policyVersion);
- assertEquals(policyVersion, response.getPolicyVersion());
- response.setMatchingConditions(property);
- assertEquals(property, response.getMatchingConditions());
- response.setResponseAttributes(property);
- assertEquals(property, response.getResponseAttributes());
- response.setPolicyResponseStatus(policyResponseStatus);
- assertEquals(policyResponseStatus, response.getPolicyResponseStatus());
- response.setDecision(policyDecision);
- assertEquals(policyDecision, response.getDecision());
- response.setDetails(message);
- assertEquals(message, response.getDetails());
- response.setActionAdvised(property);
- assertEquals(property, response.getActionAdvised());
- response.setActionTaken(property);
- assertEquals(property, response.getActionTaken());
- response.setRequestAttributes(property);
- assertEquals(property, response.getRequestAttributes());
- response.setPolicyResponseMessage(message);
- assertEquals(message, response.getPolicyResponseMessage());
- }
+ response.setStatus(message, policyResponseStatus, policyConfigStatus);
+ response.setConfig(config);
+ assertEquals(config, response.getConfig());
+ response.setType(type);
+ assertEquals(type, response.getType());
+ response.setPolicyConfigStatus(policyConfigStatus);
+ assertEquals(policyConfigStatus, response.getPolicyConfigStatus());
+ response.setPolicyConfigMessage(message);
+ assertEquals(message, response.getPolicyConfigMessage());
+ response.setProperty(property);
+ assertEquals(property, response.getProperty());
+ response.setPolicyName(policyName);
+ assertEquals(policyName, response.getPolicyName());
+ response.setPolicyVersion(policyVersion);
+ assertEquals(policyVersion, response.getPolicyVersion());
+ response.setMatchingConditions(property);
+ assertEquals(property, response.getMatchingConditions());
+ response.setResponseAttributes(property);
+ assertEquals(property, response.getResponseAttributes());
+ response.setPolicyResponseStatus(policyResponseStatus);
+ assertEquals(policyResponseStatus, response.getPolicyResponseStatus());
+ response.setDecision(policyDecision);
+ assertEquals(policyDecision, response.getDecision());
+ response.setDetails(message);
+ assertEquals(message, response.getDetails());
+ response.setActionAdvised(property);
+ assertEquals(property, response.getActionAdvised());
+ response.setActionTaken(property);
+ assertEquals(property, response.getActionTaken());
+ response.setRequestAttributes(property);
+ assertEquals(property, response.getRequestAttributes());
+ response.setPolicyResponseMessage(message);
+ assertEquals(message, response.getPolicyResponseMessage());
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java
index 3461825ac..30bb26bc5 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSParamPolicyServiceTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.Arrays;
@@ -35,7 +34,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
-
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -47,30 +45,30 @@ import org.onap.policy.api.PolicyParameters;
public class BRMSParamPolicyServiceTest {
- BRMSParamPolicyService service = null;
-
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- Properties prop = new Properties();
- prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
- String succeeded = prop.getProperty("xacml.rest.pap.url");
- List<String> paps = Arrays.asList(succeeded.split(","));
- PAPServices.setPaps(paps);
- PAPServices.setJunit(true);
- }
-
- @Before
- public void setUp() throws Exception {
- PolicyParameters policyParameters = new PolicyParameters();
+ BRMSParamPolicyService service = null;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ Properties prop = new Properties();
+ prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
+ String succeeded = prop.getProperty("xacml.rest.pap.url");
+ List<String> paps = Arrays.asList(succeeded.split(","));
+ PAPServices.setPaps(paps);
+ PAPServices.setJunit(true);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
policyParameters.setPolicyName("Test.testBRMSPolicy");
policyParameters.setRequestID(UUID.randomUUID());
- SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateformat3.parse("15/10/2016");
- policyParameters.setTtlDate(date);
- policyParameters.setGuard(true);
- policyParameters.setRiskLevel("5");
- policyParameters.setRiskType("TEST");
+ SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateformat3.parse("15/10/2016");
+ policyParameters.setTtlDate(date);
+ policyParameters.setGuard(true);
+ policyParameters.setRiskLevel("5");
+ policyParameters.setRiskType("TEST");
Map<String, String> ruleAttributes = new HashMap<>();
ruleAttributes.put("templateName", "Sample");
@@ -81,39 +79,37 @@ public class BRMSParamPolicyServiceTest {
attributes.put(AttributeType.RULE, ruleAttributes);
policyParameters.setAttributes(attributes);
- String policyName = "testBRMSPolicy";
- String policyScope = "Test";
- service = new BRMSParamPolicyService(policyName, policyScope, policyParameters, date.toString());
- }
-
- @AfterClass
- public static void tearDownAfterClass() {
- PAPServices.setPaps(null);
- PAPServices.setJunit(false);
- }
-
- @Test
- public final void testFirewallPolicyService() {
- assertNotNull(service);
- }
-
- @Test
- public final void testGetValidation() {
- assertTrue(service.getValidation());
- }
-
- @Test
- public final void testGetMessage() {
- String message = service.getMessage();
- assertNull(message);
- }
-
- @Test
- public final void testGetResult() throws PolicyException {
- service.getValidation();
- String result = service.getResult(false);
- assertEquals("success",result);
- }
-
-
+ String policyName = "testBRMSPolicy";
+ String policyScope = "Test";
+ service = new BRMSParamPolicyService(policyName, policyScope, policyParameters, date.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
+ }
+
+ @Test
+ public final void testFirewallPolicyService() {
+ assertNotNull(service);
+ }
+
+ @Test
+ public final void testGetValidation() {
+ assertTrue(service.getValidation());
+ }
+
+ @Test
+ public final void testGetMessage() {
+ String message = service.getMessage();
+ assertNull(message);
+ }
+
+ @Test
+ public final void testGetResult() throws PolicyException {
+ service.getValidation();
+ String result = service.getResult(false);
+ assertEquals("success", result);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyServiceTest.java
index 8781b827e..5f79d8d79 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyServiceTest.java
@@ -22,14 +22,12 @@
package org.onap.policy.pdp.rest.api.services;
import static org.junit.Assert.assertEquals;
-
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
-
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -72,8 +70,7 @@ public class BRMSRawPolicyServiceTest {
// Set the system property temporarily
System.setProperty(SYSTEM_KEY, "xacml.pdp.properties");
- BRMSRawPolicyService service =
- new BRMSRawPolicyService(testVal, testVal, testParams, testVal);
+ BRMSRawPolicyService service = new BRMSRawPolicyService(testVal, testVal, testParams, testVal);
assertEquals(false, service.getValidation());
assertEquals("PE300 - Data Issue: No Rule Body given", service.getMessage());
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyServiceTest.java
index c21bc9c77..a953137e2 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopFaultPolicyServiceTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* 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.
@@ -20,7 +22,6 @@
package org.onap.policy.pdp.rest.api.services;
import static org.junit.Assert.*;
-
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.Arrays;
@@ -28,7 +29,6 @@ import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -37,61 +37,82 @@ import org.onap.policy.api.PolicyException;
import org.onap.policy.api.PolicyParameters;
public class ClosedLoopFaultPolicyServiceTest {
-
- ClosedLoopFaultPolicyService service = null;
-
- @Before
- public void setUp() throws Exception {
- Properties prop = new Properties();
- prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
- String succeeded = prop.getProperty("xacml.rest.pap.url");
- List<String> paps = Arrays.asList(succeeded.split(","));
- PAPServices.setPaps(paps);
- PAPServices.setJunit(true);
-
- PolicyParameters policyParameters = new PolicyParameters();
- policyParameters.setPolicyConfigType(PolicyConfigType.ClosedLoop_Fault);
- policyParameters.setPolicyName("Test.testCLFaultPolicy");
- policyParameters.setRequestID(UUID.randomUUID());
- SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateformat3.parse("15/10/2016");
- policyParameters.setTtlDate(date);
- policyParameters.setGuard(true);
- policyParameters.setRiskLevel("5");
- policyParameters.setRiskType("TEST");
- policyParameters.setConfigBody("{\"trinity\":true,\"vUSP\":false,\"mcr\":true,\"gamma\":true,\"vDNS\":false,\"geoLink\":\"testing\",\"emailAddress\":\"mm117s@att.com\",\"serviceTypePolicyName\":\"Registration Failure(Trinity)\",\"attributes\":{\"Window\":\"200\",\"Training\":\"123\",\"ConsecutiveIntervalOnset\":\"300\",\"FractionSamplePerDay\":\"30\",\"OnsetMessage\":\"test\",\"PtileLimit\":\"300\",\"PolicyName\":\"testD2ServicesView\",\"AbatementMessage\":\"test\",\"RetryTimer\":\"30\",\"ConsecutiveIntervalAbatement\":\"300\",\"Threshold\":\"120\"},\"templateVersion\":\"1604\",\"onapname\":\"java\"}");
- String policyName = "testCLFaultPolicy";
- String policyScope = "Test";
- service = new ClosedLoopFaultPolicyService(policyName, policyScope, policyParameters, date.toString());
- }
+ ClosedLoopFaultPolicyService service = null;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties prop = new Properties();
+ prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
+ String succeeded = prop.getProperty("xacml.rest.pap.url");
+ List<String> paps = Arrays.asList(succeeded.split(","));
+ PAPServices.setPaps(paps);
+ PAPServices.setJunit(true);
+
+ PolicyParameters policyParameters = new PolicyParameters();
+ policyParameters.setPolicyConfigType(PolicyConfigType.ClosedLoop_Fault);
+ policyParameters.setPolicyName("Test.testCLFaultPolicy");
+ policyParameters.setRequestID(UUID.randomUUID());
+ SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateformat3.parse("15/10/2016");
+ policyParameters.setTtlDate(date);
+ policyParameters.setGuard(true);
+ policyParameters.setRiskLevel("5");
+ policyParameters.setRiskType("TEST");
+ policyParameters.setConfigBody(
+ "{\"trinity\":true,"
+ + "\"vUSP\":false,"
+ + "\"mcr\":true,"
+ + "\"gamma\":true,"
+ + "\"vDNS\":false,"
+ + "\"geoLink\":\"testing\","
+ + "\"emailAddress\":\"mm117s@att.com\","
+ + "\"serviceTypePolicyName\":\"Registration Failure(Trinity)\","
+ + "\"attributes\":{\"Window\":\"200\","
+ + "\"Training\":\"123\","
+ + "\"ConsecutiveIntervalOnset\":\"300\","
+ + "\"FractionSamplePerDay\":\"30\","
+ + "\"OnsetMessage\":\"test\","
+ + "\"PtileLimit\":\"300\","
+ + "\"PolicyName\":\"testD2ServicesView\","
+ + "\"AbatementMessage\":\"test\","
+ + "\"RetryTimer\":\"30\","
+ + "\"ConsecutiveIntervalAbatement\":\"300\","
+ + "\"Threshold\":\"120\"},"
+ + "\"templateVersion\":\"1604\","
+ + "\"onapname\":\"java\"}");
+
+ String policyName = "testCLFaultPolicy";
+ String policyScope = "Test";
+ service = new ClosedLoopFaultPolicyService(policyName, policyScope, policyParameters, date.toString());
+ }
- @After
- public void tearDown() throws Exception {
- PAPServices.setPaps(null);
- PAPServices.setJunit(false);
- }
+ @After
+ public void tearDown() throws Exception {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
+ }
- @Test
- public final void testFirewallPolicyService() {
- assertNotNull(service);
- }
+ @Test
+ public final void testFirewallPolicyService() {
+ assertNotNull(service);
+ }
- @Test
- public final void testGetValidation() {
- assertTrue(service.getValidation());
- }
+ @Test
+ public final void testGetValidation() {
+ assertTrue(service.getValidation());
+ }
- @Test
- public final void testGetMessage() {
- String message = service.getMessage();
- assertNull(message);
- }
+ @Test
+ public final void testGetMessage() {
+ String message = service.getMessage();
+ assertNull(message);
+ }
- @Test
- public final void testGetResult() throws PolicyException {
- service.getValidation();
- String result = service.getResult(false);
- assertEquals("success",result);
- }
+ @Test
+ public final void testGetResult() throws PolicyException {
+ service.getValidation();
+ String result = service.getResult(false);
+ assertEquals("success", result);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyServiceTest.java
index 99dc67742..e2b614eee 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ClosedLoopPMPolicyServiceTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* 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.
@@ -20,7 +22,6 @@
package org.onap.policy.pdp.rest.api.services;
import static org.junit.Assert.*;
-
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.Arrays;
@@ -28,7 +29,6 @@ import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -37,61 +37,70 @@ import org.onap.policy.api.PolicyException;
import org.onap.policy.api.PolicyParameters;
public class ClosedLoopPMPolicyServiceTest {
-
- ClosedLoopPMPolicyService service = null;
-
- @Before
- public void setUp() throws Exception {
- Properties prop = new Properties();
- prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
- String succeeded = prop.getProperty("xacml.rest.pap.url");
- List<String> paps = Arrays.asList(succeeded.split(","));
- PAPServices.setPaps(paps);
- PAPServices.setJunit(true);
-
- PolicyParameters policyParameters = new PolicyParameters();
+
+ ClosedLoopPMPolicyService service = null;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties prop = new Properties();
+ prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
+ String succeeded = prop.getProperty("xacml.rest.pap.url");
+ List<String> paps = Arrays.asList(succeeded.split(","));
+ PAPServices.setPaps(paps);
+ PAPServices.setJunit(true);
+
+ PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.ClosedLoop_PM);
policyParameters.setPolicyName("Test.testCLFaultPolicy");
policyParameters.setRequestID(UUID.randomUUID());
- SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateformat3.parse("15/10/2016");
- policyParameters.setTtlDate(date);
- policyParameters.setGuard(true);
- policyParameters.setRiskLevel("5");
- policyParameters.setRiskType("TEST");
- policyParameters.setConfigBody("{\"trinity\":true,\"vUSP\":false,\"mcr\":true,\"gama\":true,\"vDNS\":false,\"geoLink\":\"testing\",\"emailAddress\":\"mm117s@att.com\",\"serviceTypePolicyName\":\"Registration Failure(Trinity)\",\"attributes\":{\"Window\":\"200\",\"Training\":\"123\",\"ConsecutiveIntervalOnset\":\"300\",\"FractionSamplePerDay\":\"30\",\"OnsetMessage\":\"test\",\"PtileLimit\":\"300\",\"PolicyName\":\"testD2ServicesView\",\"AbatementMessage\":\"test\",\"RetryTimer\":\"30\",\"ConsecutiveIntervalAbatement\":\"300\",\"Threshold\":\"120\"},\"templateVersion\":\"1604\",\"onapname\":\"java\"}");
-
- String policyName = "testCLFaultPolicy";
- String policyScope = "Test";
- service = new ClosedLoopPMPolicyService(policyName, policyScope, policyParameters, date.toString());
- }
+ SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateformat3.parse("15/10/2016");
+ policyParameters.setTtlDate(date);
+ policyParameters.setGuard(true);
+ policyParameters.setRiskLevel("5");
+ policyParameters.setRiskType("TEST");
+ policyParameters.setConfigBody(
+ "{\"trinity\":true,\"vUSP\":false,\"mcr\":true,\"gama\":true,\"vDNS\":false,\"geoLink\":\"testing\","
+ + "\"emailAddress\":\"mm117s@att.com\","
+ + "\"serviceTypePolicyName\":\"Registration Failure(Trinity)\",\"attributes\":"
+ + "{\"Window\":\"200\",\"Training\":\"123\",\"ConsecutiveIntervalOnset\":\"300\","
+ + "\"FractionSamplePerDay\":\"30\",\"OnsetMessage\":\"test\",\"PtileLimit\":\"300\","
+ + "\"PolicyName\":\"testD2ServicesView\",\"AbatementMessage\":\"test\",\"RetryTimer\":\"30\","
+ + "\"ConsecutiveIntervalAbatement\":\"300\",\"Threshold\":\"120\"},"
+ + "\"templateVersion\":\"1604\",\"onapname\":\"java\"}");
+
+ String policyName = "testCLFaultPolicy";
+ String policyScope = "Test";
+ service = new ClosedLoopPMPolicyService(policyName, policyScope, policyParameters,
+ date.toString());
+ }
- @After
- public void tearDown() throws Exception {
- PAPServices.setPaps(null);
- PAPServices.setJunit(false);
- }
+ @After
+ public void tearDown() throws Exception {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
+ }
- @Test
- public final void testFirewallPolicyService() {
- assertNotNull(service);
- }
+ @Test
+ public final void testFirewallPolicyService() {
+ assertNotNull(service);
+ }
- @Test
- public final void testGetValidation() {
- assertTrue(service.getValidation());
- }
+ @Test
+ public final void testGetValidation() {
+ assertTrue(service.getValidation());
+ }
- @Test
- public final void testGetMessage() {
- String message = service.getMessage();
- assertNull(message);
- }
+ @Test
+ public final void testGetMessage() {
+ String message = service.getMessage();
+ assertNull(message);
+ }
- @Test
- public final void testGetResult() throws PolicyException {
- service.getValidation();
- String result = service.getResult(false);
- assertEquals("success",result);
- }
+ @Test
+ public final void testGetResult() throws PolicyException {
+ service.getValidation();
+ String result = service.getResult(false);
+ assertEquals("success", result);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyServiceTest.java
index 5a3a6b387..926f505d8 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyServiceTest.java
@@ -22,14 +22,12 @@
package org.onap.policy.pdp.rest.api.services;
import static org.junit.Assert.assertEquals;
-
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
-
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -37,43 +35,43 @@ import org.onap.policy.api.PolicyParameters;
public class ConfigPolicyServiceTest {
- private static final String SYSTEM_KEY = "xacml.properties";
- private static String oldProperty;
+ private static final String SYSTEM_KEY = "xacml.properties";
+ private static String oldProperty;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- Properties prop = new Properties();
- prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
- String succeeded = prop.getProperty("xacml.rest.pap.url");
- List<String> paps = Arrays.asList(succeeded.split(","));
- PAPServices.setPaps(paps);
- PAPServices.setJunit(true);
- oldProperty = System.getProperty(SYSTEM_KEY);
- }
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ Properties prop = new Properties();
+ prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
+ String succeeded = prop.getProperty("xacml.rest.pap.url");
+ List<String> paps = Arrays.asList(succeeded.split(","));
+ PAPServices.setPaps(paps);
+ PAPServices.setJunit(true);
+ oldProperty = System.getProperty(SYSTEM_KEY);
+ }
- @AfterClass
- public static void tearDownAfterClass() {
- PAPServices.setPaps(null);
- PAPServices.setJunit(false);
- // Restore the original system property
- if (oldProperty != null) {
- System.setProperty(SYSTEM_KEY, oldProperty);
- } else {
- System.clearProperty(SYSTEM_KEY);
- }
- }
+ @AfterClass
+ public static void tearDownAfterClass() {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
+ // Restore the original system property
+ if (oldProperty != null) {
+ System.setProperty(SYSTEM_KEY, oldProperty);
+ } else {
+ System.clearProperty(SYSTEM_KEY);
+ }
+ }
- @Test
- public void testRaw() throws FileNotFoundException, IOException {
+ @Test
+ public void testRaw() throws FileNotFoundException, IOException {
- String testVal = "testVal";
- PolicyParameters testParams = new PolicyParameters();
+ String testVal = "testVal";
+ PolicyParameters testParams = new PolicyParameters();
- // Set the system property temporarily
- System.setProperty(SYSTEM_KEY, "xacml.pdp.properties");
+ // Set the system property temporarily
+ System.setProperty(SYSTEM_KEY, "xacml.pdp.properties");
- ConfigPolicyService service = new ConfigPolicyService(testVal, testVal, testParams, testVal);
- assertEquals(service.getValidation(), false);
- assertEquals(service.getMessage(), "PE300 - Data Issue: No Config Body given.");
- }
+ ConfigPolicyService service = new ConfigPolicyService(testVal, testVal, testParams, testVal);
+ assertEquals(service.getValidation(), false);
+ assertEquals(service.getMessage(), "PE300 - Data Issue: No Config Body given.");
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyServiceTest.java
index 24b8497e3..72c12155f 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyServiceTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* 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.
@@ -41,107 +43,103 @@ import org.onap.policy.api.PolicyParameters;
public class DecisionPolicyServiceTest {
- DecisionPolicyService service = null;
-
- @Before
- public void setUp() throws Exception {
- Properties prop = new Properties();
- prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
- String succeeded = prop.getProperty("xacml.rest.pap.url");
- List<String> paps = Arrays.asList(succeeded.split(","));
- PAPServices.setPaps(paps);
- PAPServices.setJunit(true);
-
- PolicyParameters policyParameters = new PolicyParameters();
- policyParameters.setPolicyClass(PolicyClass.Decision);
- policyParameters.setPolicyName("Test.testDecisionPolicy");
- policyParameters.setOnapName("MSO");
- policyParameters
- .setPolicyDescription("This is a sample Decision policy UPDATE example with Settings");
-
- Map<String, String> configAttributes = new HashMap<>();
- configAttributes.put("Template", "UpdateTemplate");
- configAttributes.put("controller", "default");
- configAttributes.put("SamPoll", "30");
- configAttributes.put("value", "abcd");
- Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
- attributes.put(AttributeType.MATCHING, configAttributes);
- Map<String, String> settingsMap = new HashMap<>();
- settingsMap.put("server", "5");
- attributes.put(AttributeType.SETTINGS, settingsMap);
- policyParameters.setAttributes(attributes);
-
- List<String> dynamicRuleAlgorithmLabels = new LinkedList<>();
- List<String> dynamicRuleAlgorithmFunctions = new LinkedList<>();
- List<String> dynamicRuleAlgorithmField1 = new LinkedList<>();
- List<String> dynamicRuleAlgorithmField2 = new LinkedList<>();
- dynamicRuleAlgorithmLabels = Arrays.asList("A1", "A2", "A3", "A4", "A5", "A6", "A7");
- dynamicRuleAlgorithmField1 =
- Arrays.asList("S_server", "cap", "cobal", "A2", "Config", "A4", "A1");
- dynamicRuleAlgorithmFunctions = Arrays.asList("integer-equal", "string-contains",
- "integer-equal", "and", "integer-greater-than", "or", "and");
- dynamicRuleAlgorithmField2 = Arrays.asList("90", "ca", "90", "A3", "45", "A5", "A6");
- policyParameters.setDynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels);
- policyParameters.setDynamicRuleAlgorithmField1(dynamicRuleAlgorithmField1);
- policyParameters.setDynamicRuleAlgorithmFunctions(dynamicRuleAlgorithmFunctions);
- policyParameters.setDynamicRuleAlgorithmField2(dynamicRuleAlgorithmField2);
-
- policyParameters.setRequestID(UUID.randomUUID());
- policyParameters.setGuard(true);
- policyParameters.setRiskLevel("5");
- policyParameters.setRiskType("TEST");
- String policyName = "testDecisionPolicy";
- String policyScope = "Test";
- service = new DecisionPolicyService(policyName, policyScope, policyParameters);
- }
-
- @After
- public void tearDown() throws Exception {
- PAPServices.setPaps(null);
- PAPServices.setJunit(false);
- }
-
- @Test
- public final void testDecisionPolicyService() {
- assertNotNull(service);
- }
-
- @Test
- public final void testGetValidation() {
- assertTrue(service.getValidation());
- }
-
- @Test
- public final void testGetMessage() {
- String message = service.getMessage();
- assertNull(message);
- }
-
- @Test
- public final void testGetResult() throws PolicyException {
- service.getValidation();
- String result = service.getResult(false);
- assertEquals("success", result);
- }
-
- @Test
- public void testExtraPaths() throws PolicyException {
- // Set up test data
- String value = "testVal";
- PolicyParameters params = new PolicyParameters();
- Map<AttributeType, Map<String, String>> attributes =
- new HashMap<AttributeType, Map<String, String>>();
- // attributes.put(AttributeType.MATCHING, null);
- attributes.put(AttributeType.SETTINGS, null);
- params.setAttributes(attributes);
- DecisionPolicyService service = new DecisionPolicyService(value, value, params);
-
- // Negative test methods
- assertEquals(false, service.getValidation());
- assertEquals("success", service.getResult(true));
- attributes.remove(AttributeType.SETTINGS);
- attributes.put(AttributeType.MATCHING, null);
- assertEquals("success", service.getResult(true));
- }
-
+ DecisionPolicyService service = null;
+
+ @Before
+ public void setUp() throws Exception {
+ Properties prop = new Properties();
+ prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
+ String succeeded = prop.getProperty("xacml.rest.pap.url");
+ List<String> paps = Arrays.asList(succeeded.split(","));
+ PAPServices.setPaps(paps);
+ PAPServices.setJunit(true);
+
+ PolicyParameters policyParameters = new PolicyParameters();
+ policyParameters.setPolicyClass(PolicyClass.Decision);
+ policyParameters.setPolicyName("Test.testDecisionPolicy");
+ policyParameters.setOnapName("MSO");
+ policyParameters.setPolicyDescription("This is a sample Decision policy UPDATE example with Settings");
+
+ Map<String, String> configAttributes = new HashMap<>();
+ configAttributes.put("Template", "UpdateTemplate");
+ configAttributes.put("controller", "default");
+ configAttributes.put("SamPoll", "30");
+ configAttributes.put("value", "abcd");
+ Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
+ attributes.put(AttributeType.MATCHING, configAttributes);
+ Map<String, String> settingsMap = new HashMap<>();
+ settingsMap.put("server", "5");
+ attributes.put(AttributeType.SETTINGS, settingsMap);
+ policyParameters.setAttributes(attributes);
+
+ List<String> dynamicRuleAlgorithmLabels = new LinkedList<>();
+ List<String> dynamicRuleAlgorithmFunctions = new LinkedList<>();
+ List<String> dynamicRuleAlgorithmField1 = new LinkedList<>();
+ List<String> dynamicRuleAlgorithmField2 = new LinkedList<>();
+ dynamicRuleAlgorithmLabels = Arrays.asList("A1", "A2", "A3", "A4", "A5", "A6", "A7");
+ dynamicRuleAlgorithmField1 = Arrays.asList("S_server", "cap", "cobal", "A2", "Config", "A4", "A1");
+ dynamicRuleAlgorithmFunctions = Arrays.asList("integer-equal", "string-contains", "integer-equal", "and",
+ "integer-greater-than", "or", "and");
+ dynamicRuleAlgorithmField2 = Arrays.asList("90", "ca", "90", "A3", "45", "A5", "A6");
+ policyParameters.setDynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels);
+ policyParameters.setDynamicRuleAlgorithmField1(dynamicRuleAlgorithmField1);
+ policyParameters.setDynamicRuleAlgorithmFunctions(dynamicRuleAlgorithmFunctions);
+ policyParameters.setDynamicRuleAlgorithmField2(dynamicRuleAlgorithmField2);
+
+ policyParameters.setRequestID(UUID.randomUUID());
+ policyParameters.setGuard(true);
+ policyParameters.setRiskLevel("5");
+ policyParameters.setRiskType("TEST");
+ String policyName = "testDecisionPolicy";
+ String policyScope = "Test";
+ service = new DecisionPolicyService(policyName, policyScope, policyParameters);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
+ }
+
+ @Test
+ public final void testDecisionPolicyService() {
+ assertNotNull(service);
+ }
+
+ @Test
+ public final void testGetValidation() {
+ assertTrue(service.getValidation());
+ }
+
+ @Test
+ public final void testGetMessage() {
+ String message = service.getMessage();
+ assertNull(message);
+ }
+
+ @Test
+ public final void testGetResult() throws PolicyException {
+ service.getValidation();
+ String result = service.getResult(false);
+ assertEquals("success", result);
+ }
+
+ @Test
+ public void testExtraPaths() throws PolicyException {
+ // Set up test data
+ String value = "testVal";
+ PolicyParameters params = new PolicyParameters();
+ Map<AttributeType, Map<String, String>> attributes = new HashMap<AttributeType, Map<String, String>>();
+ // attributes.put(AttributeType.MATCHING, null);
+ attributes.put(AttributeType.SETTINGS, null);
+ params.setAttributes(attributes);
+ DecisionPolicyService service = new DecisionPolicyService(value, value, params);
+
+ // Negative test methods
+ assertEquals(false, service.getValidation());
+ assertEquals("success", service.getResult(true));
+ attributes.remove(AttributeType.SETTINGS);
+ attributes.put(AttributeType.MATCHING, null);
+ assertEquals("success", service.getResult(true));
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyServiceTest.java
index ccedd7553..348ba754c 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyServiceTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* 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.
@@ -37,59 +39,58 @@ import org.onap.policy.api.PolicyParameters;
public class FirewallPolicyServiceTest {
FirewallPolicyService firewallPolicyService = null;
-
-
- @Before
- public void setUp() throws Exception {
- Properties prop = new Properties();
- prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
- String succeeded = prop.getProperty("xacml.rest.pap.url");
- List<String> paps = Arrays.asList(succeeded.split(","));
- PAPServices.setPaps(paps);
- PAPServices.setJunit(true);
-
- PolicyParameters policyParameters = new PolicyParameters();
- policyParameters.setPolicyConfigType(PolicyConfigType.Firewall); //required
- policyParameters.setPolicyName("Test.testFWPolicy"); //required
+
+ @Before
+ public void setUp() throws Exception {
+ Properties prop = new Properties();
+ prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
+ String succeeded = prop.getProperty("xacml.rest.pap.url");
+ List<String> paps = Arrays.asList(succeeded.split(","));
+ PAPServices.setPaps(paps);
+ PAPServices.setJunit(true);
+
+ PolicyParameters policyParameters = new PolicyParameters();
+ policyParameters.setPolicyConfigType(PolicyConfigType.Firewall); // required
+ policyParameters.setPolicyName("Test.testFWPolicy"); // required
policyParameters.setRequestID(UUID.randomUUID());
- SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateformat3.parse("15/10/2016");
- policyParameters.setTtlDate(date);
- policyParameters.setGuard(true);
- policyParameters.setRiskLevel("5");
- policyParameters.setRiskType("TEST");
- policyParameters.setConfigBody("{\"configName\":\"test\"}");
- String policyName = "testFWPolicy";
- String policyScope = "Test";
+ SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateformat3.parse("15/10/2016");
+ policyParameters.setTtlDate(date);
+ policyParameters.setGuard(true);
+ policyParameters.setRiskLevel("5");
+ policyParameters.setRiskType("TEST");
+ policyParameters.setConfigBody("{\"configName\":\"test\"}");
+ String policyName = "testFWPolicy";
+ String policyScope = "Test";
firewallPolicyService = new FirewallPolicyService(policyName, policyScope, policyParameters, date.toString());
- }
+ }
- @After
- public void tearDown() throws Exception {
- PAPServices.setPaps(null);
- PAPServices.setJunit(false);
- }
+ @After
+ public void tearDown() throws Exception {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
+ }
- @Test
- public final void testFirewallPolicyService() {
- assertNotNull(firewallPolicyService);
- }
+ @Test
+ public final void testFirewallPolicyService() {
+ assertNotNull(firewallPolicyService);
+ }
- @Test
- public final void testGetValidation() {
- assertTrue(firewallPolicyService.getValidation());
- }
+ @Test
+ public final void testGetValidation() {
+ assertTrue(firewallPolicyService.getValidation());
+ }
- @Test
- public final void testGetMessage() {
- String message = firewallPolicyService.getMessage();
- assertNull(message);
- }
+ @Test
+ public final void testGetMessage() {
+ String message = firewallPolicyService.getMessage();
+ assertNull(message);
+ }
- @Test
- public final void testGetResult() throws PolicyException {
- firewallPolicyService.getValidation();
- String result = firewallPolicyService.getResult(false);
- assertEquals("success",result);
- }
+ @Test
+ public final void testGetResult() throws PolicyException {
+ firewallPolicyService.getValidation();
+ String result = firewallPolicyService.getResult(false);
+ assertEquals("success", result);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyServiceTest.java
index e460a853b..f80371a4f 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/MicroServicesPolicyServiceTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* 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.
@@ -20,7 +22,6 @@
package org.onap.policy.pdp.rest.api.services;
import static org.junit.Assert.*;
-
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.Arrays;
@@ -28,7 +29,6 @@ import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -40,59 +40,58 @@ public class MicroServicesPolicyServiceTest {
MicroServicesPolicyService service = null;
- @Before
- public void setUp() throws Exception {
- Properties prop = new Properties();
- prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
- String succeeded = prop.getProperty("xacml.rest.pap.url");
- List<String> paps = Arrays.asList(succeeded.split(","));
- PAPServices.setPaps(paps);
- PAPServices.setJunit(true);
-
- PolicyParameters policyParameters = new PolicyParameters();
+ @Before
+ public void setUp() throws Exception {
+ Properties prop = new Properties();
+ prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
+ String succeeded = prop.getProperty("xacml.rest.pap.url");
+ List<String> paps = Arrays.asList(succeeded.split(","));
+ PAPServices.setPaps(paps);
+ PAPServices.setJunit(true);
+
+ PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
policyParameters.setPolicyName("Test.testMSPolicy");
- policyParameters.setOnapName("DCAE");
+ policyParameters.setOnapName("DCAE");
policyParameters.setRequestID(UUID.randomUUID());
- SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateformat3.parse("15/10/2016");
- policyParameters.setTtlDate(date);
- policyParameters.setGuard(true);
- policyParameters.setRiskLevel("5");
- policyParameters.setRiskType("TEST");
- policyParameters.setConfigBody("{\"configName\":\"test\"}");
- String policyName = "testMSPolicy";
- String policyScope = "Test";
- service = new MicroServicesPolicyService(policyName, policyScope, policyParameters, date.toString());
- }
-
- @After
- public void tearDown() throws Exception {
- PAPServices.setPaps(null);
- PAPServices.setJunit(false);
- }
+ SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateformat3.parse("15/10/2016");
+ policyParameters.setTtlDate(date);
+ policyParameters.setGuard(true);
+ policyParameters.setRiskLevel("5");
+ policyParameters.setRiskType("TEST");
+ policyParameters.setConfigBody("{\"configName\":\"test\"}");
+ String policyName = "testMSPolicy";
+ String policyScope = "Test";
+ service = new MicroServicesPolicyService(policyName, policyScope, policyParameters, date.toString());
+ }
- @Test
- public final void testFirewallPolicyService() {
- assertNotNull(service);
- }
+ @After
+ public void tearDown() throws Exception {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
+ }
- @Test
- public final void testGetValidation() {
- assertTrue(service.getValidation());
- }
+ @Test
+ public final void testFirewallPolicyService() {
+ assertNotNull(service);
+ }
- @Test
- public final void testGetMessage() {
- String message = service.getMessage();
- assertNull(message);
- }
+ @Test
+ public final void testGetValidation() {
+ assertTrue(service.getValidation());
+ }
- @Test
- public final void testGetResult() throws PolicyException {
- service.getValidation();
- String result = service.getResult(false);
- assertEquals("success",result);
- }
+ @Test
+ public final void testGetMessage() {
+ String message = service.getMessage();
+ assertNull(message);
+ }
+ @Test
+ public final void testGetResult() throws PolicyException {
+ service.getValidation();
+ String result = service.getResult(false);
+ assertEquals("success", result);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyServiceTest.java
index 5a4195b79..76cc92290 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/OptimizationPolicyServiceTest.java
@@ -24,7 +24,6 @@ package org.onap.policy.pdp.rest.api.services;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.Arrays;
@@ -32,7 +31,6 @@ import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
-
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -43,58 +41,57 @@ import org.onap.policy.api.PolicyParameters;
public class OptimizationPolicyServiceTest {
- OptimizationPolicyService service = null;
+ OptimizationPolicyService service = null;
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- Properties prop = new Properties();
- prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
- String succeeded = prop.getProperty("xacml.rest.pap.url");
- List<String> paps = Arrays.asList(succeeded.split(","));
- PAPServices.setPaps(paps);
- PAPServices.setJunit(true);
- }
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ Properties prop = new Properties();
+ prop.load(new FileInputStream("src/test/resources/pass.xacml.pdp.properties"));
+ String succeeded = prop.getProperty("xacml.rest.pap.url");
+ List<String> paps = Arrays.asList(succeeded.split(","));
+ PAPServices.setPaps(paps);
+ PAPServices.setJunit(true);
+ }
- @Before
- public void setUp() throws Exception {
- PolicyParameters policyParameters = new PolicyParameters();
+ @Before
+ public void setUp() throws Exception {
+ PolicyParameters policyParameters = new PolicyParameters();
policyParameters.setPolicyConfigType(PolicyConfigType.Optimization);
policyParameters.setPolicyName("Test.testOOFPolicy");
- policyParameters.setOnapName("OOF");
+ policyParameters.setOnapName("OOF");
policyParameters.setRequestID(UUID.randomUUID());
- SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
- Date date = dateformat3.parse("15/10/2016");
- policyParameters.setTtlDate(date);
- policyParameters.setGuard(true);
- policyParameters.setRiskLevel("5");
- policyParameters.setRiskType("TEST");
- policyParameters.setConfigBody("{\"optimization\":\"test\"}");
- String policyName = "testOOFPolicy";
- String policyScope = "Test";
- service = new OptimizationPolicyService(policyName, policyScope, policyParameters, date.toString());
- }
-
- @AfterClass
- public static void tearDownAfterClass() {
- PAPServices.setPaps(null);
- PAPServices.setJunit(false);
- }
+ SimpleDateFormat dateformat3 = new SimpleDateFormat("dd/MM/yyyy");
+ Date date = dateformat3.parse("15/10/2016");
+ policyParameters.setTtlDate(date);
+ policyParameters.setGuard(true);
+ policyParameters.setRiskLevel("5");
+ policyParameters.setRiskType("TEST");
+ policyParameters.setConfigBody("{\"optimization\":\"test\"}");
+ String policyName = "testOOFPolicy";
+ String policyScope = "Test";
+ service = new OptimizationPolicyService(policyName, policyScope, policyParameters, date.toString());
+ }
- @Test
- public final void testOptimizationPolicyService() {
- assertNotNull(service);
- }
+ @AfterClass
+ public static void tearDownAfterClass() {
+ PAPServices.setPaps(null);
+ PAPServices.setJunit(false);
+ }
- @Test
- public final void testGetMessage() {
- String message = service.getMessage();
- assertNull(message);
- }
+ @Test
+ public final void testOptimizationPolicyService() {
+ assertNotNull(service);
+ }
- @Test
- public final void testGetResult() throws PolicyException {
- String result = service.getResult(false);
- assertEquals("success",result);
- }
+ @Test
+ public final void testGetMessage() {
+ String message = service.getMessage();
+ assertNull(message);
+ }
+ @Test
+ public final void testGetResult() throws PolicyException {
+ String result = service.getResult(false);
+ assertEquals("success", result);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PAPServicesTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PAPServicesTest.java
index 09014cc3d..d74d0a28a 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PAPServicesTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PAPServicesTest.java
@@ -1,9 +1,11 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* 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
@@ -20,13 +22,11 @@
package org.onap.policy.pdp.rest.api.services;
import static org.junit.Assert.*;
-
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -47,7 +47,6 @@ public class PAPServicesTest {
List<String> paps = Arrays.asList(succeeded.split(","));
PAPServices.setPaps(paps);
papServices = new PAPServices();
-
}
@After
@@ -60,23 +59,22 @@ public class PAPServicesTest {
public final void testCallPAP() throws PolicyException {
StdPAPPolicy newPAPPolicy = new StdPAPPolicy();
String response = null;
- response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=create", "apiflag=api",
- "policyType=Config"}, UUID.randomUUID(), "Config");
+ response = (String) papServices.callPAP(newPAPPolicy,
+ new String[] {"operation=create", "apiflag=api", "policyType=Config"}, UUID.randomUUID(), "Config");
assertEquals("success", response);
}
@Test
public final void testGetActiveVersion() {
- String activeVersion = papServices.getActiveVersion("test", "Config_", "test.testpolicy", "Config",
- UUID.randomUUID());
+ String activeVersion =
+ papServices.getActiveVersion("test", "Config_", "test.testpolicy", "Config", UUID.randomUUID());
assertNull(activeVersion);
}
@Test
public final void testPushPolicy() throws PolicyException {
- StdPDPPolicy selectedPolicy = papServices.pushPolicy("test", "Config_", "test.testpolicy", "Config", "default"
- , UUID.randomUUID());
+ StdPDPPolicy selectedPolicy =
+ papServices.pushPolicy("test", "Config_", "test.testpolicy", "Config", "default", UUID.randomUUID());
assertNull(selectedPolicy);
}
-
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PDPServicesTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PDPServicesTest.java
index 4e8a0fa4a..5b660bf7d 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PDPServicesTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PDPServicesTest.java
@@ -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.
@@ -24,17 +26,13 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.Map.Entry;
-
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
-
import org.junit.*;
import org.junit.runner.RunWith;
-
import static org.junit.Assert.*;
-
import org.onap.policy.api.DecisionRequestParameters;
import org.onap.policy.api.PolicyDecisionException;
import org.onap.policy.pdp.rest.api.models.PDPResponse;
@@ -47,148 +45,136 @@ import org.springframework.test.context.web.WebAppConfiguration;
@ContextConfiguration(classes = {PDPRestConfig.class})
@WebAppConfiguration
public class PDPServicesTest {
- /**
- * Run the PDPServices() constructor test.
- *
- * @generatedBy CodePro at 7/20/17 9:26 AM
- */
- @Test
- public void testPDPServices_1()
- throws Exception {
- PDPServices result = new PDPServices();
- assertNotNull(result);
- // add additional test code here
- }
-
- /**
- * Run the Collection<PDPResponse> generateRequest(String,UUID,boolean,boolean) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 7/20/17 9:26 AM
- */
- @Test
- public void testGenerateRequest_1()
- throws Exception {
- DecisionRequestParameters pep = new DecisionRequestParameters();
- Map<String,String> eventAttributes = new HashMap<>();
- eventAttributes.put("TEST", "test");
- pep.setOnapName("te123");
- pep.setDecisionAttributes(eventAttributes);
- PDPServices fixture = new PDPServices();
-
- //Failure Tests.
- String jsonString = getModel(pep).toString();
- UUID requestID = UUID.randomUUID();
-
- Collection<PDPResponse> result = fixture.generateRequest(jsonString, requestID, false, true);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.pdp.rest.api.services.PDPServices
- assertNotNull(result);
-
- }
-
- private JsonObject getModel(DecisionRequestParameters pep) throws PolicyDecisionException{
+ /**
+ * Run the PDPServices() constructor test.
+ *
+ * @generatedBy CodePro at 7/20/17 9:26 AM
+ */
+ @Test
+ public void testPDPServices_1() throws Exception {
+ PDPServices result = new PDPServices();
+ assertNotNull(result);
+ // add additional test code here
+ }
+
+ /**
+ * Run the Collection<PDPResponse> generateRequest(String,UUID,boolean,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 7/20/17 9:26 AM
+ */
+ @Test
+ public void testGenerateRequest_1() throws Exception {
+ DecisionRequestParameters pep = new DecisionRequestParameters();
+ Map<String, String> eventAttributes = new HashMap<>();
+ eventAttributes.put("TEST", "test");
+ pep.setOnapName("te123");
+ pep.setDecisionAttributes(eventAttributes);
+ PDPServices fixture = new PDPServices();
+
+ // Failure Tests.
+ String jsonString = getModel(pep).toString();
+ UUID requestID = UUID.randomUUID();
+
+ Collection<PDPResponse> result = fixture.generateRequest(jsonString, requestID, false, true);
+
+ // add additional test code here
+ // An unexpected exception was thrown in user code while executing this test:
+ // java.lang.NoClassDefFoundError: Could not initialize class
+ // org.onap.policy.pdp.rest.api.services.PDPServices
+ assertNotNull(result);
+
+ }
+
+ private JsonObject getModel(DecisionRequestParameters pep) throws PolicyDecisionException {
JsonArrayBuilder resourceArray = Json.createArrayBuilder();
-
+
Map<String, String> decisionAttributes = pep.getDecisionAttributes();
- for (Entry<String,String> key : decisionAttributes.entrySet()) {
+ for (Entry<String, String> key : decisionAttributes.entrySet()) {
JsonObjectBuilder resourceBuilder = Json.createObjectBuilder();
if (key.getValue().matches("[0-9]+")) {
-
- if ((key.getKey().equals("ErrorCode")) || (key.getKey().equals("WorkStep"))) {
-
- resourceBuilder.add("Value", key.getValue());
- } else {
-
+ if ((key.getKey().equals("ErrorCode")) || (key.getKey().equals("WorkStep"))) {
+
+ resourceBuilder.add("Value", key.getValue());
+
+ } else {
+
int val = Integer.parseInt(key.getValue());
resourceBuilder.add("Value", val);
-
- }
-
+
+ }
+
} else {
resourceBuilder.add("Value", key.getValue());
}
resourceBuilder.add("AttributeId", key.getKey());
resourceArray.add(resourceBuilder);
}
- return Json.createObjectBuilder()
- .add("Request", Json.createObjectBuilder()
- .add("AccessSubject", Json.createObjectBuilder()
- .add("Attribute", Json.createObjectBuilder()
- .add("Value", pep.getOnapName())
- .add("AttributeId", "ONAPName")))
- .add("Resource", Json.createObjectBuilder()
- .add("Attribute", resourceArray))
- .add("Action", Json.createObjectBuilder()
- .add("Attribute", Json.createObjectBuilder()
- .add("Value", "DECIDE")
- .add("AttributeId", "urn:oasis:names:tc:xacml:1.0:action:action-id"))))
+ return Json.createObjectBuilder().add("Request", Json.createObjectBuilder().add("AccessSubject",
+ Json.createObjectBuilder().add("Attribute",
+ Json.createObjectBuilder().add("Value", pep.getOnapName()).add("AttributeId", "ONAPName")))
+ .add("Resource", Json.createObjectBuilder().add("Attribute", resourceArray))
+ .add("Action", Json.createObjectBuilder().add("Attribute", Json.createObjectBuilder()
+ .add("Value", "DECIDE").add("AttributeId", "urn:oasis:names:tc:xacml:1.0:action:action-id"))))
.build();
}
-
- /**
- * Run the Collection<PDPResponse> generateRequest(String,UUID,boolean,boolean) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 7/20/17 9:26 AM
- */
- @Test(expected = org.onap.policy.api.PolicyException.class)
- public void testGenerateRequest_2()
- throws Exception {
- PDPServices fixture = new PDPServices();
- fixture.generateRequest("", UUID.randomUUID(), true, true);
- String jsonString = "";
- UUID requestID = UUID.randomUUID();
- boolean unique = true;
- boolean decide = true;
-
- Collection<PDPResponse> result = fixture.generateRequest(jsonString, requestID, unique, decide);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 7/20/17 9:26 AM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 7/20/17 9:26 AM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 7/20/17 9:26 AM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PDPServicesTest.class);
- }
-} \ No newline at end of file
+
+ /**
+ * Run the Collection<PDPResponse> generateRequest(String,UUID,boolean,boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 7/20/17 9:26 AM
+ */
+ @Test(expected = org.onap.policy.api.PolicyException.class)
+ public void testGenerateRequest_2() throws Exception {
+ PDPServices fixture = new PDPServices();
+ fixture.generateRequest("", UUID.randomUUID(), true, true);
+ String jsonString = "";
+ UUID requestID = UUID.randomUUID();
+ boolean unique = true;
+ boolean decide = true;
+
+ Collection<PDPResponse> result = fixture.generateRequest(jsonString, requestID, unique, decide);
+
+ // add additional test code here
+ assertNotNull(result);
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 7/20/17 9:26 AM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 7/20/17 9:26 AM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 7/20/17 9:26 AM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PDPServicesTest.class);
+ }
+}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PolicyEngineImportServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PolicyEngineImportServiceTest.java
index 9a90cc4fa..3275d8c47 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PolicyEngineImportServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/services/PolicyEngineImportServiceTest.java
@@ -1,9 +1,11 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* 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
@@ -25,30 +27,30 @@ import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
public class PolicyEngineImportServiceTest {
- @Test
- public final void negativeTestService1() {
- // Negative test constructor
- String json = "testJson";
- MultipartFile file = null;
- String id = "testID";
- PolicyEngineImportService service = new PolicyEngineImportService(json, file, id);
-
- // Test gets
- assertNotNull(service.getResult());
- assertEquals(service.getResponseCode().value(), 400);
- }
+ @Test
+ public final void negativeTestService1() {
+ // Negative test constructor
+ String json = "testJson";
+ MultipartFile file = null;
+ String id = "testID";
+ PolicyEngineImportService service = new PolicyEngineImportService(json, file, id);
+
+ // Test gets
+ assertNotNull(service.getResult());
+ assertEquals(service.getResponseCode().value(), 400);
+ }
+
+ @Test
+ public final void negativeTestService2() {
+ // Negative test constructor
+ String json = "{\n\"serviceName\": \"testVal\"\n}\n";
+ byte[] content = "bar".getBytes();
+ MultipartFile file = new MockMultipartFile("foo", content);
+ String id = "testID";
+ PolicyEngineImportService service = new PolicyEngineImportService(json, file, id);
- @Test
- public final void negativeTestService2() {
- // Negative test constructor
- String json = "{\n\"serviceName\": \"testVal\"\n}\n";
- byte[] content = "bar".getBytes();
- MultipartFile file = new MockMultipartFile("foo", content);
- String id = "testID";
- PolicyEngineImportService service = new PolicyEngineImportService(json, file, id);
-
- // Test gets
- assertNotNull(service.getResult());
- assertEquals(service.getResponseCode().value(), 400);
- }
+ // Test gets
+ assertNotNull(service.getResult());
+ assertEquals(service.getResponseCode().value(), 400);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetConfigServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetConfigServiceTest.java
index a3c1b2b05..61d37dca4 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetConfigServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetConfigServiceTest.java
@@ -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.
@@ -20,7 +22,6 @@
package org.onap.policy.pdp.rest.api.test;
import static org.junit.Assert.assertEquals;
-
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
@@ -28,7 +29,6 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-
import org.junit.Test;
import org.onap.policy.api.ConfigRequestParameters;
import org.onap.policy.api.PolicyConfigStatus;
@@ -36,35 +36,38 @@ import org.onap.policy.pdp.rest.api.models.PolicyConfig;
import org.onap.policy.pdp.rest.api.services.GetConfigService;
public class GetConfigServiceTest {
- private static final String TEST = "test";
-
- @SuppressWarnings("unchecked")
- @Test
- public void filterMethodTest() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
- ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
- GetConfigService getConfigService= new GetConfigService(configRequestParameters, null);
- Method filter = GetConfigService.class.getDeclaredMethod("filterResults", Collection.class,ConfigRequestParameters.class);
- filter.setAccessible(true);
- List<PolicyConfig> policyConfigs = new LinkedList<>();
-
- List<PolicyConfig> filterResults = (List<PolicyConfig>) filter.invoke(getConfigService, policyConfigs,configRequestParameters);
- assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus());
- // Check again with some values
- configRequestParameters.setPolicyName(TEST);
- configRequestParameters.setOnapName(TEST);
- configRequestParameters.setConfigName(TEST);
- Map<String,String> configAttributes = new HashMap<>();
- configAttributes.put(TEST, TEST);
- configRequestParameters.setConfigAttributes(configAttributes);
- PolicyConfig pConfig = new PolicyConfig();
- pConfig.setPolicyName(TEST);
- Map<String,String> matching = new HashMap<>();
- matching.put("ONAPName", TEST);
- matching.put("ConfigName", TEST);
- matching.put("TEST", TEST);
- pConfig.setMatchingConditions(matching);
- policyConfigs.add(pConfig);
- filterResults = (List<PolicyConfig>) filter.invoke(getConfigService, policyConfigs,configRequestParameters);
- assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus());
- }
+ private static final String TEST = "test";
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void filterMethodTest() throws NoSuchMethodException, SecurityException, IllegalAccessException,
+ IllegalArgumentException, InvocationTargetException {
+ ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
+ GetConfigService getConfigService = new GetConfigService(configRequestParameters, null);
+ Method filter = GetConfigService.class.getDeclaredMethod("filterResults", Collection.class,
+ ConfigRequestParameters.class);
+ filter.setAccessible(true);
+ List<PolicyConfig> policyConfigs = new LinkedList<>();
+
+ List<PolicyConfig> filterResults =
+ (List<PolicyConfig>) filter.invoke(getConfigService, policyConfigs, configRequestParameters);
+ assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus());
+ // Check again with some values
+ configRequestParameters.setPolicyName(TEST);
+ configRequestParameters.setOnapName(TEST);
+ configRequestParameters.setConfigName(TEST);
+ Map<String, String> configAttributes = new HashMap<>();
+ configAttributes.put(TEST, TEST);
+ configRequestParameters.setConfigAttributes(configAttributes);
+ PolicyConfig pConfig = new PolicyConfig();
+ pConfig.setPolicyName(TEST);
+ Map<String, String> matching = new HashMap<>();
+ matching.put("ONAPName", TEST);
+ matching.put("ConfigName", TEST);
+ matching.put("TEST", TEST);
+ pConfig.setMatchingConditions(matching);
+ policyConfigs.add(pConfig);
+ filterResults = (List<PolicyConfig>) filter.invoke(getConfigService, policyConfigs, configRequestParameters);
+ assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus());
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java
index dcff39b88..682c9a1e0 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/GetDictionaryServiceTest.java
@@ -29,202 +29,207 @@ import org.onap.policy.pdp.rest.api.services.GetDictionaryService;
public class GetDictionaryServiceTest {
- @Test
- public void dictionaryJsonTest() throws Exception{
- Method formatDictionary = GetDictionaryService.class.getDeclaredMethod("formatDictionaryJson", String.class);
- formatDictionary.setAccessible(true);
- String input="{\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
- + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
- + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"}";
- DictionaryParameters dp = new DictionaryParameters();
- dp.setDictionary("test");
- GetDictionaryService gds = new GetDictionaryService(dp, null);
- String result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("OnapName");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("Attribute");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("Action");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("BRMSParamTemplate");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("VSCLAction");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("VNFType");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("PEPOptions");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("Varbind");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("Service");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("Site");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("Settings");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("DescriptiveScope");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("Enforcer");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("ActionList");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("ProtocolList");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("Zone");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("SecurityZone");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("PrefixList");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("AddressGroup");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("ServiceGroup");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("ServiceList");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("TermList");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("RuleList");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("FirewallRuleList");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("Term");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("MicroServiceLocation");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("MicroServiceConfigName");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("DCAEUUID");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("MicroServiceModels");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("PolicyScopeService");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("PolicyScopeResource");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("PolicyScopeType");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("PolicyScopeClosedLoop");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("GroupPolicyScopeList");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("RiskType");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("SafePolicyWarning");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- //
- dp.setDictionary("MicroServiceDictionary");
- gds = new GetDictionaryService(dp, null);
- result = (String) formatDictionary.invoke(gds, input);
- assertNotNull(result);
- }
+ @Test
+ public void dictionaryJsonTest() throws Exception {
+ Method formatDictionary =
+ GetDictionaryService.class.getDeclaredMethod("formatDictionaryJson", String.class);
+ formatDictionary.setAccessible(true);
+ String input =
+ "{\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
+ + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
+ + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
+ + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
+ + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\",\"key\":\"value\","
+ + "\"key\":\"value\",\"key\":\"value\",\"key\":\"value\"}";
+ DictionaryParameters dp = new DictionaryParameters();
+ dp.setDictionary("test");
+ GetDictionaryService gds = new GetDictionaryService(dp, null);
+ String result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("OnapName");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("Attribute");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("Action");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("BRMSParamTemplate");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("VSCLAction");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("VNFType");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("PEPOptions");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("Varbind");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("Service");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("Site");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("Settings");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("DescriptiveScope");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("Enforcer");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("ActionList");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("ProtocolList");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("Zone");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("SecurityZone");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("PrefixList");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("AddressGroup");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("ServiceGroup");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("ServiceList");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("TermList");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("RuleList");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("FirewallRuleList");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("Term");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("MicroServiceLocation");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("MicroServiceConfigName");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("DCAEUUID");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("MicroServiceModels");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("PolicyScopeService");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("PolicyScopeResource");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("PolicyScopeType");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("PolicyScopeClosedLoop");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("GroupPolicyScopeList");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("RiskType");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("SafePolicyWarning");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ //
+ dp.setDictionary("MicroServiceDictionary");
+ gds = new GetDictionaryService(dp, null);
+ result = (String) formatDictionary.invoke(gds, input);
+ assertNotNull(result);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/NotificationAPITest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/NotificationAPITest.java
index 096f7a37a..9fad27d02 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/NotificationAPITest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/NotificationAPITest.java
@@ -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,67 +23,70 @@ package org.onap.policy.pdp.rest.api.test;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
-
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.pdp.rest.api.services.NotificationService;
import org.onap.policy.pdp.rest.api.services.NotificationService.NotificationServiceType;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.springframework.http.HttpStatus;
-
import com.att.research.xacml.util.XACMLProperties;
public class NotificationAPITest {
-
- @Before
- public void setup() throws IOException{
- // Fix properties for next test cases.
- XACMLProperties.reloadProperties();
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/pass.xacml.pdp.properties");
- XACMLProperties.getProperties();
- }
-
- @Test
- public void testPropertyFailure() throws IOException{
- // Change properties and fail.
- XACMLProperties.reloadProperties();
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/fail.xacml.pdp.properties");
- XACMLProperties.getProperties();
- NotificationService notificationService = new NotificationService(null,null,null);
- assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
- setup();
- }
-
- @Test
- public void testFailureTopicName(){
- NotificationService notificationService = new NotificationService(null,null,null);
- assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
- assertEquals(XACMLErrorConstants.ERROR_DATA_ISSUE + "org.onap.policy.api.PolicyException: Notification Topic is null", notificationService.getResult());
- notificationService = new NotificationService(" ",null,null);
- assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
- assertEquals(XACMLErrorConstants.ERROR_DATA_ISSUE + "org.onap.policy.api.PolicyException: Notification Topic is not valid. ", notificationService.getResult());
- }
-
- @Test
- public void testFailureServiceType(){
- NotificationService notificationService = new NotificationService("test",null,null);
- assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
- }
-
- @Test
- public void threadTest() throws InterruptedException{
- NotificationService notificationSerivce = new NotificationService("test",null,NotificationServiceType.ADD);
- assertEquals(HttpStatus.OK, notificationSerivce.getResponseCode());
- // Wait for thread to remove the Topic Entry.
- await().atMost(Integer.toUnsignedLong(2500),TimeUnit.MILLISECONDS).until(()-> {
- // Trying to remove again should fail
- NotificationService nService = new NotificationService("test",null,NotificationServiceType.REMOVE);
- return HttpStatus.BAD_REQUEST.equals(nService.getResponseCode());
- });
- // Coverage Tests, Call Notification Service.
- NotificationService.sendNotification("test");
- }
+
+ @Before
+ public void setup() throws IOException {
+ // Fix properties for next test cases.
+ XACMLProperties.reloadProperties();
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/pass.xacml.pdp.properties");
+ XACMLProperties.getProperties();
+ }
+
+ @Test
+ public void testPropertyFailure() throws IOException {
+ // Change properties and fail.
+ XACMLProperties.reloadProperties();
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/fail.xacml.pdp.properties");
+ XACMLProperties.getProperties();
+ NotificationService notificationService = new NotificationService(null, null, null);
+ assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
+ setup();
+ }
+
+ @Test
+ public void testFailureTopicName() {
+ NotificationService notificationService = new NotificationService(null, null, null);
+ assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
+ assertEquals(
+ XACMLErrorConstants.ERROR_DATA_ISSUE
+ + "org.onap.policy.api.PolicyException: Notification Topic is null",
+ notificationService.getResult());
+ notificationService = new NotificationService(" ", null, null);
+ assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
+ assertEquals(
+ XACMLErrorConstants.ERROR_DATA_ISSUE
+ + "org.onap.policy.api.PolicyException: Notification Topic is not valid. ",
+ notificationService.getResult());
+ }
+
+ @Test
+ public void testFailureServiceType() {
+ NotificationService notificationService = new NotificationService("test", null, null);
+ assertEquals(HttpStatus.BAD_REQUEST, notificationService.getResponseCode());
+ }
+
+ @Test
+ public void threadTest() throws InterruptedException {
+ NotificationService notificationSerivce = new NotificationService("test", null, NotificationServiceType.ADD);
+ assertEquals(HttpStatus.OK, notificationSerivce.getResponseCode());
+ // Wait for thread to remove the Topic Entry.
+ await().atMost(Integer.toUnsignedLong(2500), TimeUnit.MILLISECONDS).until(() -> {
+ // Trying to remove again should fail
+ NotificationService nService = new NotificationService("test", null, NotificationServiceType.REMOVE);
+ return HttpStatus.BAD_REQUEST.equals(nService.getResponseCode());
+ });
+ // Coverage Tests, Call Notification Service.
+ NotificationService.sendNotification("test");
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java
index f6513d14b..e7c01b110 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017-2019 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
@@ -87,7 +89,8 @@ public class PolicyEngineServicesTest {
headers = new HttpHeaders();
headers.add(CLIENTAUTHHEADER, CLIENTAUTHVALUE);
XACMLProperties.reloadProperties();
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/pass.xacml.pdp.properties");
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME,
+ "src/test/resources/pass.xacml.pdp.properties");
XACMLProperties.getProperties();
this.mockMvc = webAppContextSetup(webApplicationContext).build();
}
@@ -96,9 +99,8 @@ public class PolicyEngineServicesTest {
public void getConfigAPIFailureTest() throws Exception {
ConfigRequestParameters pep = new ConfigRequestParameters();
pep.setPolicyName(".*");
- mockMvc.perform(
- post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().is(400));
+ mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().is(400));
// Authorization tests.
mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep))
.contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, ""))
@@ -112,46 +114,48 @@ public class PolicyEngineServicesTest {
// Set wrong request.
pep.setPolicyName(null);
pep.setConfigName("test");
- mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).headers(headers)
- .header(UUIDHEADER, "123").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isBadRequest());
+ mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep))
+ .headers(headers).header(UUIDHEADER, "123").contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isBadRequest());
}
@Test
public void getConfigServiceTest() throws Exception {
ConfigRequestParameters pep = new ConfigRequestParameters();
pep.setPolicyName(".*");
- mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).headers(headers)
- .header(UUIDHEADER, UUID.randomUUID()).contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk());
+ mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep))
+ .headers(headers).header(UUIDHEADER, UUID.randomUUID())
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
// Without policyName and using onapName and other fields.
pep.setPolicyName(null);
pep.setOnapName("test");
pep.setConfigName("test");
- mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).headers(headers)
- .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
+ mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep))
+ .headers(headers).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk());
// with config attributes.
Map<String, String> configAttributes = new HashMap<>();
configAttributes.put("test", "test");
pep.setConfigAttributes(configAttributes);
pep.makeUnique(true);
- mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).headers(headers)
- .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
+ mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep))
+ .headers(headers).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isOk());
}
@Test
public void getConfigByPolicyNameTest() throws Exception {
ConfigNameRequest pep = new ConfigNameRequest();
pep.setPolicyName(".*");
- mockMvc.perform(
- post("/getConfig").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().is(400));
+ mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().is(400));
// Authorization tests.
mockMvc.perform(post("/getConfig").content(PolicyUtils.objectToJsonString(pep))
.contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, ""))
.andExpect(status().isUnauthorized());
- mockMvc.perform(post("/getConfigByPolicyName").content(PolicyUtils.objectToJsonString(pep)).headers(headers)
- .header(UUIDHEADER, UUID.randomUUID()).contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk());
+ mockMvc.perform(post("/getConfigByPolicyName").content(PolicyUtils.objectToJsonString(pep))
+ .headers(headers).header(UUIDHEADER, UUID.randomUUID())
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
}
@Test
@@ -164,29 +168,30 @@ public class PolicyEngineServicesTest {
mockMvc.perform(post("/listConfig").content(PolicyUtils.objectToJsonString(pep))
.contentType(MediaType.APPLICATION_JSON).header(CLIENTAUTHHEADER, ""))
.andExpect(status().isUnauthorized());
- mockMvc.perform(post("/listConfig").content(PolicyUtils.objectToJsonString(pep)).headers(headers)
- .header(UUIDHEADER, UUID.randomUUID()).contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk());
+ mockMvc.perform(post("/listConfig").content(PolicyUtils.objectToJsonString(pep))
+ .headers(headers).header(UUIDHEADER, UUID.randomUUID())
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
}
@Test
public void listPolicyTest() throws Exception {
ConfigNameRequest pep = new ConfigNameRequest();
pep.setPolicyName(".*");
- mockMvc.perform(post("/listPolicy").content(PolicyUtils.objectToJsonString(pep)).headers(headers)
- .header(UUIDHEADER, UUID.randomUUID()).contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().isOk());
+ mockMvc.perform(post("/listPolicy").content(PolicyUtils.objectToJsonString(pep))
+ .headers(headers).header(UUIDHEADER, UUID.randomUUID())
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
pep.setPolicyName("*");
- mockMvc.perform(post("/listPolicy").content(PolicyUtils.objectToJsonString(pep)).headers(headers)
- .header(UUIDHEADER, UUID.randomUUID()).contentType(MediaType.APPLICATION_JSON))
- .andExpect(status().is4xxClientError());
+ mockMvc.perform(post("/listPolicy").content(PolicyUtils.objectToJsonString(pep))
+ .headers(headers).header(UUIDHEADER, UUID.randomUUID())
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().is4xxClientError());
}
@Test
public void getMetricsTest() throws Exception {
// Failure Tests.
mockMvc.perform(get("/getMetrics")).andExpect(status().isBadRequest());
- mockMvc.perform(get("/getMetrics").header(CLIENTAUTHHEADER, "Basic 123")).andExpect(status().isUnauthorized());
+ mockMvc.perform(get("/getMetrics").header(CLIENTAUTHHEADER, "Basic 123"))
+ .andExpect(status().isUnauthorized());
// Service Tests.
mockMvc.perform(get("/getMetrics").headers(headers).header(UUIDHEADER, "123"))
.andExpect(status().isBadRequest());
@@ -199,24 +204,30 @@ public class PolicyEngineServicesTest {
public void getNotificationAuthFailureTest() throws Exception {
mockMvc.perform(post("/getNotification").header(CLIENTAUTHHEADER, "").content("test"))
.andExpect(status().isUnauthorized());
- mockMvc.perform(post("/getNotification").header(CLIENTAUTHHEADER, "Basic test123").content("test"))
+ mockMvc.perform(
+ post("/getNotification").header(CLIENTAUTHHEADER, "Basic test123").content("test"))
.andExpect(status().isUnauthorized());
- mockMvc.perform(post("/getNotification").header(CLIENTAUTHHEADER, ERRORCLIENTVALUE).content(" "))
+ mockMvc.perform(
+ post("/getNotification").header(CLIENTAUTHHEADER, ERRORCLIENTVALUE).content(" "))
.andExpect(status().isUnauthorized());
}
@Test
public void getNotificationTopicFailureTest() throws Exception {
mockMvc.perform(post("/getNotification")).andExpect(status().isBadRequest());
- mockMvc.perform(post("/getNotification").headers(headers).content("")).andExpect(status().isBadRequest());
+ mockMvc.perform(post("/getNotification").headers(headers).content(""))
+ .andExpect(status().isBadRequest());
}
@Test
public void getNotificationTopicValidFailTest() throws Exception {
// Check failures.
- mockMvc.perform(post("/getNotification").headers(headers).content(" ")).andExpect(status().isBadRequest());
- mockMvc.perform(post("/stopNotification").headers(headers).content(" ")).andExpect(status().isBadRequest());
- mockMvc.perform(post("/sendHeartbeat").headers(headers).content(" ")).andExpect(status().isBadRequest());
+ mockMvc.perform(post("/getNotification").headers(headers).content(" "))
+ .andExpect(status().isBadRequest());
+ mockMvc.perform(post("/stopNotification").headers(headers).content(" "))
+ .andExpect(status().isBadRequest());
+ mockMvc.perform(post("/sendHeartbeat").headers(headers).content(" "))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -228,17 +239,22 @@ public class PolicyEngineServicesTest {
XACMLProperties.getProperties();
NotificationService.reloadProps();
// Add a Topic.
- mockMvc.perform(post("/getNotification").headers(headers).header(UUIDHEADER, "123").content("test"))
+ mockMvc.perform(
+ post("/getNotification").headers(headers).header(UUIDHEADER, "123").content("test"))
.andExpect(status().isOk());
// Try to add same topic should fail.
- mockMvc.perform(post("/getNotification").headers(headers).header(UUIDHEADER, UUID.randomUUID()).content("test"))
+ mockMvc.perform(post("/getNotification").headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID()).content("test"))
.andExpect(status().isBadRequest());
// do a heart beat.
- mockMvc.perform(post("/sendHeartbeat").headers(headers).content("test")).andExpect(status().isOk());
+ mockMvc.perform(post("/sendHeartbeat").headers(headers).content("test"))
+ .andExpect(status().isOk());
// remove the added Topic.
- mockMvc.perform(post("/stopNotification").headers(headers).content("test")).andExpect(status().isOk());
+ mockMvc.perform(post("/stopNotification").headers(headers).content("test"))
+ .andExpect(status().isOk());
// try to remove again should fail.
- mockMvc.perform(post("/sendHeartbeat").headers(headers).content("test")).andExpect(status().isBadRequest());
+ mockMvc.perform(post("/sendHeartbeat").headers(headers).content("test"))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -258,15 +274,17 @@ public class PolicyEngineServicesTest {
.andExpect(status().isOk());
pep.setEventAttributes(null);
mockMvc.perform(post("/sendEvent").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setEventAttributes(eventAttributes);
mockMvc.perform(post("/sendEvent").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isOk());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isOk());
pep.setEventAttributes(eventAttributes);
pep.setRequestID(UUID.randomUUID());
mockMvc.perform(post("/sendEvent").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isOk());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isOk());
}
@Test
@@ -288,15 +306,17 @@ public class PolicyEngineServicesTest {
pep.setDecisionAttributes(null);
pep.setOnapName(null);
mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setOnapName("testing");
mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setDecisionAttributes(eventAttributes);
pep.setRequestID(UUID.randomUUID());
mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isOk());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isOk());
}
@Test
@@ -309,49 +329,61 @@ public class PolicyEngineServicesTest {
.andExpect(status().isUnauthorized());
// Service Tests.
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyName("scopeless");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyName("testing.test");
pep.setPolicyType("wrong");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("BRMS_PARAM");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("BRMS_RAW");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("MicroService");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("ClosedLoop_PM");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("ClosedLoop_Fault");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("Base");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("Decision");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("Action");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("Firewall");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPdpGroup("default");
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
.contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "123"))
.andExpect(status().isBadRequest());
pep.setRequestID(UUID.randomUUID());
mockMvc.perform(put("/pushPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -364,90 +396,93 @@ public class PolicyEngineServicesTest {
.andExpect(status().isUnauthorized());
// Service Tests.
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyName("testing");
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "test123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "test123")).andExpect(status().isBadRequest());
pep.setPolicyName("testscope.name");
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyName("testscope.name");
pep.setPolicyType("wrong");
pep.setRequestID(UUID.randomUUID());
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("BRMS_PARAM");
pep.setPolicyComponent("wrong");
pep.setRequestID(null);
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyType("BRMS_RAW");
pep.setPolicyComponent("PDP");
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyType("MicroService");
pep.setPolicyComponent("PAP");
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyType("ClosedLoop_PM");
pep.setPolicyComponent("PDP");
pep.setDeleteCondition(DeletePolicyCondition.ALL);
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyType("ClosedLoop_Fault");
pep.setDeleteCondition(DeletePolicyCondition.ONE);
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyType("Base");
pep.setPolicyComponent("PAP");
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyType("Decision");
pep.setPolicyComponent("PDP");
pep.setPolicyName("test.xml");
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyType("Action");
pep.setPolicyName("scope.Config_test.xml");
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPdpGroup("default");
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyComponent("PAP");
pep.setPolicyType("Firewall");
pep.setDeleteCondition(null);
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyComponent("PAP");
pep.setDeleteCondition(DeletePolicyCondition.ONE);
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyComponent("fail");
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyComponent("PDP");
pep.setPolicyName("testscope.policyName");
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyComponent(null);
mockMvc.perform(delete("/deletePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
}
@Test
@@ -464,38 +499,40 @@ public class PolicyEngineServicesTest {
// Service Tests.
setCreateUpdateImpl();
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyName("failName");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "test 123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "test 123")).andExpect(status().isBadRequest());
pep.setPolicyName("test. name");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setPolicyName(" ");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyName("test. ");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyName("te st.name");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyName("test.name");
pep.setPolicyDescription("testá");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setPolicyName("test.name");
pep.setPolicyDescription("good");
pep.setTtlDate(new Date());
pep.setRequestID(UUID.randomUUID());
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -509,10 +546,12 @@ public class PolicyEngineServicesTest {
// Checks for BRMS Param Policy.
pep.setPolicyConfigType(PolicyConfigType.BRMS_PARAM);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRiskLevel("test");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
Map<String, String> matching = new HashMap<>();
matching.put("key", "value");
@@ -520,26 +559,38 @@ public class PolicyEngineServicesTest {
pep.setAttributes(attributes);
pep.setRiskLevel("5");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
// Checks for BRMS Raw Policy
pep.setPolicyConfigType(PolicyConfigType.BRMS_RAW);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("test");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRiskLevel(null);
pep.setConfigBody(
- "package droolsexample\n\n import com.sample.ItemCity;\nimport java.math.BigDecimal;\nrule \"Nagpur Medicine Item\"\n\n when\n item : ItemCity(purchaseCity == ItemCity.City.NAGPUR,\n typeofItem == ItemCity.Type.MEDICINES)\n then\n BigDecimal tax = new BigDecimal(0.0);\n item.setLocalTax(tax.multiply(item.getSellPrice()));\nend");
- mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ "package droolsexample\n\n import com.sample.ItemCity;\nimport java.math.BigDecimal;\n"
+ + "rule \"Nagpur Medicine Item\"\n\n when\n"
+ + " item : ItemCity(purchaseCity == ItemCity.City.NAGPUR,\n"
+ + " typeofItem == ItemCity.Type.MEDICINES)\n then\n"
+ + " BigDecimal tax = new BigDecimal(0.0);\n"
+ + " item.setLocalTax(tax.multiply(item.getSellPrice()));\nend");
+ mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRiskLevel("5");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -553,31 +604,39 @@ public class PolicyEngineServicesTest {
// Checks for Base config Policy.
pep.setPolicyConfigType(PolicyConfigType.Base);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("testbody");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBodyType(PolicyType.OTHER);
pep.setRiskLevel("test");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRiskLevel("4");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setOnapName("ec nam-e");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setOnapName("onapName");
pep.setConfigName("tes config");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigName("configName");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{'test':'test}");
pep.setConfigBodyType(PolicyType.JSON);
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
Map<String, String> matching = new HashMap<>();
matching.put("key", "value");
@@ -585,7 +644,8 @@ public class PolicyEngineServicesTest {
pep.setAttributes(attributes);
pep.setConfigBody("testBody");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -599,30 +659,39 @@ public class PolicyEngineServicesTest {
// Checks for Closed loop Policy.
pep.setPolicyConfigType(PolicyConfigType.ClosedLoop_Fault);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("te stá");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("testBody");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{\"key\":\"value\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{\"onapname\":\"\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{\"onapname\":\"test\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRiskLevel("test");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRiskLevel("4");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -636,35 +705,46 @@ public class PolicyEngineServicesTest {
// Checks for Closed loop Policy.
pep.setPolicyConfigType(PolicyConfigType.ClosedLoop_PM);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("te stá");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("testBody");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{\"key\":\"value\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{\"onapname\":\"\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{\"onapname\":\"test\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{\"onapname\":\"test\", \"serviceTypePolicyName\":\"value\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRiskLevel("test");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRiskLevel("4");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -678,25 +758,32 @@ public class PolicyEngineServicesTest {
// Checks for Closed loop Policy.
pep.setPolicyConfigType(PolicyConfigType.Firewall);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("te st");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{\"test\":\"test\"}");
pep.setRiskLevel("test");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRiskLevel("4");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{\"configName\":\"test\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -710,28 +797,36 @@ public class PolicyEngineServicesTest {
// Checks for Closed loop Policy.
pep.setPolicyConfigType(PolicyConfigType.MicroService);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("te st");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody("{\"test\":\"test\"}");
pep.setOnapName(" ");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setOnapName("testonap");
pep.setRiskLevel("fail");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRiskLevel("4");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setConfigBody(
- "{\"service\":\"test\",\"uuid\":\"test\",\"location\":\"test\",\"configName\":\"test\",\"description\":\"test\",\"priority\":\"test\",\"version\":\"test\"}");
+ "{\"service\":\"test\",\"uuid\":\"test\",\"location\":\"test\",\"configName\":\"test\","
+ + "\"description\":\"test\",\"priority\":\"test\",\"version\":\"test\"}");
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -745,50 +840,63 @@ public class PolicyEngineServicesTest {
// Checks for action Policy.
pep.setPolicyClass(PolicyClass.Action);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
pep.setAttributes(attributes);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
attributes.put(AttributeType.MATCHING, new HashMap<>());
pep.setAttributes(attributes);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
Map<String, String> matching = new HashMap<>();
matching.put("key", "value");
attributes.put(AttributeType.MATCHING, matching);
pep.setAttributes(attributes);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setActionAttribute("A1");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setActionPerformer("PEX");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setActionPerformer("PEP");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
// Checks for Decision Policy.
pep.setPolicyClass(PolicyClass.Decision);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setOnapName("xyz");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
attributes.remove(AttributeType.MATCHING);
attributes.put(AttributeType.SETTINGS, matching);
pep.setAttributes(attributes);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
attributes.put(AttributeType.MATCHING, matching);
pep.setAttributes(attributes);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -804,29 +912,32 @@ public class PolicyEngineServicesTest {
.andExpect(status().isUnauthorized());
// Service Tests.
mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
pep.setDictionaryType(DictionaryType.MicroService);
mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
- mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
.andExpect(status().isBadRequest());
+ mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep))
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setDictionary("test dict");
pep.setRequestID(UUID.randomUUID());
mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setDictionaryJson("{\"test\":\"value\"}");
mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, UUID.randomUUID()))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
pep.setDictionaryJson("test123");
mockMvc.perform(put("/updateDictionaryItem").content(PolicyUtils.objectToJsonString(pep))
.contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "123"))
.andExpect(status().isBadRequest());
pep.setDictionary("MicroServiceDictionary");
mockMvc.perform(put("/createDictionaryItem").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -839,18 +950,21 @@ public class PolicyEngineServicesTest {
.andExpect(status().isUnauthorized());
// Service Tests.
mockMvc.perform(post("/getDictionaryItems").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
pep.setDictionaryType(DictionaryType.Common);
mockMvc.perform(post("/getDictionaryItems").content(PolicyUtils.objectToJsonString(pep))
.contentType(MediaType.APPLICATION_JSON).headers(headers)
- .header(UUIDHEADER, UUID.randomUUID().toString())).andExpect(status().isBadRequest());
+ .header(UUIDHEADER, UUID.randomUUID().toString()))
+ .andExpect(status().isBadRequest());
pep.setDictionary("OnapName");
mockMvc.perform(post("/getDictionaryItems").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
pep.setRequestID(UUID.randomUUID());
mockMvc.perform(post("/getDictionaryItems").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers)).andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers))
+ .andExpect(status().isBadRequest());
}
@Test
@@ -872,24 +986,24 @@ public class PolicyEngineServicesTest {
.andExpect(status().isUnauthorized());
// Service Tests.
mockMvc.perform(put("/createConfig").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
pep.setPolicyScope("test");
mockMvc.perform(put("/createConfig").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
pep.setPolicyName("name");
mockMvc.perform(put("/createConfig").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
pep.setConfigType("OTHER");
mockMvc.perform(put("/createConfig").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
pep.setTtlDate(new Date().toString());
mockMvc.perform(put("/updateConfig").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
}
@Test
@@ -905,25 +1019,26 @@ public class PolicyEngineServicesTest {
.andExpect(status().isUnauthorized());
// Service Tests.
mockMvc.perform(put("/createFirewallConfig").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
pep.setPolicyScope("test");
mockMvc.perform(put("/createFirewallConfig").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
pep.setPolicyName("name");
mockMvc.perform(put("/createFirewallConfig").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
pep.setTtlDate(new Date().toString());
mockMvc.perform(put("/updateFirewallConfig").content(PolicyUtils.objectToJsonString(pep))
- .contentType(MediaType.APPLICATION_JSON).headers(headers).header(UUIDHEADER, "tes123"))
- .andExpect(status().isBadRequest());
+ .contentType(MediaType.APPLICATION_JSON).headers(headers)
+ .header(UUIDHEADER, "tes123")).andExpect(status().isBadRequest());
}
- private void setCreateUpdateImpl() throws NoSuchMethodException, SecurityException, IllegalAccessException,
- IllegalArgumentException, InvocationTargetException {
- Method setter = XACMLPdpServlet.class.getDeclaredMethod("setCreateUpdatePolicyConstructor", String.class);
+ private void setCreateUpdateImpl() throws NoSuchMethodException, SecurityException,
+ IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ Method setter = XACMLPdpServlet.class.getDeclaredMethod("setCreateUpdatePolicyConstructor",
+ String.class);
setter.setAccessible(true);
setter.invoke(new XACMLPdpServlet(), CreateUpdatePolicyServiceImpl.class.getName());
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/utils/test/PolicyApiUtilsTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/utils/test/PolicyApiUtilsTest.java
index a38603a33..d1da554d9 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/utils/test/PolicyApiUtilsTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/utils/test/PolicyApiUtilsTest.java
@@ -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.
@@ -23,246 +25,203 @@ package org.onap.policy.pdp.rest.api.utils.test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
-
import org.json.JSONObject;
import org.junit.Test;
import org.onap.policy.pdp.rest.api.utils.PolicyApiUtils;
public class PolicyApiUtilsTest {
- @Test
- public void testValidateDirectoryJsonFields() {
-
- String dictonaryAction = "Action";
-
-
- JsonObject jsonObjAttrGood = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "GET")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .build();
-
- JsonObject jsonObjAttrNull = Json.createObjectBuilder().add("attributeName", "").build();
- JsonObject jsonObjAttrBad = Json.createObjectBuilder().add("attributeName", "succ ess").build();
- JsonObject jsonObjectMissingAttrName = Json.createObjectBuilder().add("foo", "bar").build();
-
-
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGood, dictonaryAction).contains("success"));
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrNull, dictonaryAction).contains("No Attribute Name provided"));
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrBad, dictonaryAction).contains("Invalid Attribute Name"));
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjectMissingAttrName, dictonaryAction).contains("Missing attributeName"));
-
- /* "type" parameter variations. */
- JsonObject jsonObjAttrGoodTemp = jsonObjAttrGood;
-
- //null/empty type
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "")
- .add("method", "GET")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("No Type provided"));
-
- //missing type
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("method", "GET")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .build();
-
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("Missing type key in the dictionaryJson parameter"));
-
- //invalid type
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "INVALID")
- .add("method", "GET")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .build();
-
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("Invalid Type value"));
-
- /* "method" parameter variations. */
- jsonObjAttrGoodTemp = jsonObjAttrGood;
-
- //null/empty method
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("No Method provided"));
-
- //missing method
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("Missing method key in the dictionaryJson parameter"));
-
- //valid method
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "GET")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("success"));
-
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "PUT")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("success"));
-
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "POST")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("success"));
-
-
- //invalid method
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "INVALID")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("Invalid Method value"));
-
-
- /* url parameter variations */
- jsonObjAttrGoodTemp = jsonObjAttrGood;
-
- //null/empty url
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "GET")
- .add("url", "")
- .add("body", "foobody")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("No URL provided"));
-
- //missing url
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "GET")
- .add("body", "foobody")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("Missing url key in the dictionaryJson parameter"));
-
- /* body parameter variations */
- jsonObjAttrGoodTemp = jsonObjAttrGood;
-
- //null body
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "GET")
- .add("url", "http://foobar.com")
- .add("body", "")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("No Body provided"));
-
- //missing body
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "GET")
- .add("url", "http://foobar.com")
- .build();
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("Missing body key in the dictionaryJson parameter"));
-
-
- /*headers parameter variations*/
- JsonObject jsonObjOption;
- JsonObject jsonObjNumber;
- JsonArray jsonArrayHeaders;
-
- //missing number headers
- jsonObjOption = Json.createObjectBuilder().add("option","foobar").build();
- //jsonObjNumber = Json.createObjectBuilder().add("number","foobar").build();
-
- jsonArrayHeaders = Json.createArrayBuilder()
- .add(jsonObjOption)
- //.add(jsonObjNumber)
- .build();
-
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "GET")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .add("headers", jsonArrayHeaders)
- .build();
-
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("Missing number key in the headers list of the dictionaryJson parameter."));
-
- //missing options headers
- jsonObjOption = Json.createObjectBuilder().add("option","foobar").build();
- jsonObjNumber = Json.createObjectBuilder().add("number","foobar").build();
-
- jsonArrayHeaders = Json.createArrayBuilder()
- //.add(jsonObjOption)
- .add(jsonObjNumber)
- .build();
-
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "GET")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .add("headers", jsonArrayHeaders)
- .build();
-
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("Missing option key in the headers list of the dictionaryJson parameter."));
-
- //null option
- jsonObjOption = Json.createObjectBuilder().add("option","").build();
- jsonObjNumber = Json.createObjectBuilder().add("number","foobar").build();
-
- jsonArrayHeaders = Json.createArrayBuilder()
- .add(jsonObjOption)
- .add(jsonObjNumber)
- .build();
-
- jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
- .add("type", "REST")
- .add("method", "GET")
- .add("url", "http://foobar.com")
- .add("body", "foobody")
- .add("headers", jsonArrayHeaders)
- .build();
-
- assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction).contains("Missing required Option value"));
-
- //null number can't be tested
-
- }
-
- @Test
- public void testStringToJsonObject() {
- String jsonString = "{\"foo\":\"bar\"}";
- JsonObject obj = PolicyApiUtils.stringToJsonObject(jsonString);
- assertTrue(obj.get("foo").toString().equals("\"bar\""));
- }
-
- @Test
- public void testIsNumeric() {
- assertFalse(PolicyApiUtils.isNumeric("notNumeric"));
- assertTrue(PolicyApiUtils.isNumeric("2"));
- }
-
-
+ @Test
+ public void testValidateDirectoryJsonFields() {
+
+ String dictonaryAction = "Action";
+
+ JsonObject jsonObjAttrGood = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "GET").add("url", "http://foobar.com")
+ .add("body", "foobody").build();
+
+ JsonObject jsonObjAttrNull = Json.createObjectBuilder().add("attributeName", "").build();
+ JsonObject jsonObjAttrBad =
+ Json.createObjectBuilder().add("attributeName", "succ ess").build();
+ JsonObject jsonObjectMissingAttrName = Json.createObjectBuilder().add("foo", "bar").build();
+
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGood, dictonaryAction)
+ .contains("success"));
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrNull, dictonaryAction)
+ .contains("No Attribute Name provided"));
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrBad, dictonaryAction)
+ .contains("Invalid Attribute Name"));
+ assertTrue(PolicyApiUtils
+ .validateDictionaryJsonFields(jsonObjectMissingAttrName, dictonaryAction)
+ .contains("Missing attributeName"));
+
+ /* "type" parameter variations. */
+ JsonObject jsonObjAttrGoodTemp = jsonObjAttrGood;
+
+ // null/empty type
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "").add("method", "GET").add("url", "http://foobar.com")
+ .add("body", "foobody").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("No Type provided"));
+
+ // missing type
+ jsonObjAttrGoodTemp =
+ Json.createObjectBuilder().add("attributeName", "success").add("method", "GET")
+ .add("url", "http://foobar.com").add("body", "foobody").build();
+
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("Missing type key in the dictionaryJson parameter"));
+
+ // invalid type
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "INVALID").add("method", "GET").add("url", "http://foobar.com")
+ .add("body", "foobody").build();
+
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("Invalid Type value"));
+
+ /* "method" parameter variations. */
+ jsonObjAttrGoodTemp = jsonObjAttrGood;
+
+ // null/empty method
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "").add("url", "http://foobar.com")
+ .add("body", "foobody").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("No Method provided"));
+
+ // missing method
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("url", "http://foobar.com").add("body", "foobody").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("Missing method key in the dictionaryJson parameter"));
+
+ // valid method
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "GET").add("url", "http://foobar.com")
+ .add("body", "foobody").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("success"));
+
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "PUT").add("url", "http://foobar.com")
+ .add("body", "foobody").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("success"));
+
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "POST").add("url", "http://foobar.com")
+ .add("body", "foobody").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("success"));
+
+
+ // invalid method
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "INVALID").add("url", "http://foobar.com")
+ .add("body", "foobody").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("Invalid Method value"));
+
+ /* url parameter variations */
+ jsonObjAttrGoodTemp = jsonObjAttrGood;
+
+ // null/empty url
+ jsonObjAttrGoodTemp =
+ Json.createObjectBuilder().add("attributeName", "success").add("type", "REST")
+ .add("method", "GET").add("url", "").add("body", "foobody").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("No URL provided"));
+
+ // missing url
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "GET").add("body", "foobody").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("Missing url key in the dictionaryJson parameter"));
+
+ /* body parameter variations */
+ jsonObjAttrGoodTemp = jsonObjAttrGood;
+
+ // null body
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "GET").add("url", "http://foobar.com")
+ .add("body", "").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("No Body provided"));
+
+ // missing body
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "GET").add("url", "http://foobar.com").build();
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("Missing body key in the dictionaryJson parameter"));
+
+ /* headers parameter variations */
+ JsonObject jsonObjOption;
+ JsonObject jsonObjNumber;
+ JsonArray jsonArrayHeaders;
+
+ // missing number headers
+ jsonObjOption = Json.createObjectBuilder().add("option", "foobar").build();
+ // jsonObjNumber = Json.createObjectBuilder().add("number","foobar").build();
+
+ jsonArrayHeaders = Json.createArrayBuilder().add(jsonObjOption)
+ // .add(jsonObjNumber)
+ .build();
+
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "GET").add("url", "http://foobar.com")
+ .add("body", "foobody").add("headers", jsonArrayHeaders).build();
+
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains(
+ "Missing number key in the headers list of the dictionaryJson parameter."));
+
+ // missing options headers
+ jsonObjOption = Json.createObjectBuilder().add("option", "foobar").build();
+ jsonObjNumber = Json.createObjectBuilder().add("number", "foobar").build();
+
+ jsonArrayHeaders = Json.createArrayBuilder()
+ // .add(jsonObjOption)
+ .add(jsonObjNumber).build();
+
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "GET").add("url", "http://foobar.com")
+ .add("body", "foobody").add("headers", jsonArrayHeaders).build();
+
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains(
+ "Missing option key in the headers list of the dictionaryJson parameter."));
+
+ // null option
+ jsonObjOption = Json.createObjectBuilder().add("option", "").build();
+ jsonObjNumber = Json.createObjectBuilder().add("number", "foobar").build();
+
+ jsonArrayHeaders = Json.createArrayBuilder().add(jsonObjOption).add(jsonObjNumber).build();
+
+ jsonObjAttrGoodTemp = Json.createObjectBuilder().add("attributeName", "success")
+ .add("type", "REST").add("method", "GET").add("url", "http://foobar.com")
+ .add("body", "foobody").add("headers", jsonArrayHeaders).build();
+
+ assertTrue(PolicyApiUtils.validateDictionaryJsonFields(jsonObjAttrGoodTemp, dictonaryAction)
+ .contains("Missing required Option value"));
+
+ // null number can't be tested
+ }
+
+ @Test
+ public void testStringToJsonObject() {
+ String jsonString = "{\"foo\":\"bar\"}";
+ JsonObject obj = PolicyApiUtils.stringToJsonObject(jsonString);
+ assertTrue(obj.get("foo").toString().equals("\"bar\""));
+ }
+
+ @Test
+ public void testIsNumeric() {
+ assertFalse(PolicyApiUtils.isNumeric("notNumeric"));
+ assertTrue(PolicyApiUtils.isNumeric("2"));
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/AuthenticationServiceTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/AuthenticationServiceTest.java
index 1585fe420..564187675 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/AuthenticationServiceTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/AuthenticationServiceTest.java
@@ -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.
@@ -27,27 +29,26 @@ import org.junit.Test;
import org.onap.policy.pdp.rest.restAuth.AuthenticationService;
public class AuthenticationServiceTest {
- private final String testCred = "testpdp:alpha456";
- private final String testCredEncoded = new String(Base64.getEncoder().encode(testCred.getBytes()));
- private final String basicCred = "Basic " + testCredEncoded;
-
- @Test
- public void testAuth() throws UnsupportedEncodingException {
- String systemKey = "xacml.properties";
+ private final String testCred = "testpdp:alpha456";
+ private final String testCredEncoded = new String(Base64.getEncoder().encode(testCred.getBytes()));
+ private final String basicCred = "Basic " + testCredEncoded;
+
+ @Test
+ public void testAuth() throws UnsupportedEncodingException {
+ String systemKey = "xacml.properties";
+
+ // Set the system property temporarily
+ String oldProperty = System.getProperty(systemKey);
+ System.setProperty(systemKey, "xacml.pdp.properties");
+
+ AuthenticationService service = new AuthenticationService();
+ assertEquals(service.authenticate(basicCred), true);
- // Set the system property temporarily
- String oldProperty = System.getProperty(systemKey);
- System.setProperty(systemKey, "xacml.pdp.properties");
-
- AuthenticationService service = new AuthenticationService();
- assertEquals(service.authenticate(basicCred), true);
-
- // 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);
+ }
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/FilterTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/FilterTest.java
index 1185eddff..99ecefb80 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/FilterTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/auth/test/FilterTest.java
@@ -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.
@@ -23,177 +25,161 @@ package org.onap.policy.pdp.rest.auth.test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.io.IOException;
-
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.pdp.rest.restAuth.PDPAuthenticationFilter;
-
import com.att.research.xacml.util.XACMLProperties;
import com.mockrunner.mock.web.MockRequestDispatcher;
public class FilterTest {
-
- private PDPAuthenticationFilter authenticationFilter = new PDPAuthenticationFilter();
- private final String VALIDHEADERVALUE = "Basic dGVzdHBkcDphbHBoYTQ1Ng==";
-
- @Before
- public void setUp() throws Exception{
- authenticationFilter.init(null);
- XACMLProperties.reloadProperties();
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/pass.xacml.pdp.properties");
- XACMLProperties.getProperties();
- }
-
- @Test
- public void testDoFilterError() throws IOException, ServletException {
- // create the objects to be mocked
- HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
- HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
- FilterChain filterChain = mock(FilterChain.class);
- //
- when(httpServletRequest.getRequestURI()).thenReturn("error");
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- // verify if unauthorized
- verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- }
-
- @Test
- public void testDoFilterNotification() throws IOException, ServletException {
- // create the objects to be mocked
- HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
- HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
- FilterChain filterChain = mock(FilterChain.class);
- //
- when(httpServletRequest.getRequestURI()).thenReturn("notifications");
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- verify(filterChain).doFilter(httpServletRequest,httpServletResponse);
- }
-
- @Test
- public void testDoFilterSwagger() throws Exception{
- // create the objects to be mocked
- HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
- HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
- FilterChain filterChain = mock(FilterChain.class);
- //
- when(httpServletRequest.getRequestURI()).thenReturn("/pdp/swagger");
- when(httpServletRequest.getRequestDispatcher("/api/swagger")).thenReturn(new MockRequestDispatcher());
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- verify(httpServletRequest).getRequestDispatcher("/api/swagger");
- when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api-docs/");
- when(httpServletRequest.getRequestDispatcher("/api/api-docs/")).thenReturn(new MockRequestDispatcher());
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- verify(httpServletRequest).getRequestDispatcher("/api/api-docs/");
- when(httpServletRequest.getRequestURI()).thenReturn("/pdp/configuration");
- when(httpServletRequest.getRequestDispatcher("/api/configuration")).thenReturn(new MockRequestDispatcher());
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- verify(httpServletRequest).getRequestDispatcher("/api/configuration");
- }
-
- @Test
- public void newRequestAuthFailTest() throws Exception{
- // create the objects to be mocked
- HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
- HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
- FilterChain filterChain = mock(FilterChain.class);
- //
- when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
- when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn("error");
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- // verify if unauthorized
- verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- }
-
- @Test
- public void tokenFailureTest() throws Exception{
- // create the objects to be mocked
- HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
- HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
- FilterChain filterChain = mock(FilterChain.class);
- //
- when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
- when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn("Basic test123");
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- // verify if unauthorized
- verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- }
-
- @Test
- public void oldRequestAuthPassTest() throws Exception{
- // create the objects to be mocked
- HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
- HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
- FilterChain filterChain = mock(FilterChain.class);
- // New request no environment header check
- when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
- when(httpServletRequest.getRequestDispatcher("/api/getConfig")).thenReturn(new MockRequestDispatcher());
- when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- // verify if authorized
- verify(httpServletRequest).getRequestDispatcher("/api/getConfig");
- //
- // Old Requests Checks
- //
- when(httpServletRequest.getRequestURI()).thenReturn("/pdp/getConfig");
- when(httpServletRequest.getRequestDispatcher("/api//getConfig")).thenReturn(new MockRequestDispatcher());
- when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- // verify if authorized
- verify(httpServletRequest).getRequestDispatcher("/api//getConfig");
- }
-
- @Test
- public void newRequestAuthPassTest() throws Exception{
- // create the objects to be mocked
- HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
- HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
- FilterChain filterChain = mock(FilterChain.class);
- //
- // Requests with Valid Environment Header values.
- //
- when(httpServletRequest.getRequestURI()).thenReturn("/pdp/getConfig");
- when(httpServletRequest.getRequestDispatcher("/api//getConfig")).thenReturn(new MockRequestDispatcher());
- when(httpServletRequest.getHeader(PDPAuthenticationFilter.ENVIRONMENT_HEADER)).thenReturn("DEVL");
- when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- // verify if authorized
- verify(httpServletRequest).getRequestDispatcher("/api//getConfig");
- // New request no environment header check
- when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
- when(httpServletRequest.getRequestDispatcher("/api/getConfig")).thenReturn(new MockRequestDispatcher());
- when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- // verify if authorized
- verify(httpServletRequest).getRequestDispatcher("/api/getConfig");
- //
- //
- // Requests with InValid Environment Header
- //
- when(httpServletRequest.getRequestURI()).thenReturn("/pdp/getConfig");
- when(httpServletRequest.getRequestDispatcher("/api//getConfig")).thenReturn(new MockRequestDispatcher());
- when(httpServletRequest.getHeader(PDPAuthenticationFilter.ENVIRONMENT_HEADER)).thenReturn("TEST");
- when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
- authenticationFilter.doFilter(httpServletRequest, httpServletResponse,
- filterChain);
- // verify if unauthorized
- verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
- }
+
+ private PDPAuthenticationFilter authenticationFilter = new PDPAuthenticationFilter();
+ private final String VALIDHEADERVALUE = "Basic dGVzdHBkcDphbHBoYTQ1Ng==";
+
+ @Before
+ public void setUp() throws Exception {
+ authenticationFilter.init(null);
+ XACMLProperties.reloadProperties();
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/pass.xacml.pdp.properties");
+ XACMLProperties.getProperties();
+ }
+
+ @Test
+ public void testDoFilterError() throws IOException, ServletException {
+ // create the objects to be mocked
+ HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+ HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+ FilterChain filterChain = mock(FilterChain.class);
+ //
+ when(httpServletRequest.getRequestURI()).thenReturn("error");
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ // verify if unauthorized
+ verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+
+ @Test
+ public void testDoFilterNotification() throws IOException, ServletException {
+ // create the objects to be mocked
+ HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+ HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+ FilterChain filterChain = mock(FilterChain.class);
+ //
+ when(httpServletRequest.getRequestURI()).thenReturn("notifications");
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ verify(filterChain).doFilter(httpServletRequest, httpServletResponse);
+ }
+
+ @Test
+ public void testDoFilterSwagger() throws Exception {
+ // create the objects to be mocked
+ HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+ HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+ FilterChain filterChain = mock(FilterChain.class);
+ //
+ when(httpServletRequest.getRequestURI()).thenReturn("/pdp/swagger");
+ when(httpServletRequest.getRequestDispatcher("/api/swagger")).thenReturn(new MockRequestDispatcher());
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ verify(httpServletRequest).getRequestDispatcher("/api/swagger");
+ when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api-docs/");
+ when(httpServletRequest.getRequestDispatcher("/api/api-docs/")).thenReturn(new MockRequestDispatcher());
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ verify(httpServletRequest).getRequestDispatcher("/api/api-docs/");
+ when(httpServletRequest.getRequestURI()).thenReturn("/pdp/configuration");
+ when(httpServletRequest.getRequestDispatcher("/api/configuration")).thenReturn(new MockRequestDispatcher());
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ verify(httpServletRequest).getRequestDispatcher("/api/configuration");
+ }
+
+ @Test
+ public void newRequestAuthFailTest() throws Exception {
+ // create the objects to be mocked
+ HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+ HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+ FilterChain filterChain = mock(FilterChain.class);
+ //
+ when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
+ when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn("error");
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ // verify if unauthorized
+ verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+
+ @Test
+ public void tokenFailureTest() throws Exception {
+ // create the objects to be mocked
+ HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+ HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+ FilterChain filterChain = mock(FilterChain.class);
+ //
+ when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
+ when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn("Basic test123");
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ // verify if unauthorized
+ verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+
+ @Test
+ public void oldRequestAuthPassTest() throws Exception {
+ // create the objects to be mocked
+ HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+ HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+ FilterChain filterChain = mock(FilterChain.class);
+ // New request no environment header check
+ when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
+ when(httpServletRequest.getRequestDispatcher("/api/getConfig")).thenReturn(new MockRequestDispatcher());
+ when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ // verify if authorized
+ verify(httpServletRequest).getRequestDispatcher("/api/getConfig");
+ //
+ // Old Requests Checks
+ //
+ when(httpServletRequest.getRequestURI()).thenReturn("/pdp/getConfig");
+ when(httpServletRequest.getRequestDispatcher("/api//getConfig")).thenReturn(new MockRequestDispatcher());
+ when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ // verify if authorized
+ verify(httpServletRequest).getRequestDispatcher("/api//getConfig");
+ }
+
+ @Test
+ public void newRequestAuthPassTest() throws Exception {
+ // create the objects to be mocked
+ HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
+ HttpServletResponse httpServletResponse = mock(HttpServletResponse.class);
+ FilterChain filterChain = mock(FilterChain.class);
+ //
+ // Requests with Valid Environment Header values.
+ //
+ when(httpServletRequest.getRequestURI()).thenReturn("/pdp/getConfig");
+ when(httpServletRequest.getRequestDispatcher("/api//getConfig")).thenReturn(new MockRequestDispatcher());
+ when(httpServletRequest.getHeader(PDPAuthenticationFilter.ENVIRONMENT_HEADER)).thenReturn("DEVL");
+ when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ // verify if authorized
+ verify(httpServletRequest).getRequestDispatcher("/api//getConfig");
+ // New request no environment header check
+ when(httpServletRequest.getRequestURI()).thenReturn("/pdp/api/getConfig");
+ when(httpServletRequest.getRequestDispatcher("/api/getConfig")).thenReturn(new MockRequestDispatcher());
+ when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ // verify if authorized
+ verify(httpServletRequest).getRequestDispatcher("/api/getConfig");
+ //
+ //
+ // Requests with InValid Environment Header
+ //
+ when(httpServletRequest.getRequestURI()).thenReturn("/pdp/getConfig");
+ when(httpServletRequest.getRequestDispatcher("/api//getConfig")).thenReturn(new MockRequestDispatcher());
+ when(httpServletRequest.getHeader(PDPAuthenticationFilter.ENVIRONMENT_HEADER)).thenReturn("TEST");
+ when(httpServletRequest.getHeader(PDPAuthenticationFilter.AUTHENTICATION_HEADER)).thenReturn(VALIDHEADERVALUE);
+ authenticationFilter.doFilter(httpServletRequest, httpServletResponse, filterChain);
+ // verify if unauthorized
+ verify(httpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/config/PDPRestInitializerTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/config/PDPRestInitializerTest.java
index b2dc98ad0..8a53975d6 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/config/PDPRestInitializerTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/config/PDPRestInitializerTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP-PAP-REST
+ * ONAP-PDP-REST
* ================================================================================
* 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,17 +30,16 @@ import org.junit.Test;
import org.mockito.Mockito;
public class PDPRestInitializerTest {
- @Test
- public void testNegativeStartup() throws ServletException {
- try {
- PDPRestInitializer init = new PDPRestInitializer();
- ServletContext container = Mockito.mock(ServletContext.class);
- init.onStartup(container);
- fail("Expecting an exception.");
- }
- catch (Exception ex) {
- // Expecting an exception
- assertTrue(true);
- }
- }
+ @Test
+ public void testNegativeStartup() throws ServletException {
+ try {
+ PDPRestInitializer init = new PDPRestInitializer();
+ ServletContext container = Mockito.mock(ServletContext.class);
+ init.onStartup(container);
+ fail("Expecting an exception.");
+ } catch (Exception ex) {
+ // Expecting an exception
+ assertTrue(true);
+ }
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPIPFinderFactoryTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPIPFinderFactoryTest.java
index d10d3a7be..dceadfa25 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPIPFinderFactoryTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPIPFinderFactoryTest.java
@@ -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,19 +30,19 @@ import com.att.research.xacml.api.pip.PIPException;
import com.att.research.xacml.api.pip.PIPFinder;
public class XACMLPdpPIPFinderFactoryTest {
- @Test
- public void testGets() throws PIPException {
- // Test constructors
- Properties props = new Properties();
- XACMLPdpPIPFinderFactory blankFactory = new XACMLPdpPIPFinderFactory();
- assertNotNull(blankFactory);
- XACMLPdpPIPFinderFactory factory = new XACMLPdpPIPFinderFactory(props);
- assertNotNull(factory);
-
- // Test get
- PIPFinder finder = factory.getFinder();
- assertNotNull(finder);
- finder = blankFactory.getFinder(props);
- assertNotNull(finder);
- }
+ @Test
+ public void testGets() throws PIPException {
+ // Test constructors
+ Properties props = new Properties();
+ XACMLPdpPIPFinderFactory blankFactory = new XACMLPdpPIPFinderFactory();
+ assertNotNull(blankFactory);
+ XACMLPdpPIPFinderFactory factory = new XACMLPdpPIPFinderFactory(props);
+ assertNotNull(factory);
+
+ // Test get
+ PIPFinder finder = factory.getFinder();
+ assertNotNull(finder);
+ finder = blankFactory.getFinder(props);
+ assertNotNull(finder);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPolicyFinderFactoryTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPolicyFinderFactoryTest.java
index af2ea7271..11811ecf3 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPolicyFinderFactoryTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/impl/test/XACMLPdpPolicyFinderFactoryTest.java
@@ -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.
@@ -22,58 +24,53 @@ package org.onap.policy.pdp.rest.impl.test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.onap.policy.pdp.rest.impl.XACMLPdpPolicyFinderFactory;
-
import com.att.research.xacml.util.XACMLProperties;
public class XACMLPdpPolicyFinderFactoryTest {
- private static Log LOGGER = LogFactory.getLog(XACMLPdpPolicyFinderFactoryTest.class);
-
- @Test
- public void testDefaultConstructor() throws IOException {
-
- LOGGER.info("XACMLPdpPolicyFinderFactoryTest - testDefaultConstructor");
- try {
- XACMLProperties.reloadProperties();
- System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pdp.properties");
- XACMLProperties.getProperties();
-
- XACMLPdpPolicyFinderFactory finderFactory = new XACMLPdpPolicyFinderFactory();
-
- finderFactory.getPolicyFinder();
-
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error("Exception Occured"+e);
- fail();
-
- }
- }
- @Test
- public void testPropertiesConstructor () {
-
- LOGGER.info("XACMLPdpPolicyFinderFactoryTest - testPropertiesConstructor");
- try {
- Properties properties = new Properties();
- FileInputStream input = new FileInputStream("src/test/resources/xacml.pdp.properties");
- properties.load(input);
-
- XACMLPdpPolicyFinderFactory finderFactory = new XACMLPdpPolicyFinderFactory(properties);
-
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error("Exception Occured"+e);
- fail();
-
- }
-
- }
+ private static Log LOGGER = LogFactory.getLog(XACMLPdpPolicyFinderFactoryTest.class);
+
+ @Test
+ public void testDefaultConstructor() throws IOException {
+
+ LOGGER.info("XACMLPdpPolicyFinderFactoryTest - testDefaultConstructor");
+ try {
+ XACMLProperties.reloadProperties();
+ System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pdp.properties");
+ XACMLProperties.getProperties();
+
+ XACMLPdpPolicyFinderFactory finderFactory = new XACMLPdpPolicyFinderFactory();
+
+ finderFactory.getPolicyFinder();
+
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error("Exception Occured" + e);
+ fail();
+ }
+ }
+
+ @Test
+ public void testPropertiesConstructor() {
+
+ LOGGER.info("XACMLPdpPolicyFinderFactoryTest - testPropertiesConstructor");
+ try {
+ Properties properties = new Properties();
+ FileInputStream input = new FileInputStream("src/test/resources/xacml.pdp.properties");
+ properties.load(input);
+
+ XACMLPdpPolicyFinderFactory finderFactory = new XACMLPdpPolicyFinderFactory(properties);
+
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error("Exception Occured" + e);
+ fail();
+ }
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/DummyServerContextImpl.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/DummyServerContextImpl.java
index 056b73199..e1498a8dc 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/DummyServerContextImpl.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/DummyServerContextImpl.java
@@ -4,6 +4,8 @@
* ================================================================================
* 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
@@ -27,7 +29,6 @@ import java.util.Enumeration;
import java.util.EventListener;
import java.util.Map;
import java.util.Set;
-
import javax.servlet.Filter;
import javax.servlet.FilterRegistration;
import javax.servlet.RequestDispatcher;
@@ -259,8 +260,8 @@ public class DummyServerContextImpl implements ServletContext {
}
@Override
- public javax.servlet.FilterRegistration.Dynamic addFilter(
- String filterName, Class<? extends Filter> filterClass) {
+ public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName,
+ Class<? extends Filter> filterClass) {
// TODO Auto-generated method stub
return null;
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java
index 59e14db1e..7fcc84bb9 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/jmx/PdpRestMBeanListenerTest.java
@@ -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.
@@ -21,35 +23,30 @@ package org.onap.policy.pdp.rest.jmx;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import javax.servlet.ServletContextEvent;
-
import org.junit.Test;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
public class PdpRestMBeanListenerTest {
- private static Logger LOGGER = FlexLogger.getLogger(PdpRestMBeanListenerTest.class);
-
- @Test
- public void test() {
+ private static Logger LOGGER = FlexLogger.getLogger(PdpRestMBeanListenerTest.class);
+
+ @Test
+ public void test() {
+
+ try {
+ PdpRestMBeanListener listener = new PdpRestMBeanListener();
+ DummyServerContextImpl source = new DummyServerContextImpl();
+ ServletContextEvent event = new ServletContextEvent(source);
- try {
- PdpRestMBeanListener listener = new PdpRestMBeanListener();
- DummyServerContextImpl source = new DummyServerContextImpl();
- ServletContextEvent event = new ServletContextEvent(source);
-
- listener.contextInitialized(event);
- listener.contextDestroyed(event);
-
- assertTrue(true);
- } catch (Exception e) {
- LOGGER.error("Exception Occured"+e);
- fail();
-
- }
-
- }
+ listener.contextInitialized(event);
+ listener.contextDestroyed(event);
+ assertTrue(true);
+ } catch (Exception e) {
+ LOGGER.error("Exception Occured" + e);
+ fail();
+ }
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/RemovedTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/RemovedTest.java
index 98b073eb8..2636847e7 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/RemovedTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/RemovedTest.java
@@ -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.
@@ -24,14 +26,14 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class RemovedTest {
- @Test
- public void testRemoved() {
- String testVal = "testVal";
-
- Removed removed = new Removed();
- removed.setVersionNo(testVal);
- assertEquals(removed.getVersionNo(), testVal);
- removed.setPolicyName(testVal);
- assertEquals(removed.getPolicyName(), testVal);
- }
+ @Test
+ public void testRemoved() {
+ String testVal = "testVal";
+
+ Removed removed = new Removed();
+ removed.setVersionNo(testVal);
+ assertEquals(removed.getVersionNo(), testVal);
+ removed.setPolicyName(testVal);
+ assertEquals(removed.getPolicyName(), testVal);
+ }
}
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/test/NotificationTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/test/NotificationTest.java
index a18f93275..261226527 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/test/NotificationTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/notifications/test/NotificationTest.java
@@ -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.
@@ -20,12 +22,10 @@
package org.onap.policy.pdp.rest.notifications.test;
import static org.junit.Assert.assertEquals;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-
import org.junit.Test;
import org.onap.policy.api.NotificationType;
import org.onap.policy.pdp.rest.notifications.Notification;
@@ -33,45 +33,41 @@ import org.onap.policy.pdp.rest.notifications.Removed;
import org.onap.policy.pdp.rest.notifications.Updated;
public class NotificationTest {
-
- @Test
- public void test() {
- List<Removed> removedPolicies = new ArrayList<>();
- List<Updated> loadedPolicies = new ArrayList<>();
-
- Updated u1 = new Updated();
- Removed r1 = new Removed();
- Notification n = new Notification();
+ @Test
+ public void test() {
+ List<Removed> removedPolicies = new ArrayList<>();
+ List<Updated> loadedPolicies = new ArrayList<>();
+
+ Updated u1 = new Updated();
+ Removed r1 = new Removed();
+ Notification n = new Notification();
+
+ u1.setPolicyName("update");
+ u1.setVersionNo("1");
+ u1.setMatches(null);
+ u1.setUpdateType(null);
+
+ assertEquals("update", u1.getPolicyName());
+ assertEquals("1", u1.getVersionNo());
+ assertEquals(null, u1.getMatches());
+ assertEquals(null, u1.getUpdateType());
+
+ loadedPolicies.add(u1);
+
+ r1.setPolicyName("removed");
+ r1.setVersionNo("1");
+ assertEquals(r1.getPolicyName(), "removed");
+ assertEquals(r1.getVersionNo(), "1");
+
+ removedPolicies.add(r1);
+
+ n.setLoadedPolicies(loadedPolicies);
+ n.setRemovedPolicies(removedPolicies);
+ n.setNotificationType(NotificationType.BOTH);
- u1.setPolicyName("update");
- u1.setVersionNo("1");
- u1.setMatches(null);
- u1.setUpdateType(null);
-
- assertEquals("update", u1.getPolicyName());
- assertEquals("1", u1.getVersionNo());
- assertEquals(null, u1.getMatches());
- assertEquals(null, u1.getUpdateType());
-
- loadedPolicies.add(u1);
-
- r1.setPolicyName("removed");
- r1.setVersionNo("1");
- assertEquals(r1.getPolicyName(),"removed");
- assertEquals(r1.getVersionNo(),"1");
-
- removedPolicies.add(r1);
-
- n.setLoadedPolicies(loadedPolicies);
- n.setRemovedPolicies(removedPolicies);
- n.setNotificationType(NotificationType.BOTH);
-
- assertEquals(removedPolicies, n.getRemovedPolicies());
- assertEquals(loadedPolicies, n.getLoadedPolicies());
- assertEquals(NotificationType.BOTH, n.getNotificationType());
-
-
-
- }
+ assertEquals(removedPolicies, n.getRemovedPolicies());
+ assertEquals(loadedPolicies, n.getLoadedPolicies());
+ assertEquals(NotificationType.BOTH, n.getNotificationType());
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/api/XACMLErrorConstantsTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/api/XACMLErrorConstantsTest.java
index 221481723..0166a128a 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/api/XACMLErrorConstantsTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/api/XACMLErrorConstantsTest.java
@@ -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();
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineFactoryTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineFactoryTest.java
index 2e0a0de17..6ab9790c1 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineFactoryTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineFactoryTest.java
@@ -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);
+ }
}
- }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java
index f0ee8dd73..79b43b130 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdEngineTest.java
@@ -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);
+ }
}
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupStatusTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupStatusTest.java
index 3e1d81578..55413d83b 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupStatusTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupStatusTest.java
@@ -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(""));
}
-
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupTest.java
index 323b0348a..e5e058a5c 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPGroupTest.java
@@ -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.
@@ -20,12 +22,10 @@
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);
+ }
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPItemSetChangeNotifierTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPItemSetChangeNotifierTest.java
index 1be34ee00..cea7c32c7 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPItemSetChangeNotifierTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPItemSetChangeNotifierTest.java
@@ -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);
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPIPConfigTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPIPConfigTest.java
index 05b8ae7cc..b5713d362 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPIPConfigTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPIPConfigTest.java
@@ -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)));
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPolicyTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPolicyTest.java
index 26af008b6..7aaa381ce 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPolicyTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPPolicyTest.java
@@ -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);
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPStatusTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPStatusTest.java
index c99eef8ee..dfdbf5f16 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPStatusTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPStatusTest.java
@@ -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());
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPTest.java
index e62f1fdb1..0beb28275 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pap/StdPDPTest.java
@@ -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)));
- }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pip/engines/OperationHistoryEngineTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pip/engines/OperationHistoryEngineTest.java
index bc9a67460..2b43ce753 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pip/engines/OperationHistoryEngineTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/std/pip/engines/OperationHistoryEngineTest.java
@@ -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);
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/AAFEngineTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/AAFEngineTest.java
index f60645fef..319198e69 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/AAFEngineTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/AAFEngineTest.java
@@ -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");
+ }
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/MetricsUtilTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/MetricsUtilTest.java
index 041acdee6..291bae808 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/MetricsUtilTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/MetricsUtilTest.java
@@ -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.
@@ -20,33 +22,32 @@
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);
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyScannerTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyScannerTest.java
index 09dcf837f..0270a8901 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyScannerTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyScannerTest.java
@@ -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);
+ }
+ }
}
diff --git a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyWriterTest.java b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyWriterTest.java
index 446a87d1a..4cf40a315 100644
--- a/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyWriterTest.java
+++ b/ONAP-XACML/src/test/java/org/onap/policy/xacml/test/util/XACMLPolicyWriterTest.java
@@ -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());
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/ManualClientEndDMAAPTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/ManualClientEndDMAAPTest.java
index 8c0c6c4e0..b19e07f9d 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/ManualClientEndDMAAPTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/ManualClientEndDMAAPTest.java
@@ -1,15 +1,17 @@
/*-
* ============LICENSE_START=======================================================
- * ONAP Policy Engine
+ * PolicyEngineAPI
* ================================================================================
* 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.
@@ -29,24 +31,24 @@ import org.onap.policy.api.NotificationScheme;
import org.onap.policy.api.PDPNotification;
public class ManualClientEndDMAAPTest {
- @Test
- public void testStaticMethods() {
- // Negative test result
- PDPNotification notification = ManualClientEndDMAAP.result(NotificationScheme.AUTO_ALL_NOTIFICATIONS);
- assertNull(notification);
-
- // Negative test create and start
- String topic = "testTopic";
- String uniqueID = "testID";
- List<String> dmaapList = new ArrayList<String>();
- String aafLogin = "testLogin";
- String aafPassword = "testPassword";
- try {
- ManualClientEndDMAAP.createTopic(topic, uniqueID, dmaapList, aafLogin, aafPassword);
- ManualClientEndDMAAP.start(dmaapList, topic, aafLogin, aafPassword, uniqueID);
- }
- catch (Exception ex) {
- fail("Not expecting any exception: " + ex);
- }
- }
+ @Test
+ public void testStaticMethods() {
+ // Negative test result
+ PDPNotification notification =
+ ManualClientEndDMAAP.result(NotificationScheme.AUTO_ALL_NOTIFICATIONS);
+ assertNull(notification);
+
+ // Negative test create and start
+ String topic = "testTopic";
+ String uniqueID = "testID";
+ List<String> dmaapList = new ArrayList<String>();
+ String aafLogin = "testLogin";
+ String aafPassword = "testPassword";
+ try {
+ ManualClientEndDMAAP.createTopic(topic, uniqueID, dmaapList, aafLogin, aafPassword);
+ ManualClientEndDMAAP.start(dmaapList, topic, aafLogin, aafPassword, uniqueID);
+ } catch (Exception ex) {
+ fail("Not expecting any exception: " + ex);
+ }
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/StdPolicyEngineTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/StdPolicyEngineTest.java
index 4ede02806..90e00c2c3 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/StdPolicyEngineTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/StdPolicyEngineTest.java
@@ -4,12 +4,14 @@
* ================================================================================
* 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.
@@ -111,877 +113,889 @@ import org.springframework.web.client.RestClientException;
@RunWith(PowerMockRunner.class)
public class StdPolicyEngineTest {
- private static final String ONAP_NAME_VAL = "ONAP_NAME";
- private static final String POLICY_VERSION = "1.0.0";
- private static final String POLICY_NAME = "ONAP";
- private static final String COMMENTS = "";
- private static final UUID REQUEST_UUID = UUID.randomUUID();
- private static final String SERVER_NAME = "localhost.com";
- private static final String PDP_PROP_VALUE = "http://localhost:8092/pdp/ , test, test";
- private static final String PDP_PROP_VALUE_1 = "https://localhost:8091/pdp/ , onap, onap";
- private static final String JSON_CONFIGURATION = "{\"name\":\"value\"}";
- private static final String XML_CONFIGURATION =
- "<map><entry><string>name</string><string>value</string></entry></map>";
-
- @Rule
- public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
- private static final String CONFIG_PROPERTIES_FILE = "config_pass.properties";
- private static final String INVALID_CONFIG_PROPERTY_FILE = "config_fail.properties";
-
- @Test
- public void testStdPolicyEngineInitialize_noException() throws Exception {
- final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
-
- creatPropertyFile(file, getDefaultProperties());
-
- final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
- policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
- assertEquals("TEST", StdPolicyEngine.getEnvironment());
- assertEquals("http://localhost:8092/pdp/", StdPolicyEngine.getPDPURL());
- assertEquals(Arrays.asList(UEB, DMAAP), policyEngine.getNotificationType());
- assertEquals(Arrays.asList(SERVER_NAME, SERVER_NAME), policyEngine.getNotificationURLList());
- }
-
- @Test
- public void testStdPolicyEngineWithPropertiesInitialize_noException() throws Exception {
- final StdPolicyEngine policyEngine = new StdPolicyEngine(getDefaultProperties(), (String) null);
- policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
- assertEquals("TEST", StdPolicyEngine.getEnvironment());
- assertEquals("http://localhost:8092/pdp/", StdPolicyEngine.getPDPURL());
- assertEquals(Arrays.asList(UEB, DMAAP), policyEngine.getNotificationType());
- assertEquals(Arrays.asList(SERVER_NAME, SERVER_NAME), policyEngine.getNotificationURLList());
- }
-
- @Test
- public void testStdPolicyEngineInitializeWithSingleServerName_noException() throws Exception {
- final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
-
- final Properties properties = new Properties();
- properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
- properties.setProperty(CLIENT_ID_PROP_NAME, "test");
- properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
- properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB);
- properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME);
- properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
- properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
- creatPropertyFile(file, properties);
-
- final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
- policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
- assertEquals(Arrays.asList(SERVER_NAME), policyEngine.getNotificationURLList());
- }
-
- @Test
- public void testStdPolicyEngineInitializeWithSingleNotificationType_noException()
- throws Exception {
- final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
-
- final Properties properties = new Properties();
- properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
- properties.setProperty(CLIENT_ID_PROP_NAME, "test");
- properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
- properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB);
- properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME);
- properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
- properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
- creatPropertyFile(file, properties);
-
- final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
- policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
- assertEquals(Arrays.asList(UEB), policyEngine.getNotificationType());
- }
-
- @Test(expected = PolicyEngineException.class)
- public void testStdPolicyEngineInitialize_InvalidPropertyFile_Exception()
- throws PolicyEngineException {
- new StdPolicyEngine("Invalid.properties", (String) null);
- }
-
- @Test(expected = PolicyEngineException.class)
- public void testStdPolicyEngineInitialize_InvalidPropertyFileWithExt_Exception()
- throws Exception {
- final File emptyFile = temporaryFolder.newFile("EmptyFile.txt");
- new StdPolicyEngine(emptyFile.toString(), (String) null);
- }
-
- @Test(expected = PolicyEngineException.class)
- public void testStdPolicyEngineInitialize_NullArguments_Exception() throws Exception {
- new StdPolicyEngine((String) null, (String) null);
- }
-
- @Test(expected = PolicyEngineException.class)
- public void testStdPolicyEngineWithPropertiesInitialize_NullArguments_Exception()
- throws Exception {
- new StdPolicyEngine((Properties) null, (String) null);
- }
-
- @Test(expected = PolicyEngineException.class)
- public void testStdPolicyEngineInitialize_PropertyFileMissingMandatoryProperties_Exception()
- throws Exception {
- final File file = temporaryFolder.newFile(INVALID_CONFIG_PROPERTY_FILE);
- final Properties properties = new Properties();
- properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
- creatPropertyFile(file, properties);
-
- new StdPolicyEngine(file.toString(), (String) null);
- }
-
- @Test
- public void testStdPolicyEngineInitialize_MultiplePdp_noException() throws Exception {
- final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
-
- final Properties properties = new Properties();
- properties.setProperty(PDP_URL_PROP_NAME,
- PDP_PROP_VALUE + PolicyConfigConstants.SEMICOLLON + PDP_PROP_VALUE_1);
- properties.setProperty(CLIENT_ID_PROP_NAME, "test");
- properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
- properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB + COMMA + DMAAP);
- properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
- properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
- properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
- creatPropertyFile(file, properties);
-
- final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
- policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
- assertEquals("http://localhost:8092/pdp/", StdPolicyEngine.getPDPURL());
- StdPolicyEngine.rotatePDPList();
- assertEquals("https://localhost:8091/pdp/", StdPolicyEngine.getPDPURL());
- assertEquals(Arrays.asList(UEB, DMAAP), policyEngine.getNotificationType());
- assertEquals(Arrays.asList(SERVER_NAME, SERVER_NAME), policyEngine.getNotificationURLList());
- }
-
- @Test(expected = PolicyEngineException.class)
- public void testStdPolicyEngineInitialize_NoPDP_noException() throws Exception {
- final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
-
- final Properties properties = new Properties();
- properties.setProperty(CLIENT_ID_PROP_NAME, "test");
- properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
- properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB + COMMA + DMAAP);
- properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
- properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
- properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
- creatPropertyFile(file, properties);
-
- new StdPolicyEngine(file.toString(), (String) null);
- }
-
- @Test
- public void testStdPolicyEngineInitializeNotificationTypeDMMAP_noException() throws Exception {
- final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
-
- final Properties properties = new Properties();
- properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
- properties.setProperty(CLIENT_ID_PROP_NAME, "test");
- properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
- properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, DMAAP);
- properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
- properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
- properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
- creatPropertyFile(file, properties);
-
- final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
- policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
-
- assertEquals(Arrays.asList(DMAAP), policyEngine.getNotificationType());
-
- }
-
- @Test
- public void testStdPolicyEngineSendEvent_noException() throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doReturn(new ResponseEntity<>(getStdPolicyResponse(), HttpStatus.ACCEPTED))
- .when(spyPolicyEngine).callNewPDP(eq(SEND_EVENT_RESOURCE_NAME), any(), any(), any());
-
- final Collection<PolicyResponse> actualPolicyResponses =
+ private static final String ONAP_NAME_VAL = "ONAP_NAME";
+ private static final String POLICY_VERSION = "1.0.0";
+ private static final String POLICY_NAME = "ONAP";
+ private static final String COMMENTS = "";
+ private static final UUID REQUEST_UUID = UUID.randomUUID();
+ private static final String SERVER_NAME = "localhost.com";
+ private static final String PDP_PROP_VALUE = "http://localhost:8092/pdp/ , test, test";
+ private static final String PDP_PROP_VALUE_1 = "https://localhost:8091/pdp/ , onap, onap";
+ private static final String JSON_CONFIGURATION = "{\"name\":\"value\"}";
+ private static final String XML_CONFIGURATION =
+ "<map><entry><string>name</string><string>value</string></entry></map>";
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private static final String CONFIG_PROPERTIES_FILE = "config_pass.properties";
+ private static final String INVALID_CONFIG_PROPERTY_FILE = "config_fail.properties";
+
+ @Test
+ public void testStdPolicyEngineInitialize_noException() throws Exception {
+ final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
+
+ creatPropertyFile(file, getDefaultProperties());
+
+ final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
+ policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
+ assertEquals("TEST", StdPolicyEngine.getEnvironment());
+ assertEquals("http://localhost:8092/pdp/", StdPolicyEngine.getPDPURL());
+ assertEquals(Arrays.asList(UEB, DMAAP), policyEngine.getNotificationType());
+ assertEquals(Arrays.asList(SERVER_NAME, SERVER_NAME),
+ policyEngine.getNotificationURLList());
+ }
+
+ @Test
+ public void testStdPolicyEngineWithPropertiesInitialize_noException() throws Exception {
+ final StdPolicyEngine policyEngine =
+ new StdPolicyEngine(getDefaultProperties(), (String) null);
+ policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
+ assertEquals("TEST", StdPolicyEngine.getEnvironment());
+ assertEquals("http://localhost:8092/pdp/", StdPolicyEngine.getPDPURL());
+ assertEquals(Arrays.asList(UEB, DMAAP), policyEngine.getNotificationType());
+ assertEquals(Arrays.asList(SERVER_NAME, SERVER_NAME),
+ policyEngine.getNotificationURLList());
+ }
+
+ @Test
+ public void testStdPolicyEngineInitializeWithSingleServerName_noException() throws Exception {
+ final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
+
+ final Properties properties = new Properties();
+ properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
+ properties.setProperty(CLIENT_ID_PROP_NAME, "test");
+ properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
+ properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB);
+ properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME);
+ properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
+ properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
+ creatPropertyFile(file, properties);
+
+ final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
+ policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
+ assertEquals(Arrays.asList(SERVER_NAME), policyEngine.getNotificationURLList());
+ }
+
+ @Test
+ public void testStdPolicyEngineInitializeWithSingleNotificationType_noException()
+ throws Exception {
+ final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
+
+ final Properties properties = new Properties();
+ properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
+ properties.setProperty(CLIENT_ID_PROP_NAME, "test");
+ properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
+ properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB);
+ properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME);
+ properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
+ properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
+ creatPropertyFile(file, properties);
+
+ final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
+ policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
+ assertEquals(Arrays.asList(UEB), policyEngine.getNotificationType());
+ }
+
+ @Test(expected = PolicyEngineException.class)
+ public void testStdPolicyEngineInitialize_InvalidPropertyFile_Exception()
+ throws PolicyEngineException {
+ new StdPolicyEngine("Invalid.properties", (String) null);
+ }
+
+ @Test(expected = PolicyEngineException.class)
+ public void testStdPolicyEngineInitialize_InvalidPropertyFileWithExt_Exception()
+ throws Exception {
+ final File emptyFile = temporaryFolder.newFile("EmptyFile.txt");
+ new StdPolicyEngine(emptyFile.toString(), (String) null);
+ }
+
+ @Test(expected = PolicyEngineException.class)
+ public void testStdPolicyEngineInitialize_NullArguments_Exception() throws Exception {
+ new StdPolicyEngine((String) null, (String) null);
+ }
+
+ @Test(expected = PolicyEngineException.class)
+ public void testStdPolicyEngineWithPropertiesInitialize_NullArguments_Exception()
+ throws Exception {
+ new StdPolicyEngine((Properties) null, (String) null);
+ }
+
+ @Test(expected = PolicyEngineException.class)
+ public void testStdPolicyEngineInitialize_PropertyFileMissingMandatoryProperties_Exception()
+ throws Exception {
+ final File file = temporaryFolder.newFile(INVALID_CONFIG_PROPERTY_FILE);
+ final Properties properties = new Properties();
+ properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
+ creatPropertyFile(file, properties);
+
+ new StdPolicyEngine(file.toString(), (String) null);
+ }
+
+ @Test
+ public void testStdPolicyEngineInitialize_MultiplePdp_noException() throws Exception {
+ final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
+
+ final Properties properties = new Properties();
+ properties.setProperty(PDP_URL_PROP_NAME,
+ PDP_PROP_VALUE + PolicyConfigConstants.SEMICOLLON + PDP_PROP_VALUE_1);
+ properties.setProperty(CLIENT_ID_PROP_NAME, "test");
+ properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
+ properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB + COMMA + DMAAP);
+ properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
+ properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
+ properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
+ creatPropertyFile(file, properties);
+
+ final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
+ policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
+ assertEquals("http://localhost:8092/pdp/", StdPolicyEngine.getPDPURL());
+ StdPolicyEngine.rotatePDPList();
+ assertEquals("https://localhost:8091/pdp/", StdPolicyEngine.getPDPURL());
+ assertEquals(Arrays.asList(UEB, DMAAP), policyEngine.getNotificationType());
+ assertEquals(Arrays.asList(SERVER_NAME, SERVER_NAME),
+ policyEngine.getNotificationURLList());
+ }
+
+ @Test(expected = PolicyEngineException.class)
+ public void testStdPolicyEngineInitialize_NoPDP_noException() throws Exception {
+ final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
+
+ final Properties properties = new Properties();
+ properties.setProperty(CLIENT_ID_PROP_NAME, "test");
+ properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
+ properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB + COMMA + DMAAP);
+ properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
+ properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
+ properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
+ creatPropertyFile(file, properties);
+
+ new StdPolicyEngine(file.toString(), (String) null);
+ }
+
+ @Test
+ public void testStdPolicyEngineInitializeNotificationTypeDMMAP_noException() throws Exception {
+ final File file = temporaryFolder.newFile(CONFIG_PROPERTIES_FILE);
+
+ final Properties properties = new Properties();
+ properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
+ properties.setProperty(CLIENT_ID_PROP_NAME, "test");
+ properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
+ properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, DMAAP);
+ properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
+ properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
+ properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
+ creatPropertyFile(file, properties);
+
+ final StdPolicyEngine policyEngine = new StdPolicyEngine(file.toString(), (String) null);
+ policyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
+
+ assertEquals(Arrays.asList(DMAAP), policyEngine.getNotificationType());
+
+ }
+
+ @Test
+ public void testStdPolicyEngineSendEvent_noException() throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doReturn(new ResponseEntity<>(getStdPolicyResponse(), HttpStatus.ACCEPTED))
+ .when(spyPolicyEngine)
+ .callNewPDP(eq(SEND_EVENT_RESOURCE_NAME), any(), any(), any());
+
+ final Collection<PolicyResponse> actualPolicyResponses =
+ spyPolicyEngine.sendEvent(Collections.emptyMap(), REQUEST_UUID);
+
+ assertEquals(1, actualPolicyResponses.size());
+
+ }
+
+ @Test(expected = PolicyEventException.class)
+ public void testStdPolicyEngineSendEvent_NullEventRequestParameters_Exception()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ spyPolicyEngine.sendEvent((EventRequestParameters) null);
+ }
+
+ @Test(expected = PolicyEventException.class)
+ public void testStdPolicyEngineSendEvent_EventRequestParameters_CallPDPThrow401Exception_Exception()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ Mockito.doThrow(new RuntimeException(new RestClientException("Error 401")))
+ .when(spyPolicyEngine).callNewPDP(any(), any(), any(), any());
spyPolicyEngine.sendEvent(Collections.emptyMap(), REQUEST_UUID);
+ }
- assertEquals(1, actualPolicyResponses.size());
+ @Test
+ public void testStdPolicyEngineSendEvent_EventRequestParameters_noException() throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- }
+ final ResponseEntity<StdPolicyResponse[]> stubbedResponse =
+ new ResponseEntity<>(getStdPolicyResponse(), HttpStatus.ACCEPTED);
- @Test(expected = PolicyEventException.class)
- public void testStdPolicyEngineSendEvent_NullEventRequestParameters_Exception() throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- spyPolicyEngine.sendEvent((EventRequestParameters) null);
- }
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(SEND_EVENT_RESOURCE_NAME),
+ any(), any(), any());
- @Test(expected = PolicyEventException.class)
- public void testStdPolicyEngineSendEvent_EventRequestParameters_CallPDPThrow401Exception_Exception()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- Mockito.doThrow(new RuntimeException(new RestClientException("Error 401")))
- .when(spyPolicyEngine).callNewPDP(any(), any(), any(), any());
- spyPolicyEngine.sendEvent(Collections.emptyMap(), REQUEST_UUID);
- }
+ final EventRequestParameters eventRequestParameters = new EventRequestParameters();
+ eventRequestParameters.setEventAttributes(Collections.emptyMap());
+ eventRequestParameters.setRequestID(REQUEST_UUID);
- @Test
- public void testStdPolicyEngineSendEvent_EventRequestParameters_noException() throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ final Collection<PolicyResponse> actualPolicyResponses =
+ spyPolicyEngine.sendEvent(eventRequestParameters);
- final ResponseEntity<StdPolicyResponse[]> stubbedResponse =
- new ResponseEntity<>(getStdPolicyResponse(), HttpStatus.ACCEPTED);
+ assertEquals(1, actualPolicyResponses.size());
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(SEND_EVENT_RESOURCE_NAME), any(),
- any(), any());
+ }
- final EventRequestParameters eventRequestParameters = new EventRequestParameters();
- eventRequestParameters.setEventAttributes(Collections.emptyMap());
- eventRequestParameters.setRequestID(REQUEST_UUID);
+ @Test
+ public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigJSON_noException()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- final Collection<PolicyResponse> actualPolicyResponses =
- spyPolicyEngine.sendEvent(eventRequestParameters);
+ final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse = new ResponseEntity<>(
+ getAPIPolicyConfigResponse(PolicyType.JSON, JSON_CONFIGURATION),
+ HttpStatus.ACCEPTED);
- assertEquals(1, actualPolicyResponses.size());
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- }
+ final Collection<PolicyConfig> actualPolicyResponses =
+ spyPolicyEngine.getConfig(new ConfigRequestParameters());
- @Test
- public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigJSON_noException()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ assertEquals(1, actualPolicyResponses.size());
- final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse = new ResponseEntity<>(
- getAPIPolicyConfigResponse(PolicyType.JSON, JSON_CONFIGURATION), HttpStatus.ACCEPTED);
+ final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
+ assertNotNull(actualPolicyConfig.toJSON());
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
- eq(HttpMethod.POST), any(), any());
+ }
- final Collection<PolicyConfig> actualPolicyResponses =
- spyPolicyEngine.getConfig(new ConfigRequestParameters());
+ @Test
+ public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigOther_noException()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertEquals(1, actualPolicyResponses.size());
+ final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse = new ResponseEntity<>(
+ getAPIPolicyConfigResponse(PolicyType.OTHER, COMMENTS), HttpStatus.ACCEPTED);
- final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
- assertNotNull(actualPolicyConfig.toJSON());
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- }
+ final Collection<PolicyConfig> actualPolicyResponses =
+ spyPolicyEngine.getConfig(new ConfigRequestParameters());
- @Test
- public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigOther_noException()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ assertEquals(1, actualPolicyResponses.size());
- final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse = new ResponseEntity<>(
- getAPIPolicyConfigResponse(PolicyType.OTHER, COMMENTS), HttpStatus.ACCEPTED);
+ final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
+ assertNotNull(actualPolicyConfig.toOther());
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
- eq(HttpMethod.POST), any(), any());
+ }
- final Collection<PolicyConfig> actualPolicyResponses =
- spyPolicyEngine.getConfig(new ConfigRequestParameters());
+ @Test
+ public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigXML_noException()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertEquals(1, actualPolicyResponses.size());
+ final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse = new ResponseEntity<>(
+ getAPIPolicyConfigResponse(PolicyType.XML, XML_CONFIGURATION), HttpStatus.ACCEPTED);
- final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
- assertNotNull(actualPolicyConfig.toOther());
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- }
+ final Collection<PolicyConfig> actualPolicyResponses =
+ spyPolicyEngine.getConfig(new ConfigRequestParameters());
- @Test
- public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigXML_noException()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ assertEquals(1, actualPolicyResponses.size());
- final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse = new ResponseEntity<>(
- getAPIPolicyConfigResponse(PolicyType.XML, XML_CONFIGURATION), HttpStatus.ACCEPTED);
+ final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
+ assertNotNull(actualPolicyConfig.toXML());
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
- eq(HttpMethod.POST), any(), any());
+ }
- final Collection<PolicyConfig> actualPolicyResponses =
- spyPolicyEngine.getConfig(new ConfigRequestParameters());
+ @Test
+ public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigProperties_noException()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertEquals(1, actualPolicyResponses.size());
+ final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse = new ResponseEntity<>(
+ getAPIPolicyConfigResponse(PolicyType.PROPERTIES, COMMENTS), HttpStatus.ACCEPTED);
- final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
- assertNotNull(actualPolicyConfig.toXML());
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- }
+ final Collection<PolicyConfig> actualPolicyResponses =
+ spyPolicyEngine.getConfig(new ConfigRequestParameters());
- @Test
- public void testStdPolicyEngineGetConfig_ConfigRequestParametersPolicyConfigProperties_noException()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ assertEquals(1, actualPolicyResponses.size());
- final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse = new ResponseEntity<>(
- getAPIPolicyConfigResponse(PolicyType.PROPERTIES, COMMENTS), HttpStatus.ACCEPTED);
+ final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
+ assertNotNull(actualPolicyConfig.toProperties());
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
- eq(HttpMethod.POST), any(), any());
+ }
- final Collection<PolicyConfig> actualPolicyResponses =
+ @Test(expected = PolicyConfigException.class)
+ public void testStdPolicyEngineSendEvent_ConfigRequestParameters_CallPDPThrow404Exception_Exception()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doThrow(new RuntimeException(new RestClientException("Error 404"))).when(spyPolicyEngine)
+ .callNewPDP(any(), any(), any(), any());
spyPolicyEngine.getConfig(new ConfigRequestParameters());
+ }
- assertEquals(1, actualPolicyResponses.size());
+ @Test
+ public void testStdPolicyEngineListConfig_ConfigRequestParametersPolicyConfigProperties_noException()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- final PolicyConfig actualPolicyConfig = actualPolicyResponses.iterator().next();
- assertNotNull(actualPolicyConfig.toProperties());
+ final APIPolicyConfigResponse[] apiPolicyConfigResponse =
+ getAPIPolicyConfigResponse(PolicyType.JSON, JSON_CONFIGURATION);
- }
+ final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse =
+ new ResponseEntity<>(apiPolicyConfigResponse, HttpStatus.ACCEPTED);
- @Test(expected = PolicyConfigException.class)
- public void testStdPolicyEngineSendEvent_ConfigRequestParameters_CallPDPThrow404Exception_Exception()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doThrow(new RuntimeException(new RestClientException("Error 404"))).when(spyPolicyEngine)
- .callNewPDP(any(), any(), any(), any());
- spyPolicyEngine.getConfig(new ConfigRequestParameters());
- }
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- @Test
- public void testStdPolicyEngineListConfig_ConfigRequestParametersPolicyConfigProperties_noException()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ final Collection<String> actualResponse =
+ spyPolicyEngine.listConfig(new ConfigRequestParameters());
+ assertEquals(1, actualResponse.size());
+ assertNotNull(actualResponse.iterator().next());
- final APIPolicyConfigResponse[] apiPolicyConfigResponse =
- getAPIPolicyConfigResponse(PolicyType.JSON, JSON_CONFIGURATION);
+ }
- final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse =
- new ResponseEntity<>(apiPolicyConfigResponse, HttpStatus.ACCEPTED);
+ @Test
+ public void testStdPolicyEngineListConfig_ConfigRequestParametersMessageConfigContainsPE300_noException()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
- eq(HttpMethod.POST), any(), any());
+ final APIPolicyConfigResponse[] apiPolicyConfigResponse = getAPIPolicyConfigResponse(
+ PolicyType.JSON, JSON_CONFIGURATION, PolicyConfigConstants.PE300);
- final Collection<String> actualResponse =
- spyPolicyEngine.listConfig(new ConfigRequestParameters());
- assertEquals(1, actualResponse.size());
- assertNotNull(actualResponse.iterator().next());
+ final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse =
+ new ResponseEntity<>(apiPolicyConfigResponse, HttpStatus.ACCEPTED);
- }
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- @Test
- public void testStdPolicyEngineListConfig_ConfigRequestParametersMessageConfigContainsPE300_noException()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ final Collection<String> actualResponse =
+ spyPolicyEngine.listConfig(new ConfigRequestParameters());
- final APIPolicyConfigResponse[] apiPolicyConfigResponse = getAPIPolicyConfigResponse(
- PolicyType.JSON, JSON_CONFIGURATION, PolicyConfigConstants.PE300);
+ assertEquals(1, actualResponse.size());
- final ResponseEntity<APIPolicyConfigResponse[]> stubbedResponse =
- new ResponseEntity<>(apiPolicyConfigResponse, HttpStatus.ACCEPTED);
+ }
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_CONFIG_RESOURCE_NAME),
- eq(HttpMethod.POST), any(), any());
+ @Test
+ public void testStdPolicyEngineListConfig_ConfigRequestParametersWithTestProperty_noException()
+ throws Exception {
+ final Properties defaultProperties = getDefaultProperties();
+ defaultProperties.setProperty(PolicyConfigConstants.JUNIT_PROP_NAME, "test");
+ final StdPolicyEngine spyPolicyEngine =
+ getSpyPolicyEngine("test" + CONFIG_PROPERTIES_FILE, defaultProperties);
- final Collection<String> actualResponse =
- spyPolicyEngine.listConfig(new ConfigRequestParameters());
+ final Collection<String> actualResponse =
+ spyPolicyEngine.listConfig(new ConfigRequestParameters());
- assertEquals(1, actualResponse.size());
+ assertEquals(1, actualResponse.size());
- }
+ }
- @Test
- public void testStdPolicyEngineListConfig_ConfigRequestParametersWithTestProperty_noException()
- throws Exception {
- final Properties defaultProperties = getDefaultProperties();
- defaultProperties.setProperty(PolicyConfigConstants.JUNIT_PROP_NAME, "test");
- final StdPolicyEngine spyPolicyEngine =
- getSpyPolicyEngine("test" + CONFIG_PROPERTIES_FILE, defaultProperties);
+ @Test
+ public void testStdPolicyEnginGetDecision_PolicyDecision_noException() throws Exception {
- final Collection<String> actualResponse =
- spyPolicyEngine.listConfig(new ConfigRequestParameters());
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertEquals(1, actualResponse.size());
+ final ResponseEntity<StdDecisionResponse> stubbedResponse =
+ new ResponseEntity<>(getStdDecisionResponse(), HttpStatus.ACCEPTED);
- }
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_DECISION_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- @Test
- public void testStdPolicyEnginGetDecision_PolicyDecision_noException() throws Exception {
+ final DecisionResponse actualResponse =
+ spyPolicyEngine.getDecision(ONAP_NAME_VAL, Collections.emptyMap(), REQUEST_UUID);
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ assertNotNull(actualResponse);
+ }
- final ResponseEntity<StdDecisionResponse> stubbedResponse =
- new ResponseEntity<>(getStdDecisionResponse(), HttpStatus.ACCEPTED);
+ @Test(expected = PolicyDecisionException.class)
+ public void testStdPolicyEngineGetDecision_PolicyDecision_CallPDPThrow400Exception_Exception()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doThrow(new RuntimeException(new RestClientException("Error 400"))).when(spyPolicyEngine)
+ .callNewPDP(eq(GET_DECISION_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
+ spyPolicyEngine.getDecision(ONAP_NAME_VAL, Collections.emptyMap(), REQUEST_UUID);
+ }
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_DECISION_RESOURCE_NAME),
- eq(HttpMethod.POST), any(), any());
+ @Test
+ public void testStdPolicyEnginGetDecision_DecisionRequestParameters_noException()
+ throws Exception {
- final DecisionResponse actualResponse =
- spyPolicyEngine.getDecision(ONAP_NAME_VAL, Collections.emptyMap(), REQUEST_UUID);
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertNotNull(actualResponse);
- }
+ final ResponseEntity<StdDecisionResponse> stubbedResponse =
+ new ResponseEntity<>(getStdDecisionResponse(), HttpStatus.ACCEPTED);
- @Test(expected = PolicyDecisionException.class)
- public void testStdPolicyEngineGetDecision_PolicyDecision_CallPDPThrow400Exception_Exception()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doThrow(new RuntimeException(new RestClientException("Error 400"))).when(spyPolicyEngine)
- .callNewPDP(eq(GET_DECISION_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
- spyPolicyEngine.getDecision(ONAP_NAME_VAL, Collections.emptyMap(), REQUEST_UUID);
- }
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_DECISION_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- @Test
- public void testStdPolicyEnginGetDecision_DecisionRequestParameters_noException()
- throws Exception {
+ final DecisionRequestParameters requestParameters = new DecisionRequestParameters();
+ requestParameters.setOnapName(ONAP_NAME_VAL);
+ requestParameters.setRequestID(REQUEST_UUID);
+ requestParameters.setDecisionAttributes(Collections.emptyMap());
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ final DecisionResponse actualResponse = spyPolicyEngine.getDecision(requestParameters);
- final ResponseEntity<StdDecisionResponse> stubbedResponse =
- new ResponseEntity<>(getStdDecisionResponse(), HttpStatus.ACCEPTED);
+ assertNotNull(actualResponse);
+ }
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_DECISION_RESOURCE_NAME),
- eq(HttpMethod.POST), any(), any());
+ @Test(expected = PolicyDecisionException.class)
+ public void ttestStdPolicyEnginGetDecision_NullDecisionRequestParameters_Exception()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ spyPolicyEngine.getDecision((DecisionRequestParameters) null);
+ }
- final DecisionRequestParameters requestParameters = new DecisionRequestParameters();
- requestParameters.setOnapName(ONAP_NAME_VAL);
- requestParameters.setRequestID(REQUEST_UUID);
- requestParameters.setDecisionAttributes(Collections.emptyMap());
+ @Test
+ public void testStdPolicyEnginGetMetrics_MetricsRequestParameters_noException()
+ throws Exception {
- final DecisionResponse actualResponse = spyPolicyEngine.getDecision(requestParameters);
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertNotNull(actualResponse);
- }
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Metrics", HttpStatus.ACCEPTED);
- @Test(expected = PolicyDecisionException.class)
- public void ttestStdPolicyEnginGetDecision_NullDecisionRequestParameters_Exception()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- spyPolicyEngine.getDecision((DecisionRequestParameters) null);
- }
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_METRICS_RESOURCE_NAME),
+ eq(HttpMethod.GET), any(), any());
- @Test
- public void testStdPolicyEnginGetMetrics_MetricsRequestParameters_noException() throws Exception {
+ final MetricsResponse actualResponse =
+ spyPolicyEngine.getMetrics(new MetricsRequestParameters());
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.ACCEPTED.value(), actualResponse.getResponseCode());
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ }
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Metrics", HttpStatus.ACCEPTED);
+ @Test
+ public void testStdPolicyEngineGetMetrics_MetricsRequestParametersCallPDPThrowHttpException_ResponseWithHttpCode()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doThrow(new PolicyException(new HttpClientErrorException(HttpStatus.BAD_GATEWAY)))
+ .when(spyPolicyEngine)
+ .callNewPDP(eq(GET_METRICS_RESOURCE_NAME), eq(HttpMethod.GET), any(), any());
+
+ final MetricsResponse actualResponse =
+ spyPolicyEngine.getMetrics(new MetricsRequestParameters());
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.BAD_GATEWAY.value(), actualResponse.getResponseCode());
+
+ }
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(GET_METRICS_RESOURCE_NAME),
- eq(HttpMethod.GET), any(), any());
+ @Test(expected = PolicyException.class)
+ public void testStdPolicyEngineGetMetrics_MetricsRequestParametersCallPDPThrowPolicyException_Exception()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doThrow(PolicyException.class).when(spyPolicyEngine)
+ .callNewPDP(eq(GET_METRICS_RESOURCE_NAME), eq(HttpMethod.GET), any(), any());
- final MetricsResponse actualResponse =
spyPolicyEngine.getMetrics(new MetricsRequestParameters());
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.ACCEPTED.value(), actualResponse.getResponseCode());
- }
+ }
- @Test
- public void testStdPolicyEngineGetMetrics_MetricsRequestParametersCallPDPThrowHttpException_ResponseWithHttpCode()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doThrow(new PolicyException(new HttpClientErrorException(HttpStatus.BAD_GATEWAY)))
- .when(spyPolicyEngine)
- .callNewPDP(eq(GET_METRICS_RESOURCE_NAME), eq(HttpMethod.GET), any(), any());
+ @Test
+ public void testStdPolicyEnginPushPolicy_PushPolicyParameters_noException() throws Exception {
- final MetricsResponse actualResponse =
- spyPolicyEngine.getMetrics(new MetricsRequestParameters());
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.BAD_GATEWAY.value(), actualResponse.getResponseCode());
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- }
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Successful", HttpStatus.OK);
- @Test(expected = PolicyException.class)
- public void testStdPolicyEngineGetMetrics_MetricsRequestParametersCallPDPThrowPolicyException_Exception()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doThrow(PolicyException.class).when(spyPolicyEngine).callNewPDP(eq(GET_METRICS_RESOURCE_NAME),
- eq(HttpMethod.GET), any(), any());
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME),
+ eq(HttpMethod.PUT), any(), any());
- spyPolicyEngine.getMetrics(new MetricsRequestParameters());
+ final PolicyChangeResponse actualResponse =
+ spyPolicyEngine.pushPolicy(new PushPolicyParameters());
- }
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
+ }
- @Test
- public void testStdPolicyEnginPushPolicy_PushPolicyParameters_noException() throws Exception {
+ @Test
+ public void testStdPolicyEnginePushPolicy_PushPolicyParametersThrowsHttpClientErrorException_ResponseWithHttpCode()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doThrow(new PolicyException(new HttpClientErrorException(HttpStatus.BAD_GATEWAY)))
+ .when(spyPolicyEngine)
+ .callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME), eq(HttpMethod.PUT), any(), any());
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ final PolicyChangeResponse actualResponse =
+ spyPolicyEngine.pushPolicy(new PushPolicyParameters());
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Successful", HttpStatus.OK);
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.BAD_GATEWAY.value(), actualResponse.getResponseCode());
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME),
- eq(HttpMethod.PUT), any(), any());
+ }
+
+ @Test(expected = PolicyException.class)
+ public void testStdPolicyEnginePushPolicy_PushPolicyParameters_Exception() throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doThrow(PolicyException.class).when(spyPolicyEngine)
+ .callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME), eq(HttpMethod.PUT), any(), any());
- final PolicyChangeResponse actualResponse =
spyPolicyEngine.pushPolicy(new PushPolicyParameters());
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
- }
+ }
- @Test
- public void testStdPolicyEnginePushPolicy_PushPolicyParametersThrowsHttpClientErrorException_ResponseWithHttpCode()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doThrow(new PolicyException(new HttpClientErrorException(HttpStatus.BAD_GATEWAY)))
- .when(spyPolicyEngine)
- .callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME), eq(HttpMethod.PUT), any(), any());
+ @Test
+ public void testStdPolicyEnginDeletePolicy_DeletePolicyParameters_noException()
+ throws Exception {
- final PolicyChangeResponse actualResponse =
- spyPolicyEngine.pushPolicy(new PushPolicyParameters());
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Successful", HttpStatus.OK);
+
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(DELETE_POLICY_RESOURCE_NAME),
+ eq(HttpMethod.DELETE), any(), any());
+
+ final PolicyChangeResponse actualResponse =
+ spyPolicyEngine.deletePolicy(new DeletePolicyParameters());
+
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
+ }
+
+ @Test
+ public void testStdPolicyEnginGetDictionaryItem_DictionaryParameters_noException()
+ throws Exception {
+
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+
+ final ResponseEntity<APIDictionaryResponse> stubbedResponse =
+ new ResponseEntity<>(getAPIDictionaryResponse(), HttpStatus.OK);
+
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(
+ eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
+
+ final DictionaryResponse actualResponse =
+ spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
+
+ assertNotNull(actualResponse);
+ }
+
+ @Test
+ public void testStdPolicyGetDictionaryItem_DictionaryParametersWithHttp400ExceptionThrown_ResponseWithHttpCode()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doThrow(new RuntimeException(
+ new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Error 400")))
+ .when(spyPolicyEngine).callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.BAD_GATEWAY.value(), actualResponse.getResponseCode());
+ final DictionaryResponse actualResponse =
+ spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
- }
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.BAD_REQUEST.value(), actualResponse.getResponseCode());
- @Test(expected = PolicyException.class)
- public void testStdPolicyEnginePushPolicy_PushPolicyParameters_Exception() throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doThrow(PolicyException.class).when(spyPolicyEngine).callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME),
- eq(HttpMethod.PUT), any(), any());
+ }
- spyPolicyEngine.pushPolicy(new PushPolicyParameters());
+ @Test
+ public void testStdPolicyGetDictionaryItem_DictionaryParametersWithHttp401ExceptionThrown_ResponseWithHttpCode()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doThrow(new RuntimeException(
+ new HttpClientErrorException(HttpStatus.UNAUTHORIZED, "Error 401")))
+ .when(spyPolicyEngine).callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- }
+ final DictionaryResponse actualResponse =
+ spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
- @Test
- public void testStdPolicyEnginDeletePolicy_DeletePolicyParameters_noException() throws Exception {
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.UNAUTHORIZED.value(), actualResponse.getResponseCode());
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ }
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Successful", HttpStatus.OK);
+ @Test
+ public void testStdPolicyGetDictionaryItem_DictionaryParametersWithRunTimeExceptionThrown_ResponseWithHttpCode()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doThrow(new RuntimeException(
+ new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, "Error")))
+ .when(spyPolicyEngine).callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME),
+ eq(HttpMethod.POST), any(), any());
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(DELETE_POLICY_RESOURCE_NAME),
- eq(HttpMethod.DELETE), any(), any());
+ final DictionaryResponse actualResponse =
+ spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
- final PolicyChangeResponse actualResponse =
- spyPolicyEngine.deletePolicy(new DeletePolicyParameters());
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), actualResponse.getResponseCode());
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
- }
+ }
- @Test
- public void testStdPolicyEnginGetDictionaryItem_DictionaryParameters_noException()
- throws Exception {
+ @Test
+ public void testStdPolicyEnginCreateDictionaryItem_DictionaryParameters_noException()
+ throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- final ResponseEntity<APIDictionaryResponse> stubbedResponse =
- new ResponseEntity<>(getAPIDictionaryResponse(), HttpStatus.OK);
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Successful", HttpStatus.OK);
- doReturn(stubbedResponse).when(spyPolicyEngine)
- .callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(
+ eq(CREATE_DICTIONARY_ITEM_RESOURCE_NAME), eq(HttpMethod.PUT), any(), any());
- final DictionaryResponse actualResponse =
- spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
+ final PolicyChangeResponse actualResponse =
+ spyPolicyEngine.createDictionaryItem(new DictionaryParameters());
- assertNotNull(actualResponse);
- }
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
+ }
- @Test
- public void testStdPolicyGetDictionaryItem_DictionaryParametersWithHttp400ExceptionThrown_ResponseWithHttpCode()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doThrow(new RuntimeException(new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Error 400")))
- .when(spyPolicyEngine)
- .callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
+ @Test
+ public void testStdPolicyEnginUpdateDictionaryItem_DictionaryParameters_noException()
+ throws Exception {
- final DictionaryResponse actualResponse =
- spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.BAD_REQUEST.value(), actualResponse.getResponseCode());
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Successful", HttpStatus.OK);
- }
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(
+ eq(UPDATE_DICTIONARY_ITEM_RESOURCE_NAME), eq(HttpMethod.PUT), any(), any());
- @Test
- public void testStdPolicyGetDictionaryItem_DictionaryParametersWithHttp401ExceptionThrown_ResponseWithHttpCode()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doThrow(
- new RuntimeException(new HttpClientErrorException(HttpStatus.UNAUTHORIZED, "Error 401")))
- .when(spyPolicyEngine)
- .callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
+ final PolicyChangeResponse actualResponse =
+ spyPolicyEngine.updateDictionaryItem(new DictionaryParameters());
- final DictionaryResponse actualResponse =
- spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
+ }
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.UNAUTHORIZED.value(), actualResponse.getResponseCode());
+ @Test
+ public void testStdPolicyEnginPolicyEngineImport_ImportParameters_noException()
+ throws Exception {
+ final File emptyfile = temporaryFolder.newFile("emptyFile.txt");
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- }
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Successful", HttpStatus.OK);
- @Test
- public void testStdPolicyGetDictionaryItem_DictionaryParametersWithRunTimeExceptionThrown_ResponseWithHttpCode()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doThrow(new RuntimeException(
- new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, "Error")))
- .when(spyPolicyEngine)
- .callNewPDP(eq(GET_DICTIONARY_ITEMS_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(
+ eq(POLICY_ENGINE_IMPORT_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
- final DictionaryResponse actualResponse =
- spyPolicyEngine.getDictionaryItem(new DictionaryParameters());
+ final ImportParameters importParameters = new ImportParameters();
+ importParameters.setFilePath(emptyfile.toString());
+ final PolicyChangeResponse actualResponse =
+ spyPolicyEngine.policyEngineImport(importParameters);
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), actualResponse.getResponseCode());
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
+ }
- }
+ @Test
+ public void testStdPolicyEnginCreatePolicy_PolicyParameters_noException() throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- @Test
- public void testStdPolicyEnginCreateDictionaryItem_DictionaryParameters_noException()
- throws Exception {
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Successful", HttpStatus.OK);
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(CREATE_POLICY_RESOURCE_NAME),
+ eq(HttpMethod.PUT), any(), any());
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Successful", HttpStatus.OK);
+ final PolicyChangeResponse actualResponse =
+ spyPolicyEngine.createPolicy(new PolicyParameters());
- doReturn(stubbedResponse).when(spyPolicyEngine)
- .callNewPDP(eq(CREATE_DICTIONARY_ITEM_RESOURCE_NAME), eq(HttpMethod.PUT), any(), any());
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
+ }
- final PolicyChangeResponse actualResponse =
- spyPolicyEngine.createDictionaryItem(new DictionaryParameters());
+ @Test
+ public void testStdPolicyEnginUpdatePolicy_PolicyParameters_noException() throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
- }
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Successful", HttpStatus.OK);
- @Test
- public void testStdPolicyEnginUpdateDictionaryItem_DictionaryParameters_noException()
- throws Exception {
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(UPDATE_POLICY_RESOURCE_NAME),
+ eq(HttpMethod.PUT), any(), any());
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ final PolicyChangeResponse actualResponse =
+ spyPolicyEngine.updatePolicy(new PolicyParameters());
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Successful", HttpStatus.OK);
+ assertNotNull(actualResponse);
+ assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
+ }
- doReturn(stubbedResponse).when(spyPolicyEngine)
- .callNewPDP(eq(UPDATE_DICTIONARY_ITEM_RESOURCE_NAME), eq(HttpMethod.PUT), any(), any());
+ @Test(expected = PolicyException.class)
+ public void testStdPolicyEnginPushPolicy_NullValues_Exception() throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- final PolicyChangeResponse actualResponse =
- spyPolicyEngine.updateDictionaryItem(new DictionaryParameters());
+ spyPolicyEngine.pushPolicy(null, null, null, null, null);
+ }
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
- }
+ @Test(expected = PolicyException.class)
+ public void testStdPolicyEnginPushPolicy_EmptyPolicyScope_Exception() throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- @Test
- public void testStdPolicyEnginPolicyEngineImport_ImportParameters_noException() throws Exception {
- final File emptyfile = temporaryFolder.newFile("emptyFile.txt");
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ spyPolicyEngine.pushPolicy("", null, null, null, null);
+ }
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Successful", HttpStatus.OK);
+ @Test(expected = PolicyException.class)
+ public void testStdPolicyEnginPushPolicy_EmptyPolicyName_Exception() throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- doReturn(stubbedResponse).when(spyPolicyEngine)
- .callNewPDP(eq(POLICY_ENGINE_IMPORT_RESOURCE_NAME), eq(HttpMethod.POST), any(), any());
+ spyPolicyEngine.pushPolicy("POLICY_SCOPE", "", null, null, null);
+ }
- final ImportParameters importParameters = new ImportParameters();
- importParameters.setFilePath(emptyfile.toString());
- final PolicyChangeResponse actualResponse =
- spyPolicyEngine.policyEngineImport(importParameters);
+ @Test
+ public void testStdPolicyEnginPushPolicy_PolicyParameters_noException() throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
- }
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Successful", HttpStatus.OK);
- @Test
- public void testStdPolicyEnginCreatePolicy_PolicyParameters_noException() throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME),
+ eq(HttpMethod.PUT), any(), any());
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Successful", HttpStatus.OK);
+ final String actualResponse = spyPolicyEngine.pushPolicy("POLICY_SCOPE", ONAP_NAME_VAL,
+ "POLICY_TYPE", "POLICY_GROUP", REQUEST_UUID);
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(CREATE_POLICY_RESOURCE_NAME),
- eq(HttpMethod.PUT), any(), any());
+ assertNotNull(actualResponse);
+ }
- final PolicyChangeResponse actualResponse =
- spyPolicyEngine.createPolicy(new PolicyParameters());
+ @Test
+ public void testStdPolicyEnginCreateUpdateConfigPolicy_PolicyParameters_noException()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
- }
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Successful", HttpStatus.OK);
- @Test
- public void testStdPolicyEnginUpdatePolicy_PolicyParameters_noException() throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(UPDATE_POLICY_RESOURCE_NAME),
+ eq(HttpMethod.PUT), any(), any());
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Successful", HttpStatus.OK);
+ final String actualResponse = spyPolicyEngine.createUpdateConfigPolicy("POLICY_NAME",
+ ONAP_NAME_VAL, ONAP_NAME_VAL, "CONFIG_NAME", Collections.emptyMap(),
+ PolicyType.JSON.toString().toUpperCase(), "", "POLICY_SCOPE", REQUEST_UUID, "", "",
+ "", new Date().toString(), true);
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(UPDATE_POLICY_RESOURCE_NAME),
- eq(HttpMethod.PUT), any(), any());
+ assertNotNull(actualResponse);
+ }
- final PolicyChangeResponse actualResponse =
- spyPolicyEngine.updatePolicy(new PolicyParameters());
+ @Test(expected = PolicyException.class)
+ public void testStdPolicyEnginCreateUpdateConfigPolicy_NullPolicyName_Exception()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- assertNotNull(actualResponse);
- assertEquals(HttpStatus.OK.value(), actualResponse.getResponseCode());
- }
+ spyPolicyEngine.createUpdateConfigPolicy(null, null, null, null, null, null, null, null,
+ null, null, null, null, null, true);
+ }
- @Test(expected = PolicyException.class)
- public void testStdPolicyEnginPushPolicy_NullValues_Exception() throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ @Test
+ public void testStdPolicyEnginCreateUpdateConfigFirewallPolicy_PolicyParameters_noException()
+ throws Exception {
+ final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
- spyPolicyEngine.pushPolicy(null, null, null, null, null);
- }
+ final ResponseEntity<String> stubbedResponse =
+ new ResponseEntity<>("Successful", HttpStatus.OK);
- @Test(expected = PolicyException.class)
- public void testStdPolicyEnginPushPolicy_EmptyPolicyScope_Exception() throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(UPDATE_POLICY_RESOURCE_NAME),
+ eq(HttpMethod.PUT), any(), any());
- spyPolicyEngine.pushPolicy("", null, null, null, null);
- }
+ final String actualResponse = spyPolicyEngine.createUpdateConfigFirewallPolicy(
+ "POLICY_NAME", getJsonObject(JSON_CONFIGURATION), "POLICY_SCOPE", REQUEST_UUID, "",
+ "", "", new Date().toString(), true);
- @Test(expected = PolicyException.class)
- public void testStdPolicyEnginPushPolicy_EmptyPolicyName_Exception() throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ assertNotNull(actualResponse);
+ }
- spyPolicyEngine.pushPolicy("POLICY_SCOPE", "", null, null, null);
- }
+ private JsonObject getJsonObject(final String jsonString) {
+ try (final JsonReader jsonReader = Json.createReader(new StringReader(jsonString));) {
+ return jsonReader.readObject();
+ }
+ }
- @Test
- public void testStdPolicyEnginPushPolicy_PolicyParameters_noException() throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ private StdPolicyEngine getSpyPolicyEngine() throws IOException, PolicyEngineException {
+ return getSpyPolicyEngine(CONFIG_PROPERTIES_FILE, getDefaultProperties());
+ }
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Successful", HttpStatus.OK);
+ private StdPolicyEngine getSpyPolicyEngine(final String filename, final Properties properties)
+ throws IOException, PolicyEngineException {
+ final File file = temporaryFolder.newFile(filename);
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(PUSH_POLICY_RESOURCE_NAME),
- eq(HttpMethod.PUT), any(), any());
+ creatPropertyFile(file, properties);
- final String actualResponse = spyPolicyEngine.pushPolicy("POLICY_SCOPE", ONAP_NAME_VAL,
- "POLICY_TYPE", "POLICY_GROUP", REQUEST_UUID);
+ final StdPolicyEngine spyPolicyEngine =
+ spy(new StdPolicyEngine(file.toString(), (String) null));
+ spyPolicyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
+ return spyPolicyEngine;
+ }
- assertNotNull(actualResponse);
- }
+ private Properties getDefaultProperties() {
+ final Properties properties = new Properties();
+ properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
+ properties.setProperty(CLIENT_ID_PROP_NAME, "test");
+ properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
+ properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB + COMMA + DMAAP);
+ properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
+ properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
+ properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
+ properties.setProperty(PolicyConfigConstants.JUNIT_PROP_NAME, "false");
+ return properties;
+ }
- @Test
- public void testStdPolicyEnginCreateUpdateConfigPolicy_PolicyParameters_noException()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ private StdDecisionResponse getStdDecisionResponse() {
+ final StdDecisionResponse response = new StdDecisionResponse();
+ response.setDecision(PolicyDecision.PERMIT);
+ response.setDetails(PolicyDecision.PERMIT.name());
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Successful", HttpStatus.OK);
+ return response;
+ }
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(UPDATE_POLICY_RESOURCE_NAME),
- eq(HttpMethod.PUT), any(), any());
+ private APIDictionaryResponse getAPIDictionaryResponse() {
+ final APIDictionaryResponse response = new APIDictionaryResponse();
+ response.setResponseCode(0);
+ response.setResponseMessage("");
+ response.setDictionaryData(Collections.<String, String>emptyMap());
+ response.setDictionaryJson(Collections.<String, String>emptyMap());
+ return response;
+ }
- final String actualResponse =
- spyPolicyEngine.createUpdateConfigPolicy("POLICY_NAME", ONAP_NAME_VAL, ONAP_NAME_VAL,
- "CONFIG_NAME", Collections.emptyMap(), PolicyType.JSON.toString().toUpperCase(), "",
- "POLICY_SCOPE", REQUEST_UUID, "", "", "", new Date().toString(), true);
+ private StdPolicyResponse[] getStdPolicyResponse() {
+ final StdPolicyResponse response = new StdPolicyResponse();
+ response.setPolicyResponseStatus(PolicyResponseStatus.ACTION_TAKEN);
+ return new StdPolicyResponse[] {response};
+ }
+
+ private void creatPropertyFile(final File file, final Properties properties)
+ throws IOException {
+ try (final BufferedWriter bufferedWriter = Files.newBufferedWriter(file.toPath());) {
+ properties.store(bufferedWriter, COMMENTS);
+ }
+ }
- assertNotNull(actualResponse);
- }
+ private APIPolicyConfigResponse[] getAPIPolicyConfigResponse(final PolicyType policyType,
+ final String configuration) {
- @Test(expected = PolicyException.class)
- public void testStdPolicyEnginCreateUpdateConfigPolicy_NullPolicyName_Exception()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ return getAPIPolicyConfigResponse(policyType, configuration, null);
+ }
- spyPolicyEngine.createUpdateConfigPolicy(null, null, null, null, null, null, null, null, null,
- null, null, null, null, true);
- }
-
- @Test
- public void testStdPolicyEnginCreateUpdateConfigFirewallPolicy_PolicyParameters_noException()
- throws Exception {
- final StdPolicyEngine spyPolicyEngine = getSpyPolicyEngine();
+ private APIPolicyConfigResponse[] getAPIPolicyConfigResponse(final PolicyType policyType,
+ final String configuration, final String policyConfigMessage) {
+ final APIPolicyConfigResponse configResponse = new APIPolicyConfigResponse();
+ configResponse.setConfig(configuration);
+ configResponse.setMatchingConditions(getMatchingConditions());
+ configResponse.setPolicyConfigStatus(PolicyConfigStatus.CONFIG_RETRIEVED);
+ configResponse.setPolicyName(POLICY_NAME);
+ configResponse.setPolicyType(PolicyConfigType.BRMS_RAW);
+ configResponse.setType(policyType);
+ configResponse.setPolicyVersion(POLICY_VERSION);
+ configResponse.setProperty(Collections.emptyMap());
+ configResponse.setPolicyConfigMessage(policyConfigMessage);
+
+ return new APIPolicyConfigResponse[] {configResponse};
+ }
- final ResponseEntity<String> stubbedResponse =
- new ResponseEntity<>("Successful", HttpStatus.OK);
-
- doReturn(stubbedResponse).when(spyPolicyEngine).callNewPDP(eq(UPDATE_POLICY_RESOURCE_NAME),
- eq(HttpMethod.PUT), any(), any());
-
- final String actualResponse = spyPolicyEngine.createUpdateConfigFirewallPolicy("POLICY_NAME",
- getJsonObject(JSON_CONFIGURATION), "POLICY_SCOPE", REQUEST_UUID, "", "", "",
- new Date().toString(), true);
-
- assertNotNull(actualResponse);
- }
-
- private JsonObject getJsonObject(final String jsonString) {
- try (final JsonReader jsonReader = Json.createReader(new StringReader(jsonString));) {
- return jsonReader.readObject();
- }
- }
-
- private StdPolicyEngine getSpyPolicyEngine() throws IOException, PolicyEngineException {
- return getSpyPolicyEngine(CONFIG_PROPERTIES_FILE, getDefaultProperties());
- }
-
- private StdPolicyEngine getSpyPolicyEngine(final String filename, final Properties properties)
- throws IOException, PolicyEngineException {
- final File file = temporaryFolder.newFile(filename);
-
- creatPropertyFile(file, properties);
-
- final StdPolicyEngine spyPolicyEngine =
- spy(new StdPolicyEngine(file.toString(), (String) null));
- spyPolicyEngine.setScheme(NotificationScheme.MANUAL_NOTIFICATIONS);
- return spyPolicyEngine;
- }
-
- private Properties getDefaultProperties() {
- final Properties properties = new Properties();
- properties.setProperty(PDP_URL_PROP_NAME, PDP_PROP_VALUE);
- properties.setProperty(CLIENT_ID_PROP_NAME, "test");
- properties.setProperty(CLIENT_KEY_PROP_NAME, "test");
- properties.setProperty(NOTIFICATION_TYPE_PROP_NAME, UEB + COMMA + DMAAP);
- properties.setProperty(NOTIFICATION_SERVERS_PROP_NAME, SERVER_NAME + COMMA + SERVER_NAME);
- properties.setProperty(NOTIFICATION_TOPIC_PROP_NAME, "test");
- properties.setProperty(ENVIRONMENT_PROP_NAME, "TEST");
- properties.setProperty(PolicyConfigConstants.JUNIT_PROP_NAME, "false");
- return properties;
- }
-
- private StdDecisionResponse getStdDecisionResponse() {
- final StdDecisionResponse response = new StdDecisionResponse();
- response.setDecision(PolicyDecision.PERMIT);
- response.setDetails(PolicyDecision.PERMIT.name());
-
- return response;
- }
-
- private APIDictionaryResponse getAPIDictionaryResponse() {
- final APIDictionaryResponse response = new APIDictionaryResponse();
- response.setResponseCode(0);
- response.setResponseMessage("");
- response.setDictionaryData(Collections.<String, String>emptyMap());
- response.setDictionaryJson(Collections.<String, String>emptyMap());
- return response;
- }
-
- private StdPolicyResponse[] getStdPolicyResponse() {
- final StdPolicyResponse response = new StdPolicyResponse();
- response.setPolicyResponseStatus(PolicyResponseStatus.ACTION_TAKEN);
- return new StdPolicyResponse[] {response};
- }
-
- private void creatPropertyFile(final File file, final Properties properties) throws IOException {
- try (final BufferedWriter bufferedWriter = Files.newBufferedWriter(file.toPath());) {
- properties.store(bufferedWriter, COMMENTS);
- }
- }
-
- private APIPolicyConfigResponse[] getAPIPolicyConfigResponse(final PolicyType policyType,
- final String configuration) {
-
- return getAPIPolicyConfigResponse(policyType, configuration, null);
- }
-
- private APIPolicyConfigResponse[] getAPIPolicyConfigResponse(final PolicyType policyType,
- final String configuration, final String policyConfigMessage) {
- final APIPolicyConfigResponse configResponse = new APIPolicyConfigResponse();
- configResponse.setConfig(configuration);
- configResponse.setMatchingConditions(getMatchingConditions());
- configResponse.setPolicyConfigStatus(PolicyConfigStatus.CONFIG_RETRIEVED);
- configResponse.setPolicyName(POLICY_NAME);
- configResponse.setPolicyType(PolicyConfigType.BRMS_RAW);
- configResponse.setType(policyType);
- configResponse.setPolicyVersion(POLICY_VERSION);
- configResponse.setProperty(Collections.emptyMap());
- configResponse.setPolicyConfigMessage(policyConfigMessage);
-
- return new APIPolicyConfigResponse[] {configResponse};
- }
-
- private Map<String, String> getMatchingConditions() {
- final Map<String, String> attributes = new HashMap<>();
- attributes.put(ONAP_NAME, POLICY_NAME);
- attributes.put(CONFIG_NAME, "Configuration_name");
- return attributes;
- }
+ private Map<String, String> getMatchingConditions() {
+ final Map<String, String> attributes = new HashMap<>();
+ attributes.put(ONAP_NAME, POLICY_NAME);
+ attributes.put(CONFIG_NAME, "Configuration_name");
+ return attributes;
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientUEBTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientUEBTest.java
index eef76bdd7..b6b9c4a95 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientUEBTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/AutoClientUEBTest.java
@@ -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.
@@ -22,164 +24,158 @@ package org.onap.policy.std.test;
import java.util.LinkedList;
import java.util.List;
-
import org.junit.*;
import org.onap.policy.api.NotificationHandler;
import org.onap.policy.api.NotificationScheme;
import org.onap.policy.std.AutoClientUEB;
-
import static org.junit.Assert.*;
/**
- * The class <code>AutoClientUEBTest</code> contains tests for the class <code>{@link AutoClientUEB}</code>.
+ * The class <code>AutoClientUEBTest</code> contains tests for the class
+ * <code>{@link AutoClientUEB}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class AutoClientUEBTest {
- /**
- * Run the AutoClientUEB(String,List<String>) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testAutoClientUEB_1()
- throws Exception {
- String url = "";
- String apiKey = "";
- String apiSecret = "";
- List<String> uebURLList = new LinkedList<String>();
-
- AutoClientUEB result = new AutoClientUEB(url, uebURLList, apiKey, apiSecret);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.ExceptionInInitializerError
- // at org.apache.log4j.Logger.getLogger(Logger.java:104)
- // at org.onap.policy.std.AutoClientUEB.<clinit>(AutoClientUEB.java:39)
- assertNotNull(result);
- }
-
- /**
- * Run the String getNotficationType() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetNotficationType_1()
- throws Exception {
-
- String result = AutoClientUEB.getNotficationType();
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.AutoClientUEB
- assertNull(result);
- }
-
- /**
- * Run the boolean getStatus() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetStatus_1()
- throws Exception {
-
- boolean result = AutoClientUEB.getStatus();
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.AutoClientUEB
- assertFalse(result);
- }
-
- /**
- * Run the String getURL() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetURL_1()
- throws Exception {
-
- String result = AutoClientUEB.getURL();
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.AutoClientUEB
- assertNotNull(result);
- }
-
- /**
- * Run the void setScheme(NotificationScheme) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetScheme_1()
- throws Exception {
- NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS;
-
- AutoClientUEB.setScheme(scheme);
-
- // add additional test code here
- // An unexpected exception was thrown in user code while executing this test:
- // java.lang.NoClassDefFoundError: Could not initialize class org.onap.policy.std.AutoClientUEB
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add set up code here
- List<String> urlList = new LinkedList<String>();
- urlList.add("test2.com");
- @SuppressWarnings("unused")
+ /**
+ * Run the AutoClientUEB(String,List<String>) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testAutoClientUEB_1() throws Exception {
+ String url = "";
+ String apiKey = "";
+ String apiSecret = "";
+ List<String> uebURLList = new LinkedList<String>();
+
+ AutoClientUEB result = new AutoClientUEB(url, uebURLList, apiKey, apiSecret);
+
+ // add additional test code here
+ // An unexpected exception was thrown in user code while executing this test:
+ // java.lang.ExceptionInInitializerError
+ // at org.apache.log4j.Logger.getLogger(Logger.java:104)
+ // at org.onap.policy.std.AutoClientUEB.<clinit>(AutoClientUEB.java:39)
+ assertNotNull(result);
+ }
+
+ /**
+ * Run the String getNotficationType() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetNotficationType_1() throws Exception {
+
+ String result = AutoClientUEB.getNotficationType();
+
+ // add additional test code here
+ // An unexpected exception was thrown in user code while executing this test:
+ // java.lang.NoClassDefFoundError: Could not initialize class
+ // org.onap.policy.std.AutoClientUEB
+ assertNull(result);
+ }
+
+ /**
+ * Run the boolean getStatus() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetStatus_1() throws Exception {
+
+ boolean result = AutoClientUEB.getStatus();
+
+ // add additional test code here
+ // An unexpected exception was thrown in user code while executing this test:
+ // java.lang.NoClassDefFoundError: Could not initialize class
+ // org.onap.policy.std.AutoClientUEB
+ assertFalse(result);
+ }
+
+ /**
+ * Run the String getURL() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetURL_1() throws Exception {
+
+ String result = AutoClientUEB.getURL();
+
+ // add additional test code here
+ // An unexpected exception was thrown in user code while executing this test:
+ // java.lang.NoClassDefFoundError: Could not initialize class
+ // org.onap.policy.std.AutoClientUEB
+ assertNotNull(result);
+ }
+
+ /**
+ * Run the void setScheme(NotificationScheme) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetScheme_1() throws Exception {
+ NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS;
+
+ AutoClientUEB.setScheme(scheme);
+
+ // add additional test code here
+ // An unexpected exception was thrown in user code while executing this test:
+ // java.lang.NoClassDefFoundError: Could not initialize class
+ // org.onap.policy.std.AutoClientUEB
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add set up code here
+ List<String> urlList = new LinkedList<String>();
+ urlList.add("test2.com");
+ @SuppressWarnings("unused")
AutoClientUEB client = new AutoClientUEB("test.com", urlList, "testKey", "testSecret");
- NotificationHandler handler = null;
- AutoClientUEB.setAuto(NotificationScheme.AUTO_ALL_NOTIFICATIONS, handler);
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(AutoClientUEBTest.class);
- }
+ NotificationHandler handler = null;
+ AutoClientUEB.setAuto(NotificationScheme.AUTO_ALL_NOTIFICATIONS, handler);
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(AutoClientUEBTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/DummyNotificationHandler.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/DummyNotificationHandler.java
index cdc717597..7cfe92541 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/DummyNotificationHandler.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/DummyNotificationHandler.java
@@ -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,7 +23,6 @@
package org.onap.policy.std.test;
import java.util.Collection;
-
import org.onap.policy.api.LoadedPolicy;
import org.onap.policy.api.NotificationHandler;
import org.onap.policy.api.NotificationType;
@@ -35,92 +36,95 @@ import org.onap.policy.api.RemovedPolicy;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-public class DummyNotificationHandler implements NotificationHandler{
-
- private static final Logger LOGGER = FlexLogger.getLogger(DummyNotificationHandler.class);
-
- @Override
- public void notificationReceived(PDPNotification notification) {
- System.out.println("Notification Received...");
- System.out.println(notification.getNotificationType());
- if(notification.getNotificationType().equals(NotificationType.REMOVE)){
- System.out.println("Removed Policies: \n");
- for(RemovedPolicy removedPolicy: notification.getRemovedPolicies()){
- System.out.println(removedPolicy.getPolicyName());
- System.out.println(removedPolicy.getVersionNo());
- }
- }else if(notification.getNotificationType().equals(NotificationType.UPDATE)){
- System.out.println("Updated Policies: \n");
- for(LoadedPolicy updatedPolicy: notification.getLoadedPolicies()){
- System.out.println("policyName : " + updatedPolicy.getPolicyName());
- System.out.println("policyVersion :" + updatedPolicy.getVersionNo());
- if(updatedPolicy.getPolicyName().contains(".Config_")){
- System.out.println("Matches: " + updatedPolicy.getMatches());
- System.out.println("UpdateType: "+ updatedPolicy.getUpdateType());
- // Checking the Name is correct or not.
- try {
- PolicyEngine policyEngine = new PolicyEngine("config.properties");
- @SuppressWarnings("deprecation")
- Collection<PolicyConfig> policyConfigs = policyEngine.getConfigByPolicyName(updatedPolicy.getPolicyName());
- for(PolicyConfig policyConfig: policyConfigs){
- if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){
- System.out.println("Policy Retrieved with this Name notified. ");
- }else{
- System.err.println("\n\n Fail to retrieve policy !!!!\n\n");
- }
- // Also Test this case.
- if(policyConfig.getPolicyName().equals(updatedPolicy.getPolicyName())){
- System.out.println("Policy Name is good. ");
- }else{
- System.err.println("\n\n Fail to check Name \n\n");
- }
- }
- } catch (PolicyEngineException e) {
- LOGGER.error("Exception Occured"+e);
- } catch (PolicyConfigException e) {
- LOGGER.error("Exception Occured"+e);
- }
- }
- }
- }else if(notification.getNotificationType().equals(NotificationType.BOTH)){
- System.out.println("Both updated and Removed Notification: \n");
- System.out.println("Removed Policies: \n");
- for(RemovedPolicy removedPolicy: notification.getRemovedPolicies()){
- System.out.println(removedPolicy.getPolicyName());
- System.out.println(removedPolicy.getVersionNo());
- }
- System.out.println("Updated Policies: \n");
- for(LoadedPolicy updatedPolicy: notification.getLoadedPolicies()){
- System.out.println("policyName : " + updatedPolicy.getPolicyName());
- System.out.println("policyVersion :" + updatedPolicy.getVersionNo());
- System.out.println("Matches: " + updatedPolicy.getMatches());
- System.out.println("UpdateType: "+ updatedPolicy.getUpdateType());
- // Checking the Name is correct or not.
- try {
- PolicyEngine policyEngine = new PolicyEngine("config.properties");
- @SuppressWarnings("deprecation")
- Collection<PolicyConfig> policyConfigs = policyEngine.getConfigByPolicyName(updatedPolicy.getPolicyName());
- for(PolicyConfig policyConfig: policyConfigs){
- if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){
- System.out.println("Policy Retrieved with this Name notified. ");
- }else{
- System.err.println("\n\n Fail to retrieve policy !!!!\n\n");
- }
- // Also Test this case.
- if(policyConfig.getPolicyName().equals(updatedPolicy.getPolicyName())){
- System.out.println("Policy Name is good. ");
- }else{
- System.err.println("\n\n Fail to check Name \n\n");
- }
- }
- } catch (PolicyEngineException e) {
- LOGGER.error("Exception Occured"+e);
- } catch (PolicyConfigException e) {
- LOGGER.error("Exception Occured"+e);
- }
- }
- }
- }
+public class DummyNotificationHandler implements NotificationHandler {
+ private static final Logger LOGGER = FlexLogger.getLogger(DummyNotificationHandler.class);
+ @Override
+ public void notificationReceived(PDPNotification notification) {
+ System.out.println("Notification Received...");
+ System.out.println(notification.getNotificationType());
+ if (notification.getNotificationType().equals(NotificationType.REMOVE)) {
+ System.out.println("Removed Policies: \n");
+ for (RemovedPolicy removedPolicy : notification.getRemovedPolicies()) {
+ System.out.println(removedPolicy.getPolicyName());
+ System.out.println(removedPolicy.getVersionNo());
+ }
+ } else if (notification.getNotificationType().equals(NotificationType.UPDATE)) {
+ System.out.println("Updated Policies: \n");
+ for (LoadedPolicy updatedPolicy : notification.getLoadedPolicies()) {
+ System.out.println("policyName : " + updatedPolicy.getPolicyName());
+ System.out.println("policyVersion :" + updatedPolicy.getVersionNo());
+ if (updatedPolicy.getPolicyName().contains(".Config_")) {
+ System.out.println("Matches: " + updatedPolicy.getMatches());
+ System.out.println("UpdateType: " + updatedPolicy.getUpdateType());
+ // Checking the Name is correct or not.
+ try {
+ PolicyEngine policyEngine = new PolicyEngine("config.properties");
+ @SuppressWarnings("deprecation")
+ Collection<PolicyConfig> policyConfigs =
+ policyEngine.getConfigByPolicyName(updatedPolicy.getPolicyName());
+ for (PolicyConfig policyConfig : policyConfigs) {
+ if (policyConfig.getPolicyConfigStatus()
+ .equals(PolicyConfigStatus.CONFIG_RETRIEVED)) {
+ System.out.println("Policy Retrieved with this Name notified. ");
+ } else {
+ System.err.println("\n\n Fail to retrieve policy !!!!\n\n");
+ }
+ // Also Test this case.
+ if (policyConfig.getPolicyName()
+ .equals(updatedPolicy.getPolicyName())) {
+ System.out.println("Policy Name is good. ");
+ } else {
+ System.err.println("\n\n Fail to check Name \n\n");
+ }
+ }
+ } catch (PolicyEngineException e) {
+ LOGGER.error("Exception Occured" + e);
+ } catch (PolicyConfigException e) {
+ LOGGER.error("Exception Occured" + e);
+ }
+ }
+ }
+ } else if (notification.getNotificationType().equals(NotificationType.BOTH)) {
+ System.out.println("Both updated and Removed Notification: \n");
+ System.out.println("Removed Policies: \n");
+ for (RemovedPolicy removedPolicy : notification.getRemovedPolicies()) {
+ System.out.println(removedPolicy.getPolicyName());
+ System.out.println(removedPolicy.getVersionNo());
+ }
+ System.out.println("Updated Policies: \n");
+ for (LoadedPolicy updatedPolicy : notification.getLoadedPolicies()) {
+ System.out.println("policyName : " + updatedPolicy.getPolicyName());
+ System.out.println("policyVersion :" + updatedPolicy.getVersionNo());
+ System.out.println("Matches: " + updatedPolicy.getMatches());
+ System.out.println("UpdateType: " + updatedPolicy.getUpdateType());
+ // Checking the Name is correct or not.
+ try {
+ PolicyEngine policyEngine = new PolicyEngine("config.properties");
+ @SuppressWarnings("deprecation")
+ Collection<PolicyConfig> policyConfigs =
+ policyEngine.getConfigByPolicyName(updatedPolicy.getPolicyName());
+ for (PolicyConfig policyConfig : policyConfigs) {
+ if (policyConfig.getPolicyConfigStatus()
+ .equals(PolicyConfigStatus.CONFIG_RETRIEVED)) {
+ System.out.println("Policy Retrieved with this Name notified. ");
+ } else {
+ System.err.println("\n\n Fail to retrieve policy !!!!\n\n");
+ }
+ // Also Test this case.
+ if (policyConfig.getPolicyName().equals(updatedPolicy.getPolicyName())) {
+ System.out.println("Policy Name is good. ");
+ } else {
+ System.err.println("\n\n Fail to check Name \n\n");
+ }
+ }
+ } catch (PolicyEngineException e) {
+ LOGGER.error("Exception Occured" + e);
+ } catch (PolicyConfigException e) {
+ LOGGER.error("Exception Occured" + e);
+ }
+ }
+ }
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndTest.java
index 42df545d2..0872c2387 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndTest.java
@@ -1,15 +1,17 @@
-/*
+/*-
* ============LICENSE_START=======================================================
* PolicyEngineAPI
* ================================================================================
* 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.
@@ -23,7 +25,6 @@ package org.onap.policy.std.test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.concurrent.CountDownLatch;
@@ -73,11 +74,12 @@ public class ManualClientEndTest {
recvMsg = message;
conn.send("{\"removedPolicies\": [],\"loadedPolicies\":"
- + "[{\"policyName\": \"Test.Config_BRMS_Param_BrmsParamTestPa.1.xml\","
- + "\"versionNo\": \"1\",\"matches\": {\"ECOMPName\": \"DROOLS\","
- + "\"ONAPName\": \"DROOLS\",\"ConfigName\": \"BRMS_PARAM_RULE\","
- + "\"guard\": \"false\",\"TTLDate\": \"NA\",\"RiskLevel\": \"5\","
- + "\"RiskType\": \"default\"},\"updateType\": \"NEW\"}],\"notificationType\": \"UPDATE\"}");
+ + "[{\"policyName\": \"Test.Config_BRMS_Param_BrmsParamTestPa.1.xml\","
+ + "\"versionNo\": \"1\",\"matches\": {\"ECOMPName\": \"DROOLS\","
+ + "\"ONAPName\": \"DROOLS\",\"ConfigName\": \"BRMS_PARAM_RULE\","
+ + "\"guard\": \"false\",\"TTLDate\": \"NA\",\"RiskLevel\": \"5\","
+ + "\"RiskType\": \"default\"},\"updateType\": \"NEW\"}],"
+ + "\"notificationType\": \"UPDATE\"}");
}
@Override
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndUEBTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndUEBTest.java
index d81ba3f98..f8af9c4f2 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndUEBTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/ManualClientEndUEBTest.java
@@ -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.
@@ -22,10 +24,8 @@ package org.onap.policy.std.test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-
import java.util.LinkedList;
import java.util.List;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -35,73 +35,70 @@ import org.onap.policy.std.ManualClientEndUEB;
import org.onap.policy.std.StdPDPNotification;
/**
- * The class <code>ManualClientEndUEBTest</code> contains tests for the class <code>{@link ManualClientEndUEB}</code>.
+ * The class <code>ManualClientEndUEBTest</code> contains tests for the class
+ * <code>{@link ManualClientEndUEB}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class ManualClientEndUEBTest {
-
- String resultJson = "{'test':'testing'}";
- String json = "{\"test\":\"testing\"}";
- StdPDPNotification notification = new StdPDPNotification();
- ManualClientEndUEB mockManualClient = null;
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- String url = "http://test.com";
- List<String> uebURLList = new LinkedList<String>();
- uebURLList.add(url);
-
- }
- /**
- * Run the PDPNotification result(NotificationScheme) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testResult_1()
- throws Exception {
- NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS;
+ String resultJson = "{'test':'testing'}";
+ String json = "{\"test\":\"testing\"}";
+ StdPDPNotification notification = new StdPDPNotification();
+ ManualClientEndUEB mockManualClient = null;
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ String url = "http://test.com";
+ List<String> uebURLList = new LinkedList<String>();
+ uebURLList.add(url);
+
+ }
+
+ /**
+ * Run the PDPNotification result(NotificationScheme) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testResult_1() throws Exception {
+ NotificationScheme scheme = NotificationScheme.AUTO_ALL_NOTIFICATIONS;
- PDPNotification result = ManualClientEndUEB.result(scheme);
+ PDPNotification result = ManualClientEndUEB.result(scheme);
- assertNull(result);
- }
+ assertNull(result);
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(ManualClientEndUEBTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(ManualClientEndUEBTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java
index e3ea73563..83f5ef2df 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/MatchStoreTest.java
@@ -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.
@@ -25,14 +27,12 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -71,8 +71,7 @@ public class MatchStoreTest {
/**
* Perform pre-test initialization.
*
- * @throws Exception
- * if the initialization fails for some reason
+ * @throws Exception if the initialization fails for some reason
*/
@Before
public void setUp() throws Exception {
@@ -113,7 +112,8 @@ public class MatchStoreTest {
}
@Test
- public void testStoreMatch_ShouldRetrunEmptyLoadedRemovedPolicesIfNotMatchFoundInMatchStore() throws Exception {
+ public void testStoreMatch_ShouldRetrunEmptyLoadedRemovedPolicesIfNotMatchFoundInMatchStore()
+ throws Exception {
final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL);
MatchStore.storeMatch(newMatch);
@@ -129,11 +129,12 @@ public class MatchStoreTest {
}
@Test
- public void testStoreMatch_NotificationTypeRemoved_IfRemovedPolicyExistInOldNotification() throws Exception {
+ public void testStoreMatch_NotificationTypeRemoved_IfRemovedPolicyExistInOldNotification()
+ throws Exception {
final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL);
final StdRemovedPolicy removedPolicy = getRemovedPolicy(POLICY_VERSION, POLICY_NAME);
- final PDPNotification oldNotification = getPDPNotification(Arrays.asList(removedPolicy),
- Collections.emptySet());
+ final PDPNotification oldNotification =
+ getPDPNotification(Arrays.asList(removedPolicy), Collections.emptySet());
MatchStore.storeMatch(newMatch);
@@ -147,11 +148,13 @@ public class MatchStoreTest {
}
@Test
- public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithEmptyMatches() throws Exception {
+ public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithEmptyMatches()
+ throws Exception {
final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL);
- final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, Collections.emptyMap());
- final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
- Arrays.asList(stdLoadedPolicy));
+ final StdLoadedPolicy stdLoadedPolicy =
+ getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, Collections.emptyMap());
+ final PDPNotification oldNotification =
+ getPDPNotification(Collections.emptySet(), Arrays.asList(stdLoadedPolicy));
MatchStore.storeMatch(newMatch);
@@ -164,16 +167,18 @@ public class MatchStoreTest {
}
@Test
- public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithMatches() throws Exception {
+ public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithMatches()
+ throws Exception {
final Map<String, String> attribute = getAttributesMap();
final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, attribute);
final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
matches.putAll(attribute);
- final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
- final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
- Arrays.asList(stdLoadedPolicy));
+ final StdLoadedPolicy stdLoadedPolicy =
+ getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+ final PDPNotification oldNotification =
+ getPDPNotification(Collections.emptySet(), Arrays.asList(stdLoadedPolicy));
MatchStore.storeMatch(newMatch);
@@ -183,7 +188,8 @@ public class MatchStoreTest {
assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
- final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ final Collection<LoadedPolicy> actualLoadPolicies =
+ actualPDPNotification.getLoadedPolicies();
assertFalse(actualLoadPolicies.isEmpty());
final LoadedPolicy loadedPolicy = actualLoadPolicies.iterator().next();
@@ -192,14 +198,16 @@ public class MatchStoreTest {
}
@Test
- public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithNullMatches() throws Exception {
+ public void testStoreMatch_NoticficationTypeUpdate_IfStdLoadPolicyExistsWithNullMatches()
+ throws Exception {
final Map<String, String> attribute = getAttributesMap();
final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, attribute);
- final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, null);
- final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
- Arrays.asList(stdLoadedPolicy));
+ final StdLoadedPolicy stdLoadedPolicy =
+ getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, null);
+ final PDPNotification oldNotification =
+ getPDPNotification(Collections.emptySet(), Arrays.asList(stdLoadedPolicy));
MatchStore.storeMatch(newMatch);
@@ -209,7 +217,8 @@ public class MatchStoreTest {
assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
- final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ final Collection<LoadedPolicy> actualLoadPolicies =
+ actualPDPNotification.getLoadedPolicies();
assertFalse(actualLoadPolicies.isEmpty());
final LoadedPolicy loadedPolicy = actualLoadPolicies.iterator().next();
@@ -220,12 +229,14 @@ public class MatchStoreTest {
@Test
public void testStoreMatch_NoticficationTypeNull_IfStdLoadPolicyExistsWithMatchesWithOutMatchingConfigAttribute()
throws Exception {
- final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
+ final Matches newMatch =
+ getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
- final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
- final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
- Arrays.asList(stdLoadedPolicy));
+ final StdLoadedPolicy stdLoadedPolicy =
+ getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+ final PDPNotification oldNotification =
+ getPDPNotification(Collections.emptySet(), Arrays.asList(stdLoadedPolicy));
MatchStore.storeMatch(newMatch);
@@ -235,7 +246,8 @@ public class MatchStoreTest {
assertNull(actualPDPNotification.getNotificationType());
- final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ final Collection<LoadedPolicy> actualLoadPolicies =
+ actualPDPNotification.getLoadedPolicies();
assertTrue(actualLoadPolicies.isEmpty());
}
@@ -248,9 +260,10 @@ public class MatchStoreTest {
final Map<String, String> matches = new HashMap<>();
matches.put(ONAP_NAME_VAL, ONAP_NAME_VAL);
- final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
- final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
- Arrays.asList(stdLoadedPolicy));
+ final StdLoadedPolicy stdLoadedPolicy =
+ getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+ final PDPNotification oldNotification =
+ getPDPNotification(Collections.emptySet(), Arrays.asList(stdLoadedPolicy));
MatchStore.storeMatch(newMatch);
@@ -260,20 +273,24 @@ public class MatchStoreTest {
assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
- final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ final Collection<LoadedPolicy> actualLoadPolicies =
+ actualPDPNotification.getLoadedPolicies();
assertFalse(actualLoadPolicies.isEmpty());
}
@Test
- public void testStoreMatch_NoticficationTypeUpdate_IfMatchStoreContainMatchingMatches() throws Exception {
+ public void testStoreMatch_NoticficationTypeUpdate_IfMatchStoreContainMatchingMatches()
+ throws Exception {
- final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+ final Matches newMatch =
+ getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
- final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
- final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
- Arrays.asList(stdLoadedPolicy));
+ final StdLoadedPolicy stdLoadedPolicy =
+ getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+ final PDPNotification oldNotification =
+ getPDPNotification(Collections.emptySet(), Arrays.asList(stdLoadedPolicy));
MatchStore.storeMatch(newMatch);
@@ -283,7 +300,8 @@ public class MatchStoreTest {
assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
- final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ final Collection<LoadedPolicy> actualLoadPolicies =
+ actualPDPNotification.getLoadedPolicies();
assertFalse(actualLoadPolicies.isEmpty());
final LoadedPolicy loadedPolicy = actualLoadPolicies.iterator().next();
@@ -292,18 +310,23 @@ public class MatchStoreTest {
}
@Test
- public void testStoreMatch_NoticficationTypeUpdate_IfMatchStoreContainMatchingMatches2() throws Exception {
+ public void testStoreMatch_NoticficationTypeUpdate_IfMatchStoreContainMatchingMatches2()
+ throws Exception {
- final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+ final Matches firstObj =
+ getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
final Map<String, String> firstPolicyObj = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
final Map<String, String> attributesMap = getAttributesMap();
final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, attributesMap);
- final Map<String, String> secondPolicyObj = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
+ final Map<String, String> secondPolicyObj =
+ getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
secondPolicyObj.putAll(attributesMap);
- final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, firstPolicyObj);
- final StdLoadedPolicy secondStdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, secondPolicyObj);
+ final StdLoadedPolicy stdLoadedPolicy =
+ getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, firstPolicyObj);
+ final StdLoadedPolicy secondStdLoadedPolicy =
+ getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, secondPolicyObj);
final PDPNotification oldNotification = getPDPNotification(Collections.emptySet(),
Arrays.asList(stdLoadedPolicy, secondStdLoadedPolicy));
@@ -316,7 +339,8 @@ public class MatchStoreTest {
assertEquals(NotificationType.UPDATE, actualPDPNotification.getNotificationType());
- final Collection<LoadedPolicy> actualLoadPolicies = actualPDPNotification.getLoadedPolicies();
+ final Collection<LoadedPolicy> actualLoadPolicies =
+ actualPDPNotification.getLoadedPolicies();
assertFalse(actualLoadPolicies.isEmpty());
assertEquals(1, actualLoadPolicies.size());
}
@@ -325,13 +349,15 @@ public class MatchStoreTest {
public void testStoreMatch_NoticficationTypeBoth_IfOldNotificationContainRemovedAndLoadedPolicies()
throws Exception {
- final Matches newMatch = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+ final Matches newMatch =
+ getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
final Map<String, String> matches = getPolicyMatches(ONAP_NAME_VAL, CONFIG_NAME_VAL);
final StdRemovedPolicy removedPolicy = getRemovedPolicy(POLICY_VERSION, POLICY_NAME);
- final StdLoadedPolicy stdLoadedPolicy = getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
- final PDPNotification oldNotification = getPDPNotification(Arrays.asList(removedPolicy),
- Arrays.asList(stdLoadedPolicy));
+ final StdLoadedPolicy stdLoadedPolicy =
+ getStdLoadedPolicy(POLICY_VERSION, POLICY_NAME, matches);
+ final PDPNotification oldNotification =
+ getPDPNotification(Arrays.asList(removedPolicy), Arrays.asList(stdLoadedPolicy));
MatchStore.storeMatch(newMatch);
@@ -352,15 +378,17 @@ public class MatchStoreTest {
}
@Test
- public void testStoreMatch_MatchesObjectShouldbeAddOnceToMatchStoreAndNoDuplication() throws Exception {
- final String[] configNames = new String[] { CONFIG_NAME_VAL, CONFIG_NAME_VAL, "ConfigName1", CONFIG_NAME_VAL,
- "ConfigName1", null };
- final String[] onapNames = new String[] { ONAP_NAME_VAL, ONAP_NAME_VAL, "ONAPName1", "ONAPName1", ONAP_NAME_VAL,
- ONAP_NAME_VAL };
+ public void testStoreMatch_MatchesObjectShouldbeAddOnceToMatchStoreAndNoDuplication()
+ throws Exception {
+ final String[] configNames = new String[] {CONFIG_NAME_VAL, CONFIG_NAME_VAL, "ConfigName1",
+ CONFIG_NAME_VAL, "ConfigName1", null};
+ final String[] onapNames = new String[] {ONAP_NAME_VAL, ONAP_NAME_VAL, "ONAPName1",
+ "ONAPName1", ONAP_NAME_VAL, ONAP_NAME_VAL};
for (int i = 0; i < configNames.length; i++) {
- final Matches matches = getMatchesInstance(configNames[i], onapNames[i], getAttributesMap());
+ final Matches matches =
+ getMatchesInstance(configNames[i], onapNames[i], getAttributesMap());
MatchStore.storeMatch(matches);
MatchStore.storeMatch(matches);
}
@@ -372,8 +400,10 @@ public class MatchStoreTest {
@Test
public void testStoreMatch_MatchesObjectShouldBeAddedToMatchStore_ConfigAttrValuesAreDifferentThenExistingOne()
throws Exception {
- final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
- final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
+ final Matches firstObj =
+ getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
+ final Matches secondObj =
+ getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, Collections.emptyMap());
MatchStore.storeMatch(firstObj);
MatchStore.storeMatch(secondObj);
@@ -384,7 +414,8 @@ public class MatchStoreTest {
}
@Test
- public void testStoreMatch_MatchesObjectShouldBeAddedToMatchStore_ConfigAttrValuesNull() throws Exception {
+ public void testStoreMatch_MatchesObjectShouldBeAddedToMatchStore_ConfigAttrValuesNull()
+ throws Exception {
final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, null);
final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, null);
@@ -399,8 +430,10 @@ public class MatchStoreTest {
@Test
public void testStoreMatch_MatchesObjectShouldBeAddedToMatchStore_OnapNameIsDifferentThenExistingOne()
throws Exception {
- final Matches firstObj = getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
- final Matches secondObj = getMatchesInstance(CONFIG_NAME_VAL, "ONAPName1", getAttributesMap());
+ final Matches firstObj =
+ getMatchesInstance(CONFIG_NAME_VAL, ONAP_NAME_VAL, getAttributesMap());
+ final Matches secondObj =
+ getMatchesInstance(CONFIG_NAME_VAL, "ONAPName1", getAttributesMap());
MatchStore.storeMatch(firstObj);
MatchStore.storeMatch(secondObj);
@@ -476,8 +509,7 @@ public class MatchStoreTest {
/**
* Perform post-test clean-up.
*
- * @throws Exception
- * if the clean-up fails for some reason
+ * @throws Exception if the clean-up fails for some reason
*/
@After
public void tearDown() throws Exception {
@@ -487,8 +519,7 @@ public class MatchStoreTest {
/**
* Launch the test.
*
- * @param args
- * the command line arguments
+ * @param args the command line arguments
*/
public static void main(final String[] args) {
new org.junit.runner.JUnitCore().run(MatchStoreTest.class);
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationStoreTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationStoreTest.java
index a453736ec..cb5c40c60 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationStoreTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/NotificationStoreTest.java
@@ -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.
@@ -23,324 +25,304 @@ package org.onap.policy.std.test;
import org.junit.*;
import org.onap.policy.std.NotificationStore;
import org.onap.policy.std.StdPDPNotification;
-
import static org.junit.Assert.*;
/**
- * The class <code>NotificationStoreTest</code> contains tests for the class <code>{@link NotificationStore}</code>.
+ * The class <code>NotificationStoreTest</code> contains tests for the class
+ * <code>{@link NotificationStore}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class NotificationStoreTest {
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_1()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_2()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_3()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_4()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_5()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_6()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_7()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_8()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_9()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_10()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_11()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_12()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_13()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_14()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_15()
- throws Exception {
- StdPDPNotification notification = new StdPDPNotification();
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Run the void recordNotification(StdPDPNotification) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testRecordNotification_16()
- throws Exception {
- StdPDPNotification notification = null;
-
- NotificationStore.recordNotification(notification);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(NotificationStoreTest.class);
- }
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_1() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_2() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_3() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_4() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_5() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_6() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_7() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_8() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_9() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_10() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_11() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_12() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_13() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_14() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_15() throws Exception {
+ StdPDPNotification notification = new StdPDPNotification();
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void recordNotification(StdPDPNotification) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testRecordNotification_16() throws Exception {
+ StdPDPNotification notification = null;
+
+ NotificationStore.recordNotification(notification);
+
+ // add additional test code here
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(NotificationStoreTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdLoadedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdLoadedPolicyTest.java
index c45a5aca7..0275fd2bb 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdLoadedPolicyTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdLoadedPolicyTest.java
@@ -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.
@@ -22,293 +24,277 @@ package org.onap.policy.std.test;
import java.util.Hashtable;
import java.util.Map;
-
import org.junit.*;
import org.onap.policy.api.UpdateType;
import org.onap.policy.std.StdLoadedPolicy;
-
import static org.junit.Assert.*;
/**
- * The class <code>StdLoadedPolicyTest</code> contains tests for the class <code>{@link StdLoadedPolicy}</code>.
+ * The class <code>StdLoadedPolicyTest</code> contains tests for the class
+ * <code>{@link StdLoadedPolicy}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class StdLoadedPolicyTest {
- /**
- * Run the StdLoadedPolicy() constructor test.
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testStdLoadedPolicy_1()
- throws Exception {
- StdLoadedPolicy result = new StdLoadedPolicy();
- assertNotNull(result);
- // add additional test code here
- }
-
- /**
- * Run the Map<String, String> getMatches() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetMatches_1()
- throws Exception {
- StdLoadedPolicy fixture = new StdLoadedPolicy();
- fixture.setPolicyName("");
- fixture.setVersionNo("");
- fixture.setUpdateType(UpdateType.NEW);
- fixture.setMatches(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getMatches();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_1()
- throws Exception {
- StdLoadedPolicy fixture = new StdLoadedPolicy();
- fixture.setPolicyName("");
- fixture.setVersionNo("");
- fixture.setUpdateType(UpdateType.NEW);
- fixture.setMatches(new Hashtable<String, String>());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_2()
- throws Exception {
- StdLoadedPolicy fixture = new StdLoadedPolicy();
- fixture.setPolicyName((String) null);
- fixture.setVersionNo("");
- fixture.setUpdateType(UpdateType.NEW);
- fixture.setMatches(new Hashtable<String, String>());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals(null, result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_3()
- throws Exception {
- StdLoadedPolicy fixture = new StdLoadedPolicy();
- fixture.setPolicyName("");
- fixture.setVersionNo("");
- fixture.setUpdateType(UpdateType.NEW);
- fixture.setMatches(new Hashtable<String, String>());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the UpdateType getUpdateType() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetUpdateType_1()
- throws Exception {
- StdLoadedPolicy fixture = new StdLoadedPolicy();
- fixture.setPolicyName("");
- fixture.setVersionNo("");
- fixture.setUpdateType(UpdateType.NEW);
- fixture.setMatches(new Hashtable<String, String>());
-
- UpdateType result = fixture.getUpdateType();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("new", result.toString());
- assertEquals("NEW", result.name());
- assertEquals(1, result.ordinal());
- }
-
- /**
- * Run the String getVersionNo() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetVersionNo_1()
- throws Exception {
- StdLoadedPolicy fixture = new StdLoadedPolicy();
- fixture.setPolicyName("");
- fixture.setVersionNo("");
- fixture.setUpdateType(UpdateType.NEW);
- fixture.setMatches(new Hashtable<String, String>());
-
- String result = fixture.getVersionNo();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the void setMatches(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetMatches_1()
- throws Exception {
- StdLoadedPolicy fixture = new StdLoadedPolicy();
- fixture.setPolicyName("");
- fixture.setVersionNo("");
- fixture.setUpdateType(UpdateType.NEW);
- fixture.setMatches(new Hashtable<String, String>());
- Map<String, String> matches = new Hashtable<String, String>();
-
- fixture.setMatches(matches);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyName_1()
- throws Exception {
- StdLoadedPolicy fixture = new StdLoadedPolicy();
- fixture.setPolicyName("");
- fixture.setVersionNo("");
- fixture.setUpdateType(UpdateType.NEW);
- fixture.setMatches(new Hashtable<String, String>());
- String policyName = "";
-
- fixture.setPolicyName(policyName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setUpdateType(UpdateType) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetUpdateType_1()
- throws Exception {
- StdLoadedPolicy fixture = new StdLoadedPolicy();
- fixture.setPolicyName("");
- fixture.setVersionNo("");
- fixture.setUpdateType(UpdateType.NEW);
- fixture.setMatches(new Hashtable<String, String>());
- UpdateType updateType = UpdateType.NEW;
-
- fixture.setUpdateType(updateType);
-
- // add additional test code here
- }
-
- /**
- * Run the void setVersionNo(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetVersionNo_1()
- throws Exception {
- StdLoadedPolicy fixture = new StdLoadedPolicy();
- fixture.setPolicyName("");
- fixture.setVersionNo("");
- fixture.setUpdateType(UpdateType.NEW);
- fixture.setMatches(new Hashtable<String, String>());
- String versionNo = "";
-
- fixture.setVersionNo(versionNo);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(StdLoadedPolicyTest.class);
- }
+ /**
+ * Run the StdLoadedPolicy() constructor test.
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testStdLoadedPolicy_1() throws Exception {
+ StdLoadedPolicy result = new StdLoadedPolicy();
+ assertNotNull(result);
+ // add additional test code here
+ }
+
+ /**
+ * Run the Map<String, String> getMatches() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetMatches_1() throws Exception {
+ StdLoadedPolicy fixture = new StdLoadedPolicy();
+ fixture.setPolicyName("");
+ fixture.setVersionNo("");
+ fixture.setUpdateType(UpdateType.NEW);
+ fixture.setMatches(new Hashtable<String, String>());
+
+ Map<String, String> result = fixture.getMatches();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_1() throws Exception {
+ StdLoadedPolicy fixture = new StdLoadedPolicy();
+ fixture.setPolicyName("");
+ fixture.setVersionNo("");
+ fixture.setUpdateType(UpdateType.NEW);
+ fixture.setMatches(new Hashtable<String, String>());
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_2() throws Exception {
+ StdLoadedPolicy fixture = new StdLoadedPolicy();
+ fixture.setPolicyName((String) null);
+ fixture.setVersionNo("");
+ fixture.setUpdateType(UpdateType.NEW);
+ fixture.setMatches(new Hashtable<String, String>());
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals(null, result);
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_3() throws Exception {
+ StdLoadedPolicy fixture = new StdLoadedPolicy();
+ fixture.setPolicyName("");
+ fixture.setVersionNo("");
+ fixture.setUpdateType(UpdateType.NEW);
+ fixture.setMatches(new Hashtable<String, String>());
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the UpdateType getUpdateType() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetUpdateType_1() throws Exception {
+ StdLoadedPolicy fixture = new StdLoadedPolicy();
+ fixture.setPolicyName("");
+ fixture.setVersionNo("");
+ fixture.setUpdateType(UpdateType.NEW);
+ fixture.setMatches(new Hashtable<String, String>());
+
+ UpdateType result = fixture.getUpdateType();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("new", result.toString());
+ assertEquals("NEW", result.name());
+ assertEquals(1, result.ordinal());
+ }
+
+ /**
+ * Run the String getVersionNo() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetVersionNo_1() throws Exception {
+ StdLoadedPolicy fixture = new StdLoadedPolicy();
+ fixture.setPolicyName("");
+ fixture.setVersionNo("");
+ fixture.setUpdateType(UpdateType.NEW);
+ fixture.setMatches(new Hashtable<String, String>());
+
+ String result = fixture.getVersionNo();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the void setMatches(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetMatches_1() throws Exception {
+ StdLoadedPolicy fixture = new StdLoadedPolicy();
+ fixture.setPolicyName("");
+ fixture.setVersionNo("");
+ fixture.setUpdateType(UpdateType.NEW);
+ fixture.setMatches(new Hashtable<String, String>());
+ Map<String, String> matches = new Hashtable<String, String>();
+
+ fixture.setMatches(matches);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyName(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyName_1() throws Exception {
+ StdLoadedPolicy fixture = new StdLoadedPolicy();
+ fixture.setPolicyName("");
+ fixture.setVersionNo("");
+ fixture.setUpdateType(UpdateType.NEW);
+ fixture.setMatches(new Hashtable<String, String>());
+ String policyName = "";
+
+ fixture.setPolicyName(policyName);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setUpdateType(UpdateType) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetUpdateType_1() throws Exception {
+ StdLoadedPolicy fixture = new StdLoadedPolicy();
+ fixture.setPolicyName("");
+ fixture.setVersionNo("");
+ fixture.setUpdateType(UpdateType.NEW);
+ fixture.setMatches(new Hashtable<String, String>());
+ UpdateType updateType = UpdateType.NEW;
+
+ fixture.setUpdateType(updateType);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setVersionNo(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetVersionNo_1() throws Exception {
+ StdLoadedPolicy fixture = new StdLoadedPolicy();
+ fixture.setPolicyName("");
+ fixture.setVersionNo("");
+ fixture.setUpdateType(UpdateType.NEW);
+ fixture.setMatches(new Hashtable<String, String>());
+ String versionNo = "";
+
+ fixture.setVersionNo(versionNo);
+
+ // add additional test code here
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(StdLoadedPolicyTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPDPNotificationTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPDPNotificationTest.java
index 23b570e9a..ecfd77c25 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPDPNotificationTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPDPNotificationTest.java
@@ -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.
@@ -23,7 +25,6 @@ package org.onap.policy.std.test;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
-
import org.junit.*;
import org.onap.policy.api.LoadedPolicy;
import org.onap.policy.api.NotificationType;
@@ -31,282 +32,267 @@ import org.onap.policy.api.RemovedPolicy;
import org.onap.policy.std.StdLoadedPolicy;
import org.onap.policy.std.StdPDPNotification;
import org.onap.policy.std.StdRemovedPolicy;
-
import static org.junit.Assert.*;
/**
- * The class <code>StdPDPNotificationTest</code> contains tests for the class <code>{@link StdPDPNotification}</code>.
+ * The class <code>StdPDPNotificationTest</code> contains tests for the class
+ * <code>{@link StdPDPNotification}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class StdPDPNotificationTest {
- /**
- * Run the StdPDPNotification() constructor test.
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testStdPDPNotification_1()
- throws Exception {
- StdPDPNotification result = new StdPDPNotification();
- assertNotNull(result);
- // add additional test code here
- }
-
- /**
- * Run the Collection<LoadedPolicy> getLoadedPolicies() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetLoadedPolicies_1()
- throws Exception {
- StdPDPNotification fixture = new StdPDPNotification();
- fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
- fixture.setNotificationType(NotificationType.BOTH);
- fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
-
- Collection<LoadedPolicy> result = fixture.getLoadedPolicies();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the Collection<LoadedPolicy> getLoadedPolicies() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetLoadedPolicies_2()
- throws Exception {
- StdPDPNotification fixture = new StdPDPNotification();
- fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
- fixture.setNotificationType(NotificationType.BOTH);
- fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
-
- Collection<LoadedPolicy> result = fixture.getLoadedPolicies();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the Collection<LoadedPolicy> getLoadedPolicies() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetLoadedPolicies_3()
- throws Exception {
- StdPDPNotification fixture = new StdPDPNotification();
- fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
- fixture.setNotificationType(NotificationType.BOTH);
- fixture.setLoadedPolicies(null);
-
- Collection<LoadedPolicy> result = fixture.getLoadedPolicies();
-
- // add additional test code here
- assertEquals(Collections.EMPTY_LIST, result);
- }
-
- /**
- * Run the NotificationType getNotificationType() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetNotificationType_1()
- throws Exception {
- StdPDPNotification fixture = new StdPDPNotification();
- fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
- fixture.setNotificationType(NotificationType.BOTH);
- fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
-
- NotificationType result = fixture.getNotificationType();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("both", result.toString());
- assertEquals("BOTH", result.name());
- assertEquals(2, result.ordinal());
- }
-
- /**
- * Run the Collection<RemovedPolicy> getRemovedPolicies() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetRemovedPolicies_1()
- throws Exception {
- StdPDPNotification fixture = new StdPDPNotification();
- fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
- fixture.setNotificationType(NotificationType.BOTH);
- fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
-
- Collection<RemovedPolicy> result = fixture.getRemovedPolicies();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the Collection<RemovedPolicy> getRemovedPolicies() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetRemovedPolicies_2()
- throws Exception {
- StdPDPNotification fixture = new StdPDPNotification();
- fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
- fixture.setNotificationType(NotificationType.BOTH);
- fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
-
- Collection<RemovedPolicy> result = fixture.getRemovedPolicies();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the Collection<RemovedPolicy> getRemovedPolicies() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetRemovedPolicies_3()
- throws Exception {
- StdPDPNotification fixture = new StdPDPNotification();
- fixture.setRemovedPolicies(null);
- fixture.setNotificationType(NotificationType.BOTH);
- fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
-
- Collection<RemovedPolicy> result = fixture.getRemovedPolicies();
-
- // add additional test code here
- assertEquals(Collections.EMPTY_LIST, result);
- }
-
- /**
- * Run the void setNotificationType(NotificationType) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetNotificationType_1()
- throws Exception {
- StdPDPNotification fixture = new StdPDPNotification();
- fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
- fixture.setNotificationType(NotificationType.BOTH);
- fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
- NotificationType notificationType = NotificationType.BOTH;
-
- fixture.setNotificationType(notificationType);
-
- // add additional test code here
- }
-
- /**
- * Run the void setRemovedPolicies(Collection<StdRemovedPolicy>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetRemovedPolicies_1()
- throws Exception {
- StdPDPNotification fixture = new StdPDPNotification();
- fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
- fixture.setNotificationType(NotificationType.BOTH);
- fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
- Collection<StdRemovedPolicy> removedPolicies = new LinkedList<StdRemovedPolicy>();
-
- fixture.setRemovedPolicies(removedPolicies);
-
- // add additional test code here
- }
-
- /**
- * Run the void setUpdatedPolicies(Collection<StdLoadedPolicy>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetUpdatedPolicies_1()
- throws Exception {
- StdPDPNotification fixture = new StdPDPNotification();
- fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
- fixture.setNotificationType(NotificationType.BOTH);
- fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
- Collection<StdLoadedPolicy> updatedPolicies = new LinkedList<StdLoadedPolicy>();
-
- fixture.setLoadedPolicies(updatedPolicies);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(StdPDPNotificationTest.class);
- }
+ /**
+ * Run the StdPDPNotification() constructor test.
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testStdPDPNotification_1() throws Exception {
+ StdPDPNotification result = new StdPDPNotification();
+ assertNotNull(result);
+ // add additional test code here
+ }
+
+ /**
+ * Run the Collection<LoadedPolicy> getLoadedPolicies() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetLoadedPolicies_1() throws Exception {
+ StdPDPNotification fixture = new StdPDPNotification();
+ fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
+ fixture.setNotificationType(NotificationType.BOTH);
+ fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
+
+ Collection<LoadedPolicy> result = fixture.getLoadedPolicies();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the Collection<LoadedPolicy> getLoadedPolicies() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetLoadedPolicies_2() throws Exception {
+ StdPDPNotification fixture = new StdPDPNotification();
+ fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
+ fixture.setNotificationType(NotificationType.BOTH);
+ fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
+
+ Collection<LoadedPolicy> result = fixture.getLoadedPolicies();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the Collection<LoadedPolicy> getLoadedPolicies() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetLoadedPolicies_3() throws Exception {
+ StdPDPNotification fixture = new StdPDPNotification();
+ fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
+ fixture.setNotificationType(NotificationType.BOTH);
+ fixture.setLoadedPolicies(null);
+
+ Collection<LoadedPolicy> result = fixture.getLoadedPolicies();
+
+ // add additional test code here
+ assertEquals(Collections.EMPTY_LIST, result);
+ }
+
+ /**
+ * Run the NotificationType getNotificationType() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetNotificationType_1() throws Exception {
+ StdPDPNotification fixture = new StdPDPNotification();
+ fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
+ fixture.setNotificationType(NotificationType.BOTH);
+ fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
+
+ NotificationType result = fixture.getNotificationType();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("both", result.toString());
+ assertEquals("BOTH", result.name());
+ assertEquals(2, result.ordinal());
+ }
+
+ /**
+ * Run the Collection<RemovedPolicy> getRemovedPolicies() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetRemovedPolicies_1() throws Exception {
+ StdPDPNotification fixture = new StdPDPNotification();
+ fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
+ fixture.setNotificationType(NotificationType.BOTH);
+ fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
+
+ Collection<RemovedPolicy> result = fixture.getRemovedPolicies();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the Collection<RemovedPolicy> getRemovedPolicies() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetRemovedPolicies_2() throws Exception {
+ StdPDPNotification fixture = new StdPDPNotification();
+ fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
+ fixture.setNotificationType(NotificationType.BOTH);
+ fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
+
+ Collection<RemovedPolicy> result = fixture.getRemovedPolicies();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the Collection<RemovedPolicy> getRemovedPolicies() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetRemovedPolicies_3() throws Exception {
+ StdPDPNotification fixture = new StdPDPNotification();
+ fixture.setRemovedPolicies(null);
+ fixture.setNotificationType(NotificationType.BOTH);
+ fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
+
+ Collection<RemovedPolicy> result = fixture.getRemovedPolicies();
+
+ // add additional test code here
+ assertEquals(Collections.EMPTY_LIST, result);
+ }
+
+ /**
+ * Run the void setNotificationType(NotificationType) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetNotificationType_1() throws Exception {
+ StdPDPNotification fixture = new StdPDPNotification();
+ fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
+ fixture.setNotificationType(NotificationType.BOTH);
+ fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
+ NotificationType notificationType = NotificationType.BOTH;
+
+ fixture.setNotificationType(notificationType);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setRemovedPolicies(Collection<StdRemovedPolicy>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetRemovedPolicies_1() throws Exception {
+ StdPDPNotification fixture = new StdPDPNotification();
+ fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
+ fixture.setNotificationType(NotificationType.BOTH);
+ fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
+ Collection<StdRemovedPolicy> removedPolicies = new LinkedList<StdRemovedPolicy>();
+
+ fixture.setRemovedPolicies(removedPolicies);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setUpdatedPolicies(Collection<StdLoadedPolicy>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetUpdatedPolicies_1() throws Exception {
+ StdPDPNotification fixture = new StdPDPNotification();
+ fixture.setRemovedPolicies(new LinkedList<StdRemovedPolicy>());
+ fixture.setNotificationType(NotificationType.BOTH);
+ fixture.setLoadedPolicies(new LinkedList<StdLoadedPolicy>());
+ Collection<StdLoadedPolicy> updatedPolicies = new LinkedList<StdLoadedPolicy>();
+
+ fixture.setLoadedPolicies(updatedPolicies);
+
+ // add additional test code here
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(StdPDPNotificationTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyChangeResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyChangeResponseTest.java
index 5ce53d133..72dda97c4 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyChangeResponseTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyChangeResponseTest.java
@@ -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.
@@ -22,145 +24,136 @@ package org.onap.policy.std.test;
import org.junit.*;
import org.onap.policy.std.StdPolicyChangeResponse;
-
import static org.junit.Assert.*;
/**
- * The class <code>StdPolicyChangeResponseTest</code> contains tests for the class <code>{@link StdPolicyChangeResponse}</code>.
+ * The class <code>StdPolicyChangeResponseTest</code> contains tests for the class
+ * <code>{@link StdPolicyChangeResponse}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class StdPolicyChangeResponseTest {
- /**
- * Run the StdPolicyChangeResponse() constructor test.
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testStdPolicyChangeResponse_1()
- throws Exception {
- StdPolicyChangeResponse result = new StdPolicyChangeResponse();
- assertNotNull(result);
- // add additional test code here
- }
-
- /**
- * Run the int getResponseCode() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetResponseCode_1()
- throws Exception {
- StdPolicyChangeResponse fixture = new StdPolicyChangeResponse();
- fixture.setResponseMessage("");
- fixture.setResponseCode(1);
-
- int result = fixture.getResponseCode();
-
- // add additional test code here
- assertEquals(1, result);
- }
-
- /**
- * Run the String getResponseMessage() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetResponseMessage_1()
- throws Exception {
- StdPolicyChangeResponse fixture = new StdPolicyChangeResponse();
- fixture.setResponseMessage("");
- fixture.setResponseCode(1);
-
- String result = fixture.getResponseMessage();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the void setResponseCode(int) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetResponseCode_1()
- throws Exception {
- StdPolicyChangeResponse fixture = new StdPolicyChangeResponse();
- fixture.setResponseMessage("");
- fixture.setResponseCode(1);
- int responseCode = 1;
-
- fixture.setResponseCode(responseCode);
-
- // add additional test code here
- }
-
- /**
- * Run the void setResponseMessage(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetResponseMessage_1()
- throws Exception {
- StdPolicyChangeResponse fixture = new StdPolicyChangeResponse();
- fixture.setResponseMessage("");
- fixture.setResponseCode(1);
- String responseMessage = "";
-
- fixture.setResponseMessage(responseMessage);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(StdPolicyChangeResponseTest.class);
- }
+ /**
+ * Run the StdPolicyChangeResponse() constructor test.
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testStdPolicyChangeResponse_1() throws Exception {
+ StdPolicyChangeResponse result = new StdPolicyChangeResponse();
+ assertNotNull(result);
+ // add additional test code here
+ }
+
+ /**
+ * Run the int getResponseCode() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetResponseCode_1() throws Exception {
+ StdPolicyChangeResponse fixture = new StdPolicyChangeResponse();
+ fixture.setResponseMessage("");
+ fixture.setResponseCode(1);
+
+ int result = fixture.getResponseCode();
+
+ // add additional test code here
+ assertEquals(1, result);
+ }
+
+ /**
+ * Run the String getResponseMessage() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetResponseMessage_1() throws Exception {
+ StdPolicyChangeResponse fixture = new StdPolicyChangeResponse();
+ fixture.setResponseMessage("");
+ fixture.setResponseCode(1);
+
+ String result = fixture.getResponseMessage();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the void setResponseCode(int) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetResponseCode_1() throws Exception {
+ StdPolicyChangeResponse fixture = new StdPolicyChangeResponse();
+ fixture.setResponseMessage("");
+ fixture.setResponseCode(1);
+ int responseCode = 1;
+
+ fixture.setResponseCode(responseCode);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setResponseMessage(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetResponseMessage_1() throws Exception {
+ StdPolicyChangeResponse fixture = new StdPolicyChangeResponse();
+ fixture.setResponseMessage("");
+ fixture.setResponseCode(1);
+ String responseMessage = "";
+
+ fixture.setResponseMessage(responseMessage);
+
+ // add additional test code here
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(StdPolicyChangeResponseTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyResponseTest.java
index 11179aece..9c30a5131 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyResponseTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdPolicyResponseTest.java
@@ -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.
@@ -22,327 +24,312 @@ package org.onap.policy.std.test;
import java.util.Hashtable;
import java.util.Map;
-
import org.junit.*;
import org.onap.policy.api.PolicyResponseStatus;
import org.onap.policy.std.StdPolicyResponse;
-
import static org.junit.Assert.*;
/**
- * The class <code>StdPolicyResponseTest</code> contains tests for the class <code>{@link StdPolicyResponse}</code>.
+ * The class <code>StdPolicyResponseTest</code> contains tests for the class
+ * <code>{@link StdPolicyResponse}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class StdPolicyResponseTest {
- /**
- * Run the Map<String, String> getActionAdvised() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetActionAdvised_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getActionAdvised();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the Map<String, String> getActionTaken() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetActionTaken_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getActionTaken();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the String getPolicyResponseMessage() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyResponseMessage_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
-
- String result = fixture.getPolicyResponseMessage();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the PolicyResponseStatus getPolicyResponseStatus() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyResponseStatus_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
-
- PolicyResponseStatus result = fixture.getPolicyResponseStatus();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("action_advised", result.toString());
- assertEquals("ACTION_ADVISED", result.name());
- assertEquals(1, result.ordinal());
- }
-
- /**
- * Run the Map<String, String> getRequestAttributes() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetRequestAttributes_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getRequestAttributes();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the void setActionAdvised(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetActionAdvised_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
- Map<String, String> actionAdvised = new Hashtable<String, String>();
-
- fixture.setActionAdvised(actionAdvised);
-
- // add additional test code here
- }
-
- /**
- * Run the void setActionTaken(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetActionTaken_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
- Map<String, String> actionTaken = new Hashtable<String, String>();
-
- fixture.setActionTaken(actionTaken);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyResponseMessage(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyResponseMessage_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
- String policyResponseMessage = "";
-
- fixture.setPolicyResponseMessage(policyResponseMessage);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyResponseStatus(PolicyResponseStatus) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyResponseStatus_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
- PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
-
- fixture.setPolicyResponseStatus(policyResponseStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyResponseStatus(String,PolicyResponseStatus) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyResponseStatus_2()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
- String policyResponseMessage = "";
- PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
-
- fixture.setPolicyResponseStatus(policyResponseMessage, policyResponseStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the void setRequestAttributes(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetRequestAttributes_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
- Map<String, String> requestAttributes = new Hashtable<String, String>();
-
- fixture.setRequestAttributes(requestAttributes);
-
- // add additional test code here
- }
-
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- StdPolicyResponse fixture = new StdPolicyResponse();
- fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setActionTaken(new Hashtable<String, String>());
-
- String result = fixture.toString();
-
- // add additional test code here
- assertEquals("PolicyResponse [ policyResponseStatus=action_advised, policyResponseMessage=, ]", result);
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(StdPolicyResponseTest.class);
- }
+ /**
+ * Run the Map<String, String> getActionAdvised() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetActionAdvised_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ Map<String, String> result = fixture.getActionAdvised();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the Map<String, String> getActionTaken() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetActionTaken_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ Map<String, String> result = fixture.getActionTaken();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the String getPolicyResponseMessage() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyResponseMessage_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ String result = fixture.getPolicyResponseMessage();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the PolicyResponseStatus getPolicyResponseStatus() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyResponseStatus_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ PolicyResponseStatus result = fixture.getPolicyResponseStatus();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("action_advised", result.toString());
+ assertEquals("ACTION_ADVISED", result.name());
+ assertEquals(1, result.ordinal());
+ }
+
+ /**
+ * Run the Map<String, String> getRequestAttributes() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetRequestAttributes_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ Map<String, String> result = fixture.getRequestAttributes();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the void setActionAdvised(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetActionAdvised_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+ Map<String, String> actionAdvised = new Hashtable<String, String>();
+
+ fixture.setActionAdvised(actionAdvised);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setActionTaken(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetActionTaken_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+ Map<String, String> actionTaken = new Hashtable<String, String>();
+
+ fixture.setActionTaken(actionTaken);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyResponseMessage(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyResponseMessage_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+ String policyResponseMessage = "";
+
+ fixture.setPolicyResponseMessage(policyResponseMessage);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyResponseStatus(PolicyResponseStatus) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyResponseStatus_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+ PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
+
+ fixture.setPolicyResponseStatus(policyResponseStatus);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyResponseStatus(String,PolicyResponseStatus) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyResponseStatus_2() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+ String policyResponseMessage = "";
+ PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
+
+ fixture.setPolicyResponseStatus(policyResponseMessage, policyResponseStatus);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setRequestAttributes(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetRequestAttributes_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+ Map<String, String> requestAttributes = new Hashtable<String, String>();
+
+ fixture.setRequestAttributes(requestAttributes);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the String toString() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testToString_1() throws Exception {
+ StdPolicyResponse fixture = new StdPolicyResponse();
+ fixture.setPolicyResponseStatus("", PolicyResponseStatus.ACTION_ADVISED);
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals(
+ "PolicyResponse [ policyResponseStatus=action_advised, policyResponseMessage=, ]",
+ result);
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(StdPolicyResponseTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdRemovedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdRemovedPolicyTest.java
index 2482c3015..14f418c74 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdRemovedPolicyTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdRemovedPolicyTest.java
@@ -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.
@@ -22,185 +24,174 @@ package org.onap.policy.std.test;
import org.junit.*;
import org.onap.policy.std.StdRemovedPolicy;
-
import static org.junit.Assert.*;
/**
- * The class <code>StdRemovedPolicyTest</code> contains tests for the class <code>{@link StdRemovedPolicy}</code>.
+ * The class <code>StdRemovedPolicyTest</code> contains tests for the class
+ * <code>{@link StdRemovedPolicy}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class StdRemovedPolicyTest {
- /**
- * Run the StdRemovedPolicy() constructor test.
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testStdRemovedPolicy_1()
- throws Exception {
- StdRemovedPolicy result = new StdRemovedPolicy();
- assertNotNull(result);
- // add additional test code here
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_1()
- throws Exception {
- StdRemovedPolicy fixture = new StdRemovedPolicy();
- fixture.setVersionNo("");
- fixture.setPolicyName("");
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_2()
- throws Exception {
- StdRemovedPolicy fixture = new StdRemovedPolicy();
- fixture.setVersionNo("");
- fixture.setPolicyName((String) null);
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals(null, result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_3()
- throws Exception {
- StdRemovedPolicy fixture = new StdRemovedPolicy();
- fixture.setVersionNo("");
- fixture.setPolicyName("");
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getVersionNo() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetVersionNo_1()
- throws Exception {
- StdRemovedPolicy fixture = new StdRemovedPolicy();
- fixture.setVersionNo("");
- fixture.setPolicyName("");
-
- String result = fixture.getVersionNo();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the void setPolicyName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyName_1()
- throws Exception {
- StdRemovedPolicy fixture = new StdRemovedPolicy();
- fixture.setVersionNo("");
- fixture.setPolicyName("");
- String policyName = "";
-
- fixture.setPolicyName(policyName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setVersionNo(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetVersionNo_1()
- throws Exception {
- StdRemovedPolicy fixture = new StdRemovedPolicy();
- fixture.setVersionNo("");
- fixture.setPolicyName("");
- String versionNo = "";
-
- fixture.setVersionNo(versionNo);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(StdRemovedPolicyTest.class);
- }
+ /**
+ * Run the StdRemovedPolicy() constructor test.
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testStdRemovedPolicy_1() throws Exception {
+ StdRemovedPolicy result = new StdRemovedPolicy();
+ assertNotNull(result);
+ // add additional test code here
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_1() throws Exception {
+ StdRemovedPolicy fixture = new StdRemovedPolicy();
+ fixture.setVersionNo("");
+ fixture.setPolicyName("");
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_2() throws Exception {
+ StdRemovedPolicy fixture = new StdRemovedPolicy();
+ fixture.setVersionNo("");
+ fixture.setPolicyName((String) null);
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals(null, result);
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_3() throws Exception {
+ StdRemovedPolicy fixture = new StdRemovedPolicy();
+ fixture.setVersionNo("");
+ fixture.setPolicyName("");
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getVersionNo() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetVersionNo_1() throws Exception {
+ StdRemovedPolicy fixture = new StdRemovedPolicy();
+ fixture.setVersionNo("");
+ fixture.setPolicyName("");
+
+ String result = fixture.getVersionNo();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the void setPolicyName(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyName_1() throws Exception {
+ StdRemovedPolicy fixture = new StdRemovedPolicy();
+ fixture.setVersionNo("");
+ fixture.setPolicyName("");
+ String policyName = "";
+
+ fixture.setPolicyName(policyName);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setVersionNo(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetVersionNo_1() throws Exception {
+ StdRemovedPolicy fixture = new StdRemovedPolicy();
+ fixture.setVersionNo("");
+ fixture.setPolicyName("");
+ String versionNo = "";
+
+ fixture.setVersionNo(versionNo);
+
+ // add additional test code here
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(StdRemovedPolicyTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdStatusTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdStatusTest.java
index b72d2568d..85d9c027f 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdStatusTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/test/StdStatusTest.java
@@ -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.
@@ -23,18 +25,14 @@ package org.onap.policy.std.test;
import java.util.Hashtable;
import java.util.Map;
import java.util.Properties;
-
import javax.json.JsonObject;
-
import org.junit.*;
import org.onap.policy.api.PolicyConfigStatus;
import org.onap.policy.api.PolicyDecision;
import org.onap.policy.api.PolicyResponseStatus;
import org.onap.policy.api.PolicyType;
import org.onap.policy.std.StdStatus;
-
import static org.junit.Assert.*;
-
import org.w3c.dom.Document;
/**
@@ -44,1390 +42,1425 @@ import org.w3c.dom.Document;
* @version $Revision: 1.0 $
*/
public class StdStatusTest {
- /**
- * Run the Map<String, String> getActionAdvised() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetActionAdvised_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getActionAdvised();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the Map<String, String> getActionTaken() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetActionTaken_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getActionTaken();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the Map<String, String> getMatchingConditions() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetMatchingConditions_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getMatchingConditions();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the String getPolicyConfigMessage() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyConfigMessage_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- String result = fixture.getPolicyConfigMessage();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the PolicyConfigStatus getPolicyConfigStatus() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyConfigStatus_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- PolicyConfigStatus result = fixture.getPolicyConfigStatus();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("not_found", result.toString());
- assertEquals("CONFIG_NOT_FOUND", result.name());
- assertEquals(1, result.ordinal());
- }
-
- /**
- * Run the PolicyDecision getPolicyDecision() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyDecision_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- PolicyDecision result = fixture.getDecision();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("deny", result.toString());
- assertEquals("DENY", result.name());
- assertEquals(1, result.ordinal());
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_2()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName((String) null);
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals(null, result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_3()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyResponseMessage() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyResponseMessage_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- String result = fixture.getPolicyResponseMessage();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the PolicyResponseStatus getPolicyResponseStatus() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyResponseStatus_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- PolicyResponseStatus result = fixture.getPolicyResponseStatus();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("action_advised", result.toString());
- assertEquals("ACTION_ADVISED", result.name());
- assertEquals(1, result.ordinal());
- }
-
- /**
- * Run the String getPolicyVersion() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyVersion_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- String result = fixture.getPolicyVersion();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the Map<String, String> getRequestAttributes() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetRequestAttributes_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getRequestAttributes();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the Map<String, String> getResponseAttributes() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetResponseAttributes_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- Map<String, String> result = fixture.getResponseAttributes();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the PolicyType getType() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetType_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- PolicyType result = fixture.getType();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("json", result.toString());
- assertEquals("JSON", result.name());
- assertEquals(1, result.ordinal());
- }
-
- /**
- * Run the void setActionAdvised(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetActionAdvised_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- Map<String, String> actionAdvised = new Hashtable<String, String>();
-
- fixture.setActionAdvised(actionAdvised);
-
- // add additional test code here
- }
-
- /**
- * Run the void setActionTaken(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetActionTaken_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- Map<String, String> actionTaken = new Hashtable<String, String>();
-
- fixture.setActionTaken(actionTaken);
-
- // add additional test code here
- }
-
- /**
- * Run the void setConfigStatus(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetConfigStatus_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- String configStatus = "";
-
- fixture.setConfigStatus(configStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the void setDocument(Document) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetDocument_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- Document document = null;
-
- fixture.setDocument(document);
-
- // add additional test code here
- }
-
- /**
- * Run the void setJsonObject(JsonObject) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetJsonObject_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- JsonObject jsonObject = null;
-
- fixture.setJsonObject(jsonObject);
-
- // add additional test code here
- }
-
- /**
- * Run the void setMatchingConditions(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetMatchingConditions_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- Map<String, String> matchingConditions = new Hashtable<String, String>();
-
- fixture.setMatchingConditions(matchingConditions);
-
- // add additional test code here
- }
-
- /**
- * Run the void setOther(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetOther_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- String other = "";
-
- fixture.setOther(other);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyConfigStatus(PolicyConfigStatus) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyConfigStatus_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
-
- fixture.setPolicyConfigStatus(policyConfigStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyConfigStatus(String,PolicyConfigStatus) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyConfigStatus_2()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- String configStatus = "";
- PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
-
- fixture.setPolicyConfigStatus(configStatus, policyConfigStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyDecision(PolicyDecision) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyDecision_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- PolicyDecision policyDecision = PolicyDecision.DENY;
-
- fixture.setDecision(policyDecision);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyName_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- String policyName = "";
-
- fixture.setPolicyName(policyName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyResponseMessage(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyResponseMessage_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- String policyResponseMessage = "";
-
- fixture.setPolicyResponseMessage(policyResponseMessage);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyResponseStatus(PolicyResponseStatus) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyResponseStatus_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
-
- fixture.setPolicyResponseStatus(policyResponseStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyResponseStatus(String,PolicyResponseStatus) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyResponseStatus_2()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- String policyResponseMessage = "";
- PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
-
- fixture.setPolicyResponseStatus(policyResponseMessage, policyResponseStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyType(PolicyType) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyType_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- PolicyType policyType = PolicyType.JSON;
-
- fixture.setPolicyType(policyType);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyVersion(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyVersion_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- String policyVersion = "";
-
- fixture.setPolicyVersion(policyVersion);
-
- // add additional test code here
- }
-
- /**
- * Run the void setProperties(Properties) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetProperties_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- Properties properties = new Properties();
-
- fixture.setProperties(properties);
-
- // add additional test code here
- }
-
- /**
- * Run the void setRequestAttributes(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetRequestAttributes_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- Map<String, String> requestAttributes = new Hashtable<String, String>();
-
- fixture.setRequestAttributes(requestAttributes);
-
- // add additional test code here
- }
-
- /**
- * Run the void setResposneAttributes(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetResposneAttributes_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- Map<String, String> responseAttributes = new Hashtable<String, String>();
-
- fixture.setResposneAttributes(responseAttributes);
-
- // add additional test code here
- }
-
- /**
- * Run the void setStatus(String,PolicyResponseStatus,PolicyConfigStatus) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetStatus_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
- String message = "";
- PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
- PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
-
- fixture.setStatus(message, policyResponseStatus, policyConfigStatus);
-
- // add additional test code here
- }
-
- /**
- * Run the JsonObject toJSON() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testToJSON_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- JsonObject result = fixture.toJSON();
-
- // add additional test code here
- assertEquals(null, result);
- }
-
- /**
- * Run the String toOther() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testToOther_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- String result = fixture.toOther();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the Properties toProperties() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testToProperties_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- Properties result = fixture.toProperties();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the Document toXML() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testToXML_1()
- throws Exception {
- StdStatus fixture = new StdStatus();
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setPolicyName("");
- fixture.setPolicyType(PolicyType.JSON);
- fixture.setResposneAttributes(new Hashtable<String, String>());
- fixture.setMatchingConditions(new Hashtable<String, String>());
- fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED, PolicyConfigStatus.CONFIG_NOT_FOUND);
- fixture.setJsonObject((JsonObject) null);
- fixture.setDocument((Document) null);
- fixture.setProperties(new Properties());
- fixture.setRequestAttributes(new Hashtable<String, String>());
- fixture.setPolicyVersion("");
- fixture.setActionAdvised(new Hashtable<String, String>());
- fixture.setOther("");
- fixture.setDecision(PolicyDecision.DENY);
- fixture.setDetails("");
- fixture.setActionTaken(new Hashtable<String, String>());
-
- Document result = fixture.toXML();
-
- // add additional test code here
- assertEquals(null, result);
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(StdStatusTest.class);
- }
+ /**
+ * Run the Map<String, String> getActionAdvised() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetActionAdvised_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ Map<String, String> result = fixture.getActionAdvised();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the Map<String, String> getActionTaken() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetActionTaken_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ Map<String, String> result = fixture.getActionTaken();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the Map<String, String> getMatchingConditions() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetMatchingConditions_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ Map<String, String> result = fixture.getMatchingConditions();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the String getPolicyConfigMessage() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyConfigMessage_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ String result = fixture.getPolicyConfigMessage();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the PolicyConfigStatus getPolicyConfigStatus() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyConfigStatus_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ PolicyConfigStatus result = fixture.getPolicyConfigStatus();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("not_found", result.toString());
+ assertEquals("CONFIG_NOT_FOUND", result.name());
+ assertEquals(1, result.ordinal());
+ }
+
+ /**
+ * Run the PolicyDecision getPolicyDecision() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyDecision_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ PolicyDecision result = fixture.getDecision();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("deny", result.toString());
+ assertEquals("DENY", result.name());
+ assertEquals(1, result.ordinal());
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_2() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName((String) null);
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals(null, result);
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_3() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getPolicyResponseMessage() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyResponseMessage_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ String result = fixture.getPolicyResponseMessage();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the PolicyResponseStatus getPolicyResponseStatus() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyResponseStatus_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ PolicyResponseStatus result = fixture.getPolicyResponseStatus();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("action_advised", result.toString());
+ assertEquals("ACTION_ADVISED", result.name());
+ assertEquals(1, result.ordinal());
+ }
+
+ /**
+ * Run the String getPolicyVersion() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyVersion_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ String result = fixture.getPolicyVersion();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the Map<String, String> getRequestAttributes() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetRequestAttributes_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ Map<String, String> result = fixture.getRequestAttributes();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the Map<String, String> getResponseAttributes() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetResponseAttributes_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ Map<String, String> result = fixture.getResponseAttributes();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the PolicyType getType() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetType_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ PolicyType result = fixture.getType();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("json", result.toString());
+ assertEquals("JSON", result.name());
+ assertEquals(1, result.ordinal());
+ }
+
+ /**
+ * Run the void setActionAdvised(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetActionAdvised_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ Map<String, String> actionAdvised = new Hashtable<String, String>();
+
+ fixture.setActionAdvised(actionAdvised);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setActionTaken(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetActionTaken_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ Map<String, String> actionTaken = new Hashtable<String, String>();
+
+ fixture.setActionTaken(actionTaken);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setConfigStatus(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetConfigStatus_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ String configStatus = "";
+
+ fixture.setConfigStatus(configStatus);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setDocument(Document) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetDocument_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ Document document = null;
+
+ fixture.setDocument(document);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setJsonObject(JsonObject) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetJsonObject_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ JsonObject jsonObject = null;
+
+ fixture.setJsonObject(jsonObject);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setMatchingConditions(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetMatchingConditions_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ Map<String, String> matchingConditions = new Hashtable<String, String>();
+
+ fixture.setMatchingConditions(matchingConditions);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setOther(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetOther_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ String other = "";
+
+ fixture.setOther(other);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyConfigStatus(PolicyConfigStatus) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyConfigStatus_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
+
+ fixture.setPolicyConfigStatus(policyConfigStatus);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyConfigStatus(String,PolicyConfigStatus) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyConfigStatus_2() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ String configStatus = "";
+ PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
+
+ fixture.setPolicyConfigStatus(configStatus, policyConfigStatus);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyDecision(PolicyDecision) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyDecision_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ PolicyDecision policyDecision = PolicyDecision.DENY;
+
+ fixture.setDecision(policyDecision);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyName(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyName_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ String policyName = "";
+
+ fixture.setPolicyName(policyName);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyResponseMessage(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyResponseMessage_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ String policyResponseMessage = "";
+
+ fixture.setPolicyResponseMessage(policyResponseMessage);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyResponseStatus(PolicyResponseStatus) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyResponseStatus_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
+
+ fixture.setPolicyResponseStatus(policyResponseStatus);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyResponseStatus(String,PolicyResponseStatus) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyResponseStatus_2() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ String policyResponseMessage = "";
+ PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
+
+ fixture.setPolicyResponseStatus(policyResponseMessage, policyResponseStatus);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyType(PolicyType) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyType_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ PolicyType policyType = PolicyType.JSON;
+
+ fixture.setPolicyType(policyType);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyVersion(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyVersion_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ String policyVersion = "";
+
+ fixture.setPolicyVersion(policyVersion);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setProperties(Properties) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetProperties_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ Properties properties = new Properties();
+
+ fixture.setProperties(properties);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setRequestAttributes(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetRequestAttributes_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ Map<String, String> requestAttributes = new Hashtable<String, String>();
+
+ fixture.setRequestAttributes(requestAttributes);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setResposneAttributes(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetResposneAttributes_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ Map<String, String> responseAttributes = new Hashtable<String, String>();
+
+ fixture.setResposneAttributes(responseAttributes);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setStatus(String,PolicyResponseStatus,PolicyConfigStatus) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetStatus_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+ String message = "";
+ PolicyResponseStatus policyResponseStatus = PolicyResponseStatus.ACTION_ADVISED;
+ PolicyConfigStatus policyConfigStatus = PolicyConfigStatus.CONFIG_NOT_FOUND;
+
+ fixture.setStatus(message, policyResponseStatus, policyConfigStatus);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the JsonObject toJSON() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testToJSON_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ JsonObject result = fixture.toJSON();
+
+ // add additional test code here
+ assertEquals(null, result);
+ }
+
+ /**
+ * Run the String toOther() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testToOther_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ String result = fixture.toOther();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the Properties toProperties() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testToProperties_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ Properties result = fixture.toProperties();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the Document toXML() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testToXML_1() throws Exception {
+ StdStatus fixture = new StdStatus();
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setPolicyName("");
+ fixture.setPolicyType(PolicyType.JSON);
+ fixture.setResposneAttributes(new Hashtable<String, String>());
+ fixture.setMatchingConditions(new Hashtable<String, String>());
+ fixture.setStatus("", PolicyResponseStatus.ACTION_ADVISED,
+ PolicyConfigStatus.CONFIG_NOT_FOUND);
+ fixture.setJsonObject((JsonObject) null);
+ fixture.setDocument((Document) null);
+ fixture.setProperties(new Properties());
+ fixture.setRequestAttributes(new Hashtable<String, String>());
+ fixture.setPolicyVersion("");
+ fixture.setActionAdvised(new Hashtable<String, String>());
+ fixture.setOther("");
+ fixture.setDecision(PolicyDecision.DENY);
+ fixture.setDetails("");
+ fixture.setActionTaken(new Hashtable<String, String>());
+
+ Document result = fixture.toXML();
+
+ // add additional test code here
+ assertEquals(null, result);
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(StdStatusTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/std/utils/PolicyConstantsTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/std/utils/PolicyConstantsTest.java
index d2f6002cc..8af73a529 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/std/utils/PolicyConstantsTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/std/utils/PolicyConstantsTest.java
@@ -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.
@@ -27,19 +29,23 @@ import java.lang.reflect.Modifier;
import org.junit.Test;
public class PolicyConstantsTest {
- @Test
- public void testConstructorIsPrivate1() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
- Constructor<PolicyCommonConfigConstants> constructor = PolicyCommonConfigConstants.class.getDeclaredConstructor();
- assertTrue(Modifier.isPrivate(constructor.getModifiers()));
- constructor.setAccessible(true);
- constructor.newInstance();
- }
+ @Test
+ public void testConstructorIsPrivate1() throws NoSuchMethodException, IllegalAccessException,
+ InvocationTargetException, InstantiationException {
+ Constructor<PolicyCommonConfigConstants> constructor =
+ PolicyCommonConfigConstants.class.getDeclaredConstructor();
+ assertTrue(Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
- @Test
- public void testConstructorIsPrivate2() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
- Constructor<PolicyConfigConstants> constructor = PolicyConfigConstants.class.getDeclaredConstructor();
- assertTrue(Modifier.isPrivate(constructor.getModifiers()));
- constructor.setAccessible(true);
- constructor.newInstance();
- }
+ @Test
+ public void testConstructorIsPrivate2() throws NoSuchMethodException, IllegalAccessException,
+ InvocationTargetException, InstantiationException {
+ Constructor<PolicyConfigConstants> constructor =
+ PolicyConfigConstants.class.getDeclaredConstructor();
+ assertTrue(Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/APIPolicyConfigResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/APIPolicyConfigResponseTest.java
index 6e5959d08..a3f690838 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/APIPolicyConfigResponseTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/APIPolicyConfigResponseTest.java
@@ -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.
@@ -27,49 +29,49 @@ import org.onap.policy.api.PolicyConfigStatus;
import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.api.PolicyType;
import org.onap.policy.models.APIPolicyConfigResponse;
-import junit.framework.TestCase;
+import junit.framework.TestCase;
public class APIPolicyConfigResponseTest extends TestCase {
- private final String testKey = "testKey";
- private final String testValue = "testValue";
- private final PolicyType testType = PolicyType.JSON;
- private final PolicyConfigStatus testStatus = PolicyConfigStatus.CONFIG_RETRIEVED;
- private final PolicyConfigType testConfigType = PolicyConfigType.BRMS_PARAM;
-
- @Test
- public final void testSetAndGet() {
- APIPolicyConfigResponse response = new APIPolicyConfigResponse();
- response.setConfig(testValue);
- assertEquals(response.getConfig(), testValue);
-
- response.setType(testType);
- assertEquals(response.getType(), testType);
-
- response.setPolicyConfigStatus(testStatus);
- assertEquals(response.getPolicyConfigStatus(), testStatus);
-
- response.setPolicyConfigMessage(testValue);
- assertEquals(response.getPolicyConfigMessage(), testValue);
-
- response.setPolicyName(testValue);
- assertEquals(response.getPolicyName(), testValue);
-
- response.setPolicyType(testConfigType);
- assertEquals(response.getPolicyType(), testConfigType);
-
- response.setPolicyVersion(testValue);
- assertEquals(response.getPolicyVersion(), testValue);
-
- Map<String, String> testMap = new HashMap<String, String>();
- testMap.put(testKey, testValue);
-
- response.setMatchingConditions(testMap);
- assertEquals(response.getMatchingConditions(), testMap);
-
- response.setProperty(testMap);
- assertEquals(response.getProperty(), testMap);
-
- response.setResponseAttributes(testMap);
- assertEquals(response.getResponseAttributes(), testMap);
- }
+ private final String testKey = "testKey";
+ private final String testValue = "testValue";
+ private final PolicyType testType = PolicyType.JSON;
+ private final PolicyConfigStatus testStatus = PolicyConfigStatus.CONFIG_RETRIEVED;
+ private final PolicyConfigType testConfigType = PolicyConfigType.BRMS_PARAM;
+
+ @Test
+ public final void testSetAndGet() {
+ APIPolicyConfigResponse response = new APIPolicyConfigResponse();
+ response.setConfig(testValue);
+ assertEquals(response.getConfig(), testValue);
+
+ response.setType(testType);
+ assertEquals(response.getType(), testType);
+
+ response.setPolicyConfigStatus(testStatus);
+ assertEquals(response.getPolicyConfigStatus(), testStatus);
+
+ response.setPolicyConfigMessage(testValue);
+ assertEquals(response.getPolicyConfigMessage(), testValue);
+
+ response.setPolicyName(testValue);
+ assertEquals(response.getPolicyName(), testValue);
+
+ response.setPolicyType(testConfigType);
+ assertEquals(response.getPolicyType(), testConfigType);
+
+ response.setPolicyVersion(testValue);
+ assertEquals(response.getPolicyVersion(), testValue);
+
+ Map<String, String> testMap = new HashMap<String, String>();
+ testMap.put(testKey, testValue);
+
+ response.setMatchingConditions(testMap);
+ assertEquals(response.getMatchingConditions(), testMap);
+
+ response.setProperty(testMap);
+ assertEquals(response.getProperty(), testMap);
+
+ response.setResponseAttributes(testMap);
+ assertEquals(response.getResponseAttributes(), testMap);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ActionPolicyApiTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ActionPolicyApiTest.java
index ae971b405..e5d3a4a11 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ActionPolicyApiTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ActionPolicyApiTest.java
@@ -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.
@@ -23,7 +25,6 @@ package org.onap.policy.test;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -36,204 +37,205 @@ import org.onap.policy.api.PolicyParameters;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.std.StdPolicyChangeResponse;
-
-import junit.framework.TestCase;
+import junit.framework.TestCase;
public class ActionPolicyApiTest extends TestCase {
-
- private static final Logger logger = FlexLogger.getLogger(ActionPolicyApiTest.class);
-
- private PolicyEngine policyEngine = null;
- private PolicyEngine mockPolicyEngine = null;
-
- PolicyChangeResponse result = null;
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
- PolicyParameters policyParameters = new PolicyParameters();
-
- @Before
- public void setUp() throws Exception {
- try {
- policyEngine = new PolicyEngine("Test/config_pass.properties");
- } catch (PolicyEngineException e) {
- logger.error(e.getMessage());
- fail("PolicyEngine Instantiation Error" + e);
- }
- logger.info("Loaded.. PolicyEngine");
-
- mockPolicyEngine = Mockito.mock(PolicyEngine.class);
-
- policyParameters.setPolicyClass(PolicyClass.Action); //required
- policyParameters.setPolicyName("test.junitTest"); //required
- policyParameters.setPolicyDescription("testing"); //optional
- //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI
-
- //Set the Component Attributes... These are Optional
- Map<String, String> configAttributes = new HashMap<String, String>();
+
+ private static final Logger logger = FlexLogger.getLogger(ActionPolicyApiTest.class);
+
+ private PolicyEngine policyEngine = null;
+ private PolicyEngine mockPolicyEngine = null;
+
+ PolicyChangeResponse result = null;
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+ PolicyParameters policyParameters = new PolicyParameters();
+
+ @Before
+ public void setUp() throws Exception {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+
+ mockPolicyEngine = Mockito.mock(PolicyEngine.class);
+
+ policyParameters.setPolicyClass(PolicyClass.Action); // required
+ policyParameters.setPolicyName("test.junitTest"); // required
+ policyParameters.setPolicyDescription("testing"); // optional
+ // policyParameters.setPolicyScope("test"); //Directory will be created where the Policies
+ // are saved... this displays a a subscope on the GUI
+
+ // Set the Component Attributes... These are Optional
+ Map<String, String> configAttributes = new HashMap<String, String>();
configAttributes.put("test", "testing");
-
- Map<AttributeType, Map<String,String>> attributes = new HashMap<AttributeType, Map<String,String>>();
+
+ Map<AttributeType, Map<String, String>> attributes =
+ new HashMap<AttributeType, Map<String, String>>();
attributes.put(AttributeType.MATCHING, configAttributes);
policyParameters.setAttributes(attributes);
-
+
policyParameters.setActionPerformer("PEP");
policyParameters.setActionAttribute("testing");
policyParameters.setRequestID(UUID.randomUUID());
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- @Test
- public final void testCreatePolicy() {
- response.setResponseMessage("success");
- PolicyChangeResponse result = null;
- try {
-
- Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.createPolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- @Test
- public final void testUpdatePolicy() {
- response.setResponseMessage("success");
- PolicyChangeResponse result = null;
- try {
-
- Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.updatePolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
-
- }
-
- @Test
- public final void testCreatePolicyNullPolicyName() {
- response.setResponseMessage("PE300 - Data Issue: No Policy Name given.");
- policyParameters.setPolicyName(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullPolicyScope() {
- response.setResponseMessage("PE300 - Data Issue: No Policy Scope given.");
- policyParameters.setPolicyName("test");
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullActionAttributes() {
- response.setResponseMessage("PE300 - Data Issue: No Action Attribute given.");
- policyParameters.setActionAttribute(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullActionPerformer() {
- response.setResponseMessage("PE300 - Data Issue: No Action Performer given.");
- policyParameters.setActionPerformer(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyInvalidActionPerformer() {
- response.setResponseMessage("PE300 - Data Issue: Invalid Action Performer given.");
- policyParameters.setActionPerformer("testfail");
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyName() {
- response.setResponseMessage("PE300 - Data Issue: No Policy Name given.");
- policyParameters.setPolicyName(null);
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyScope() {
- response.setResponseMessage("PE300 - Data Issue: No Policy Scope given.");
- policyParameters.setPolicyName("test");
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullActionAttributes() {
- response.setResponseMessage("PE300 - Data Issue: No Action Attribute given.");
- policyParameters.setActionAttribute(null);
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullActionPerformer() {
- response.setResponseMessage("PE300 - Data Issue: No Action Performer given.");
- policyParameters.setActionPerformer(null);
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyInvalidActionPerformer() {
- response.setResponseMessage("PE300 - Data Issue: Invalid Action Performer given.");
- policyParameters.setActionPerformer("testfail");
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ @Test
+ public final void testCreatePolicy() {
+ response.setResponseMessage("success");
+ PolicyChangeResponse result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.createPolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ @Test
+ public final void testUpdatePolicy() {
+ response.setResponseMessage("success");
+ PolicyChangeResponse result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.updatePolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyName() {
+ response.setResponseMessage("PE300 - Data Issue: No Policy Name given.");
+ policyParameters.setPolicyName(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyScope() {
+ response.setResponseMessage("PE300 - Data Issue: No Policy Scope given.");
+ policyParameters.setPolicyName("test");
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullActionAttributes() {
+ response.setResponseMessage("PE300 - Data Issue: No Action Attribute given.");
+ policyParameters.setActionAttribute(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullActionPerformer() {
+ response.setResponseMessage("PE300 - Data Issue: No Action Performer given.");
+ policyParameters.setActionPerformer(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyInvalidActionPerformer() {
+ response.setResponseMessage("PE300 - Data Issue: Invalid Action Performer given.");
+ policyParameters.setActionPerformer("testfail");
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyName() {
+ response.setResponseMessage("PE300 - Data Issue: No Policy Name given.");
+ policyParameters.setPolicyName(null);
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyScope() {
+ response.setResponseMessage("PE300 - Data Issue: No Policy Scope given.");
+ policyParameters.setPolicyName("test");
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullActionAttributes() {
+ response.setResponseMessage("PE300 - Data Issue: No Action Attribute given.");
+ policyParameters.setActionAttribute(null);
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullActionPerformer() {
+ response.setResponseMessage("PE300 - Data Issue: No Action Performer given.");
+ policyParameters.setActionPerformer(null);
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyInvalidActionPerformer() {
+ response.setResponseMessage("PE300 - Data Issue: Invalid Action Performer given.");
+ policyParameters.setActionPerformer("testfail");
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/AttributeTypeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/AttributeTypeTest.java
index d817deff3..17d2f37b7 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/AttributeTypeTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/AttributeTypeTest.java
@@ -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.
@@ -22,69 +24,63 @@ package org.onap.policy.test;
import org.junit.*;
import org.onap.policy.api.AttributeType;
-
import static org.junit.Assert.*;
/**
- * The class <code>AttributeTypeTest</code> contains tests for the class <code>{@link AttributeType}</code>.
+ * The class <code>AttributeTypeTest</code> contains tests for the class
+ * <code>{@link AttributeType}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class AttributeTypeTest {
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- AttributeType fixture = AttributeType.MATCHING;
+ /**
+ * Run the String toString() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testToString_1() throws Exception {
+ AttributeType fixture = AttributeType.MATCHING;
+
+ String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals("matching", result);
- String result = fixture.toString();
+ AttributeType type = AttributeType.create("dictionary");
+ assertEquals(AttributeType.DICTIONARY, type);
- // add additional test code here
- assertEquals("matching", result);
-
- AttributeType type = AttributeType.create("dictionary");
- assertEquals(AttributeType.DICTIONARY, type);
-
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testException() {
- AttributeType.create("foobar");
- }
+ }
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void testException() {
+ AttributeType.create("foobar");
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigBasePolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigBasePolicyTest.java
index b5fb75c42..0caa9f3d4 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigBasePolicyTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigBasePolicyTest.java
@@ -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.
@@ -23,7 +25,6 @@ package org.onap.policy.test;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.policy.api.AttributeType;
@@ -36,290 +37,296 @@ import org.onap.policy.api.PolicyType;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.std.StdPolicyChangeResponse;
-
-import junit.framework.TestCase;
+import junit.framework.TestCase;
/**
* The class <code>ConfigBasePolicyTest</code> contains tests for the class
* {@link <code>PolicyEngine</code>}
*
- * @pattern JUnit Test Case
- * *
+ * @pattern JUnit Test Case *
*/
public class ConfigBasePolicyTest extends TestCase {
- private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class);
-
- private PolicyEngine policyEngine = null;
- private PolicyEngine mockPolicyEngine = null;
-
- PolicyChangeResponse result = null;
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
- PolicyParameters policyParameters = new PolicyParameters();
-
- /**
- * Perform pre-test initialization
- *
- * @throws Exception
- *
- * @see TestCase#setUp()
- */
- public void setUp() throws Exception {
- try {
- policyEngine = new PolicyEngine("Test/config_pass.properties");
- } catch (PolicyEngineException e) {
- logger.error(e.getMessage());
- fail("PolicyEngine Instantiation Error" + e);
- }
- logger.info("Loaded.. PolicyEngine");
-
- mockPolicyEngine = Mockito.mock(PolicyEngine.class);
-
- policyParameters.setPolicyConfigType(PolicyConfigType.Base); //required
- policyParameters.setPolicyName("test.junitTest"); //required
+ private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class);
+
+ private PolicyEngine policyEngine = null;
+ private PolicyEngine mockPolicyEngine = null;
+
+ PolicyChangeResponse result = null;
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+ PolicyParameters policyParameters = new PolicyParameters();
+
+ /**
+ * Perform pre-test initialization
+ *
+ * @throws Exception
+ *
+ * @see TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+
+ mockPolicyEngine = Mockito.mock(PolicyEngine.class);
+
+ policyParameters.setPolicyConfigType(PolicyConfigType.Base); // required
+ policyParameters.setPolicyName("test.junitTest"); // required
policyParameters.setOnapName("test");
policyParameters.setConfigName("testBase");
policyParameters.setConfigBodyType(PolicyType.OTHER);
policyParameters.setConfigBody("testing");
- policyParameters.setPolicyDescription("testing"); //optional
- //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI
-
- //Set the Component Attributes... These are Optional
- Map<String, String> configAttributes = new HashMap<String, String>();
+ policyParameters.setPolicyDescription("testing"); // optional
+ // policyParameters.setPolicyScope("test"); //Directory will be created where the Policies
+ // are saved... this displays a a subscope on the GUI
+
+ // Set the Component Attributes... These are Optional
+ Map<String, String> configAttributes = new HashMap<String, String>();
configAttributes.put("test", "testing");
-
- Map<AttributeType, Map<String,String>> attributes = new HashMap<AttributeType, Map<String,String>>();
+
+ Map<AttributeType, Map<String, String>> attributes =
+ new HashMap<AttributeType, Map<String, String>>();
attributes.put(AttributeType.MATCHING, configAttributes);
policyParameters.setAttributes(attributes);
policyParameters.setRequestID(UUID.randomUUID());
- }
-
- /**
- * Perform post-test clean up
- *
- * @throws Exception
- *
- * @see TestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- // Add additional tear down code here
- }
-
- /**
- * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test
- */
- public void testCreatePolicy() {
- response.setResponseMessage("success");
- PolicyChangeResponse result = null;
- try {
-
- Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.createPolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the String createConfigPolicy() method test
- */
- @SuppressWarnings("deprecation")
- @Test
- public void testCreateConfigPolicy() {
- String response = "success";
- String result = null;
- try {
-
- Mockito.when(mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response);
- result = mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test
- */
- public void testUpdatePolicy() {
- response.setResponseMessage("success");
- PolicyChangeResponse result = null;
- try {
-
- Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.updatePolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the String updateConfigPolicy() method test
- */
- @SuppressWarnings("deprecation")
- @Test
- public void testUpdateConfigPolicy() {
- String response = "success";
- String result = null;
- try {
-
- Mockito.when(mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response);
- result = mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- @Test
- public final void testCreatePolicyNullPolicyName() {
- response.setResponseMessage("PE300 - Data Issue: No Policy Name given.");
- policyParameters.setPolicyName(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullPolicyScope() {
- response.setResponseMessage("PE300 - Data Issue: No Policy Scope given.");
- policyParameters.setPolicyName("test");
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullOnapName() {
- response.setResponseMessage("PE300 - Data Issue: No ONAP Name given.");
- policyParameters.setOnapName(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullPolicyConfigName() {
- response.setResponseMessage("PE300 - Data Issue: No Config Name given.");
- policyParameters.setConfigName(null);;
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullPolicyConfigBodyType() {
- response.setResponseMessage("PE300 - Data Issue: No Config Body Type given.");
- policyParameters.setConfigBodyType(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullPolicyConfigBody() {
- response.setResponseMessage("PE300 - Data Issue: No Config Body given.");
- policyParameters.setConfigBody(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyName() {
- response.setResponseMessage("PE300 - Data Issue: No Policy Name given.");
- policyParameters.setPolicyName(null);
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyScope() {
- response.setResponseMessage("PE300 - Data Issue: No Policy Scope given.");
- policyParameters.setPolicyName("test");
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullOnapName() {
- response.setResponseMessage("PE300 - Data Issue: No ONAP Name given.");
- policyParameters.setOnapName(null);
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyConfigName() {
- response.setResponseMessage("PE300 - Data Issue: No Config Name given.");
- policyParameters.setConfigName(null);;
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyConfigBodyType() {
- response.setResponseMessage("PE300 - Data Issue: No Config Body Type given.");
- policyParameters.setConfigBodyType(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyConfigBody() {
- response.setResponseMessage("PE300 - Data Issue: No Config Body given.");
- policyParameters.setConfigBody(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- //assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-} \ No newline at end of file
+ }
+
+ /**
+ * Perform post-test clean up
+ *
+ * @throws Exception
+ *
+ * @see TestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ // Add additional tear down code here
+ }
+
+ /**
+ * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test
+ */
+ public void testCreatePolicy() {
+ response.setResponseMessage("success");
+ PolicyChangeResponse result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.createPolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the String createConfigPolicy() method test
+ */
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testCreateConfigPolicy() {
+ String response = "success";
+ String result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.createConfigPolicy("testPolicy", "test", "test",
+ "testConfig", null, "OTHER", "test", "test", null, null, null, null, null))
+ .thenReturn(response);
+ result = mockPolicyEngine.createConfigPolicy("testPolicy", "test", "test", "testConfig",
+ null, "OTHER", "test", "test", null, null, null, null, null);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test
+ */
+ public void testUpdatePolicy() {
+ response.setResponseMessage("success");
+ PolicyChangeResponse result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.updatePolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the String updateConfigPolicy() method test
+ */
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testUpdateConfigPolicy() {
+ String response = "success";
+ String result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.updateConfigPolicy("testPolicy", "test", "test",
+ "testConfig", null, "OTHER", "test", "test", null, null, null, null, null))
+ .thenReturn(response);
+ result = mockPolicyEngine.updateConfigPolicy("testPolicy", "test", "test", "testConfig",
+ null, "OTHER", "test", "test", null, null, null, null, null);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyName() {
+ response.setResponseMessage("PE300 - Data Issue: No Policy Name given.");
+ policyParameters.setPolicyName(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyScope() {
+ response.setResponseMessage("PE300 - Data Issue: No Policy Scope given.");
+ policyParameters.setPolicyName("test");
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullOnapName() {
+ response.setResponseMessage("PE300 - Data Issue: No ONAP Name given.");
+ policyParameters.setOnapName(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyConfigName() {
+ response.setResponseMessage("PE300 - Data Issue: No Config Name given.");
+ policyParameters.setConfigName(null);;
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyConfigBodyType() {
+ response.setResponseMessage("PE300 - Data Issue: No Config Body Type given.");
+ policyParameters.setConfigBodyType(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyConfigBody() {
+ response.setResponseMessage("PE300 - Data Issue: No Config Body given.");
+ policyParameters.setConfigBody(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyName() {
+ response.setResponseMessage("PE300 - Data Issue: No Policy Name given.");
+ policyParameters.setPolicyName(null);
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyScope() {
+ response.setResponseMessage("PE300 - Data Issue: No Policy Scope given.");
+ policyParameters.setPolicyName("test");
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullOnapName() {
+ response.setResponseMessage("PE300 - Data Issue: No ONAP Name given.");
+ policyParameters.setOnapName(null);
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyConfigName() {
+ response.setResponseMessage("PE300 - Data Issue: No Config Name given.");
+ policyParameters.setConfigName(null);;
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyConfigBodyType() {
+ response.setResponseMessage("PE300 - Data Issue: No Config Body Type given.");
+ policyParameters.setConfigBodyType(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyConfigBody() {
+ response.setResponseMessage("PE300 - Data Issue: No Config Body given.");
+ policyParameters.setConfigBody(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ // assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigFirewallPolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigFirewallPolicyTest.java
index c50b3de47..bb12adc32 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigFirewallPolicyTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigFirewallPolicyTest.java
@@ -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.
@@ -22,11 +24,9 @@ package org.onap.policy.test;
import java.io.StringReader;
import java.util.UUID;
-
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
-
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.policy.api.PolicyChangeResponse;
@@ -37,218 +37,240 @@ import org.onap.policy.api.PolicyParameters;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.std.StdPolicyChangeResponse;
-
-import junit.framework.TestCase;
+import junit.framework.TestCase;
public class ConfigFirewallPolicyTest extends TestCase {
- private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class);
-
- private PolicyEngine policyEngine = null;
- private PolicyEngine mockPolicyEngine = null;
-
- PolicyChangeResponse result = null;
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
- PolicyParameters policyParameters = new PolicyParameters();
- String json = null;
-
- /**
- * Perform pre-test initialization
- *
- * @throws Exception
- *
- * @see TestCase#setUp()
- */
- public void setUp() throws Exception {
- try {
- policyEngine = new PolicyEngine("Test/config_pass.properties");
- } catch (PolicyEngineException e) {
- logger.error(e.getMessage());
- fail("PolicyEngine Instantiation Error" + e);
- }
- logger.info("Loaded.. PolicyEngine");
-
- mockPolicyEngine = Mockito.mock(PolicyEngine.class);
-
- policyParameters.setPolicyConfigType(PolicyConfigType.Firewall); //required
- policyParameters.setPolicyName("test.junitTest"); //required
-
- json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\",\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\",\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\",\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\",\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\",\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,\"log\":true}]}";
-
+ private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class);
+
+ private PolicyEngine policyEngine = null;
+ private PolicyEngine mockPolicyEngine = null;
+
+ PolicyChangeResponse result = null;
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+ PolicyParameters policyParameters = new PolicyParameters();
+ String json = null;
+
+ /**
+ * Perform pre-test initialization
+ *
+ * @throws Exception
+ *
+ * @see TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+
+ mockPolicyEngine = Mockito.mock(PolicyEngine.class);
+
+ policyParameters.setPolicyConfigType(PolicyConfigType.Firewall); // required
+ policyParameters.setPolicyName("test.junitTest"); // required
+
+ json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":"
+ + "{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":"
+ + "[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\","
+ + "\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\","
+ + "\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\",\"appProtocol\":null,"
+ + "\"ports\":\"514\"},{\"name\":\"SList\",\"description\":\"Service List\",\"type\":\"SERVICE\","
+ + "\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":"
+ + "[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"SUBNET\","
+ + "\"value\":\"10.11.12.13/14\"},{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},"
+ + "{\"name\":\"PL_CCE3\",\"description\":\"CCE Routers\",\"members\":"
+ + "[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":"
+ + "[{\"position\":\"1\",\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],"
+ + "\"toZones\":[\"Untrusted\"],\"negateSource\":false,\"negateDestination\":false,"
+ + "\"sourceList\":[{\"type\":\"REFERENCE\",\"value\":\"PL_CCE3\"},"
+ + "{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"destinationList\":"
+ + "[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"sourceServices\":[],"
+ + "\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],"
+ + "\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,\"log\":true}]}";
+
policyParameters.setConfigBody(buildJSON(json).toString());
-
- //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI
+
+ // policyParameters.setPolicyScope("test"); //Directory will be created where the Policies
+ // are saved... this displays a a subscope on the GUI
policyParameters.setRequestID(UUID.randomUUID());
- }
+ }
private static JsonObject buildJSON(String jsonString) {
JsonObject json = null;;
if (jsonString != null) {
StringReader in = null;
-
+
in = new StringReader(jsonString);
-
+
JsonReader jsonReader = Json.createReader(in);
- json = jsonReader.readObject();
- }
-
+ json = jsonReader.readObject();
+ }
+
return json;
}
- /**
- * Perform post-test clean up
- *
- * @throws Exception
- *
- * @see TestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- // Add additional tear down code here
- }
-
- /**
- * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test
- */
- public void testCreatePolicy() {
- response.setResponseMessage("success");
- PolicyChangeResponse result = null;
- try {
-
- Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.createPolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the String createConfigFirewallPolicy() method test
- */
- @SuppressWarnings("deprecation")
- @Test
- public void testCreateConfigFirewallPolicy() {
- String response = "success";
- String result = null;
- JsonObject jsonObj = buildJSON(json);
- try {
-
- Mockito.when(mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response);
- result = mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test
- */
- public void testUpdatePolicy() {
- response.setResponseMessage("success");
- PolicyChangeResponse result = null;
- try {
-
- Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.updatePolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the String updateConfigFirewallPolicy() method test
- */
- @SuppressWarnings("deprecation")
- @Test
- public void testUpdateConfigFirewallPolicy() {
- String response = "success";
- String result = null;
- JsonObject jsonObj = buildJSON(json);
- try {
-
- Mockito.when(mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response);
- result = mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- @Test
- public final void testCreatePolicyNullPolicyName() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setPolicyName(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullPolicyScope() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setPolicyName("test");
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullPolicyConfigBody() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setConfigBody(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyName() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setPolicyName(null);
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyScope() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setPolicyName("test");
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyConfigBody() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setConfigBody(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
+
+ /**
+ * Perform post-test clean up
+ *
+ * @throws Exception
+ *
+ * @see TestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ // Add additional tear down code here
+ }
+
+ /**
+ * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test
+ */
+ public void testCreatePolicy() {
+ response.setResponseMessage("success");
+ PolicyChangeResponse result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.createPolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the String createConfigFirewallPolicy() method test
+ */
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testCreateConfigFirewallPolicy() {
+ String response = "success";
+ String result = null;
+ JsonObject jsonObj = buildJSON(json);
+ try {
+
+ Mockito.when(mockPolicyEngine.createConfigFirewallPolicy("testPolicy", jsonObj, "test",
+ null, null, null, null, null)).thenReturn(response);
+ result = mockPolicyEngine.createConfigFirewallPolicy("testPolicy", jsonObj, "test",
+ null, null, null, null, null);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test
+ */
+ public void testUpdatePolicy() {
+ response.setResponseMessage("success");
+ PolicyChangeResponse result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.updatePolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the String updateConfigFirewallPolicy() method test
+ */
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testUpdateConfigFirewallPolicy() {
+ String response = "success";
+ String result = null;
+ JsonObject jsonObj = buildJSON(json);
+ try {
+
+ Mockito.when(mockPolicyEngine.updateConfigFirewallPolicy("testPolicy", jsonObj, "test",
+ null, null, null, null, null)).thenReturn(response);
+ result = mockPolicyEngine.updateConfigFirewallPolicy("testPolicy", jsonObj, "test",
+ null, null, null, null, null);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyName() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setPolicyName(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyScope() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setPolicyName("test");
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyConfigBody() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setConfigBody(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyName() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setPolicyName(null);
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyScope() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setPolicyName("test");
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyConfigBody() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setConfigBody(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigRequestParametersTest.java
index 91025f5c0..993796290 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigRequestParametersTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ConfigRequestParametersTest.java
@@ -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.
@@ -23,340 +25,338 @@ package org.onap.policy.test;
import java.util.Hashtable;
import java.util.Map;
import java.util.UUID;
-
import org.junit.*;
import org.onap.policy.api.ConfigRequestParameters;
-
import static org.junit.Assert.*;
/**
- * The class <code>ConfigRequestParametersTest</code> contains tests for the class <code>{@link ConfigRequestParameters}</code>.
+ * The class <code>ConfigRequestParametersTest</code> contains tests for the class
+ * <code>{@link ConfigRequestParameters}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class ConfigRequestParametersTest {
- /**
- * Run the ConfigRequestParameters() constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testConfigRequestParameters_1()
- throws Exception {
-
- ConfigRequestParameters result = new ConfigRequestParameters();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getPolicyName());
- assertEquals(null, result.getConfigName());
- assertEquals(null, result.getConfigAttributes());
- assertEquals(null, result.getRequestID());
- assertEquals(null, result.getOnapName());
- assertEquals(Boolean.FALSE, result.getUnique());
- }
-
- /**
- * Run the ConfigRequestParameters(String,String,String,Map<String,String>,Boolean,UUID) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testConfigRequestParameters_2()
- throws Exception {
- String policyName = "";
- String onapComponentName = "";
- String configName = "";
- Map<String, String> configAttributes = new Hashtable<String, String>();
- Boolean unique = new Boolean(true);
- UUID requestID = UUID.randomUUID();
-
- ConfigRequestParameters result = createConfigRequest(policyName, onapComponentName, configName, configAttributes, unique, requestID);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("", result.getPolicyName());
- assertEquals("", result.getConfigName());
- assertEquals("", result.getOnapName());
- assertEquals(Boolean.TRUE, result.getUnique());
- }
-
- /**
- * Run the Map<String, String> getConfigAttributes() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetConfigAttributes_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
-
- Map<String, String> result = fixture.getConfigAttributes();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the String getConfigName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetConfigName_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
-
- String result = fixture.getConfigName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getOnapName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetOnapName_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
-
- String result = fixture.getOnapName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the UUID getRequestID() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetRequestID_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.fromString("6b5aa070-90bc-46a6-9a59-e1fe526df7ae"));
-
- UUID result = fixture.getRequestID();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("6b5aa070-90bc-46a6-9a59-e1fe526df7ae", result.toString());
- assertEquals(4, result.version());
- assertEquals(2, result.variant());
- assertEquals(-7324574836520519762L, result.getLeastSignificantBits());
- assertEquals(7735671715287287462L, result.getMostSignificantBits());
- }
-
- /**
- * Run the Boolean getUnique() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetUnique_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
-
- Boolean result = fixture.getUnique();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("true", result.toString());
- assertEquals(true, result.booleanValue());
- }
-
- /**
- * Run the void makeUnique(Boolean) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testMakeUnique_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
- Boolean unique = new Boolean(true);
-
- fixture.makeUnique(unique);
-
- // add additional test code here
- }
-
- /**
- * Run the void setConfigAttributes(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetConfigAttributes_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
- Map<String, String> configAttributes = new Hashtable<String, String>();
-
- fixture.setConfigAttributes(configAttributes);
-
- // add additional test code here
- }
-
- /**
- * Run the void setConfigName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetConfigName_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
- String configName = "";
-
- fixture.setConfigName(configName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setOnapName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetOnapName_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
- String onapComponentName = "";
-
- fixture.setOnapName(onapComponentName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyName_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
- String policyName = "";
-
- fixture.setPolicyName(policyName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setRequestID(UUID) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetRequestID_1()
- throws Exception {
- ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
- UUID requestID = UUID.randomUUID();
-
- fixture.setRequestID(requestID);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(ConfigRequestParametersTest.class);
- }
-
- private ConfigRequestParameters createConfigRequest(String policyName, String onapComponentName, String configName, Map<String,String> configAttributes, Boolean unique, UUID requestID){
- ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
- configRequestParameters.setRequestID(requestID);
- configRequestParameters.setPolicyName(policyName);
- configRequestParameters.setOnapName(onapComponentName);
- configRequestParameters.setConfigName(configName);
- configRequestParameters.setConfigAttributes(configAttributes);
- configRequestParameters.makeUnique(unique);
- return configRequestParameters;
- }
+ /**
+ * Run the ConfigRequestParameters() constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testConfigRequestParameters_1() throws Exception {
+
+ ConfigRequestParameters result = new ConfigRequestParameters();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getPolicyName());
+ assertEquals(null, result.getConfigName());
+ assertEquals(null, result.getConfigAttributes());
+ assertEquals(null, result.getRequestID());
+ assertEquals(null, result.getOnapName());
+ assertEquals(Boolean.FALSE, result.getUnique());
+ }
+
+ /**
+ * Run the ConfigRequestParameters(String,String,String,Map<String,String>,Boolean,UUID)
+ * constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testConfigRequestParameters_2() throws Exception {
+ String policyName = "";
+ String onapComponentName = "";
+ String configName = "";
+ Map<String, String> configAttributes = new Hashtable<String, String>();
+ Boolean unique = new Boolean(true);
+ UUID requestID = UUID.randomUUID();
+
+ ConfigRequestParameters result = createConfigRequest(policyName, onapComponentName,
+ configName, configAttributes, unique, requestID);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("", result.getPolicyName());
+ assertEquals("", result.getConfigName());
+ assertEquals("", result.getOnapName());
+ assertEquals(Boolean.TRUE, result.getUnique());
+ }
+
+ /**
+ * Run the Map<String, String> getConfigAttributes() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetConfigAttributes_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+
+ Map<String, String> result = fixture.getConfigAttributes();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the String getConfigName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetConfigName_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+
+ String result = fixture.getConfigName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getOnapName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetOnapName_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+
+ String result = fixture.getOnapName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the UUID getRequestID() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetRequestID_1() throws Exception {
+ ConfigRequestParameters fixture =
+ createConfigRequest("", "", "", new Hashtable<String, String>(), new Boolean(true),
+ UUID.fromString("6b5aa070-90bc-46a6-9a59-e1fe526df7ae"));
+
+ UUID result = fixture.getRequestID();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("6b5aa070-90bc-46a6-9a59-e1fe526df7ae", result.toString());
+ assertEquals(4, result.version());
+ assertEquals(2, result.variant());
+ assertEquals(-7324574836520519762L, result.getLeastSignificantBits());
+ assertEquals(7735671715287287462L, result.getMostSignificantBits());
+ }
+
+ /**
+ * Run the Boolean getUnique() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetUnique_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+
+ Boolean result = fixture.getUnique();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("true", result.toString());
+ assertEquals(true, result.booleanValue());
+ }
+
+ /**
+ * Run the void makeUnique(Boolean) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testMakeUnique_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+ Boolean unique = new Boolean(true);
+
+ fixture.makeUnique(unique);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setConfigAttributes(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetConfigAttributes_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+ Map<String, String> configAttributes = new Hashtable<String, String>();
+
+ fixture.setConfigAttributes(configAttributes);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setConfigName(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetConfigName_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+ String configName = "";
+
+ fixture.setConfigName(configName);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setOnapName(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetOnapName_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+ String onapComponentName = "";
+
+ fixture.setOnapName(onapComponentName);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyName(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyName_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+ String policyName = "";
+
+ fixture.setPolicyName(policyName);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setRequestID(UUID) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetRequestID_1() throws Exception {
+ ConfigRequestParameters fixture = createConfigRequest("", "", "",
+ new Hashtable<String, String>(), new Boolean(true), UUID.randomUUID());
+ UUID requestID = UUID.randomUUID();
+
+ fixture.setRequestID(requestID);
+
+ // add additional test code here
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(ConfigRequestParametersTest.class);
+ }
+
+ private ConfigRequestParameters createConfigRequest(String policyName, String onapComponentName,
+ String configName, Map<String, String> configAttributes, Boolean unique,
+ UUID requestID) {
+ ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
+ configRequestParameters.setRequestID(requestID);
+ configRequestParameters.setPolicyName(policyName);
+ configRequestParameters.setOnapName(onapComponentName);
+ configRequestParameters.setConfigName(configName);
+ configRequestParameters.setConfigAttributes(configAttributes);
+ configRequestParameters.makeUnique(unique);
+ return configRequestParameters;
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionPolicyApiTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionPolicyApiTest.java
index 7c9eb3e10..c6dd0d7a7 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionPolicyApiTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionPolicyApiTest.java
@@ -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.
@@ -23,7 +25,6 @@ package org.onap.policy.test;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.policy.api.AttributeType;
@@ -35,185 +36,175 @@ import org.onap.policy.api.PolicyParameters;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.std.StdPolicyChangeResponse;
-
import junit.framework.TestCase;
/**
* The class <code>DecisionPolicyApiTest</code> contains tests for the class
* {@link <code>PolicyEngine</code>}
*
- * @pattern JUnit Test Case
- * *
+ * @pattern JUnit Test Case *
*/
public class DecisionPolicyApiTest extends TestCase {
- private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class);
-
- private PolicyEngine policyEngine = null;
- private PolicyEngine mockPolicyEngine = null;
-
- PolicyChangeResponse result = null;
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
- PolicyParameters policyParameters = new PolicyParameters();
-
- /**
- * Perform pre-test initialization
- *
- * @throws Exception
- *
- * @see TestCase#setUp()
- */
- public void setUp() throws Exception {
- try {
- policyEngine = new PolicyEngine("Test/config_pass.properties");
- } catch (PolicyEngineException e) {
- logger.error(e.getMessage());
- fail("PolicyEngine Instantiation Error" + e);
- }
- logger.info("Loaded.. PolicyEngine");
-
- mockPolicyEngine = Mockito.mock(PolicyEngine.class);
-
- policyParameters.setPolicyClass(PolicyClass.Decision); //required
- policyParameters.setPolicyName("test.junitTest"); //required
+ private static final Logger logger = FlexLogger.getLogger(DecisionPolicyApiTest.class);
+
+ private PolicyEngine policyEngine = null;
+ private PolicyEngine mockPolicyEngine = null;
+
+ PolicyChangeResponse result = null;
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+ PolicyParameters policyParameters = new PolicyParameters();
+
+ /**
+ * Perform pre-test initialization
+ *
+ * @throws Exception
+ *
+ * @see TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+
+ mockPolicyEngine = Mockito.mock(PolicyEngine.class);
+
+ policyParameters.setPolicyClass(PolicyClass.Decision); // required
+ policyParameters.setPolicyName("test.junitTest"); // required
policyParameters.setOnapName("test");
- policyParameters.setPolicyDescription("testing"); //optional
- //policyParameters.setPolicyScope("test"); //Directory will be created where the Policies are saved... this displays a a subscope on the GUI
-
- //Set the Component Attributes... These are Optional
- Map<String, String> configAttributes = new HashMap<String, String>();
+ policyParameters.setPolicyDescription("testing"); // optional
+
+ // Set the Component Attributes... These are Optional
+ Map<String, String> configAttributes = new HashMap<String, String>();
configAttributes.put("test", "testing");
-
- Map<AttributeType, Map<String,String>> attributes = new HashMap<AttributeType, Map<String,String>>();
+
+ Map<AttributeType, Map<String, String>> attributes =
+ new HashMap<AttributeType, Map<String, String>>();
attributes.put(AttributeType.MATCHING, configAttributes);
policyParameters.setAttributes(attributes);
- //Set the settings... These are Optional
-/* Map<String, String> settingsMap = new HashMap<String, String>();
- settingsMap.put("server", "5");
-
- Map<AttributeType, Map<String,String>> settings = new HashMap<AttributeType, Map<String, String>>();
- settings.put(AttributeType.SETTINGS, settingsMap);
- policyParameters.setSettings(settings);*/
-
policyParameters.setRequestID(UUID.randomUUID());
- }
-
- /**
- * Perform post-test clean up
- *
- * @throws Exception
- *
- * @see TestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- // Add additional tear down code here
- }
-
- /**
- * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test
- */
- public void testCreatePolicy() {
- response.setResponseMessage("success");
- PolicyChangeResponse result = null;
- try {
-
- Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.createPolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test
- */
- public void testUpdatePolicy() {
- response.setResponseMessage("success");
- PolicyChangeResponse result = null;
- try {
-
- Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.updatePolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- @Test
- public final void testCreatePolicyNullPolicyName() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setPolicyName(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullPolicyScope() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setPolicyName("test");
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testCreatePolicyNullOnapName() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setOnapName(null);
- try{
- result = policyEngine.createPolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyName() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setPolicyName(null);
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullPolicyScope() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setPolicyName("test");
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
-
- @Test
- public final void testUpdatePolicyNullOnapName() {
- response.setResponseMessage("PE500 - Process Flow Issue: :500:");
- policyParameters.setOnapName(null);
- try{
- result = policyEngine.updatePolicy(policyParameters);
- } catch (Exception e){
- logger.warn(e.getMessage());
- }
- assertEquals(result.getResponseMessage(), response.getResponseMessage());
- }
+ }
+
+ /**
+ * Perform post-test clean up
+ *
+ * @throws Exception
+ *
+ * @see TestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ // Add additional tear down code here
+ }
+
+ /**
+ * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test
+ */
+ public void testCreatePolicy() {
+ response.setResponseMessage("success");
+ PolicyChangeResponse result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.createPolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test
+ */
+ public void testUpdatePolicy() {
+ response.setResponseMessage("success");
+ PolicyChangeResponse result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.updatePolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyName() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setPolicyName(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullPolicyScope() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setPolicyName("test");
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testCreatePolicyNullOnapName() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setOnapName(null);
+ try {
+ result = policyEngine.createPolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyName() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setPolicyName(null);
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullPolicyScope() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setPolicyName("test");
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
+
+ @Test
+ public final void testUpdatePolicyNullOnapName() {
+ response.setResponseMessage("PE500 - Process Flow Issue: :500:");
+ policyParameters.setOnapName(null);
+ try {
+ result = policyEngine.updatePolicy(policyParameters);
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result.getResponseMessage(), response.getResponseMessage());
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionRequestParametersTest.java
index a29bb1314..41d376944 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionRequestParametersTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DecisionRequestParametersTest.java
@@ -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.
@@ -23,210 +25,205 @@ package org.onap.policy.test;
import java.util.Hashtable;
import java.util.Map;
import java.util.UUID;
-
import org.junit.*;
import org.onap.policy.api.DecisionRequestParameters;
-
import static org.junit.Assert.*;
/**
- * The class <code>DecisionRequestParametersTest</code> contains tests for the class <code>{@link DecisionRequestParameters}</code>.
+ * The class <code>DecisionRequestParametersTest</code> contains tests for the class
+ * <code>{@link DecisionRequestParameters}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class DecisionRequestParametersTest {
- /**
- * Run the DecisionRequestParameters() constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testDecisionRequestParameters_1()
- throws Exception {
-
- DecisionRequestParameters result = new DecisionRequestParameters();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getOnapName());
- assertEquals(null, result.getDecisionAttributes());
- assertEquals(null, result.getRequestID());
- }
-
- /**
- * Run the DecisionRequestParameters(String,Map<String,String>,UUID) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testDecisionRequestParameters_2()
- throws Exception {
- String onapComponentName = "";
- Map<String, String> decisionAttributes = new Hashtable<String, String>();
- UUID requestID = UUID.randomUUID();
-
- DecisionRequestParameters result = new DecisionRequestParameters(onapComponentName, decisionAttributes, requestID);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("", result.getOnapName());
- }
-
- /**
- * Run the Map<String, String> getDecisionAttributes() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetDecisionAttributes_1()
- throws Exception {
- DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable<String, String>(), UUID.randomUUID());
-
- Map<String, String> result = fixture.getDecisionAttributes();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the String getONAPComponentName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetONAPComponentName_1()
- throws Exception {
- DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable<String, String>(), UUID.randomUUID());
-
- String result = fixture.getOnapName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the UUID getRequestID() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetRequestID_1()
- throws Exception {
- DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable<String, String>(), UUID.fromString("d1db6a6d-7140-4864-8200-6b541261fdd2"));
-
- UUID result = fixture.getRequestID();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("d1db6a6d-7140-4864-8200-6b541261fdd2", result.toString());
- assertEquals(4, result.version());
- assertEquals(2, result.variant());
- assertEquals(-9079138839949083182L, result.getLeastSignificantBits());
- assertEquals(-3324946881598961564L, result.getMostSignificantBits());
- }
-
- /**
- * Run the void setDecisionAttributes(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetDecisionAttributes_1()
- throws Exception {
- DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable<String, String>(), UUID.randomUUID());
- Map<String, String> decisionAttributes = new Hashtable<String, String>();
-
- fixture.setDecisionAttributes(decisionAttributes);
-
- // add additional test code here
- }
-
- /**
- * Run the void setONAPComponentName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetONAPComponentName_1()
- throws Exception {
- DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable<String, String>(), UUID.randomUUID());
- String onapComponentName = "";
-
- fixture.setOnapName(onapComponentName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setRequestID(UUID) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetRequestID_1()
- throws Exception {
- DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable<String, String>(), UUID.randomUUID());
- UUID requestID = UUID.randomUUID();
-
- fixture.setRequestID(requestID);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(DecisionRequestParametersTest.class);
- }
+ /**
+ * Run the DecisionRequestParameters() constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testDecisionRequestParameters_1() throws Exception {
+
+ DecisionRequestParameters result = new DecisionRequestParameters();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getOnapName());
+ assertEquals(null, result.getDecisionAttributes());
+ assertEquals(null, result.getRequestID());
+ }
+
+ /**
+ * Run the DecisionRequestParameters(String,Map<String,String>,UUID) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testDecisionRequestParameters_2() throws Exception {
+ String onapComponentName = "";
+ Map<String, String> decisionAttributes = new Hashtable<String, String>();
+ UUID requestID = UUID.randomUUID();
+
+ DecisionRequestParameters result =
+ new DecisionRequestParameters(onapComponentName, decisionAttributes, requestID);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("", result.getOnapName());
+ }
+
+ /**
+ * Run the Map<String, String> getDecisionAttributes() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetDecisionAttributes_1() throws Exception {
+ DecisionRequestParameters fixture = new DecisionRequestParameters("",
+ new Hashtable<String, String>(), UUID.randomUUID());
+
+ Map<String, String> result = fixture.getDecisionAttributes();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the String getONAPComponentName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetONAPComponentName_1() throws Exception {
+ DecisionRequestParameters fixture = new DecisionRequestParameters("",
+ new Hashtable<String, String>(), UUID.randomUUID());
+
+ String result = fixture.getOnapName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the UUID getRequestID() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetRequestID_1() throws Exception {
+ DecisionRequestParameters fixture =
+ new DecisionRequestParameters("", new Hashtable<String, String>(),
+ UUID.fromString("d1db6a6d-7140-4864-8200-6b541261fdd2"));
+
+ UUID result = fixture.getRequestID();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("d1db6a6d-7140-4864-8200-6b541261fdd2", result.toString());
+ assertEquals(4, result.version());
+ assertEquals(2, result.variant());
+ assertEquals(-9079138839949083182L, result.getLeastSignificantBits());
+ assertEquals(-3324946881598961564L, result.getMostSignificantBits());
+ }
+
+ /**
+ * Run the void setDecisionAttributes(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetDecisionAttributes_1() throws Exception {
+ DecisionRequestParameters fixture = new DecisionRequestParameters("",
+ new Hashtable<String, String>(), UUID.randomUUID());
+ Map<String, String> decisionAttributes = new Hashtable<String, String>();
+
+ fixture.setDecisionAttributes(decisionAttributes);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setONAPComponentName(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetONAPComponentName_1() throws Exception {
+ DecisionRequestParameters fixture = new DecisionRequestParameters("",
+ new Hashtable<String, String>(), UUID.randomUUID());
+ String onapComponentName = "";
+
+ fixture.setOnapName(onapComponentName);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setRequestID(UUID) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetRequestID_1() throws Exception {
+ DecisionRequestParameters fixture = new DecisionRequestParameters("",
+ new Hashtable<String, String>(), UUID.randomUUID());
+ UUID requestID = UUID.randomUUID();
+
+ fixture.setRequestID(requestID);
+
+ // add additional test code here
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(DecisionRequestParametersTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryParametersTest.java
index 63e1d7c5a..1c946543e 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryParametersTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/DictionaryParametersTest.java
@@ -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.
@@ -20,32 +22,30 @@
package org.onap.policy.test;
import static org.junit.Assert.*;
-
import java.util.UUID;
-
import org.junit.Test;
import org.onap.policy.api.DictionaryParameters;
import org.onap.policy.api.DictionaryType;
public class DictionaryParametersTest {
- @Test
- public void test() {
- DictionaryParameters params = new DictionaryParameters();
-
- params.setDictionary("dictionary");
- assertEquals("dictionary", params.getDictionary());
-
- UUID uuid = UUID.randomUUID();
- params.setRequestID(uuid);
- assertEquals(uuid, params.getRequestID());
-
- params.setDictionaryJson("{}");
- assertEquals("{}", params.getDictionaryJson());
-
- params.setDictionaryType(DictionaryType.BRMS);
- assertEquals(DictionaryType.BRMS, params.getDictionaryType());
-
- }
+ @Test
+ public void test() {
+ DictionaryParameters params = new DictionaryParameters();
+
+ params.setDictionary("dictionary");
+ assertEquals("dictionary", params.getDictionary());
+
+ UUID uuid = UUID.randomUUID();
+ params.setRequestID(uuid);
+ assertEquals(uuid, params.getRequestID());
+
+ params.setDictionaryJson("{}");
+ assertEquals("{}", params.getDictionaryJson());
+
+ params.setDictionaryType(DictionaryType.BRMS);
+ assertEquals(DictionaryType.BRMS, params.getDictionaryType());
+
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/EventRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/EventRequestParametersTest.java
index 4fecea8c2..9efbaeb1f 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/EventRequestParametersTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/EventRequestParametersTest.java
@@ -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.
@@ -23,171 +25,164 @@ package org.onap.policy.test;
import java.util.Hashtable;
import java.util.Map;
import java.util.UUID;
-
import org.junit.*;
import org.onap.policy.api.EventRequestParameters;
-
import static org.junit.Assert.*;
/**
- * The class <code>EventRequestParametersTest</code> contains tests for the class <code>{@link EventRequestParameters}</code>.
+ * The class <code>EventRequestParametersTest</code> contains tests for the class
+ * <code>{@link EventRequestParameters}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class EventRequestParametersTest {
- /**
- * Run the EventRequestParameters() constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testEventRequestParameters_1()
- throws Exception {
-
- EventRequestParameters result = new EventRequestParameters();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getEventAttributes());
- assertEquals(null, result.getRequestID());
- }
-
- /**
- * Run the EventRequestParameters(Map<String,String>,UUID) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testEventRequestParameters_2()
- throws Exception {
- Map<String, String> eventAttributes = new Hashtable<String, String>();
- UUID requestID = UUID.randomUUID();
-
- EventRequestParameters result = new EventRequestParameters(eventAttributes, requestID);
-
- // add additional test code here
- assertNotNull(result);
- }
-
- /**
- * Run the Map<String, String> getEventAttributes() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetEventAttributes_1()
- throws Exception {
- EventRequestParameters fixture = new EventRequestParameters(new Hashtable<String, String>(), UUID.randomUUID());
-
- Map<String, String> result = fixture.getEventAttributes();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(0, result.size());
- }
-
- /**
- * Run the UUID getRequestID() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testGetRequestID_1()
- throws Exception {
- EventRequestParameters fixture = new EventRequestParameters(new Hashtable<String, String>(), UUID.fromString("5b15376d-569b-4772-ac75-9362043f6a6c"));
-
- UUID result = fixture.getRequestID();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("5b15376d-569b-4772-ac75-9362043f6a6c", result.toString());
- assertEquals(4, result.version());
- assertEquals(2, result.variant());
- assertEquals(-6019743277723456916L, result.getLeastSignificantBits());
- assertEquals(6563212974706345842L, result.getMostSignificantBits());
- }
-
- /**
- * Run the void setEventAttributes(Map<String,String>) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetEventAttributes_1()
- throws Exception {
- EventRequestParameters fixture = new EventRequestParameters(new Hashtable<String, String>(), UUID.randomUUID());
- Map<String, String> eventAttributes = new Hashtable<String, String>();
-
- fixture.setEventAttributes(eventAttributes);
-
- // add additional test code here
- }
-
- /**
- * Run the void setRequestID(UUID) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testSetRequestID_1()
- throws Exception {
- EventRequestParameters fixture = new EventRequestParameters(new Hashtable<String, String>(), UUID.randomUUID());
- UUID requestID = UUID.randomUUID();
-
- fixture.setRequestID(requestID);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(EventRequestParametersTest.class);
- }
+ /**
+ * Run the EventRequestParameters() constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testEventRequestParameters_1() throws Exception {
+
+ EventRequestParameters result = new EventRequestParameters();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getEventAttributes());
+ assertEquals(null, result.getRequestID());
+ }
+
+ /**
+ * Run the EventRequestParameters(Map<String,String>,UUID) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testEventRequestParameters_2() throws Exception {
+ Map<String, String> eventAttributes = new Hashtable<String, String>();
+ UUID requestID = UUID.randomUUID();
+
+ EventRequestParameters result = new EventRequestParameters(eventAttributes, requestID);
+
+ // add additional test code here
+ assertNotNull(result);
+ }
+
+ /**
+ * Run the Map<String, String> getEventAttributes() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetEventAttributes_1() throws Exception {
+ EventRequestParameters fixture =
+ new EventRequestParameters(new Hashtable<String, String>(), UUID.randomUUID());
+
+ Map<String, String> result = fixture.getEventAttributes();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
+
+ /**
+ * Run the UUID getRequestID() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testGetRequestID_1() throws Exception {
+ EventRequestParameters fixture = new EventRequestParameters(new Hashtable<String, String>(),
+ UUID.fromString("5b15376d-569b-4772-ac75-9362043f6a6c"));
+
+ UUID result = fixture.getRequestID();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("5b15376d-569b-4772-ac75-9362043f6a6c", result.toString());
+ assertEquals(4, result.version());
+ assertEquals(2, result.variant());
+ assertEquals(-6019743277723456916L, result.getLeastSignificantBits());
+ assertEquals(6563212974706345842L, result.getMostSignificantBits());
+ }
+
+ /**
+ * Run the void setEventAttributes(Map<String,String>) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetEventAttributes_1() throws Exception {
+ EventRequestParameters fixture =
+ new EventRequestParameters(new Hashtable<String, String>(), UUID.randomUUID());
+ Map<String, String> eventAttributes = new Hashtable<String, String>();
+
+ fixture.setEventAttributes(eventAttributes);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setRequestID(UUID) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testSetRequestID_1() throws Exception {
+ EventRequestParameters fixture =
+ new EventRequestParameters(new Hashtable<String, String>(), UUID.randomUUID());
+ UUID requestID = UUID.randomUUID();
+
+ fixture.setRequestID(requestID);
+
+ // add additional test code here
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(EventRequestParametersTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigByPolicyNameTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigByPolicyNameTest.java
index 07af71eaf..aa59c1e93 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigByPolicyNameTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigByPolicyNameTest.java
@@ -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,7 +23,6 @@
package org.onap.policy.test;
import java.util.Collection;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.api.PolicyConfig;
@@ -30,34 +31,34 @@ import org.onap.policy.api.PolicyEngine;
import org.onap.policy.api.PolicyEngineException;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-
-import junit.framework.TestCase;
+import junit.framework.TestCase;
public class GetConfigByPolicyNameTest extends TestCase {
- private PolicyEngine policyEngine = null;
- private String policyName = null;
- private Collection<PolicyConfig> policyConfig = null;
- private static final Logger logger = FlexLogger.getLogger(GetConfigByPolicyNameTest.class);
- @Before
- public void setUp() {
- try {
- policyEngine = new PolicyEngine("Test/config_pass.properties");
- } catch (PolicyEngineException e) {
- logger.error(e.getMessage());
- fail("PolicyEngine Instantiation Error" + e);
- }
- logger.info("Loaded.. PolicyEngine");
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void testGetConfigPolicyNameNotValid(){
- policyName = null;
- try{
- policyConfig = policyEngine.getConfigByPolicyName(policyName);
- } catch (PolicyConfigException e){
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
+ private PolicyEngine policyEngine = null;
+ private String policyName = null;
+ private Collection<PolicyConfig> policyConfig = null;
+ private static final Logger logger = FlexLogger.getLogger(GetConfigByPolicyNameTest.class);
+
+ @Before
+ public void setUp() {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testGetConfigPolicyNameNotValid() {
+ policyName = null;
+ try {
+ policyConfig = policyEngine.getConfigByPolicyName(policyName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringMapTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringMapTest.java
index f70a16a98..9ec649318 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringMapTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringMapTest.java
@@ -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.
@@ -24,11 +26,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.api.PolicyConfig;
@@ -38,222 +38,228 @@ import org.onap.policy.api.PolicyEngine;
import org.onap.policy.api.PolicyEngineException;
import org.onap.policy.api.PolicyType;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.logging.flexlogger.Logger;
public class GetConfigStringStringMapTest {
- private PolicyEngine policyEngine = null;
- private String onapComponentName = null;
- private String configName = null;
- private Map<String,String> configAttributes = new HashMap<String,String>();
- private Collection<PolicyConfig> policyConfig = null;
- private static final Logger logger = FlexLogger.getLogger(GetConfigStringStringMapTest.class);
- @Before
- public void setUp() {
- try {
- policyEngine = new PolicyEngine("Test/config_pass.properties");
- } catch (PolicyEngineException e) {
- logger.error(e.getMessage());
- fail("PolicyEngine Instantiation Error" + e);
- }
- logger.info("Loaded.. PolicyEngine");
- }
+ private PolicyEngine policyEngine = null;
+ private String onapComponentName = null;
+ private String configName = null;
+ private Map<String, String> configAttributes = new HashMap<String, String>();
+ private Collection<PolicyConfig> policyConfig = null;
+ private static final Logger logger = FlexLogger.getLogger(GetConfigStringStringMapTest.class);
+
+ @Before
+ public void setUp() {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testGetConfigStringStringMapFail() {
+ onapComponentName = null;
+ configName = null;
+ configAttributes = null;
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testGetConfigStringStringMapFail1() {
+ onapComponentName = null;
+ configName = "testFail";
+ configAttributes.put("TestValue", "Fail");
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testGetConfigStringStringMapFail2() {
+ onapComponentName = "TestFail";
+ configName = null;
+ configAttributes.put("TestValue", "Fail");
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testGetConfigStringStringMapFail3() {
+ onapComponentName = "TestFail";
+ configName = "configFail";
+ configAttributes = null;
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testGetConfigStringStringMapfail4() {
+ onapComponentName = "TestFail";
+ configName = "configFail";
+ configAttributes.put("", "");
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringStringMapNotValid() {
+ onapComponentName = "TestFail";
+ configName = "configFail";
+ configAttributes.put("Action:com.test.fail", "Value");
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyConfig policyConfig : this.policyConfig) {
+ logger.info(policyConfig.getPolicyConfigMessage() + " , "
+ + policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig);
+ assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig.getPolicyConfigMessage());
+ assertNull(policyConfig.getType());
+ assertNull(policyConfig.toJSON());
+ assertNull(policyConfig.toProperties());
+ assertNull(policyConfig.toXML());
+ assertNull(policyConfig.toOther());
+ }
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringStringMapValidJSON() {
+ onapComponentName = "JSON";
+ configName = "JSONconfig";
+ configAttributes.put("Resource.com:test:resource:json", "Test");
+ configAttributes.put("Action.com:test:action:json", "TestJSON");
+ configAttributes.put("Subject.com:test:subject:json", "TestSubject");
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyConfig policyConfig : this.policyConfig) {
+ logger.info(policyConfig.getPolicyConfigMessage() + " , "
+ + policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig);
+ assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig.getPolicyConfigMessage());
+ assertEquals(PolicyType.JSON, policyConfig.getType());
+ assertNotNull(policyConfig.toJSON());
+ assertNull(policyConfig.toProperties());
+ assertNull(policyConfig.toXML());
+ assertNull(policyConfig.toOther());
+ }
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringStringMapValidXML() {
+ onapComponentName = "XML";
+ configName = "XMLconfig";
+ configAttributes.put("Resource.com:test:resource:json", "Test");
+ configAttributes.put("Action.com:test:action:json", "TestJSON");
+ configAttributes.put("Subject.com:test:subject:json", "TestSubject");
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyConfig policyConfig : this.policyConfig) {
+ logger.info(policyConfig.getPolicyConfigMessage() + " , "
+ + policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig);
+ assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig.getPolicyConfigMessage());
+ assertEquals(PolicyType.XML, policyConfig.getType());
+ assertNull(policyConfig.toJSON());
+ assertNull(policyConfig.toProperties());
+ assertNotNull(policyConfig.toXML());
+ assertNull(policyConfig.toOther());
+ }
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringStringMapValidProperties() {
+ onapComponentName = "Properties";
+ configName = "PropConfig";
+ configAttributes.put("Resource.com:test:resource:json", "Test");
+ configAttributes.put("Action.com:test:action:json", "TestJSON");
+ configAttributes.put("Subject.com:test:subject:json", "TestSubject");
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyConfig policyConfig : this.policyConfig) {
+ logger.info(policyConfig.getPolicyConfigMessage() + " , "
+ + policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig);
+ assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig.getPolicyConfigMessage());
+ assertEquals(PolicyType.PROPERTIES, policyConfig.getType());
+ assertNull(policyConfig.toJSON());
+ assertNotNull(policyConfig.toProperties());
+ assertNull(policyConfig.toXML());
+ assertNull(policyConfig.toOther());
+ }
+ }
- @SuppressWarnings("deprecation")
- @Test
- public void testGetConfigStringStringMapFail() {
- onapComponentName = null;
- configName = null;
- configAttributes = null;
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void testGetConfigStringStringMapFail1() {
- onapComponentName = null;
- configName = "testFail";
- configAttributes.put("TestValue", "Fail");
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void testGetConfigStringStringMapFail2() {
- onapComponentName = "TestFail";
- configName = null;
- configAttributes.put("TestValue", "Fail");
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void testGetConfigStringStringMapFail3() {
- onapComponentName = "TestFail";
- configName = "configFail";
- configAttributes= null;
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void testGetConfigStringStringMapfail4() {
- onapComponentName = "TestFail";
- configName = "configFail";
- configAttributes.put("", "");
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringStringMapNotValid() {
- onapComponentName = "TestFail";
- configName = "configFail";
- configAttributes.put("Action:com.test.fail", "Value");
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertNull(policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringStringMapValidJSON() {
- onapComponentName = "JSON";
- configName = "JSONconfig";
- configAttributes.put("Resource.com:test:resource:json", "Test");
- configAttributes.put("Action.com:test:action:json", "TestJSON");
- configAttributes.put("Subject.com:test:subject:json", "TestSubject");
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.JSON,policyConfig.getType());
- assertNotNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringStringMapValidXML() {
- onapComponentName = "XML";
- configName = "XMLconfig";
- configAttributes.put("Resource.com:test:resource:json", "Test");
- configAttributes.put("Action.com:test:action:json", "TestJSON");
- configAttributes.put("Subject.com:test:subject:json", "TestSubject");
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.XML,policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNotNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringStringMapValidProperties() {
- onapComponentName = "Properties";
- configName = "PropConfig" ;
- configAttributes.put("Resource.com:test:resource:json", "Test");
- configAttributes.put("Action.com:test:action:json", "TestJSON");
- configAttributes.put("Subject.com:test:subject:json", "TestSubject");
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.PROPERTIES,policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNotNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringStringMapValidOther() {
- onapComponentName = "Other";
- configName = "OtherConfig" ;
- configAttributes.put("Resource.com:test:resource:json", "Test");
- configAttributes.put("Action.com:test:action:json", "TestJSON");
- configAttributes.put("Subject.com:test:subject:json", "TestSubject");
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.OTHER,policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNotNull(policyConfig.toOther());
- }
- }
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringStringMapValidOther() {
+ onapComponentName = "Other";
+ configName = "OtherConfig";
+ configAttributes.put("Resource.com:test:resource:json", "Test");
+ configAttributes.put("Action.com:test:action:json", "TestJSON");
+ configAttributes.put("Subject.com:test:subject:json", "TestSubject");
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyConfig policyConfig : this.policyConfig) {
+ logger.info(policyConfig.getPolicyConfigMessage() + " , "
+ + policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig);
+ assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig.getPolicyConfigMessage());
+ assertEquals(PolicyType.OTHER, policyConfig.getType());
+ assertNull(policyConfig.toJSON());
+ assertNull(policyConfig.toProperties());
+ assertNull(policyConfig.toXML());
+ assertNotNull(policyConfig.toOther());
+ }
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringTest.java
index 0a6db2dd4..0f3493b68 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringStringTest.java
@@ -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.
@@ -24,9 +26,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-
import java.util.Collection;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.api.PolicyConfig;
@@ -36,178 +36,183 @@ import org.onap.policy.api.PolicyEngine;
import org.onap.policy.api.PolicyEngineException;
import org.onap.policy.api.PolicyType;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.logging.flexlogger.Logger;
public class GetConfigStringStringTest {
-
- private PolicyEngine policyEngine = null;
- private String onapComponentName = null;
- private String configName = null;
- private Collection<PolicyConfig> policyConfig = null;
- private static final Logger logger = FlexLogger.getLogger(GetConfigStringStringTest.class);
- @Before
- public void setUp() {
- try {
- policyEngine = new PolicyEngine("Test/config_pass.properties");
- } catch (PolicyEngineException e) {
- logger.error(e.getMessage());
- fail("PolicyEngine Instantiation Error" + e);
- }
- logger.info("Loaded.. PolicyEngine");
- }
- @SuppressWarnings("deprecation")
- @Test
- public void testGetConfigStringStringFail() {
- onapComponentName = null;
- configName = null;
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void testGetConfigStringStringFail1() {
- onapComponentName = null;
- configName = "";
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void testGetConfigStringStringFail2() {
- onapComponentName = "";
- configName = null;
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringStringNotvalid() {
- onapComponentName = "fail";
- configName = "fail";
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertNull(policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringStringValidJSON() {
- onapComponentName = "JSON";
- configName = "JSONconfig";
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.JSON,policyConfig.getType());
- assertNotNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringStringValidXML() {
- onapComponentName = "XML";
- configName = "XMLconfig";
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.XML,policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNotNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringStringValidProperties() {
- onapComponentName = "Properties";
- configName = "PropConfig" ;
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.PROPERTIES,policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNotNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringStringValidOther() {
- onapComponentName = "Other";
- configName = "OtherConfig" ;
- try {
- policyConfig = policyEngine.getConfig(onapComponentName, configName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.OTHER,policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNotNull(policyConfig.toOther());
- }
- }
+ private PolicyEngine policyEngine = null;
+ private String onapComponentName = null;
+ private String configName = null;
+ private Collection<PolicyConfig> policyConfig = null;
+ private static final Logger logger = FlexLogger.getLogger(GetConfigStringStringTest.class);
+
+ @Before
+ public void setUp() {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testGetConfigStringStringFail() {
+ onapComponentName = null;
+ configName = null;
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testGetConfigStringStringFail1() {
+ onapComponentName = null;
+ configName = "";
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testGetConfigStringStringFail2() {
+ onapComponentName = "";
+ configName = null;
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringStringNotvalid() {
+ onapComponentName = "fail";
+ configName = "fail";
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyConfig policyConfig : this.policyConfig) {
+ logger.info(policyConfig.getPolicyConfigMessage() + " , "
+ + policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig);
+ assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig.getPolicyConfigMessage());
+ assertNull(policyConfig.getType());
+ assertNull(policyConfig.toJSON());
+ assertNull(policyConfig.toProperties());
+ assertNull(policyConfig.toXML());
+ assertNull(policyConfig.toOther());
+ }
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringStringValidJSON() {
+ onapComponentName = "JSON";
+ configName = "JSONconfig";
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyConfig policyConfig : this.policyConfig) {
+ logger.info(policyConfig.getPolicyConfigMessage() + " , "
+ + policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig);
+ assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig.getPolicyConfigMessage());
+ assertEquals(PolicyType.JSON, policyConfig.getType());
+ assertNotNull(policyConfig.toJSON());
+ assertNull(policyConfig.toProperties());
+ assertNull(policyConfig.toXML());
+ assertNull(policyConfig.toOther());
+ }
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringStringValidXML() {
+ onapComponentName = "XML";
+ configName = "XMLconfig";
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyConfig policyConfig : this.policyConfig) {
+ logger.info(policyConfig.getPolicyConfigMessage() + " , "
+ + policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig);
+ assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig.getPolicyConfigMessage());
+ assertEquals(PolicyType.XML, policyConfig.getType());
+ assertNull(policyConfig.toJSON());
+ assertNull(policyConfig.toProperties());
+ assertNotNull(policyConfig.toXML());
+ assertNull(policyConfig.toOther());
+ }
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringStringValidProperties() {
+ onapComponentName = "Properties";
+ configName = "PropConfig";
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyConfig policyConfig : this.policyConfig) {
+ logger.info(policyConfig.getPolicyConfigMessage() + " , "
+ + policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig);
+ assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig.getPolicyConfigMessage());
+ assertEquals(PolicyType.PROPERTIES, policyConfig.getType());
+ assertNull(policyConfig.toJSON());
+ assertNotNull(policyConfig.toProperties());
+ assertNull(policyConfig.toXML());
+ assertNull(policyConfig.toOther());
+ }
+ }
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringStringValidOther() {
+ onapComponentName = "Other";
+ configName = "OtherConfig";
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName, configName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyConfig policyConfig : this.policyConfig) {
+ logger.info(policyConfig.getPolicyConfigMessage() + " , "
+ + policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig);
+ assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED, policyConfig.getPolicyConfigStatus());
+ assertNotNull(policyConfig.getPolicyConfigMessage());
+ assertEquals(PolicyType.OTHER, policyConfig.getType());
+ assertNull(policyConfig.toJSON());
+ assertNull(policyConfig.toProperties());
+ assertNull(policyConfig.toXML());
+ assertNotNull(policyConfig.toOther());
+ }
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringTest.java
index f87a59c09..16d8e8991 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/GetConfigStringTest.java
@@ -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,7 +23,6 @@
package org.onap.policy.test;
import java.util.Collection;
-
import org.junit.Before;
import org.onap.policy.api.PolicyConfig;
import org.onap.policy.api.PolicyConfigException;
@@ -29,142 +30,35 @@ import org.onap.policy.api.PolicyEngine;
import org.onap.policy.api.PolicyEngineException;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
+import junit.framework.TestCase;
+
+public class GetConfigStringTest extends TestCase {
+
+ private PolicyEngine policyEngine = null;
+ private String onapComponentName = null;
+ private Collection<PolicyConfig> policyConfig = null;
+ private static final Logger logger = FlexLogger.getLogger(GetConfigStringTest.class);
-import junit.framework.TestCase;
+ @Before
+ public void setUp() {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+ }
-public class GetConfigStringTest extends TestCase{
-
- private PolicyEngine policyEngine = null;
- private String onapComponentName = null;
- private Collection<PolicyConfig> policyConfig = null;
- private static final Logger logger = FlexLogger.getLogger(GetConfigStringTest.class);
- @Before
- public void setUp() {
- try {
- policyEngine = new PolicyEngine("Test/config_pass.properties");
- } catch (PolicyEngineException e) {
- logger.error(e.getMessage());
- fail("PolicyEngine Instantiation Error" + e);
- }
- logger.info("Loaded.. PolicyEngine");
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testGetConfigStringFail() {
- onapComponentName = null;
- try {
- policyConfig = policyEngine.getConfig(onapComponentName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- /*@Test
- public void testGetConfigStringNotvalid() {
- onapComponentName = "fail";
- try {
- policyConfig = policyEngine.getConfig(onapComponentName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertNull(policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
- */
-
- /*@Test
- public void testGetConfigStringValidJSON() {
- onapComponentName = "JSON";
- try {
- policyConfig = policyEngine.getConfig(onapComponentName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.JSON,policyConfig.getType());
- assertNotNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
- */
- /*@Test
- public void testGetConfigStringValidXML() {
- onapComponentName = "XML";
- try {
- policyConfig = policyEngine.getConfig(onapComponentName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.XML,policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNotNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
- */
- /*@Test
- public void testGetConfigStringValidProperties() {
- onapComponentName = "Properties";
- try {
- policyConfig = policyEngine.getConfig(onapComponentName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.PROPERTIES,policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNotNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNull(policyConfig.toOther());
- }
- }
- */
- /*@Test
- public void testGetConfigStringValidOther() {
- onapComponentName = "Other";
- try {
- policyConfig = policyEngine.getConfig(onapComponentName);
- } catch (PolicyConfigException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyConfig policyConfig : this.policyConfig){
- logger.info(policyConfig.getPolicyConfigMessage() + " , " +policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig);
- assertEquals(PolicyConfigStatus.CONFIG_RETRIEVED,policyConfig.getPolicyConfigStatus());
- assertNotNull(policyConfig.getPolicyConfigMessage());
- assertEquals(PolicyType.OTHER,policyConfig.getType());
- assertNull(policyConfig.toJSON());
- assertNull(policyConfig.toProperties());
- assertNull(policyConfig.toXML());
- assertNotNull(policyConfig.toOther());
- }
- }
- */
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testGetConfigStringFail() {
+ onapComponentName = null;
+ try {
+ policyConfig = policyEngine.getConfig(onapComponentName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ImportParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ImportParametersTest.java
index be3e9c39b..8bb613c32 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/ImportParametersTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/ImportParametersTest.java
@@ -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.
@@ -22,382 +24,365 @@ package org.onap.policy.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import java.util.UUID;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.api.ImportParameters;
/**
- * The class <code>ImportParametersTest</code> contains tests for the class <code>{@link ImportParameters}</code>.
+ * The class <code>ImportParametersTest</code> contains tests for the class
+ * <code>{@link ImportParameters}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class ImportParametersTest {
- /**
- * Run the String getDescription() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetDescription_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
-
- String result = fixture.getDescription();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getFilePath() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetFilePath_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
-
- String result = fixture.getFilePath();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the UUID getRequestID() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetRequestID_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.fromString("731dca0a-fe99-456c-8ad2-87cff8437b2f"));
- fixture.setDescription("");
- fixture.setServiceName("");
-
- UUID result = fixture.getRequestID();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("731dca0a-fe99-456c-8ad2-87cff8437b2f", result.toString());
- assertEquals(4, result.version());
- assertEquals(2, result.variant());
- assertEquals(-8443537024073106641L, result.getLeastSignificantBits());
- assertEquals(8295008237256263020L, result.getMostSignificantBits());
- }
-
- /**
- * Run the String getServiceName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetServiceName_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
-
- String result = fixture.getServiceName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the ImportParameters.IMPORT_TYPE getServiceType() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetServiceType_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
-
- ImportParameters.IMPORT_TYPE result = fixture.getServiceType();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("MICROSERVICE", result.name());
- assertEquals("MICROSERVICE", result.toString());
- assertEquals(0, result.ordinal());
- }
-
- /**
- * Run the String getVersion() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetVersion_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
-
- String result = fixture.getVersion();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the void setDescription(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetDescription_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
- String description = "";
-
- fixture.setDescription(description);
-
- // add additional test code here
- }
-
- /**
- * Run the void setFilePath(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetFilePath_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
- String filePath = "";
-
- fixture.setFilePath(filePath);
-
- // add additional test code here
- }
-
- /**
- * Run the void setImportParameters(String,String,UUID,String,IMPORT_TYPE,String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetImportParameters_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
- String serviceName = "";
- String description = "";
- UUID requestID = UUID.randomUUID();
- String filePath = "";
- ImportParameters.IMPORT_TYPE importType = ImportParameters.IMPORT_TYPE.MICROSERVICE;
- String version = "";
-
- fixture.setImportParameters(serviceName, description, requestID, filePath, importType, version);
-
- // add additional test code here
- }
-
- /**
- * Run the void setRequestID(UUID) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetRequestID_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
- UUID requestID = UUID.randomUUID();
-
- fixture.setRequestID(requestID);
-
- // add additional test code here
- }
-
- /**
- * Run the void setServiceName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetServiceName_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
- String serviceName = "";
-
- fixture.setServiceName(serviceName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setServiceType(IMPORT_TYPE) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetServiceType_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
- ImportParameters.IMPORT_TYPE enumImportType = ImportParameters.IMPORT_TYPE.MICROSERVICE;
-
- fixture.setServiceType(enumImportType);
-
- // add additional test code here
- }
-
- /**
- * Run the void setVersion(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetVersion_1()
- throws Exception {
- ImportParameters fixture = new ImportParameters();
- fixture.setFilePath("");
- fixture.setVersion("");
- fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
- fixture.setRequestID(UUID.randomUUID());
- fixture.setDescription("");
- fixture.setServiceName("");
- String version = "";
-
- fixture.setVersion(version);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(ImportParametersTest.class);
- }
+ /**
+ * Run the String getDescription() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetDescription_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+
+ String result = fixture.getDescription();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getFilePath() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetFilePath_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+
+ String result = fixture.getFilePath();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the UUID getRequestID() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetRequestID_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.fromString("731dca0a-fe99-456c-8ad2-87cff8437b2f"));
+ fixture.setDescription("");
+ fixture.setServiceName("");
+
+ UUID result = fixture.getRequestID();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("731dca0a-fe99-456c-8ad2-87cff8437b2f", result.toString());
+ assertEquals(4, result.version());
+ assertEquals(2, result.variant());
+ assertEquals(-8443537024073106641L, result.getLeastSignificantBits());
+ assertEquals(8295008237256263020L, result.getMostSignificantBits());
+ }
+
+ /**
+ * Run the String getServiceName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetServiceName_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+
+ String result = fixture.getServiceName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the ImportParameters.IMPORT_TYPE getServiceType() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetServiceType_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+
+ ImportParameters.IMPORT_TYPE result = fixture.getServiceType();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("MICROSERVICE", result.name());
+ assertEquals("MICROSERVICE", result.toString());
+ assertEquals(0, result.ordinal());
+ }
+
+ /**
+ * Run the String getVersion() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetVersion_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+
+ String result = fixture.getVersion();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the void setDescription(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetDescription_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+ String description = "";
+
+ fixture.setDescription(description);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setFilePath(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetFilePath_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+ String filePath = "";
+
+ fixture.setFilePath(filePath);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setImportParameters(String,String,UUID,String,IMPORT_TYPE,String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetImportParameters_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+ String serviceName = "";
+ String description = "";
+ UUID requestID = UUID.randomUUID();
+ String filePath = "";
+ ImportParameters.IMPORT_TYPE importType = ImportParameters.IMPORT_TYPE.MICROSERVICE;
+ String version = "";
+
+ fixture.setImportParameters(serviceName, description, requestID, filePath, importType,
+ version);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setRequestID(UUID) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetRequestID_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+ UUID requestID = UUID.randomUUID();
+
+ fixture.setRequestID(requestID);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setServiceName(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetServiceName_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+ String serviceName = "";
+
+ fixture.setServiceName(serviceName);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setServiceType(IMPORT_TYPE) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetServiceType_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+ ImportParameters.IMPORT_TYPE enumImportType = ImportParameters.IMPORT_TYPE.MICROSERVICE;
+
+ fixture.setServiceType(enumImportType);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setVersion(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetVersion_1() throws Exception {
+ ImportParameters fixture = new ImportParameters();
+ fixture.setFilePath("");
+ fixture.setVersion("");
+ fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE);
+ fixture.setRequestID(UUID.randomUUID());
+ fixture.setDescription("");
+ fixture.setServiceName("");
+ String version = "";
+
+ fixture.setVersion(version);
+
+ // add additional test code here
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(ImportParametersTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/LoadedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/LoadedPolicyTest.java
index 1cc9de8df..7ebefb52a 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/LoadedPolicyTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/LoadedPolicyTest.java
@@ -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.
@@ -25,48 +27,45 @@ import org.junit.Before;
import org.onap.policy.api.LoadedPolicy;
/**
- * The class <code>LoadedPolicyTest</code> contains tests for the class <code>{@link LoadedPolicy}</code>.
+ * The class <code>LoadedPolicyTest</code> contains tests for the class
+ * <code>{@link LoadedPolicy}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class LoadedPolicyTest {
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(LoadedPolicyTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(LoadedPolicyTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/MetricsRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/MetricsRequestParametersTest.java
index 19d7933fc..771c51a31 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/MetricsRequestParametersTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/MetricsRequestParametersTest.java
@@ -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.
@@ -20,20 +22,18 @@
package org.onap.policy.test;
import static org.junit.Assert.*;
-
import java.util.UUID;
-
import org.junit.Test;
import org.onap.policy.api.MetricsRequestParameters;
public class MetricsRequestParametersTest {
- @Test
- public void test() {
- MetricsRequestParameters p = new MetricsRequestParameters();
-
- p.setRequestID(UUID.randomUUID());
- assertNotNull(p.getRequestID());
- }
+ @Test
+ public void test() {
+ MetricsRequestParameters p = new MetricsRequestParameters();
+
+ p.setRequestID(UUID.randomUUID());
+ assertNotNull(p.getRequestID());
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationHandlerTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationHandlerTest.java
index 4b996ce35..22ad1fdb6 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationHandlerTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationHandlerTest.java
@@ -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.
@@ -25,48 +27,45 @@ import org.junit.Before;
import org.onap.policy.api.NotificationHandler;
/**
- * The class <code>NotificationHandlerTest</code> contains tests for the class <code>{@link NotificationHandler}</code>.
+ * The class <code>NotificationHandlerTest</code> contains tests for the class
+ * <code>{@link NotificationHandler}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class NotificationHandlerTest {
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(NotificationHandlerTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(NotificationHandlerTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationSchemeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationSchemeTest.java
index 3274cf3ac..83f2f258c 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationSchemeTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationSchemeTest.java
@@ -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.
@@ -22,70 +24,65 @@ package org.onap.policy.test;
import org.junit.*;
import org.onap.policy.api.NotificationScheme;
-
import static org.junit.Assert.*;
/**
- * The class <code>NotificationSchemeTest</code> contains tests for the class <code>{@link NotificationScheme}</code>.
+ * The class <code>NotificationSchemeTest</code> contains tests for the class
+ * <code>{@link NotificationScheme}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class NotificationSchemeTest {
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- NotificationScheme fixture = NotificationScheme.AUTO_ALL_NOTIFICATIONS;
+ /**
+ * Run the String toString() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testToString_1() throws Exception {
+ NotificationScheme fixture = NotificationScheme.AUTO_ALL_NOTIFICATIONS;
- String result = fixture.toString();
+ String result = fixture.toString();
- // add additional test code here
- assertEquals("auto_all_notifications", result);
- }
+ // add additional test code here
+ assertEquals("auto_all_notifications", result);
+ }
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(NotificationSchemeTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(NotificationSchemeTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationTypeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationTypeTest.java
index 53ef086e2..c23b7789f 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationTypeTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/NotificationTypeTest.java
@@ -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.
@@ -22,70 +24,65 @@ package org.onap.policy.test;
import org.junit.*;
import org.onap.policy.api.NotificationType;
-
import static org.junit.Assert.*;
/**
- * The class <code>NotificationTypeTest</code> contains tests for the class <code>{@link NotificationType}</code>.
+ * The class <code>NotificationTypeTest</code> contains tests for the class
+ * <code>{@link NotificationType}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class NotificationTypeTest {
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- NotificationType fixture = NotificationType.BOTH;
+ /**
+ * Run the String toString() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testToString_1() throws Exception {
+ NotificationType fixture = NotificationType.BOTH;
- String result = fixture.toString();
+ String result = fixture.toString();
- // add additional test code here
- assertEquals("both", result);
- }
+ // add additional test code here
+ assertEquals("both", result);
+ }
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(NotificationTypeTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(NotificationTypeTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PDPNotificationTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PDPNotificationTest.java
index 50d0aa324..28d45d101 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PDPNotificationTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PDPNotificationTest.java
@@ -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.
@@ -25,48 +27,45 @@ import org.junit.Before;
import org.onap.policy.api.PDPNotification;
/**
- * The class <code>PDPNotificationTest</code> contains tests for the class <code>{@link PDPNotification}</code>.
+ * The class <code>PDPNotificationTest</code> contains tests for the class
+ * <code>{@link PDPNotification}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class PDPNotificationTest {
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PDPNotificationTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PDPNotificationTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyChangeResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyChangeResponseTest.java
index e8fd6346a..c5e47b6c8 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyChangeResponseTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyChangeResponseTest.java
@@ -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.
@@ -25,48 +27,45 @@ import org.junit.Before;
import org.onap.policy.api.PolicyChangeResponse;
/**
- * The class <code>PolicyChangeResponseTest</code> contains tests for the class <code>{@link PolicyChangeResponse}</code>.
+ * The class <code>PolicyChangeResponseTest</code> contains tests for the class
+ * <code>{@link PolicyChangeResponse}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class PolicyChangeResponseTest {
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyChangeResponseTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyChangeResponseTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigExceptionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigExceptionTest.java
index 60b11b5c4..44cd3de2e 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigExceptionTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigExceptionTest.java
@@ -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.
@@ -22,162 +24,155 @@ package org.onap.policy.test;
import org.junit.*;
import org.onap.policy.api.PolicyConfigException;
-
import static org.junit.Assert.*;
/**
- * The class <code>PolicyConfigExceptionTest</code> contains tests for the class <code>{@link PolicyConfigException}</code>.
+ * The class <code>PolicyConfigExceptionTest</code> contains tests for the class
+ * <code>{@link PolicyConfigException}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class PolicyConfigExceptionTest {
- /**
- * Run the PolicyConfigException() constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyConfigException_1()
- throws Exception {
-
- PolicyConfigException result = new PolicyConfigException();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getCause());
- assertEquals("org.onap.policy.api.PolicyConfigException", result.toString());
- assertEquals(null, result.getLocalizedMessage());
- assertEquals(null, result.getMessage());
- }
-
- /**
- * Run the PolicyConfigException(String) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyConfigException_2()
- throws Exception {
- String message = "";
-
- PolicyConfigException result = new PolicyConfigException(message);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getCause());
- assertEquals("org.onap.policy.api.PolicyConfigException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Run the PolicyConfigException(Throwable) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyConfigException_3()
- throws Exception {
- Throwable cause = new Throwable();
-
- PolicyConfigException result = new PolicyConfigException(cause);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyConfigException: java.lang.Throwable", result.toString());
- assertEquals("java.lang.Throwable", result.getLocalizedMessage());
- assertEquals("java.lang.Throwable", result.getMessage());
- }
-
- /**
- * Run the PolicyConfigException(String,Throwable) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyConfigException_4()
- throws Exception {
- String message = "";
- Throwable cause = new Throwable();
-
- PolicyConfigException result = new PolicyConfigException(message, cause);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyConfigException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Run the PolicyConfigException(String,Throwable,boolean,boolean) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyConfigException_5()
- throws Exception {
- String message = "";
- Throwable cause = new Throwable();
- boolean enableSuppression = true;
- boolean writableStackTrace = true;
-
- PolicyConfigException result = new PolicyConfigException(message, cause, enableSuppression, writableStackTrace);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyConfigException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyConfigExceptionTest.class);
- }
+ /**
+ * Run the PolicyConfigException() constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyConfigException_1() throws Exception {
+
+ PolicyConfigException result = new PolicyConfigException();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getCause());
+ assertEquals("org.onap.policy.api.PolicyConfigException", result.toString());
+ assertEquals(null, result.getLocalizedMessage());
+ assertEquals(null, result.getMessage());
+ }
+
+ /**
+ * Run the PolicyConfigException(String) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyConfigException_2() throws Exception {
+ String message = "";
+
+ PolicyConfigException result = new PolicyConfigException(message);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getCause());
+ assertEquals("org.onap.policy.api.PolicyConfigException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyConfigException(Throwable) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyConfigException_3() throws Exception {
+ Throwable cause = new Throwable();
+
+ PolicyConfigException result = new PolicyConfigException(cause);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyConfigException: java.lang.Throwable",
+ result.toString());
+ assertEquals("java.lang.Throwable", result.getLocalizedMessage());
+ assertEquals("java.lang.Throwable", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyConfigException(String,Throwable) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyConfigException_4() throws Exception {
+ String message = "";
+ Throwable cause = new Throwable();
+
+ PolicyConfigException result = new PolicyConfigException(message, cause);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyConfigException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyConfigException(String,Throwable,boolean,boolean) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyConfigException_5() throws Exception {
+ String message = "";
+ Throwable cause = new Throwable();
+ boolean enableSuppression = true;
+ boolean writableStackTrace = true;
+
+ PolicyConfigException result =
+ new PolicyConfigException(message, cause, enableSuppression, writableStackTrace);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyConfigException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyConfigExceptionTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTest.java
index 0aa4fbbfa..423c9d6f4 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTest.java
@@ -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.
@@ -25,48 +27,45 @@ import org.junit.Before;
import org.onap.policy.api.PolicyConfig;
/**
- * The class <code>PolicyConfigTest</code> contains tests for the class <code>{@link PolicyConfig}</code>.
+ * The class <code>PolicyConfigTest</code> contains tests for the class
+ * <code>{@link PolicyConfig}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class PolicyConfigTest {
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyConfigTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyConfigTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTypeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTypeTest.java
index 2d838aa08..6d8633486 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTypeTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyConfigTypeTest.java
@@ -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.
@@ -22,76 +24,73 @@ package org.onap.policy.test;
import org.junit.*;
import org.onap.policy.api.PolicyConfigType;
-
import static org.junit.Assert.*;
/**
- * The class <code>PolicyConfigTypeTest</code> contains tests for the class <code>{@link PolicyConfigType}</code>.
+ * The class <code>PolicyConfigTypeTest</code> contains tests for the class
+ * <code>{@link PolicyConfigType}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class PolicyConfigTypeTest {
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- PolicyConfigType fixture = PolicyConfigType.BRMS_PARAM;
+ /**
+ * Run the String toString() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testToString_1() throws Exception {
+ PolicyConfigType fixture = PolicyConfigType.BRMS_PARAM;
+
+ String result = fixture.toString();
+
+ // add additional test code here
+ assertEquals("BRMS_Param", result);
- String result = fixture.toString();
+ assertEquals(PolicyConfigType.MicroService,
+ PolicyConfigType.create(PolicyConfigType.MicroService.name()));
+ }
- // add additional test code here
- assertEquals("BRMS_Param", result);
-
- assertEquals(PolicyConfigType.MicroService, PolicyConfigType.create(PolicyConfigType.MicroService.name()));
- }
+ @Test(expected = IllegalArgumentException.class)
+ public void testException() {
+ PolicyConfigType.create("foobar");
+ }
- @Test(expected = IllegalArgumentException.class)
- public void testException() {
- PolicyConfigType.create("foobar");
- }
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyConfigTypeTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyConfigTypeTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionExceptionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionExceptionTest.java
index f0ee88151..8e719ac94 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionExceptionTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyDecisionExceptionTest.java
@@ -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.
@@ -22,162 +24,155 @@ package org.onap.policy.test;
import org.junit.*;
import org.onap.policy.api.PolicyDecisionException;
-
import static org.junit.Assert.*;
/**
- * The class <code>PolicyDecisionExceptionTest</code> contains tests for the class <code>{@link PolicyDecisionException}</code>.
+ * The class <code>PolicyDecisionExceptionTest</code> contains tests for the class
+ * <code>{@link PolicyDecisionException}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class PolicyDecisionExceptionTest {
- /**
- * Run the PolicyDecisionException() constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyDecisionException_1()
- throws Exception {
-
- PolicyDecisionException result = new PolicyDecisionException();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getCause());
- assertEquals("org.onap.policy.api.PolicyDecisionException", result.toString());
- assertEquals(null, result.getLocalizedMessage());
- assertEquals(null, result.getMessage());
- }
-
- /**
- * Run the PolicyDecisionException(String) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyDecisionException_2()
- throws Exception {
- String message = "";
-
- PolicyDecisionException result = new PolicyDecisionException(message);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getCause());
- assertEquals("org.onap.policy.api.PolicyDecisionException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Run the PolicyDecisionException(Throwable) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyDecisionException_3()
- throws Exception {
- Throwable cause = new Throwable();
-
- PolicyDecisionException result = new PolicyDecisionException(cause);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyDecisionException: java.lang.Throwable", result.toString());
- assertEquals("java.lang.Throwable", result.getLocalizedMessage());
- assertEquals("java.lang.Throwable", result.getMessage());
- }
-
- /**
- * Run the PolicyDecisionException(String,Throwable) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyDecisionException_4()
- throws Exception {
- String message = "";
- Throwable cause = new Throwable();
-
- PolicyDecisionException result = new PolicyDecisionException(message, cause);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyDecisionException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Run the PolicyDecisionException(String,Throwable,boolean,boolean) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyDecisionException_5()
- throws Exception {
- String message = "";
- Throwable cause = new Throwable();
- boolean enableSuppression = true;
- boolean writableStackTrace = true;
-
- PolicyDecisionException result = new PolicyDecisionException(message, cause, enableSuppression, writableStackTrace);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyDecisionException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyDecisionExceptionTest.class);
- }
+ /**
+ * Run the PolicyDecisionException() constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyDecisionException_1() throws Exception {
+
+ PolicyDecisionException result = new PolicyDecisionException();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getCause());
+ assertEquals("org.onap.policy.api.PolicyDecisionException", result.toString());
+ assertEquals(null, result.getLocalizedMessage());
+ assertEquals(null, result.getMessage());
+ }
+
+ /**
+ * Run the PolicyDecisionException(String) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyDecisionException_2() throws Exception {
+ String message = "";
+
+ PolicyDecisionException result = new PolicyDecisionException(message);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getCause());
+ assertEquals("org.onap.policy.api.PolicyDecisionException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyDecisionException(Throwable) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyDecisionException_3() throws Exception {
+ Throwable cause = new Throwable();
+
+ PolicyDecisionException result = new PolicyDecisionException(cause);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyDecisionException: java.lang.Throwable",
+ result.toString());
+ assertEquals("java.lang.Throwable", result.getLocalizedMessage());
+ assertEquals("java.lang.Throwable", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyDecisionException(String,Throwable) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyDecisionException_4() throws Exception {
+ String message = "";
+ Throwable cause = new Throwable();
+
+ PolicyDecisionException result = new PolicyDecisionException(message, cause);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyDecisionException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyDecisionException(String,Throwable,boolean,boolean) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyDecisionException_5() throws Exception {
+ String message = "";
+ Throwable cause = new Throwable();
+ boolean enableSuppression = true;
+ boolean writableStackTrace = true;
+
+ PolicyDecisionException result =
+ new PolicyDecisionException(message, cause, enableSuppression, writableStackTrace);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyDecisionException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyDecisionExceptionTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineExceptionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineExceptionTest.java
index 58c45b97c..3d10badec 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineExceptionTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineExceptionTest.java
@@ -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.
@@ -22,162 +24,155 @@ package org.onap.policy.test;
import org.junit.*;
import org.onap.policy.api.PolicyEngineException;
-
import static org.junit.Assert.*;
/**
- * The class <code>PolicyEngineExceptionTest</code> contains tests for the class <code>{@link PolicyEngineException}</code>.
+ * The class <code>PolicyEngineExceptionTest</code> contains tests for the class
+ * <code>{@link PolicyEngineException}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class PolicyEngineExceptionTest {
- /**
- * Run the PolicyEngineException() constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testPolicyEngineException_1()
- throws Exception {
-
- PolicyEngineException result = new PolicyEngineException();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getCause());
- assertEquals("org.onap.policy.api.PolicyEngineException", result.toString());
- assertEquals(null, result.getLocalizedMessage());
- assertEquals(null, result.getMessage());
- }
-
- /**
- * Run the PolicyEngineException(String) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testPolicyEngineException_2()
- throws Exception {
- String message = "";
-
- PolicyEngineException result = new PolicyEngineException(message);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getCause());
- assertEquals("org.onap.policy.api.PolicyEngineException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Run the PolicyEngineException(Throwable) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testPolicyEngineException_3()
- throws Exception {
- Throwable cause = new Throwable();
-
- PolicyEngineException result = new PolicyEngineException(cause);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyEngineException: java.lang.Throwable", result.toString());
- assertEquals("java.lang.Throwable", result.getLocalizedMessage());
- assertEquals("java.lang.Throwable", result.getMessage());
- }
-
- /**
- * Run the PolicyEngineException(String,Throwable) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testPolicyEngineException_4()
- throws Exception {
- String message = "";
- Throwable cause = new Throwable();
-
- PolicyEngineException result = new PolicyEngineException(message, cause);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyEngineException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Run the PolicyEngineException(String,Throwable,boolean,boolean) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Test
- public void testPolicyEngineException_5()
- throws Exception {
- String message = "";
- Throwable cause = new Throwable();
- boolean enableSuppression = true;
- boolean writableStackTrace = true;
-
- PolicyEngineException result = new PolicyEngineException(message, cause, enableSuppression, writableStackTrace);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyEngineException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyEngineExceptionTest.class);
- }
+ /**
+ * Run the PolicyEngineException() constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testPolicyEngineException_1() throws Exception {
+
+ PolicyEngineException result = new PolicyEngineException();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getCause());
+ assertEquals("org.onap.policy.api.PolicyEngineException", result.toString());
+ assertEquals(null, result.getLocalizedMessage());
+ assertEquals(null, result.getMessage());
+ }
+
+ /**
+ * Run the PolicyEngineException(String) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testPolicyEngineException_2() throws Exception {
+ String message = "";
+
+ PolicyEngineException result = new PolicyEngineException(message);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getCause());
+ assertEquals("org.onap.policy.api.PolicyEngineException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyEngineException(Throwable) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testPolicyEngineException_3() throws Exception {
+ Throwable cause = new Throwable();
+
+ PolicyEngineException result = new PolicyEngineException(cause);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyEngineException: java.lang.Throwable",
+ result.toString());
+ assertEquals("java.lang.Throwable", result.getLocalizedMessage());
+ assertEquals("java.lang.Throwable", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyEngineException(String,Throwable) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testPolicyEngineException_4() throws Exception {
+ String message = "";
+ Throwable cause = new Throwable();
+
+ PolicyEngineException result = new PolicyEngineException(message, cause);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyEngineException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyEngineException(String,Throwable,boolean,boolean) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Test
+ public void testPolicyEngineException_5() throws Exception {
+ String message = "";
+ Throwable cause = new Throwable();
+ boolean enableSuppression = true;
+ boolean writableStackTrace = true;
+
+ PolicyEngineException result =
+ new PolicyEngineException(message, cause, enableSuppression, writableStackTrace);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyEngineException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyEngineExceptionTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineInterfaceTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineInterfaceTest.java
index 2adf3b0bf..9367e68ff 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineInterfaceTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEngineInterfaceTest.java
@@ -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.
@@ -26,11 +28,9 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
-
import org.mockito.Mockito;
import org.onap.policy.api.AttributeType;
import org.onap.policy.api.ConfigRequestParameters;
@@ -60,12 +60,11 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.std.StdPDPNotification;
import org.onap.policy.std.StdPolicyChangeResponse;
import org.onap.policy.std.StdPolicyResponse;
-
import junit.framework.TestCase;
/**
- * The class <code>PolicyEngineInterfaceTest</code> contains tests for the
- * class {@link <code>PolicyEngine</code>}
+ * The class <code>PolicyEngineInterfaceTest</code> contains tests for the class
+ * {@link <code>PolicyEngine</code>}
*
* @pattern JUnit Test Case
*
@@ -76,595 +75,635 @@ import junit.framework.TestCase;
*/
public class PolicyEngineInterfaceTest extends TestCase {
- private static final Logger logger = FlexLogger.getLogger(PolicyEngineInterfaceTest.class);
-
- private PolicyEngine policyEngine = null;
- private PolicyEngine mockPolicyEngine = null;
- private Collection<PolicyConfig> policyConfig = null;
- private UUID requestID = UUID.randomUUID();
-
-
- PolicyChangeResponse result = null;
- StdPolicyChangeResponse response = new StdPolicyChangeResponse();
-
-
- /**
- * Construct new test instance
- *
- * @param name the test name
- */
- public PolicyEngineInterfaceTest(String name) {
- super(name);
- }
-
- /**
- * Perform pre-test initialization
- *
- * @throws Exception
- *
- * @see TestCase#setUp()
- */
- public void setUp() throws Exception {
- try {
- policyEngine = new PolicyEngine("Test/config_pass.properties");
- } catch (PolicyEngineException e) {
- logger.error(e.getMessage());
- fail("PolicyEngine Instantiation Error" + e);
- }
- logger.info("Loaded.. PolicyEngine");
-
- mockPolicyEngine = Mockito.mock(PolicyEngine.class);
- HttpURLConnection conn = Mockito.mock(HttpURLConnection.class);
- Mockito.when(conn.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK);
-
- }
-
- /**
- * Perform post-test clean up
- *
- * @throws Exception
- *
- * @see TestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- // Add additional tear down code here
- }
-
- /**
- * Run the Collection<PolicyConfig> getConfigByPolicyName(String) method
- * test
- */
- @SuppressWarnings("deprecation")
- public void testGetConfigByPolicyName() {
- String policyName = null;
- try{
- policyConfig = policyEngine.getConfigByPolicyName(policyName);
- } catch (PolicyConfigException e){
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- @SuppressWarnings("deprecation")
- public void testGetConfigByPolicyName2() {
- String policyName = null;
-
- try{
- policyConfig = policyEngine.getConfigByPolicyName(policyName, requestID);
- } catch (PolicyConfigException e){
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- /**
- * Run the Collection<PolicyConfig> getConfig(String) method test
- */
- @SuppressWarnings("deprecation")
- public void testGetConfig() {
- String onapName = null;
-
- try{
- policyConfig = policyEngine.getConfig(onapName);
- } catch (PolicyConfigException e){
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- @SuppressWarnings("deprecation")
- public void testGetConfig2() {
- String onapName = null;
-
- try{
- policyConfig = policyEngine.getConfig(onapName,requestID);
- } catch (PolicyConfigException e){
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
-
- @SuppressWarnings("deprecation")
- public void testGetConfig3() {
- String onapName = null;
- String configName = null;
-
- try{
- policyConfig = policyEngine.getConfig(onapName,configName,requestID);
- } catch (PolicyConfigException e){
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- @SuppressWarnings("deprecation")
- public void testGetConfig4() {
- String onapName = null;
- String configName = null;
- Map<String,String> configAttributes = null;
-
- try{
- policyConfig = policyEngine.getConfig(onapName,configName,configAttributes);
- } catch (PolicyConfigException e){
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- @SuppressWarnings("deprecation")
- public void testGetConfig5() {
- String onapName = null;
- String configName = null;
- Map<String,String> configAttributes = null;
-
- try{
- policyConfig = policyEngine.getConfig(onapName,configName,configAttributes,requestID);
- } catch (PolicyConfigException e){
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
- public void testGetConfig6() {
- ConfigRequestParameters parameters = new ConfigRequestParameters();
-
- try{
- policyConfig = policyEngine.getConfig(parameters);
- } catch (PolicyConfigException e){
- logger.warn(e.getMessage());
- }
- assertNull(policyConfig);
- }
-
-
- /**
- * Run the Collection<PolicyResponse> sendEvent(Map<String,String>) method
- * test
- */
- @SuppressWarnings("deprecation")
- public void testSendEvent()
- {
- Collection<PolicyResponse> result = null;
- Collection<StdPolicyResponse> response = null;
- Map<String,String> eventAttributes = null;
-
- try {
- Mockito.when(mockPolicyEngine.sendEvent(eventAttributes)).thenReturn(result);
- result = mockPolicyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.error("Exception Occured"+e);
- }
-
-
- assertEquals(result,response);
-
- }
-
- @SuppressWarnings("deprecation")
- public void testSendEvent2()
- {
- Collection<PolicyResponse> result = null;
- Collection<StdPolicyResponse> response = null;
- Map<String,String> eventAttributes = null;
-
- try {
- Mockito.when(mockPolicyEngine.sendEvent(eventAttributes,requestID)).thenReturn(result);
- result = mockPolicyEngine.sendEvent(eventAttributes,requestID);
- } catch (PolicyEventException e) {
- logger.error("Exception Occured"+e);
- }
-
-
- assertEquals(result,response);
-
- }
-
- public void testSendEvent3()
- {
- Collection<PolicyResponse> result = null;
- Collection<StdPolicyResponse> response = null;
- EventRequestParameters parameters = new EventRequestParameters();
-
- try {
- Mockito.when(mockPolicyEngine.sendEvent(parameters)).thenReturn(result);
- result = mockPolicyEngine.sendEvent(parameters);
- } catch (PolicyEventException e) {
- logger.error("Exception Occured"+e);
- }
-
- assertEquals(result,response);
-
- }
-
-
-
- /**
- * Run the PolicyDecision getDecision(String, Map<String,String>) method
- * test
- */
- @SuppressWarnings("deprecation")
- public void testGetDecision()
- {
- String onapComponentName = null;
- Map<String,String> decisionAttributes = null;
-
- DecisionResponse result = null;
-
- try {
- Mockito.when(mockPolicyEngine.getDecision(onapComponentName,decisionAttributes)).thenReturn(null);
- result = mockPolicyEngine.getDecision(onapComponentName,decisionAttributes);
- } catch (PolicyDecisionException e) {
- logger.error("Exception Occured"+e);
- }
-
- assertEquals(result,null);
- }
-
- @SuppressWarnings("deprecation")
- public void testGetDecision2()
- {
- String onapComponentName = null;
- Map<String,String> decisionAttributes = null;
-
- DecisionResponse result = null;
-
- try {
- Mockito.when(mockPolicyEngine.getDecision(onapComponentName,decisionAttributes,requestID)).thenReturn(null);
- result = mockPolicyEngine.getDecision(onapComponentName,decisionAttributes);
- } catch (PolicyDecisionException e) {
- logger.error("Exception Occured"+e);
- }
-
- assertEquals(result,null);
- }
-
- public void testGetDecision3()
- {
- DecisionRequestParameters parameters = new DecisionRequestParameters();
- DecisionResponse result = null;
-
- try {
- Mockito.when(mockPolicyEngine.getDecision(parameters)).thenReturn(null);
- result = mockPolicyEngine.getDecision(parameters);
- } catch (PolicyDecisionException e) {
- logger.error("Exception Occured"+e);
- }
-
- assertEquals(result,null);
- }
-
- /**
- * Run the void setNotification(NotificationScheme, NotificationHandler)
- * method test
- */
- public void testSetNotification() {
- // add test code here
-
- NotificationScheme scheme = null;
- NotificationHandler handler = null;
-
- Mockito.doNothing().when(mockPolicyEngine).setNotification(scheme, handler);
- mockPolicyEngine.setNotification(scheme, handler);
- //assertTrue(true);
- }
-
- /**
- * Run the void clearNotification() method test
- */
- public void testClearNotification() {
- // add test code here
-
- Mockito.doNothing().when(mockPolicyEngine).clearNotification();
- mockPolicyEngine.clearNotification();
- //assertTrue(true);
- }
-
- /**
- * Run the void setScheme(NotificationScheme) method test
- */
- public void testSetScheme() {
- NotificationScheme scheme = null;
-
- Mockito.doNothing().when(mockPolicyEngine).setScheme(scheme);
- mockPolicyEngine.setScheme(scheme);
- //assertTrue(true);
- }
-
- /**
- * Run the PDPNotification getNotification() method test
- */
- public void testGetNotification() {
- PDPNotification result = null;
- StdPDPNotification response = null;
- Mockito.when(mockPolicyEngine.getNotification()).thenReturn(response);
- result = mockPolicyEngine.getNotification();
-
- assertEquals(result,response);
- }
-
- /**
- * Run the String createConfigPolicy(String, String, String, String,
- * Map<String,String>, String, String, String, UUID) method test
- */
- @SuppressWarnings("deprecation")
- public void testCreateConfigPolicy()
- {
- String response = "success";
- String result = null;
- try {
-
- Mockito.when(mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response);
- result = mockPolicyEngine.createConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the String updateConfigPolicy(String, String, String, String,
- * Map<String,String>, String, String, String, UUID) method test
- */
- @SuppressWarnings("deprecation")
- public void testUpdateConfigPolicy()
- {
- String response = "success";
- String result = null;
- try {
-
- Mockito.when(mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null)).thenReturn(response);
- result = mockPolicyEngine.updateConfigPolicy("testPolicy","test","test","testConfig",null,"OTHER","test","test",null, null, null, null, null);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the String createConfigFirewallPolicy(String, JsonObject, String,
- * UUID) method test
- */
- @SuppressWarnings("deprecation")
- public void testCreateConfigFirewallPolicy() {
- String response = "success";
- String result = null;
- String json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\",\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\",\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\",\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\",\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\",\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,\"log\":true}]}";
- JsonObject jsonObj = buildJSON(json);
- try {
-
- Mockito.when(mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response);
- result = mockPolicyEngine.createConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the String updateConfigFirewallPolicy(String, JsonObject, String,
- * UUID) method test
- */
- @SuppressWarnings("deprecation")
- public void testUpdateConfigFirewallPolicy() {
- String response = "success";
- String result = null;
- String json = "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\",\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\",\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\",\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\",\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\",\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\",\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\",\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\",\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,\"log\":true}]}";
- JsonObject jsonObj = buildJSON(json);
- try {
-
- Mockito.when(mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null)).thenReturn(response);
- result = mockPolicyEngine.updateConfigFirewallPolicy("testPolicy",jsonObj, "test", null, null, null, null, null);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test
- */
- public void testCreatePolicy() {
- response.setResponseMessage("success");
- PolicyChangeResponse result = null;
- PolicyParameters policyParameters = new PolicyParameters();
-
- policyParameters.setPolicyClass(PolicyClass.Action); //required
- policyParameters.setPolicyName("test.junitTest"); //required
- policyParameters.setPolicyDescription("testing"); //optional
-
- //Set the Component Attributes... These are Optional
- Map<String, String> configAttributes = new HashMap<String, String>();
+ private static final Logger logger = FlexLogger.getLogger(PolicyEngineInterfaceTest.class);
+
+ private PolicyEngine policyEngine = null;
+ private PolicyEngine mockPolicyEngine = null;
+ private Collection<PolicyConfig> policyConfig = null;
+ private UUID requestID = UUID.randomUUID();
+
+
+ PolicyChangeResponse result = null;
+ StdPolicyChangeResponse response = new StdPolicyChangeResponse();
+
+
+ /**
+ * Construct new test instance
+ *
+ * @param name the test name
+ */
+ public PolicyEngineInterfaceTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Perform pre-test initialization
+ *
+ * @throws Exception
+ *
+ * @see TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+
+ mockPolicyEngine = Mockito.mock(PolicyEngine.class);
+ HttpURLConnection conn = Mockito.mock(HttpURLConnection.class);
+ Mockito.when(conn.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK);
+
+ }
+
+ /**
+ * Perform post-test clean up
+ *
+ * @throws Exception
+ *
+ * @see TestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ // Add additional tear down code here
+ }
+
+ /**
+ * Run the Collection<PolicyConfig> getConfigByPolicyName(String) method test
+ */
+ @SuppressWarnings("deprecation")
+ public void testGetConfigByPolicyName() {
+ String policyName = null;
+ try {
+ policyConfig = policyEngine.getConfigByPolicyName(policyName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testGetConfigByPolicyName2() {
+ String policyName = null;
+
+ try {
+ policyConfig = policyEngine.getConfigByPolicyName(policyName, requestID);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ /**
+ * Run the Collection<PolicyConfig> getConfig(String) method test
+ */
+ @SuppressWarnings("deprecation")
+ public void testGetConfig() {
+ String onapName = null;
+
+ try {
+ policyConfig = policyEngine.getConfig(onapName);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testGetConfig2() {
+ String onapName = null;
+
+ try {
+ policyConfig = policyEngine.getConfig(onapName, requestID);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+
+ @SuppressWarnings("deprecation")
+ public void testGetConfig3() {
+ String onapName = null;
+ String configName = null;
+
+ try {
+ policyConfig = policyEngine.getConfig(onapName, configName, requestID);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testGetConfig4() {
+ String onapName = null;
+ String configName = null;
+ Map<String, String> configAttributes = null;
+
+ try {
+ policyConfig = policyEngine.getConfig(onapName, configName, configAttributes);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testGetConfig5() {
+ String onapName = null;
+ String configName = null;
+ Map<String, String> configAttributes = null;
+
+ try {
+ policyConfig =
+ policyEngine.getConfig(onapName, configName, configAttributes, requestID);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+ public void testGetConfig6() {
+ ConfigRequestParameters parameters = new ConfigRequestParameters();
+
+ try {
+ policyConfig = policyEngine.getConfig(parameters);
+ } catch (PolicyConfigException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyConfig);
+ }
+
+
+ /**
+ * Run the Collection<PolicyResponse> sendEvent(Map<String,String>) method test
+ */
+ @SuppressWarnings("deprecation")
+ public void testSendEvent() {
+ Collection<PolicyResponse> result = null;
+ Collection<StdPolicyResponse> response = null;
+ Map<String, String> eventAttributes = null;
+
+ try {
+ Mockito.when(mockPolicyEngine.sendEvent(eventAttributes)).thenReturn(result);
+ result = mockPolicyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.error("Exception Occured" + e);
+ }
+
+
+ assertEquals(result, response);
+
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testSendEvent2() {
+ Collection<PolicyResponse> result = null;
+ Collection<StdPolicyResponse> response = null;
+ Map<String, String> eventAttributes = null;
+
+ try {
+ Mockito.when(mockPolicyEngine.sendEvent(eventAttributes, requestID)).thenReturn(result);
+ result = mockPolicyEngine.sendEvent(eventAttributes, requestID);
+ } catch (PolicyEventException e) {
+ logger.error("Exception Occured" + e);
+ }
+
+
+ assertEquals(result, response);
+
+ }
+
+ public void testSendEvent3() {
+ Collection<PolicyResponse> result = null;
+ Collection<StdPolicyResponse> response = null;
+ EventRequestParameters parameters = new EventRequestParameters();
+
+ try {
+ Mockito.when(mockPolicyEngine.sendEvent(parameters)).thenReturn(result);
+ result = mockPolicyEngine.sendEvent(parameters);
+ } catch (PolicyEventException e) {
+ logger.error("Exception Occured" + e);
+ }
+
+ assertEquals(result, response);
+
+ }
+
+
+
+ /**
+ * Run the PolicyDecision getDecision(String, Map<String,String>) method test
+ */
+ @SuppressWarnings("deprecation")
+ public void testGetDecision() {
+ String onapComponentName = null;
+ Map<String, String> decisionAttributes = null;
+
+ DecisionResponse result = null;
+
+ try {
+ Mockito.when(mockPolicyEngine.getDecision(onapComponentName, decisionAttributes))
+ .thenReturn(null);
+ result = mockPolicyEngine.getDecision(onapComponentName, decisionAttributes);
+ } catch (PolicyDecisionException e) {
+ logger.error("Exception Occured" + e);
+ }
+
+ assertEquals(result, null);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testGetDecision2() {
+ String onapComponentName = null;
+ Map<String, String> decisionAttributes = null;
+
+ DecisionResponse result = null;
+
+ try {
+ Mockito.when(
+ mockPolicyEngine.getDecision(onapComponentName, decisionAttributes, requestID))
+ .thenReturn(null);
+ result = mockPolicyEngine.getDecision(onapComponentName, decisionAttributes);
+ } catch (PolicyDecisionException e) {
+ logger.error("Exception Occured" + e);
+ }
+
+ assertEquals(result, null);
+ }
+
+ public void testGetDecision3() {
+ DecisionRequestParameters parameters = new DecisionRequestParameters();
+ DecisionResponse result = null;
+
+ try {
+ Mockito.when(mockPolicyEngine.getDecision(parameters)).thenReturn(null);
+ result = mockPolicyEngine.getDecision(parameters);
+ } catch (PolicyDecisionException e) {
+ logger.error("Exception Occured" + e);
+ }
+
+ assertEquals(result, null);
+ }
+
+ /**
+ * Run the void setNotification(NotificationScheme, NotificationHandler) method test
+ */
+ public void testSetNotification() {
+ // add test code here
+
+ NotificationScheme scheme = null;
+ NotificationHandler handler = null;
+
+ Mockito.doNothing().when(mockPolicyEngine).setNotification(scheme, handler);
+ mockPolicyEngine.setNotification(scheme, handler);
+ // assertTrue(true);
+ }
+
+ /**
+ * Run the void clearNotification() method test
+ */
+ public void testClearNotification() {
+ // add test code here
+
+ Mockito.doNothing().when(mockPolicyEngine).clearNotification();
+ mockPolicyEngine.clearNotification();
+ // assertTrue(true);
+ }
+
+ /**
+ * Run the void setScheme(NotificationScheme) method test
+ */
+ public void testSetScheme() {
+ NotificationScheme scheme = null;
+
+ Mockito.doNothing().when(mockPolicyEngine).setScheme(scheme);
+ mockPolicyEngine.setScheme(scheme);
+ // assertTrue(true);
+ }
+
+ /**
+ * Run the PDPNotification getNotification() method test
+ */
+ public void testGetNotification() {
+ PDPNotification result = null;
+ StdPDPNotification response = null;
+ Mockito.when(mockPolicyEngine.getNotification()).thenReturn(response);
+ result = mockPolicyEngine.getNotification();
+
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the String createConfigPolicy(String, String, String, String, Map<String,String>, String,
+ * String, String, UUID) method test
+ */
+ @SuppressWarnings("deprecation")
+ public void testCreateConfigPolicy() {
+ String response = "success";
+ String result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.createConfigPolicy("testPolicy", "test", "test",
+ "testConfig", null, "OTHER", "test", "test", null, null, null, null, null))
+ .thenReturn(response);
+ result = mockPolicyEngine.createConfigPolicy("testPolicy", "test", "test", "testConfig",
+ null, "OTHER", "test", "test", null, null, null, null, null);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the String updateConfigPolicy(String, String, String, String, Map<String,String>, String,
+ * String, String, UUID) method test
+ */
+ @SuppressWarnings("deprecation")
+ public void testUpdateConfigPolicy() {
+ String response = "success";
+ String result = null;
+ try {
+
+ Mockito.when(mockPolicyEngine.updateConfigPolicy("testPolicy", "test", "test",
+ "testConfig", null, "OTHER", "test", "test", null, null, null, null, null))
+ .thenReturn(response);
+ result = mockPolicyEngine.updateConfigPolicy("testPolicy", "test", "test", "testConfig",
+ null, "OTHER", "test", "test", null, null, null, null, null);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the String createConfigFirewallPolicy(String, JsonObject, String, UUID) method test
+ */
+ @SuppressWarnings("deprecation")
+ public void testCreateConfigFirewallPolicy() {
+ String response = "success";
+ String result = null;
+ String json =
+ "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":"
+ + "{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":"
+ + "[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\","
+ + "\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\","
+ + "\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\","
+ + "\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\","
+ + "\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\","
+ + "\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\","
+ + "\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},"
+ + "{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\","
+ + "\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\","
+ + "\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\","
+ + "\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],"
+ + "\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\","
+ + "\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],"
+ + "\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],"
+ + "\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],"
+ + "\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,"
+ + "\"log\":true}]}";
+ JsonObject jsonObj = buildJSON(json);
+ try {
+
+ Mockito.when(mockPolicyEngine.createConfigFirewallPolicy("testPolicy", jsonObj, "test",
+ null, null, null, null, null)).thenReturn(response);
+ result = mockPolicyEngine.createConfigFirewallPolicy("testPolicy", jsonObj, "test",
+ null, null, null, null, null);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the String updateConfigFirewallPolicy(String, JsonObject, String, UUID) method test
+ */
+ @SuppressWarnings("deprecation")
+ public void testUpdateConfigFirewallPolicy() {
+ String response = "success";
+ String result = null;
+ String json =
+ "{\"serviceTypeId\":\"/v0/firewall/pan\",\"configName\":\"rule1607\",\"deploymentOption\":"
+ + "{\"deployNow\":false},\"securityZoneId\":\"/v0/firewall/pan\",\"serviceGroups\":"
+ + "[{\"name\":\"1607Group\",\"description\":null,\"members\":[{\"type\":\"REFERENCE\","
+ + "\"name\":\"SList\"},{\"type\":\"REFERENCE\",\"name\":\"Syslog\"}]},{\"name\":\"Syslog\","
+ + "\"description\":\"NA\",\"type\":\"SERVICE\",\"transportProtocol\":\"udp\","
+ + "\"appProtocol\":null,\"ports\":\"514\"},{\"name\":\"SList\","
+ + "\"description\":\"Service List\",\"type\":\"SERVICE\",\"transportProtocol\":\"tcp\","
+ + "\"appProtocol\":null,\"ports\":\"8080\"}],\"addressGroups\":[{\"name\":\"1607Group\","
+ + "\"description\":null,\"members\":[{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"},"
+ + "{\"type\":\"SUBNET\",\"value\":\"10.11.12.13/14\"}]},{\"name\":\"PL_CCE3\","
+ + "\"description\":\"CCE Routers\",\"members\":[{\"type\":\"SUBNET\","
+ + "\"value\":\"10.11.12.13/14\"}]}],\"firewallRuleList\":[{\"position\":\"1\","
+ + "\"ruleName\":\"1607Rule\",\"fromZones\":[\"Trusted\"],\"toZones\":[\"Untrusted\"],"
+ + "\"negateSource\":false,\"negateDestination\":false,\"sourceList\":[{\"type\":\"REFERENCE\","
+ + "\"value\":\"PL_CCE3\"},{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],"
+ + "\"destinationList\":[{\"type\":\"REFERENCE\",\"value\":\"1607Group\"}],"
+ + "\"sourceServices\":[],\"destServices\":[{\"type\":\"REFERENCE\",\"name\":\"1607Group\"}],"
+ + "\"action\":\"accept\",\"description\":\"Rule for 1607 templates\",\"enabled\":true,"
+ + "\"log\":true}]}";
+ JsonObject jsonObj = buildJSON(json);
+ try {
+
+ Mockito.when(mockPolicyEngine.updateConfigFirewallPolicy("testPolicy", jsonObj, "test",
+ null, null, null, null, null)).thenReturn(response);
+ result = mockPolicyEngine.updateConfigFirewallPolicy("testPolicy", jsonObj, "test",
+ null, null, null, null, null);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the PolicyChangeResponse createPolicy(PolicyParameters) method test
+ */
+ public void testCreatePolicy() {
+ response.setResponseMessage("success");
+ PolicyChangeResponse result = null;
+ PolicyParameters policyParameters = new PolicyParameters();
+
+ policyParameters.setPolicyClass(PolicyClass.Action); // required
+ policyParameters.setPolicyName("test.junitTest"); // required
+ policyParameters.setPolicyDescription("testing"); // optional
+
+ // Set the Component Attributes... These are Optional
+ Map<String, String> configAttributes = new HashMap<String, String>();
configAttributes.put("test", "testing");
-
- Map<AttributeType, Map<String,String>> attributes = new HashMap<AttributeType, Map<String,String>>();
+
+ Map<AttributeType, Map<String, String>> attributes =
+ new HashMap<AttributeType, Map<String, String>>();
attributes.put(AttributeType.MATCHING, configAttributes);
policyParameters.setAttributes(attributes);
-
+
policyParameters.setActionPerformer("PEP");
policyParameters.setActionAttribute("testing");
policyParameters.setRequestID(UUID.randomUUID());
-
- try {
-
- //stdPolicyEngine = Mockito.mock(StdPolicyEngine.class);
- //Mockito.when(stdPolicyEngine.callPAP(newPAPPolicy, new String[] {"operation=create", "apiflag=api", "policyType=Action"}, null, "Action")).thenReturn(callPapResponse);
- Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.createPolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- logger.error("Exception Occured"+e);
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test
- */
- public void testUpdatePolicy() {
- response.setResponseMessage("success");
- PolicyChangeResponse result = null;
- PolicyParameters policyParameters = new PolicyParameters();
-
- policyParameters.setPolicyClass(PolicyClass.Action); //required
- policyParameters.setPolicyName("test.junitTest"); //required
- policyParameters.setPolicyDescription("testing"); //optional
-
- //Set the Component Attributes... These are Optional
- Map<String, String> configAttributes = new HashMap<String, String>();
+
+ try {
+
+ // stdPolicyEngine = Mockito.mock(StdPolicyEngine.class);
+ // Mockito.when(stdPolicyEngine.callPAP(newPAPPolicy, new String[] {"operation=create",
+ // "apiflag=api", "policyType=Action"}, null, "Action")).thenReturn(callPapResponse);
+ Mockito.when(mockPolicyEngine.createPolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.createPolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ logger.error("Exception Occured" + e);
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the PolicyChangeResponse updatePolicy(PolicyParameters) method test
+ */
+ public void testUpdatePolicy() {
+ response.setResponseMessage("success");
+ PolicyChangeResponse result = null;
+ PolicyParameters policyParameters = new PolicyParameters();
+
+ policyParameters.setPolicyClass(PolicyClass.Action); // required
+ policyParameters.setPolicyName("test.junitTest"); // required
+ policyParameters.setPolicyDescription("testing"); // optional
+
+ // Set the Component Attributes... These are Optional
+ Map<String, String> configAttributes = new HashMap<String, String>();
configAttributes.put("test", "testing");
-
- Map<AttributeType, Map<String,String>> attributes = new HashMap<AttributeType, Map<String,String>>();
+
+ Map<AttributeType, Map<String, String>> attributes =
+ new HashMap<AttributeType, Map<String, String>>();
attributes.put(AttributeType.MATCHING, configAttributes);
policyParameters.setAttributes(attributes);
-
+
policyParameters.setActionPerformer("PEP");
policyParameters.setActionAttribute("testing");
policyParameters.setRequestID(UUID.randomUUID());
-
- try {
-
- Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.updatePolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- assertEquals(result, response);
- }
-
- /**
- * Run the String pushPolicy(String, String, String, String, UUID) method
- * test
- */
- @SuppressWarnings("deprecation")
- public void testPushPolicy() {
- String response = "Success";
- String result = null;
- try {
-
- Mockito.when(mockPolicyEngine.pushPolicy("testing","test","Base","default",requestID)).thenReturn(response);
- result = mockPolicyEngine.pushPolicy("testing","test","Base","default",requestID);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
-
- assertEquals(result, response);
- }
-
- public void testPushPolicy2() {
- PushPolicyParameters policyParameters = new PushPolicyParameters();
- PolicyChangeResponse result = null;
-
- //String policyScope = null;
- policyParameters.setPolicyName("test.junitTest");
- policyParameters.setPolicyType("Action");
- policyParameters.setPdpGroup("Default");
-
- try {
-
- Mockito.when(mockPolicyEngine.pushPolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.pushPolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
-
- assertEquals(result, response);
- }
-
- /**
- * Run the PolicyChangeResponse deletePolicy(DeletePolicyParameters) method
- * test
- */
- public void testDeletePolicy() {
- DeletePolicyParameters policyParameters = new DeletePolicyParameters();
- PolicyChangeResponse result = null;
-
- //String policyScope = null;
- policyParameters.setPolicyName("test.junitTest.1.xml");
- policyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
- policyParameters.setPolicyComponent("PAP");
- policyParameters.setPdpGroup("Default");
-
- try {
-
- Mockito.when(mockPolicyEngine.deletePolicy(policyParameters)).thenReturn(response);
- result = mockPolicyEngine.deletePolicy(policyParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
-
- assertEquals(result, response);
- }
-
- /**
- * Run the PolicyChangeResponse policyEngineImport(ImportParameters) method
- * test
- */
- public void testPolicyEngineImport() {
- ImportParameters importParameters = new ImportParameters();
- PolicyChangeResponse result = null;
-
- importParameters.setFilePath("C:\\Workspaces\\models\\TestingModel\\ControllerServiceSampleSdnlServiceInstance-v0.1.0-SNAPSHOT.zip");
+
+ try {
+
+ Mockito.when(mockPolicyEngine.updatePolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.updatePolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the String pushPolicy(String, String, String, String, UUID) method test
+ */
+ @SuppressWarnings("deprecation")
+ public void testPushPolicy() {
+ String response = "Success";
+ String result = null;
+ try {
+
+ Mockito.when(
+ mockPolicyEngine.pushPolicy("testing", "test", "Base", "default", requestID))
+ .thenReturn(response);
+ result = mockPolicyEngine.pushPolicy("testing", "test", "Base", "default", requestID);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+
+ assertEquals(result, response);
+ }
+
+ public void testPushPolicy2() {
+ PushPolicyParameters policyParameters = new PushPolicyParameters();
+ PolicyChangeResponse result = null;
+
+ // String policyScope = null;
+ policyParameters.setPolicyName("test.junitTest");
+ policyParameters.setPolicyType("Action");
+ policyParameters.setPdpGroup("Default");
+
+ try {
+
+ Mockito.when(mockPolicyEngine.pushPolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.pushPolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the PolicyChangeResponse deletePolicy(DeletePolicyParameters) method test
+ */
+ public void testDeletePolicy() {
+ DeletePolicyParameters policyParameters = new DeletePolicyParameters();
+ PolicyChangeResponse result = null;
+
+ // String policyScope = null;
+ policyParameters.setPolicyName("test.junitTest.1.xml");
+ policyParameters.setDeleteCondition(DeletePolicyCondition.ALL);
+ policyParameters.setPolicyComponent("PAP");
+ policyParameters.setPdpGroup("Default");
+
+ try {
+
+ Mockito.when(mockPolicyEngine.deletePolicy(policyParameters)).thenReturn(response);
+ result = mockPolicyEngine.deletePolicy(policyParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+
+ assertEquals(result, response);
+ }
+
+ /**
+ * Run the PolicyChangeResponse policyEngineImport(ImportParameters) method test
+ */
+ public void testPolicyEngineImport() {
+ ImportParameters importParameters = new ImportParameters();
+ PolicyChangeResponse result = null;
+
+ importParameters.setFilePath(
+ "C:\\Workspaces\\models\\TestingModel\\ControllerServiceSampleSdnlServiceInstance-v0.1.0-SNAPSHOT.zip");
importParameters.setServiceName("ControllerServiceSampleSdnlServiceInstance");
-
+
importParameters.setRequestID(UUID.randomUUID());
importParameters.setServiceType(IMPORT_TYPE.MICROSERVICE);
importParameters.setVersion("1607-2");
-
- try {
-
- Mockito.when(mockPolicyEngine.policyEngineImport(importParameters)).thenReturn(response);
- result = mockPolicyEngine.policyEngineImport(importParameters);
-
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
-
- assertEquals(result, response);
- }
-
+ try {
+
+ Mockito.when(mockPolicyEngine.policyEngineImport(importParameters))
+ .thenReturn(response);
+ result = mockPolicyEngine.policyEngineImport(importParameters);
+
+ } catch (Exception e) {
+ logger.warn(e.getMessage());
+ }
+
+ assertEquals(result, response);
+ }
+
private static JsonObject buildJSON(String jsonString) {
JsonObject json = null;;
if (jsonString != null) {
StringReader in = null;
-
+
in = new StringReader(jsonString);
-
+
JsonReader jsonReader = Json.createReader(in);
- json = jsonReader.readObject();
- }
-
+ json = jsonReader.readObject();
+ }
return json;
}
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEventExceptionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEventExceptionTest.java
index 6f7573352..a78df1aa7 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEventExceptionTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyEventExceptionTest.java
@@ -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.
@@ -22,162 +24,155 @@ package org.onap.policy.test;
import org.junit.*;
import org.onap.policy.api.PolicyEventException;
-
import static org.junit.Assert.*;
/**
- * The class <code>PolicyEventExceptionTest</code> contains tests for the class <code>{@link PolicyEventException}</code>.
+ * The class <code>PolicyEventExceptionTest</code> contains tests for the class
+ * <code>{@link PolicyEventException}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class PolicyEventExceptionTest {
- /**
- * Run the PolicyEventException() constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyEventException_1()
- throws Exception {
-
- PolicyEventException result = new PolicyEventException();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getCause());
- assertEquals("org.onap.policy.api.PolicyEventException", result.toString());
- assertEquals(null, result.getLocalizedMessage());
- assertEquals(null, result.getMessage());
- }
-
- /**
- * Run the PolicyEventException(String) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyEventException_2()
- throws Exception {
- String message = "";
-
- PolicyEventException result = new PolicyEventException(message);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getCause());
- assertEquals("org.onap.policy.api.PolicyEventException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Run the PolicyEventException(Throwable) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyEventException_3()
- throws Exception {
- Throwable cause = new Throwable();
-
- PolicyEventException result = new PolicyEventException(cause);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyEventException: java.lang.Throwable", result.toString());
- assertEquals("java.lang.Throwable", result.getLocalizedMessage());
- assertEquals("java.lang.Throwable", result.getMessage());
- }
-
- /**
- * Run the PolicyEventException(String,Throwable) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyEventException_4()
- throws Exception {
- String message = "";
- Throwable cause = new Throwable();
-
- PolicyEventException result = new PolicyEventException(message, cause);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyEventException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Run the PolicyEventException(String,Throwable,boolean,boolean) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPolicyEventException_5()
- throws Exception {
- String message = "";
- Throwable cause = new Throwable();
- boolean enableSuppression = true;
- boolean writableStackTrace = true;
-
- PolicyEventException result = new PolicyEventException(message, cause, enableSuppression, writableStackTrace);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyEventException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyEventExceptionTest.class);
- }
+ /**
+ * Run the PolicyEventException() constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyEventException_1() throws Exception {
+
+ PolicyEventException result = new PolicyEventException();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getCause());
+ assertEquals("org.onap.policy.api.PolicyEventException", result.toString());
+ assertEquals(null, result.getLocalizedMessage());
+ assertEquals(null, result.getMessage());
+ }
+
+ /**
+ * Run the PolicyEventException(String) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyEventException_2() throws Exception {
+ String message = "";
+
+ PolicyEventException result = new PolicyEventException(message);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getCause());
+ assertEquals("org.onap.policy.api.PolicyEventException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyEventException(Throwable) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyEventException_3() throws Exception {
+ Throwable cause = new Throwable();
+
+ PolicyEventException result = new PolicyEventException(cause);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyEventException: java.lang.Throwable",
+ result.toString());
+ assertEquals("java.lang.Throwable", result.getLocalizedMessage());
+ assertEquals("java.lang.Throwable", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyEventException(String,Throwable) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyEventException_4() throws Exception {
+ String message = "";
+ Throwable cause = new Throwable();
+
+ PolicyEventException result = new PolicyEventException(message, cause);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyEventException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Run the PolicyEventException(String,Throwable,boolean,boolean) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPolicyEventException_5() throws Exception {
+ String message = "";
+ Throwable cause = new Throwable();
+ boolean enableSuppression = true;
+ boolean writableStackTrace = true;
+
+ PolicyEventException result =
+ new PolicyEventException(message, cause, enableSuppression, writableStackTrace);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyEventException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyEventExceptionTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyExceptionTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyExceptionTest.java
index f925edbfa..f85572c61 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyExceptionTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyExceptionTest.java
@@ -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.
@@ -21,72 +23,69 @@ package org.onap.policy.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import org.junit.Test;
import org.onap.policy.api.PolicyException;
public class PolicyExceptionTest {
- @Test
- public void test1() {
- PolicyException result = new PolicyException();
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getCause());
- assertEquals("org.onap.policy.api.PolicyException", result.toString());
- assertEquals(null, result.getLocalizedMessage());
- assertEquals(null, result.getMessage());
- }
+ @Test
+ public void test1() {
+ PolicyException result = new PolicyException();
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getCause());
+ assertEquals("org.onap.policy.api.PolicyException", result.toString());
+ assertEquals(null, result.getLocalizedMessage());
+ assertEquals(null, result.getMessage());
+ }
+
+ @Test
+ public void test2() {
+ String message = "message";
+ PolicyException result = new PolicyException(message);
+ assertNotNull(result);
+ assertEquals(null, result.getCause());
+ assertEquals("org.onap.policy.api.PolicyException: " + message, result.toString());
+ assertEquals(message, result.getLocalizedMessage());
+ assertEquals(message, result.getMessage());
- @Test
- public void test2() {
- String message = "message";
- PolicyException result = new PolicyException(message);
- assertNotNull(result);
- assertEquals(null, result.getCause());
- assertEquals("org.onap.policy.api.PolicyException: " + message, result.toString());
- assertEquals(message, result.getLocalizedMessage());
- assertEquals(message, result.getMessage());
-
- }
+ }
- @Test
- public void test3() {
- Throwable cause = new Throwable();
- PolicyException result = new PolicyException(cause);
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyException: java.lang.Throwable", result.toString());
- assertEquals("java.lang.Throwable", result.getLocalizedMessage());
- assertEquals("java.lang.Throwable", result.getMessage());
- }
+ @Test
+ public void test3() {
+ Throwable cause = new Throwable();
+ PolicyException result = new PolicyException(cause);
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyException: java.lang.Throwable", result.toString());
+ assertEquals("java.lang.Throwable", result.getLocalizedMessage());
+ assertEquals("java.lang.Throwable", result.getMessage());
+ }
- @Test
- public void test4() {
- String message = "";
- Throwable cause = new Throwable();
- PolicyException result = new PolicyException(message, cause);
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
-
- @Test
- public void test5()
- throws Exception {
- String message = "";
- Throwable cause = new Throwable();
- boolean enableSuppression = true;
- boolean writableStackTrace = true;
+ @Test
+ public void test4() {
+ String message = "";
+ Throwable cause = new Throwable();
+ PolicyException result = new PolicyException(message, cause);
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
- PolicyException result = new PolicyException(message, cause, enableSuppression, writableStackTrace);
+ @Test
+ public void test5() throws Exception {
+ String message = "";
+ Throwable cause = new Throwable();
+ boolean enableSuppression = true;
+ boolean writableStackTrace = true;
- // add additional test code here
- assertNotNull(result);
- assertEquals("org.onap.policy.api.PolicyException: ", result.toString());
- assertEquals("", result.getLocalizedMessage());
- assertEquals("", result.getMessage());
- }
+ PolicyException result =
+ new PolicyException(message, cause, enableSuppression, writableStackTrace);
-
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("org.onap.policy.api.PolicyException: ", result.toString());
+ assertEquals("", result.getLocalizedMessage());
+ assertEquals("", result.getMessage());
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseTest.java
index b0a71d375..93035435a 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PolicyResponseTest.java
@@ -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.
@@ -25,48 +27,45 @@ import org.junit.Before;
import org.onap.policy.api.PolicyResponse;
/**
- * The class <code>PolicyResponseTest</code> contains tests for the class <code>{@link PolicyResponse}</code>.
+ * The class <code>PolicyResponseTest</code> contains tests for the class
+ * <code>{@link PolicyResponse}</code>.
*
* @generatedBy CodePro at 6/1/16 1:41 PM
* @version $Revision: 1.0 $
*/
public class PolicyResponseTest {
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:41 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PolicyResponseTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:41 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PolicyResponseTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PushPolicyParametersTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PushPolicyParametersTest.java
index 832589757..c4356fd4c 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/PushPolicyParametersTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/PushPolicyParametersTest.java
@@ -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,249 +23,236 @@
package org.onap.policy.test;
import java.util.UUID;
-
import org.junit.*;
import org.onap.policy.api.PushPolicyParameters;
-
import static org.junit.Assert.*;
/**
- * The class <code>PushPolicyParametersTest</code> contains tests for the class <code>{@link PushPolicyParameters}</code>.
+ * The class <code>PushPolicyParametersTest</code> contains tests for the class
+ * <code>{@link PushPolicyParameters}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class PushPolicyParametersTest {
- /**
- * Run the PushPolicyParameters() constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPushPolicyParameters_1()
- throws Exception {
-
- PushPolicyParameters result = new PushPolicyParameters();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals(null, result.getPolicyName());
- assertEquals(null, result.getRequestID());
- assertEquals(null, result.getPolicyType());
- assertEquals(null, result.getPdpGroup());
- }
-
- /**
- * Run the PushPolicyParameters(String,String,String,UUID) constructor test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testPushPolicyParameters_2()
- throws Exception {
- String policyName = "";
- String policyType = "";
- String pdpGroup = "";
- UUID requestID = UUID.randomUUID();
-
- PushPolicyParameters result = new PushPolicyParameters(policyName, policyType, pdpGroup, requestID);
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("", result.getPolicyName());
- assertEquals("", result.getPolicyType());
- assertEquals("", result.getPdpGroup());
- }
-
- /**
- * Run the String getPdpGroup() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPdpGroup_1()
- throws Exception {
- PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
-
- String result = fixture.getPdpGroup();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyName() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyName_1()
- throws Exception {
- PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
-
- String result = fixture.getPolicyName();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the String getPolicyType() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetPolicyType_1()
- throws Exception {
- PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
-
- String result = fixture.getPolicyType();
-
- // add additional test code here
- assertEquals("", result);
- }
-
- /**
- * Run the UUID getRequestID() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testGetRequestID()
- throws Exception {
- PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.fromString("d1dbaac1-0944-4f07-9ce7-733c697537ea"));
-
- UUID result = fixture.getRequestID();
-
- // add additional test code here
- assertNotNull(result);
- assertEquals("d1dbaac1-0944-4f07-9ce7-733c697537ea", result.toString());
- assertEquals(4, result.version());
- assertEquals(2, result.variant());
- assertEquals(-7140611980868110358L, result.getLeastSignificantBits());
- assertEquals(-3324876153822097657L, result.getMostSignificantBits());
- }
-
- /**
- * Run the void setPdpGroup(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPdpGroup_1()
- throws Exception {
- PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
- String pdpGroup = "";
-
- fixture.setPdpGroup(pdpGroup);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyName(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyName_1()
- throws Exception {
- PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
- String policyName = "";
-
- fixture.setPolicyName(policyName);
-
- // add additional test code here
- }
-
- /**
- * Run the void setPolicyType(String) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetPolicyType_1()
- throws Exception {
- PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
- String policyType = "";
-
- fixture.setPolicyType(policyType);
-
- // add additional test code here
- }
-
- /**
- * Run the void setRequestID(UUID) method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Test
- public void testSetRequestID_1()
- throws Exception {
- PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
- UUID requestID = UUID.randomUUID();
-
- fixture.setRequestID(requestID);
-
- // add additional test code here
- }
-
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
-
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
-
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(PushPolicyParametersTest.class);
- }
+ /**
+ * Run the PushPolicyParameters() constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPushPolicyParameters_1() throws Exception {
+
+ PushPolicyParameters result = new PushPolicyParameters();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals(null, result.getPolicyName());
+ assertEquals(null, result.getRequestID());
+ assertEquals(null, result.getPolicyType());
+ assertEquals(null, result.getPdpGroup());
+ }
+
+ /**
+ * Run the PushPolicyParameters(String,String,String,UUID) constructor test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testPushPolicyParameters_2() throws Exception {
+ String policyName = "";
+ String policyType = "";
+ String pdpGroup = "";
+ UUID requestID = UUID.randomUUID();
+
+ PushPolicyParameters result =
+ new PushPolicyParameters(policyName, policyType, pdpGroup, requestID);
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("", result.getPolicyName());
+ assertEquals("", result.getPolicyType());
+ assertEquals("", result.getPdpGroup());
+ }
+
+ /**
+ * Run the String getPdpGroup() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPdpGroup_1() throws Exception {
+ PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
+
+ String result = fixture.getPdpGroup();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getPolicyName() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyName_1() throws Exception {
+ PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
+
+ String result = fixture.getPolicyName();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the String getPolicyType() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetPolicyType_1() throws Exception {
+ PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
+
+ String result = fixture.getPolicyType();
+
+ // add additional test code here
+ assertEquals("", result);
+ }
+
+ /**
+ * Run the UUID getRequestID() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testGetRequestID() throws Exception {
+ PushPolicyParameters fixture = new PushPolicyParameters("", "", "",
+ UUID.fromString("d1dbaac1-0944-4f07-9ce7-733c697537ea"));
+
+ UUID result = fixture.getRequestID();
+
+ // add additional test code here
+ assertNotNull(result);
+ assertEquals("d1dbaac1-0944-4f07-9ce7-733c697537ea", result.toString());
+ assertEquals(4, result.version());
+ assertEquals(2, result.variant());
+ assertEquals(-7140611980868110358L, result.getLeastSignificantBits());
+ assertEquals(-3324876153822097657L, result.getMostSignificantBits());
+ }
+
+ /**
+ * Run the void setPdpGroup(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPdpGroup_1() throws Exception {
+ PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
+ String pdpGroup = "";
+
+ fixture.setPdpGroup(pdpGroup);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyName(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyName_1() throws Exception {
+ PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
+ String policyName = "";
+
+ fixture.setPolicyName(policyName);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setPolicyType(String) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetPolicyType_1() throws Exception {
+ PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
+ String policyType = "";
+
+ fixture.setPolicyType(policyType);
+
+ // add additional test code here
+ }
+
+ /**
+ * Run the void setRequestID(UUID) method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Test
+ public void testSetRequestID_1() throws Exception {
+ PushPolicyParameters fixture = new PushPolicyParameters("", "", "", UUID.randomUUID());
+ UUID requestID = UUID.randomUUID();
+
+ fixture.setRequestID(requestID);
+
+ // add additional test code here
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(PushPolicyParametersTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/RemovedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/RemovedPolicyTest.java
index 6a53cbfb1..b57a157ec 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/RemovedPolicyTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/RemovedPolicyTest.java
@@ -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.
@@ -25,48 +27,45 @@ import org.junit.Before;
import org.onap.policy.api.RemovedPolicy;
/**
- * The class <code>RemovedPolicyTest</code> contains tests for the class <code>{@link RemovedPolicy}</code>.
+ * The class <code>RemovedPolicyTest</code> contains tests for the class
+ * <code>{@link RemovedPolicy}</code>.
*
* @generatedBy CodePro at 6/1/16 1:40 PM
* @version $Revision: 1.0 $
*/
public class RemovedPolicyTest {
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:40 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(RemovedPolicyTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:40 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(RemovedPolicyTest.class);
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/SendEventTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/SendEventTest.java
index 560ca463f..46f4dd1e8 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/SendEventTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/SendEventTest.java
@@ -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.
@@ -24,11 +26,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Before;
import org.onap.policy.api.PolicyEngine;
import org.onap.policy.api.PolicyEngineException;
@@ -36,120 +36,115 @@ import org.onap.policy.api.PolicyEventException;
import org.onap.policy.api.PolicyResponse;
import org.onap.policy.api.PolicyResponseStatus;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.logging.flexlogger.Logger;
public class SendEventTest {
-
- private PolicyEngine policyEngine = null;
- private Map<String,String> eventAttributes = new HashMap<String,String>();
- private Collection<PolicyResponse> policyResponse = null;
- private static final Logger logger = FlexLogger.getLogger(SendEventTest.class);
- @Before
- public void setUp() {
- try {
- policyEngine = new PolicyEngine("Test/config_pass.properties");
- } catch (PolicyEngineException e) {
- logger.error(e.getMessage());
- fail("PolicyEngine Instantiation Error" + e);
- }
- logger.info("Loaded.. PolicyEngine");
- }
- //@Test
- @SuppressWarnings("deprecation")
- public void testSendEventFail() {
- eventAttributes = null;
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyResponse);
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testSendEventFailNull() {
- eventAttributes.put("", "");
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyResponse);
- }
-
- // deprecated Test.
- /*@Test
- public void testSendEventFailAttribute() {
- eventAttributes.put("Fail.key", "Value");
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- assertNull(policyResponse.getPolicyResponseMessage());
- }*/
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testSendEventNotValid() {
- eventAttributes.put("Action.fail", "Value");
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyResponse policyResponse: this.policyResponse){
- logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse);
- assertEquals(PolicyResponseStatus.NO_ACTION_REQUIRED, policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse.getPolicyResponseMessage());
- assertNotNull(policyResponse.getRequestAttributes());
- assertNull(policyResponse.getActionTaken());
- assertNull(policyResponse.getActionAdvised());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testSendEventActionAdvised() {
- eventAttributes.put("Key", "Value");
- eventAttributes.put("cpu", "80");
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyResponse policyResponse: this.policyResponse){
- logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse);
- assertEquals(PolicyResponseStatus.ACTION_ADVISED, policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse.getPolicyResponseMessage());
- assertNotNull(policyResponse.getRequestAttributes());
- assertNull(policyResponse.getActionTaken());
- assertNotNull(policyResponse.getActionAdvised());
- }
- }
-
- //@Test
- @SuppressWarnings("deprecation")
- public void testSendEventActionTaken() {
- eventAttributes.put("Key", "Value");
- eventAttributes.put("cpu", "91");
- try {
- policyResponse = policyEngine.sendEvent(eventAttributes);
- } catch (PolicyEventException e) {
- logger.warn(e.getMessage());
- }
- for(PolicyResponse policyResponse: this.policyResponse){
- logger.info(policyResponse.getPolicyResponseMessage() + " , " + policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse);
- assertEquals(PolicyResponseStatus.ACTION_TAKEN, policyResponse.getPolicyResponseStatus());
- assertNotNull(policyResponse.getPolicyResponseMessage());
- assertNotNull(policyResponse.getRequestAttributes());
- assertNotNull(policyResponse.getActionTaken());
- assertNull(policyResponse.getActionAdvised());
- }
- }
+ private PolicyEngine policyEngine = null;
+ private Map<String, String> eventAttributes = new HashMap<String, String>();
+ private Collection<PolicyResponse> policyResponse = null;
+ private static final Logger logger = FlexLogger.getLogger(SendEventTest.class);
+
+ @Before
+ public void setUp() {
+ try {
+ policyEngine = new PolicyEngine("Test/config_pass.properties");
+ } catch (PolicyEngineException e) {
+ logger.error(e.getMessage());
+ fail("PolicyEngine Instantiation Error" + e);
+ }
+ logger.info("Loaded.. PolicyEngine");
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testSendEventFail() {
+ eventAttributes = null;
+ try {
+ policyResponse = policyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyResponse);
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testSendEventFailNull() {
+ eventAttributes.put("", "");
+ try {
+ policyResponse = policyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.warn(e.getMessage());
+ }
+ assertNull(policyResponse);
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testSendEventNotValid() {
+ eventAttributes.put("Action.fail", "Value");
+ try {
+ policyResponse = policyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyResponse policyResponse : this.policyResponse) {
+ logger.info(policyResponse.getPolicyResponseMessage() + " , "
+ + policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse);
+ assertEquals(PolicyResponseStatus.NO_ACTION_REQUIRED,
+ policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse.getPolicyResponseMessage());
+ assertNotNull(policyResponse.getRequestAttributes());
+ assertNull(policyResponse.getActionTaken());
+ assertNull(policyResponse.getActionAdvised());
+ }
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testSendEventActionAdvised() {
+ eventAttributes.put("Key", "Value");
+ eventAttributes.put("cpu", "80");
+ try {
+ policyResponse = policyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyResponse policyResponse : this.policyResponse) {
+ logger.info(policyResponse.getPolicyResponseMessage() + " , "
+ + policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse);
+ assertEquals(PolicyResponseStatus.ACTION_ADVISED,
+ policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse.getPolicyResponseMessage());
+ assertNotNull(policyResponse.getRequestAttributes());
+ assertNull(policyResponse.getActionTaken());
+ assertNotNull(policyResponse.getActionAdvised());
+ }
+ }
+
+ // @Test
+ @SuppressWarnings("deprecation")
+ public void testSendEventActionTaken() {
+ eventAttributes.put("Key", "Value");
+ eventAttributes.put("cpu", "91");
+ try {
+ policyResponse = policyEngine.sendEvent(eventAttributes);
+ } catch (PolicyEventException e) {
+ logger.warn(e.getMessage());
+ }
+ for (PolicyResponse policyResponse : this.policyResponse) {
+ logger.info(policyResponse.getPolicyResponseMessage() + " , "
+ + policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse);
+ assertEquals(PolicyResponseStatus.ACTION_TAKEN,
+ policyResponse.getPolicyResponseStatus());
+ assertNotNull(policyResponse.getPolicyResponseMessage());
+ assertNotNull(policyResponse.getRequestAttributes());
+ assertNotNull(policyResponse.getActionTaken());
+ assertNull(policyResponse.getActionAdvised());
+ }
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdDecisionResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdDecisionResponseTest.java
index 0808c6b3a..615373704 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdDecisionResponseTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdDecisionResponseTest.java
@@ -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.
@@ -20,20 +22,19 @@
package org.onap.policy.test;
import static org.junit.Assert.*;
-
import org.junit.Test;
import org.onap.policy.api.PolicyDecision;
import org.onap.policy.std.StdDecisionResponse;
public class StdDecisionResponseTest {
- @Test
- public void test() {
- StdDecisionResponse r = new StdDecisionResponse();
- r.setDecision(PolicyDecision.DENY);
- assertEquals(PolicyDecision.DENY, r.getDecision());
- r.setDetails("details");
- assertEquals("details", r.getDetails());
- }
+ @Test
+ public void test() {
+ StdDecisionResponse r = new StdDecisionResponse();
+ r.setDecision(PolicyDecision.DENY);
+ assertEquals(PolicyDecision.DENY, r.getDecision());
+ r.setDetails("details");
+ assertEquals("details", r.getDetails());
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdDictionaryResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdDictionaryResponseTest.java
index fc0b9f97c..3c7025553 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdDictionaryResponseTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdDictionaryResponseTest.java
@@ -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.
@@ -20,25 +22,23 @@
package org.onap.policy.test;
import static org.junit.Assert.*;
-
import java.util.Collections;
-
import org.junit.Test;
import org.onap.policy.std.StdDictionaryResponse;
public class StdDictionaryResponseTest {
- @Test
- public void test() {
- StdDictionaryResponse r = new StdDictionaryResponse();
- r.setResponseCode(0);
- assertEquals(0, r.getResponseCode());
- r.setResponseMessage("msg");
- assertEquals("msg", r.getResponseMessage());
- r.setDictionaryData(Collections.emptyMap());
- assertEquals(0, r.getDictionaryData().size());
- r.setDictionaryJson(null);
- assertNull(r.getDictionaryJson());
- }
+ @Test
+ public void test() {
+ StdDictionaryResponse r = new StdDictionaryResponse();
+ r.setResponseCode(0);
+ assertEquals(0, r.getResponseCode());
+ r.setResponseMessage("msg");
+ assertEquals("msg", r.getResponseMessage());
+ r.setDictionaryData(Collections.emptyMap());
+ assertEquals(0, r.getDictionaryData().size());
+ r.setDictionaryJson(null);
+ assertNull(r.getDictionaryJson());
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdMetricsResponseTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdMetricsResponseTest.java
index a17fb06c2..15e04a14b 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdMetricsResponseTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/StdMetricsResponseTest.java
@@ -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.
@@ -20,25 +22,24 @@
package org.onap.policy.test;
import static org.junit.Assert.*;
-
import org.junit.Test;
import org.onap.policy.std.StdMetricsResponse;
public class StdMetricsResponseTest {
- @Test
- public void test() {
- StdMetricsResponse r = new StdMetricsResponse();
- r.setMetricsTotal(0);
- assertEquals(0, r.getMetricsTotal());
- r.setPapMetrics(0);
- assertEquals(0, r.getPapMetrics());
- r.setPdpMetrics(0);
- assertEquals(0, r.getPdpMetrics());
- r.setResponseCode(0);
- assertEquals(0, r.getResponseCode());
- r.setResponseMessage("msg");
- assertEquals("msg", r.getResponseMessage());
- }
+ @Test
+ public void test() {
+ StdMetricsResponse r = new StdMetricsResponse();
+ r.setMetricsTotal(0);
+ assertEquals(0, r.getMetricsTotal());
+ r.setPapMetrics(0);
+ assertEquals(0, r.getPapMetrics());
+ r.setPdpMetrics(0);
+ assertEquals(0, r.getPdpMetrics());
+ r.setResponseCode(0);
+ assertEquals(0, r.getResponseCode());
+ r.setResponseMessage("msg");
+ assertEquals("msg", r.getResponseMessage());
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/TestRunner.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/TestRunner.java
index 87687f0ab..c1dbea4c0 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/TestRunner.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/TestRunner.java
@@ -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.
@@ -25,25 +27,28 @@ import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
public class TestRunner {
- public static void main(String[] args) {
- Result result = JUnitCore.runClasses(PolicyEngineTest.class);
- for(Failure failure: result.getFailures()) {
- System.out.println("Failed Test: " + failure.toString());
- }
- Result results = null;
- if(result.wasSuccessful()) {
- System.out.println("API Methods are being Tested.. ");
- results = JUnitCore.runClasses(GetConfigByPolicyNameTest.class, GetConfigStringTest.class,GetConfigStringStringTest.class,GetConfigStringStringMapTest.class,SendEventTest.class);
- for(Failure failure: results.getFailures()) {
- System.out.println("Failed Test: " + failure.toString());
- }
- System.out.println("Test Results.. ");
- System.out.println("Stats: \nRun Time: " + (results.getRunTime()+result.getRunTime()) + "\nTotal Tests:" + results.getRunCount()+ result.getRunCount()
- + "\nFailures: " + results.getFailureCount()+ result.getFailureCount());
- System.exit(1);
- }
- System.out.println("Test Failed..");
- System.out.println("Stats: \nRun Time: " + result.getRunTime() + "\nTests:" + result.getRunCount()
- + "\nFailures: " + result.getFailureCount());
- }
+ public static void main(String[] args) {
+ Result result = JUnitCore.runClasses(PolicyEngineTest.class);
+ for (Failure failure : result.getFailures()) {
+ System.out.println("Failed Test: " + failure.toString());
+ }
+ Result results = null;
+ if (result.wasSuccessful()) {
+ System.out.println("API Methods are being Tested.. ");
+ results = JUnitCore.runClasses(GetConfigByPolicyNameTest.class,
+ GetConfigStringTest.class, GetConfigStringStringTest.class,
+ GetConfigStringStringMapTest.class, SendEventTest.class);
+ for (Failure failure : results.getFailures()) {
+ System.out.println("Failed Test: " + failure.toString());
+ }
+ System.out.println("Test Results.. ");
+ System.out.println("Stats: \nRun Time: " + (results.getRunTime() + result.getRunTime())
+ + "\nTotal Tests:" + results.getRunCount() + result.getRunCount()
+ + "\nFailures: " + results.getFailureCount() + result.getFailureCount());
+ System.exit(1);
+ }
+ System.out.println("Test Failed..");
+ System.out.println("Stats: \nRun Time: " + result.getRunTime() + "\nTests:"
+ + result.getRunCount() + "\nFailures: " + result.getFailureCount());
+ }
}
diff --git a/PolicyEngineAPI/src/test/java/org/onap/policy/test/UpdateTypeTest.java b/PolicyEngineAPI/src/test/java/org/onap/policy/test/UpdateTypeTest.java
index 500d6c1c5..1194930fd 100644
--- a/PolicyEngineAPI/src/test/java/org/onap/policy/test/UpdateTypeTest.java
+++ b/PolicyEngineAPI/src/test/java/org/onap/policy/test/UpdateTypeTest.java
@@ -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.
@@ -22,70 +24,65 @@ package org.onap.policy.test;
import org.junit.*;
import org.onap.policy.api.UpdateType;
-
import static org.junit.Assert.*;
/**
- * The class <code>UpdateTypeTest</code> contains tests for the class <code>{@link UpdateType}</code>.
+ * The class <code>UpdateTypeTest</code> contains tests for the class
+ * <code>{@link UpdateType}</code>.
*
* @generatedBy CodePro at 6/1/16 1:39 PM
* @version $Revision: 1.0 $
*/
public class UpdateTypeTest {
- /**
- * Run the String toString() method test.
- *
- * @throws Exception
- *
- * @generatedBy CodePro at 6/1/16 1:39 PM
- */
- @Test
- public void testToString_1()
- throws Exception {
- UpdateType fixture = UpdateType.NEW;
+ /**
+ * Run the String toString() method test.
+ *
+ * @throws Exception
+ *
+ * @generatedBy CodePro at 6/1/16 1:39 PM
+ */
+ @Test
+ public void testToString_1() throws Exception {
+ UpdateType fixture = UpdateType.NEW;
- String result = fixture.toString();
+ String result = fixture.toString();
- // add additional test code here
- assertEquals("new", result);
- }
+ // add additional test code here
+ assertEquals("new", result);
+ }
- /**
- * Perform pre-test initialization.
- *
- * @throws Exception
- * if the initialization fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:39 PM
- */
- @Before
- public void setUp()
- throws Exception {
- // add additional set up code here
- }
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception if the initialization fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:39 PM
+ */
+ @Before
+ public void setUp() throws Exception {
+ // add additional set up code here
+ }
- /**
- * Perform post-test clean-up.
- *
- * @throws Exception
- * if the clean-up fails for some reason
- *
- * @generatedBy CodePro at 6/1/16 1:39 PM
- */
- @After
- public void tearDown()
- throws Exception {
- // Add additional tear down code here
- }
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception if the clean-up fails for some reason
+ *
+ * @generatedBy CodePro at 6/1/16 1:39 PM
+ */
+ @After
+ public void tearDown() throws Exception {
+ // Add additional tear down code here
+ }
- /**
- * Launch the test.
- *
- * @param args the command line arguments
- *
- * @generatedBy CodePro at 6/1/16 1:39 PM
- */
- public static void main(String[] args) {
- new org.junit.runner.JUnitCore().run(UpdateTypeTest.class);
- }
+ /**
+ * Launch the test.
+ *
+ * @param args the command line arguments
+ *
+ * @generatedBy CodePro at 6/1/16 1:39 PM
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(UpdateTypeTest.class);
+ }
}