From 91d04c64771832a0b8815ffbe1f0f9920320d94d Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Tue, 14 Feb 2017 19:41:00 -0500 Subject: Initial OpenECOMP policy/engine commit Change-Id: I7dbff37733b661643dd4d1caefa3d7dccc361b6e Signed-off-by: Pamela Dragosh --- .../openecomp/policy/test/ActionPolicyApiTest.java | 240 ++++ .../openecomp/policy/test/AttributeTypeTest.java | 81 ++ .../policy/test/ConfigBasePolicyTest.java | 325 +++++ .../policy/test/ConfigFirewallPolicyTest.java | 256 ++++ .../policy/test/ConfigRequestParametersTest.java | 362 +++++ .../policy/test/DecisionPolicyApiTest.java | 221 +++ .../policy/test/DecisionRequestParametersTest.java | 232 ++++ .../policy/test/DeletePolicyConditionTest.java | 91 ++ .../policy/test/DeletePolicyParametersTest.java | 314 +++++ .../policy/test/EventRequestParametersTest.java | 193 +++ .../policy/test/GetConfigByPolicyNameTest.java | 64 + .../policy/test/GetConfigStringStringMapTest.java | 251 ++++ .../policy/test/GetConfigStringStringTest.java | 207 +++ .../openecomp/policy/test/GetConfigStringTest.java | 175 +++ .../policy/test/ImportParametersTest.java | 464 +++++++ .../openecomp/policy/test/LoadedPolicyTest.java | 75 ++ .../policy/test/NotificationHandlerTest.java | 73 + .../policy/test/NotificationSchemeTest.java | 91 ++ .../policy/test/NotificationTypeTest.java | 91 ++ .../openecomp/policy/test/PDPNotificationTest.java | 75 ++ .../policy/test/PolicyChangeResponseTest.java | 73 + .../org/openecomp/policy/test/PolicyClassTest.java | 91 ++ .../policy/test/PolicyConfigExceptionTest.java | 183 +++ .../policy/test/PolicyConfigStatusTest.java | 133 ++ .../openecomp/policy/test/PolicyConfigTest.java | 80 ++ .../policy/test/PolicyConfigTypeTest.java | 91 ++ .../policy/test/PolicyDecisionExceptionTest.java | 183 +++ .../openecomp/policy/test/PolicyDecisionTest.java | 91 ++ .../policy/test/PolicyEngineExceptionTest.java | 183 +++ .../policy/test/PolicyEngineInterfaceTest.java | 672 ++++++++++ .../openecomp/policy/test/PolicyEngineTest.java | 172 +++ .../policy/test/PolicyEventExceptionTest.java | 183 +++ .../policy/test/PolicyParametersTest.java | 1406 ++++++++++++++++++++ .../policy/test/PolicyResponseStatusTest.java | 154 +++ .../openecomp/policy/test/PolicyResponseTest.java | 75 ++ .../org/openecomp/policy/test/PolicyTypeTest.java | 91 ++ .../policy/test/PushPolicyParametersTest.java | 269 ++++ .../openecomp/policy/test/RemovedPolicyTest.java | 73 + .../org/openecomp/policy/test/SendEventTest.java | 153 +++ .../java/org/openecomp/policy/test/TestRunner.java | 49 + .../org/openecomp/policy/test/UpdateTypeTest.java | 91 ++ .../org/openecomp/policy/test/package-info.java | 24 + 42 files changed, 8401 insertions(+) create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ActionPolicyApiTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/AttributeTypeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigBasePolicyTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigFirewallPolicyTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigRequestParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionPolicyApiTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionRequestParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyConditionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/EventRequestParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigByPolicyNameTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringMapTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ImportParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/LoadedPolicyTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationHandlerTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationSchemeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationTypeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PDPNotificationTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyChangeResponseTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyClassTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigExceptionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigStatusTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTypeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionExceptionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineExceptionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineInterfaceTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEventExceptionTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseStatusTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyTypeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PushPolicyParametersTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/RemovedPolicyTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/SendEventTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/TestRunner.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/UpdateTypeTest.java create mode 100644 PolicyEngineAPI/src/test/java/org/openecomp/policy/test/package-info.java (limited to 'PolicyEngineAPI/src/test/java/org/openecomp/policy/test') diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ActionPolicyApiTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ActionPolicyApiTest.java new file mode 100644 index 000000000..d830a1a29 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ActionPolicyApiTest.java @@ -0,0 +1,240 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.openecomp.policy.api.AttributeType; +import org.openecomp.policy.api.PolicyChangeResponse; +import org.openecomp.policy.api.PolicyClass; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; +import org.openecomp.policy.api.PolicyParameters; +import org.openecomp.policy.std.StdPolicyChangeResponse; + +import junit.framework.TestCase; +import org.openecomp.policy.common.logging.flexlogger.*; + +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 + protected 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 configAttributes = new HashMap(); + configAttributes.put("test", "testing"); + + Map> attributes = new HashMap>(); + attributes.put(AttributeType.MATCHING, configAttributes); + policyParameters.setAttributes(attributes); + + policyParameters.setActionPerformer("PEP"); + policyParameters.setActionAttribute("testing"); + policyParameters.setRequestID(UUID.randomUUID()); + } + + protected 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/openecomp/policy/test/AttributeTypeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/AttributeTypeTest.java new file mode 100644 index 000000000..df8713ab8 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/AttributeTypeTest.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.AttributeType; + +import static org.junit.Assert.*; + +/** + * The class AttributeTypeTest contains tests for the class {@link AttributeType}. + * + * @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; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("matching", 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 + } + +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigBasePolicyTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigBasePolicyTest.java new file mode 100644 index 000000000..c6c624af0 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigBasePolicyTest.java @@ -0,0 +1,325 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import junit.framework.TestCase; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Test; +import org.mockito.Mockito; +import org.openecomp.policy.api.AttributeType; +import org.openecomp.policy.api.PolicyChangeResponse; +import org.openecomp.policy.api.PolicyConfigType; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; +import org.openecomp.policy.api.PolicyParameters; +import org.openecomp.policy.api.PolicyType; +import org.openecomp.policy.std.StdPolicyChangeResponse; + +import org.openecomp.policy.common.logging.flexlogger.*; + +/** + * The class ConfigBasePolicyTest contains tests for the class + * {@link PolicyEngine} + * + * @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() + */ + protected 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.setEcompName("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 configAttributes = new HashMap(); + configAttributes.put("test", "testing"); + + Map> attributes = new HashMap>(); + attributes.put(AttributeType.MATCHING, configAttributes); + policyParameters.setAttributes(attributes); + + policyParameters.setRequestID(UUID.randomUUID()); + } + + /** + * Perform post-test clean up + * + * @throws Exception + * + * @see TestCase#tearDown() + */ + protected 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 + */ + @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 + */ + @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 testCreatePolicyNullEcompName() { + response.setResponseMessage("PE300 - Data Issue: No ECOMP Name given."); + policyParameters.setEcompName(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 testUpdatePolicyNullEcompName() { + response.setResponseMessage("PE300 - Data Issue: No ECOMP Name given."); + policyParameters.setEcompName(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/openecomp/policy/test/ConfigFirewallPolicyTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigFirewallPolicyTest.java new file mode 100644 index 000000000..4725c17e9 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigFirewallPolicyTest.java @@ -0,0 +1,256 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.io.StringReader; +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 junit.framework.TestCase; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Test; +import org.mockito.Mockito; +import org.openecomp.policy.api.PolicyChangeResponse; +import org.openecomp.policy.api.PolicyConfigType; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; +import org.openecomp.policy.api.PolicyParameters; +import org.openecomp.policy.std.StdPolicyChangeResponse; + +import org.openecomp.policy.common.logging.flexlogger.*; + +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() + */ + protected 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.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(); + } + + return json; + } + /** + * Perform post-test clean up + * + * @throws Exception + * + * @see TestCase#tearDown() + */ + protected 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 + */ + @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 + */ + @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("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 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 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/openecomp/policy/test/ConfigRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigRequestParametersTest.java new file mode 100644 index 000000000..c632a0035 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ConfigRequestParametersTest.java @@ -0,0 +1,362 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.Hashtable; +import java.util.Map; +import java.util.UUID; + +import org.junit.*; +import org.openecomp.policy.api.ConfigRequestParameters; + +import static org.junit.Assert.*; + +/** + * The class ConfigRequestParametersTest contains tests for the class {@link ConfigRequestParameters}. + * + * @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.getEcompName()); + assertEquals(Boolean.FALSE, result.getUnique()); + } + + /** + * Run the ConfigRequestParameters(String,String,String,Map,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 eCOMPComponentName = ""; + String configName = ""; + Map configAttributes = new Hashtable(); + Boolean unique = new Boolean(true); + UUID requestID = UUID.randomUUID(); + + ConfigRequestParameters result = createConfigRequest(policyName, eCOMPComponentName, configName, configAttributes, unique, requestID); + + // add additional test code here + assertNotNull(result); + assertEquals("", result.getPolicyName()); + assertEquals("", result.getConfigName()); + assertEquals("", result.getEcompName()); + assertEquals(Boolean.TRUE, result.getUnique()); + } + + /** + * Run the Map 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(), new Boolean(true), UUID.randomUUID()); + + Map 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(), new Boolean(true), UUID.randomUUID()); + + String result = fixture.getConfigName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getEcompName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetEcompName_1() + throws Exception { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + + String result = fixture.getEcompName(); + + // 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(), 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(), 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(), 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(), new Boolean(true), UUID.randomUUID()); + Boolean unique = new Boolean(true); + + fixture.makeUnique(unique); + + // add additional test code here + } + + /** + * Run the void setConfigAttributes(Map) 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(), new Boolean(true), UUID.randomUUID()); + Map configAttributes = new Hashtable(); + + 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(), new Boolean(true), UUID.randomUUID()); + String configName = ""; + + fixture.setConfigName(configName); + + // add additional test code here + } + + /** + * Run the void setEcompName(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetEcompName_1() + throws Exception { + ConfigRequestParameters fixture = createConfigRequest("", "", "", new Hashtable(), new Boolean(true), UUID.randomUUID()); + String eCOMPComponentName = ""; + + fixture.setEcompName(eCOMPComponentName); + + // 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(), 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(), 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 eCOMPComponentName, String configName, Map configAttributes, Boolean unique, UUID requestID){ + ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); + configRequestParameters.setRequestID(requestID); + configRequestParameters.setPolicyName(policyName); + configRequestParameters.setEcompName(eCOMPComponentName); + configRequestParameters.setConfigName(configName); + configRequestParameters.setConfigAttributes(configAttributes); + configRequestParameters.makeUnique(unique); + return configRequestParameters; + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionPolicyApiTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionPolicyApiTest.java new file mode 100644 index 000000000..70adbe032 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionPolicyApiTest.java @@ -0,0 +1,221 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Test; +import org.mockito.Mockito; +import org.openecomp.policy.api.AttributeType; +import org.openecomp.policy.api.PolicyChangeResponse; +import org.openecomp.policy.api.PolicyClass; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; +import org.openecomp.policy.api.PolicyParameters; +import org.openecomp.policy.std.StdPolicyChangeResponse; + +import org.openecomp.policy.common.logging.flexlogger.*; + +import junit.framework.TestCase; + +/** + * The class DecisionPolicyApiTest contains tests for the class + * {@link PolicyEngine} + * + * @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() + */ + protected 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.setEcompName("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 configAttributes = new HashMap(); + configAttributes.put("test", "testing"); + + Map> attributes = new HashMap>(); + attributes.put(AttributeType.MATCHING, configAttributes); + policyParameters.setAttributes(attributes); + + //Set the settings... These are Optional +/* Map settingsMap = new HashMap(); + settingsMap.put("server", "5"); + + Map> settings = new HashMap>(); + settings.put(AttributeType.SETTINGS, settingsMap); + policyParameters.setSettings(settings);*/ + + policyParameters.setRequestID(UUID.randomUUID()); + } + + /** + * Perform post-test clean up + * + * @throws Exception + * + * @see TestCase#tearDown() + */ + protected 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("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 testCreatePolicyNullEcompName() { + response.setResponseMessage("PE300 - Data Issue: No ECOMP Name given."); + policyParameters.setEcompName(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 testUpdatePolicyNullEcompName() { + response.setResponseMessage("PE300 - Data Issue: No ECOMP Name given."); + policyParameters.setEcompName(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/openecomp/policy/test/DecisionRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionRequestParametersTest.java new file mode 100644 index 000000000..5b8782658 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DecisionRequestParametersTest.java @@ -0,0 +1,232 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.Hashtable; +import java.util.Map; +import java.util.UUID; + +import org.junit.*; +import org.openecomp.policy.api.DecisionRequestParameters; + +import static org.junit.Assert.*; + +/** + * The class DecisionRequestParametersTest contains tests for the class {@link DecisionRequestParameters}. + * + * @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.getECOMPComponentName()); + assertEquals(null, result.getDecisionAttributes()); + assertEquals(null, result.getRequestID()); + } + + /** + * Run the DecisionRequestParameters(String,Map,UUID) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testDecisionRequestParameters_2() + throws Exception { + String eCOMPComponentName = ""; + Map decisionAttributes = new Hashtable(); + UUID requestID = UUID.randomUUID(); + + DecisionRequestParameters result = new DecisionRequestParameters(eCOMPComponentName, decisionAttributes, requestID); + + // add additional test code here + assertNotNull(result); + assertEquals("", result.getECOMPComponentName()); + } + + /** + * Run the Map 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(), UUID.randomUUID()); + + Map result = fixture.getDecisionAttributes(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the String getECOMPComponentName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetECOMPComponentName_1() + throws Exception { + DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); + + String result = fixture.getECOMPComponentName(); + + // 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(), 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) 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(), UUID.randomUUID()); + Map decisionAttributes = new Hashtable(); + + fixture.setDecisionAttributes(decisionAttributes); + + // add additional test code here + } + + /** + * Run the void setECOMPComponentName(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetECOMPComponentName_1() + throws Exception { + DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable(), UUID.randomUUID()); + String eCOMPComponentName = ""; + + fixture.setECOMPComponentName(eCOMPComponentName); + + // 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(), 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/openecomp/policy/test/DeletePolicyConditionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyConditionTest.java new file mode 100644 index 000000000..c2941202b --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyConditionTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.DeletePolicyCondition; + +import static org.junit.Assert.*; + +/** + * The class DeletePolicyConditionTest contains tests for the class {@link DeletePolicyCondition}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class DeletePolicyConditionTest { + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testToString_1() + throws Exception { + DeletePolicyCondition fixture = DeletePolicyCondition.ALL; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("All Versions", result); + } + + /** + * 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(DeletePolicyConditionTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyParametersTest.java new file mode 100644 index 000000000..7723f9819 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/DeletePolicyParametersTest.java @@ -0,0 +1,314 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.UUID; + +import org.junit.*; +import org.openecomp.policy.api.DeletePolicyCondition; +import org.openecomp.policy.api.DeletePolicyParameters; + +import static org.junit.Assert.*; + +/** + * The class DeletePolicyParametersTest contains tests for the class {@link DeletePolicyParameters}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class DeletePolicyParametersTest { + /** + * Run the DeletePolicyCondition getDeleteCondition() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetDeleteCondition_1() + throws Exception { + DeletePolicyParameters fixture = new DeletePolicyParameters(); + fixture.setPolicyComponent(""); + fixture.setPolicyName(""); + fixture.setDeleteCondition(DeletePolicyCondition.ALL); + fixture.setRequestID(UUID.randomUUID()); + fixture.setPdpGroup(""); + + DeletePolicyCondition result = fixture.getDeleteCondition(); + + // add additional test code here + assertNotNull(result); + assertEquals("All Versions", result.toString()); + assertEquals("ALL", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the String getPdpGroup() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPdpGroup_1() + throws Exception { + DeletePolicyParameters fixture = new DeletePolicyParameters(); + fixture.setPolicyComponent(""); + fixture.setPolicyName(""); + fixture.setDeleteCondition(DeletePolicyCondition.ALL); + fixture.setRequestID(UUID.randomUUID()); + fixture.setPdpGroup(""); + + String result = fixture.getPdpGroup(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getPolicyComponent() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetPolicyComponent_1() + throws Exception { + DeletePolicyParameters fixture = new DeletePolicyParameters(); + fixture.setPolicyComponent(""); + fixture.setPolicyName(""); + fixture.setDeleteCondition(DeletePolicyCondition.ALL); + fixture.setRequestID(UUID.randomUUID()); + fixture.setPdpGroup(""); + + String result = fixture.getPolicyComponent(); + + // 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 { + DeletePolicyParameters fixture = new DeletePolicyParameters(); + fixture.setPolicyComponent(""); + fixture.setPolicyName(""); + fixture.setDeleteCondition(DeletePolicyCondition.ALL); + fixture.setRequestID(UUID.randomUUID()); + fixture.setPdpGroup(""); + + 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 { + DeletePolicyParameters fixture = new DeletePolicyParameters(); + fixture.setPolicyComponent(""); + fixture.setPolicyName(""); + fixture.setDeleteCondition(DeletePolicyCondition.ALL); + fixture.setRequestID(UUID.fromString("482e90e2-2ad7-4265-9893-4cfe08ef1e3d")); + fixture.setPdpGroup(""); + + UUID result = fixture.getRequestID(); + + // add additional test code here + assertNotNull(result); + assertEquals("482e90e2-2ad7-4265-9893-4cfe08ef1e3d", result.toString()); + assertEquals(4, result.version()); + assertEquals(2, result.variant()); + assertEquals(-7452528304412746179L, result.getLeastSignificantBits()); + assertEquals(5201253920715260517L, result.getMostSignificantBits()); + } + + /** + * Run the void setDeleteCondition(DeletePolicyCondition) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetDeleteCondition_1() + throws Exception { + DeletePolicyParameters fixture = new DeletePolicyParameters(); + fixture.setPolicyComponent(""); + fixture.setPolicyName(""); + fixture.setDeleteCondition(DeletePolicyCondition.ALL); + fixture.setRequestID(UUID.randomUUID()); + fixture.setPdpGroup(""); + DeletePolicyCondition deleteCondition = DeletePolicyCondition.ALL; + + fixture.setDeleteCondition(deleteCondition); + + // add additional test code here + } + + /** + * 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 { + DeletePolicyParameters fixture = new DeletePolicyParameters(); + fixture.setPolicyComponent(""); + fixture.setPolicyName(""); + fixture.setDeleteCondition(DeletePolicyCondition.ALL); + fixture.setRequestID(UUID.randomUUID()); + fixture.setPdpGroup(""); + String pdpGroup = ""; + + fixture.setPdpGroup(pdpGroup); + + // add additional test code here + } + + /** + * Run the void setPolicyComponent(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetPolicyComponent_1() + throws Exception { + DeletePolicyParameters fixture = new DeletePolicyParameters(); + fixture.setPolicyComponent(""); + fixture.setPolicyName(""); + fixture.setDeleteCondition(DeletePolicyCondition.ALL); + fixture.setRequestID(UUID.randomUUID()); + fixture.setPdpGroup(""); + String policyComponent = ""; + + fixture.setPolicyComponent(policyComponent); + + // 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 { + DeletePolicyParameters fixture = new DeletePolicyParameters(); + fixture.setPolicyComponent(""); + fixture.setPolicyName(""); + fixture.setDeleteCondition(DeletePolicyCondition.ALL); + fixture.setRequestID(UUID.randomUUID()); + fixture.setPdpGroup(""); + 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 { + DeletePolicyParameters fixture = new DeletePolicyParameters(); + fixture.setPolicyComponent(""); + fixture.setPolicyName(""); + fixture.setDeleteCondition(DeletePolicyCondition.ALL); + fixture.setRequestID(UUID.randomUUID()); + fixture.setPdpGroup(""); + 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(DeletePolicyParametersTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/EventRequestParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/EventRequestParametersTest.java new file mode 100644 index 000000000..c8d9bd492 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/EventRequestParametersTest.java @@ -0,0 +1,193 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.Hashtable; +import java.util.Map; +import java.util.UUID; + +import org.junit.*; +import org.openecomp.policy.api.EventRequestParameters; + +import static org.junit.Assert.*; + +/** + * The class EventRequestParametersTest contains tests for the class {@link EventRequestParameters}. + * + * @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,UUID) constructor test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testEventRequestParameters_2() + throws Exception { + Map eventAttributes = new Hashtable(); + UUID requestID = UUID.randomUUID(); + + EventRequestParameters result = new EventRequestParameters(eventAttributes, requestID); + + // add additional test code here + assertNotNull(result); + } + + /** + * Run the Map 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(), UUID.randomUUID()); + + Map 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(), 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) 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(), UUID.randomUUID()); + Map eventAttributes = new Hashtable(); + + 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(), 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/openecomp/policy/test/GetConfigByPolicyNameTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigByPolicyNameTest.java new file mode 100644 index 000000000..ccab587da --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigByPolicyNameTest.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.Collection; + +import junit.framework.TestCase; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.policy.api.PolicyConfig; +import org.openecomp.policy.api.PolicyConfigException; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; + +import org.openecomp.policy.common.logging.flexlogger.*; + +public class GetConfigByPolicyNameTest extends TestCase { + private PolicyEngine policyEngine = null; + private String policyName = null; + private Collection 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"); + } + + @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/openecomp/policy/test/GetConfigStringStringMapTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringMapTest.java new file mode 100644 index 000000000..23cce3d8f --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringMapTest.java @@ -0,0 +1,251 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +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.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.policy.api.PolicyConfig; +import org.openecomp.policy.api.PolicyConfigException; +import org.openecomp.policy.api.PolicyConfigStatus; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; +import org.openecomp.policy.api.PolicyType; + +import org.openecomp.policy.common.logging.flexlogger.*; + +public class GetConfigStringStringMapTest { + + private PolicyEngine policyEngine = null; + private String eCOMPComponentName = null; + private String configName = null; + private Map configAttributes = new HashMap(); + private Collection 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"); + } + + @Test + public void testGetConfigStringStringMapFail() { + eCOMPComponentName = null; + configName = null; + configAttributes = null; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @Test + public void testGetConfigStringStringMapFail1() { + eCOMPComponentName = null; + configName = "testFail"; + configAttributes.put("TestValue", "Fail"); + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @Test + public void testGetConfigStringStringMapFail2() { + eCOMPComponentName = "TestFail"; + configName = null; + configAttributes.put("TestValue", "Fail"); + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @Test + public void testGetConfigStringStringMapFail3() { + eCOMPComponentName = "TestFail"; + configName = "configFail"; + configAttributes= null; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @Test + public void testGetConfigStringStringMapfail4() { + eCOMPComponentName = "TestFail"; + configName = "configFail"; + configAttributes.put("", ""); + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, configName, configAttributes); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + //@Test + public void testGetConfigStringStringMapNotValid() { + eCOMPComponentName = "TestFail"; + configName = "configFail"; + configAttributes.put("Action:com.test.fail", "Value"); + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, 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 + public void testGetConfigStringStringMapValidJSON() { + eCOMPComponentName = "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(eCOMPComponentName, 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 + public void testGetConfigStringStringMapValidXML() { + eCOMPComponentName = "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(eCOMPComponentName, 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 + public void testGetConfigStringStringMapValidProperties() { + eCOMPComponentName = "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(eCOMPComponentName, 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 + public void testGetConfigStringStringMapValidOther() { + eCOMPComponentName = "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(eCOMPComponentName, 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/openecomp/policy/test/GetConfigStringStringTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringTest.java new file mode 100644 index 000000000..fc8302c0b --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringStringTest.java @@ -0,0 +1,207 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +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.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.policy.api.PolicyConfig; +import org.openecomp.policy.api.PolicyConfigException; +import org.openecomp.policy.api.PolicyConfigStatus; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; +import org.openecomp.policy.api.PolicyType; + +import org.openecomp.policy.common.logging.flexlogger.*; + +public class GetConfigStringStringTest { + + private PolicyEngine policyEngine = null; + private String eCOMPComponentName = null; + private String configName = null; + private Collection 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"); + } + + @Test + public void testGetConfigStringStringFail() { + eCOMPComponentName = null; + configName = null; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @Test + public void testGetConfigStringStringFail1() { + eCOMPComponentName = null; + configName = ""; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + @Test + public void testGetConfigStringStringFail2() { + eCOMPComponentName = ""; + configName = null; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, configName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + //@Test + public void testGetConfigStringStringNotvalid() { + eCOMPComponentName = "fail"; + configName = "fail"; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, 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 + public void testGetConfigStringStringValidJSON() { + eCOMPComponentName = "JSON"; + configName = "JSONconfig"; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, 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 + public void testGetConfigStringStringValidXML() { + eCOMPComponentName = "XML"; + configName = "XMLconfig"; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, 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 + public void testGetConfigStringStringValidProperties() { + eCOMPComponentName = "Properties"; + configName = "PropConfig" ; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, 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 + public void testGetConfigStringStringValidOther() { + eCOMPComponentName = "Other"; + configName = "OtherConfig" ; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName, 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/openecomp/policy/test/GetConfigStringTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringTest.java new file mode 100644 index 000000000..42d38539b --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/GetConfigStringTest.java @@ -0,0 +1,175 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.Collection; + +import junit.framework.TestCase; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.openecomp.policy.api.PolicyConfig; +import org.openecomp.policy.api.PolicyConfigException; +import org.openecomp.policy.api.PolicyConfigStatus; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; +import org.openecomp.policy.api.PolicyType; + +import org.openecomp.policy.common.logging.flexlogger.*; + +public class GetConfigStringTest extends TestCase{ + + private PolicyEngine policyEngine = null; + private String eCOMPComponentName = null; + private Collection 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 + public void testGetConfigStringFail() { + eCOMPComponentName = null; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName); + } catch (PolicyConfigException e) { + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + /*@Test + public void testGetConfigStringNotvalid() { + eCOMPComponentName = "fail"; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName); + } 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() { + eCOMPComponentName = "JSON"; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName); + } 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() { + eCOMPComponentName = "XML"; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName); + } 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() { + eCOMPComponentName = "Properties"; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName); + } 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() { + eCOMPComponentName = "Other"; + try { + policyConfig = policyEngine.getConfig(eCOMPComponentName); + } 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/openecomp/policy/test/ImportParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ImportParametersTest.java new file mode 100644 index 000000000..f6ceff682 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/ImportParametersTest.java @@ -0,0 +1,464 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.UUID; + +import org.junit.*; +import org.openecomp.policy.api.ImportParameters; +import org.openecomp.policy.api.ImportParameters.IMPORT_TYPE; + +import static org.junit.Assert.*; + +/** + * The class ImportParametersTest contains tests for the class {@link ImportParameters}. + * + * @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.setImportBody(""); + 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.setImportBody(""); + 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 String getImportBody() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testGetImportBody_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setImportBody(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + + String result = fixture.getImportBody(); + + // 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.setImportBody(""); + 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.setImportBody(""); + 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.setImportBody(""); + 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.setImportBody(""); + 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.setImportBody(""); + 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.setImportBody(""); + 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 setImportBody(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testSetImportBody_1() + throws Exception { + ImportParameters fixture = new ImportParameters(); + fixture.setFilePath(""); + fixture.setVersion(""); + fixture.setImportBody(""); + fixture.setServiceType(ImportParameters.IMPORT_TYPE.MICROSERVICE); + fixture.setRequestID(UUID.randomUUID()); + fixture.setDescription(""); + fixture.setServiceName(""); + String importBody = ""; + + fixture.setImportBody(importBody); + + // 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.setImportBody(""); + 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.setImportBody(""); + 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.setImportBody(""); + 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.setImportBody(""); + 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.setImportBody(""); + 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/openecomp/policy/test/LoadedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/LoadedPolicyTest.java new file mode 100644 index 000000000..f750312b1 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/LoadedPolicyTest.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.Map; + +import org.junit.*; +import org.openecomp.policy.api.LoadedPolicy; + +import static org.junit.Assert.*; + +/** + * The class LoadedPolicyTest contains tests for the class {@link LoadedPolicy}. + * + * @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 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationHandlerTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationHandlerTest.java new file mode 100644 index 000000000..fe6b53c0d --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationHandlerTest.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.NotificationHandler; + +import static org.junit.Assert.*; + +/** + * The class NotificationHandlerTest contains tests for the class {@link NotificationHandler}. + * + * @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 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationSchemeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationSchemeTest.java new file mode 100644 index 000000000..1cb105c2f --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationSchemeTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.NotificationScheme; + +import static org.junit.Assert.*; + +/** + * The class NotificationSchemeTest contains tests for the class {@link NotificationScheme}. + * + * @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; + + String result = fixture.toString(); + + // 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 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationTypeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationTypeTest.java new file mode 100644 index 000000000..95dce6a60 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/NotificationTypeTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.NotificationType; + +import static org.junit.Assert.*; + +/** + * The class NotificationTypeTest contains tests for the class {@link NotificationType}. + * + * @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; + + String result = fixture.toString(); + + // 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 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PDPNotificationTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PDPNotificationTest.java new file mode 100644 index 000000000..4a7cdf54c --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PDPNotificationTest.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.Collection; + +import org.junit.*; +import org.openecomp.policy.api.PDPNotification; + +import static org.junit.Assert.*; + +/** + * The class PDPNotificationTest contains tests for the class {@link PDPNotification}. + * + * @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 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyChangeResponseTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyChangeResponseTest.java new file mode 100644 index 000000000..2c8dc04fc --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyChangeResponseTest.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyChangeResponse; + +import static org.junit.Assert.*; + +/** + * The class PolicyChangeResponseTest contains tests for the class {@link PolicyChangeResponse}. + * + * @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 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyClassTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyClassTest.java new file mode 100644 index 000000000..28e5beefd --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyClassTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyClass; + +import static org.junit.Assert.*; + +/** + * The class PolicyClassTest contains tests for the class {@link PolicyClass}. + * + * @generatedBy CodePro at 6/1/16 1:40 PM + * @version $Revision: 1.0 $ + */ +public class PolicyClassTest { + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:40 PM + */ + @Test + public void testToString_1() + throws Exception { + PolicyClass fixture = PolicyClass.Action; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("Action", 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(PolicyClassTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigExceptionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigExceptionTest.java new file mode 100644 index 000000000..4134eacc2 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigExceptionTest.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyConfigException; + +import static org.junit.Assert.*; + +/** + * The class PolicyConfigExceptionTest contains tests for the class {@link PolicyConfigException}. + * + * @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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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/openecomp/policy/test/PolicyConfigStatusTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigStatusTest.java new file mode 100644 index 000000000..c40253890 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigStatusTest.java @@ -0,0 +1,133 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyConfigStatus; + +import static org.junit.Assert.*; + +/** + * The class PolicyConfigStatusTest contains tests for the class {@link PolicyConfigStatus}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyConfigStatusTest { + /** + * Run the PolicyConfigStatus getStatus(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetStatus_1() + throws Exception { + String configStatus = ""; + + PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus); + + // add additional test code here + assertNotNull(result); + assertEquals("not_found", result.toString()); + assertEquals("CONFIG_NOT_FOUND", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the PolicyConfigStatus getStatus(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetStatus_2() + throws Exception { + String configStatus = ""; + + PolicyConfigStatus result = PolicyConfigStatus.getStatus(configStatus); + + // add additional test code here + assertNotNull(result); + assertEquals("not_found", result.toString()); + assertEquals("CONFIG_NOT_FOUND", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testToString_1() + throws Exception { + PolicyConfigStatus fixture = PolicyConfigStatus.CONFIG_NOT_FOUND; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("not_found", result); + } + + /** + * 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(PolicyConfigStatusTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTest.java new file mode 100644 index 000000000..cbe11f460 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTest.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.Map; +import java.util.Properties; + +import javax.json.JsonObject; + +import org.junit.*; +import org.openecomp.policy.api.PolicyConfig; + +import static org.junit.Assert.*; + +import org.w3c.dom.Document; + +/** + * The class PolicyConfigTest contains tests for the class {@link PolicyConfig}. + * + * @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 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTypeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTypeTest.java new file mode 100644 index 000000000..cd6c6a977 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyConfigTypeTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyConfigType; + +import static org.junit.Assert.*; + +/** + * The class PolicyConfigTypeTest contains tests for the class {@link PolicyConfigType}. + * + * @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; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("BRMS_Param", result); + } + + /** + * 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(PolicyConfigTypeTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionExceptionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionExceptionTest.java new file mode 100644 index 000000000..95dfd7acd --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionExceptionTest.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyDecisionException; + +import static org.junit.Assert.*; + +/** + * The class PolicyDecisionExceptionTest contains tests for the class {@link PolicyDecisionException}. + * + * @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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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/openecomp/policy/test/PolicyDecisionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionTest.java new file mode 100644 index 000000000..12069abeb --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyDecisionTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyDecision; + +import static org.junit.Assert.*; + +/** + * The class PolicyDecisionTest contains tests for the class {@link PolicyDecision}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyDecisionTest { + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testToString_1() + throws Exception { + PolicyDecision fixture = PolicyDecision.DENY; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("deny", result); + } + + /** + * 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(PolicyDecisionTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineExceptionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineExceptionTest.java new file mode 100644 index 000000000..d21fb12e2 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineExceptionTest.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyEngineException; + +import static org.junit.Assert.*; + +/** + * The class PolicyEngineExceptionTest contains tests for the class {@link PolicyEngineException}. + * + * @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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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/openecomp/policy/test/PolicyEngineInterfaceTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineInterfaceTest.java new file mode 100644 index 000000000..51a3c20f8 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineInterfaceTest.java @@ -0,0 +1,672 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.io.StringReader; +import java.net.HttpURLConnection; +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 junit.framework.TestCase; + +import org.mockito.Mockito; +import org.openecomp.policy.api.AttributeType; +import org.openecomp.policy.api.ConfigRequestParameters; +import org.openecomp.policy.api.DecisionRequestParameters; +import org.openecomp.policy.api.DecisionResponse; +import org.openecomp.policy.api.DeletePolicyCondition; +import org.openecomp.policy.api.DeletePolicyParameters; +import org.openecomp.policy.api.EventRequestParameters; +import org.openecomp.policy.api.ImportParameters; +import org.openecomp.policy.api.NotificationHandler; +import org.openecomp.policy.api.NotificationScheme; +import org.openecomp.policy.api.PDPNotification; +import org.openecomp.policy.api.PolicyChangeResponse; +import org.openecomp.policy.api.PolicyClass; +import org.openecomp.policy.api.PolicyConfig; +import org.openecomp.policy.api.PolicyConfigException; +import org.openecomp.policy.api.PolicyDecision; +import org.openecomp.policy.api.PolicyDecisionException; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; +import org.openecomp.policy.api.PolicyEventException; +import org.openecomp.policy.api.PolicyParameters; +import org.openecomp.policy.api.PolicyResponse; +import org.openecomp.policy.api.PushPolicyParameters; +import org.openecomp.policy.api.ImportParameters.IMPORT_TYPE; +import org.openecomp.policy.std.StdPDPNotification; +import org.openecomp.policy.std.StdPolicyChangeResponse; +import org.openecomp.policy.std.StdPolicyEngine; +import org.openecomp.policy.std.StdPolicyResponse; + +import org.openecomp.policy.xacml.std.pap.StdPAPPolicy; + +import org.openecomp.policy.common.logging.flexlogger.FlexLogger; +import org.openecomp.policy.common.logging.flexlogger.Logger; + +/** + * The class PolicyEngineInterfaceTest contains tests for the + * class {@link PolicyEngine} + * + * @pattern JUnit Test Case + * + * @generatedBy CodePro at 5/27/16 10:33 AM + * + * + * @version $Revision$ + */ +public class PolicyEngineInterfaceTest extends TestCase { + + private static final Logger logger = FlexLogger.getLogger(PolicyEngineInterfaceTest.class); + + private PolicyEngine policyEngine = null; + private StdPolicyEngine stdPolicyEngine = null; + private PolicyEngine mockPolicyEngine = null; + private Collection 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() + */ + protected 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() + */ + protected void tearDown() throws Exception { + super.tearDown(); + // Add additional tear down code here + } + + /** + * Run the Collection getConfigByPolicyName(String) method + * test + */ + public void testGetConfigByPolicyName() { + String policyName = null; + try{ + policyConfig = policyEngine.getConfigByPolicyName(policyName); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + public void testGetConfigByPolicyName2() { + String policyName = null; + + try{ + policyConfig = policyEngine.getConfigByPolicyName(policyName, requestID); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + /** + * Run the Collection getConfig(String) method test + */ + public void testGetConfig() { + String ecompName = null; + + try{ + policyConfig = policyEngine.getConfig(ecompName); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + public void testGetConfig2() { + String ecompName = null; + + try{ + policyConfig = policyEngine.getConfig(ecompName,requestID); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + + public void testGetConfig3() { + String ecompName = null; + String configName = null; + + try{ + policyConfig = policyEngine.getConfig(ecompName,configName,requestID); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + public void testGetConfig4() { + String ecompName = null; + String configName = null; + Map configAttributes = null; + + try{ + policyConfig = policyEngine.getConfig(ecompName,configName,configAttributes); + } catch (PolicyConfigException e){ + logger.warn(e.getMessage()); + } + assertNull(policyConfig); + } + + public void testGetConfig5() { + String ecompName = null; + String configName = null; + Map configAttributes = null; + + try{ + policyConfig = policyEngine.getConfig(ecompName,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 sendEvent(Map) method + * test + */ + public void testSendEvent() + { + Collection result = null; + Collection response = null; + Map eventAttributes = null; + + try { + Mockito.when(mockPolicyEngine.sendEvent(eventAttributes)).thenReturn(result); + result = mockPolicyEngine.sendEvent(eventAttributes); + } catch (PolicyEventException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + assertEquals(result,response); + + } + + public void testSendEvent2() + { + Collection result = null; + Collection response = null; + Map eventAttributes = null; + + try { + Mockito.when(mockPolicyEngine.sendEvent(eventAttributes,requestID)).thenReturn(result); + result = mockPolicyEngine.sendEvent(eventAttributes,requestID); + } catch (PolicyEventException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + assertEquals(result,response); + + } + + public void testSendEvent3() + { + Collection result = null; + Collection response = null; + EventRequestParameters parameters = new EventRequestParameters(); + + try { + Mockito.when(mockPolicyEngine.sendEvent(parameters)).thenReturn(result); + result = mockPolicyEngine.sendEvent(parameters); + } catch (PolicyEventException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + assertEquals(result,response); + + } + + + + /** + * Run the PolicyDecision getDecision(String, Map) method + * test + */ + public void testGetDecision() + { + String eCOMPComponentName = null; + Map decisionAttributes = null; + + DecisionResponse result = null; + + try { + Mockito.when(mockPolicyEngine.getDecision(eCOMPComponentName,decisionAttributes)).thenReturn(null); + result = mockPolicyEngine.getDecision(eCOMPComponentName,decisionAttributes); + } catch (PolicyDecisionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + assertEquals(result,null); + } + + public void testGetDecision2() + { + String eCOMPComponentName = null; + Map decisionAttributes = null; + + DecisionResponse result = null; + + try { + Mockito.when(mockPolicyEngine.getDecision(eCOMPComponentName,decisionAttributes,requestID)).thenReturn(null); + result = mockPolicyEngine.getDecision(eCOMPComponentName,decisionAttributes); + } catch (PolicyDecisionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + 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) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + 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, 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, 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"); + String callPapResponse = "success"; + PolicyChangeResponse result = null; + PolicyParameters policyParameters = new PolicyParameters(); + StdPAPPolicy newPAPPolicy = null; + + policyParameters.setPolicyClass(PolicyClass.Action); //required + policyParameters.setPolicyName("test.junitTest"); //required + policyParameters.setPolicyDescription("testing"); //optional + + //Set the Component Attributes... These are Optional + Map configAttributes = new HashMap(); + configAttributes.put("test", "testing"); + + Map> attributes = new HashMap>(); + 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()); + e.printStackTrace(); + } + 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 configAttributes = new HashMap(); + configAttributes.put("test", "testing"); + + Map> attributes = new HashMap>(); + 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 + */ + 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); + } + + 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(); + } + + return json; + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineTest.java new file mode 100644 index 000000000..e2d7c7879 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEngineTest.java @@ -0,0 +1,172 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Test; +import org.openecomp.policy.api.NotificationScheme; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; + +import org.openecomp.policy.common.logging.flexlogger.*; + +public class PolicyEngineTest { + + private static final Logger logger = FlexLogger.getLogger(PolicyEngineTest.class); + private PolicyEngine policyEngine = null; + private String filePath = null; + + @Test + public void testPolicyEngineForFail() { + filePath = null; + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNull(policyEngine); + // Test even for this case. + filePath = "NotNull"; + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNull(policyEngine); + } + + @Test + public void testPolicyEngineforPropertyFileError() { + filePath = "Test/config_error.property"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNull(policyEngine); + } + + @Test + public void testPolicyEngineforPDPURLError() { + String filePath = "Test/config_fail.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNull(policyEngine); + } + + @Test + public void testPolicyEngineForPass() { + String filePath = "Test/config_pass.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + @Test + public void testPolicyEngineForUEBPass() { + String filePath = "Test/config_UEB_pass.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + + @Test + public void testPolicyEngineForUEBBadType() { + String filePath = "Test/config_UEB_bad_type.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + @Test + public void testPolicyEngineForUEBBadServerType() { + String filePath = "Test/config_UEB_badservers.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + @Test + public void testPolicyEngineNotficationAutoUEB() { + String filePath = "Test/config_UEB_pass.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + policyEngine.setScheme(NotificationScheme.AUTO_ALL_NOTIFICATIONS); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + @Test + public void testPolicyEngineNotficationAuto() { + String filePath = "Test/config_pass.properties"; + isFileAvailable(filePath); + try { + policyEngine = new PolicyEngine(filePath); + policyEngine.setScheme(NotificationScheme.AUTO_ALL_NOTIFICATIONS); + //policyEngine.getNotification(); + } catch (PolicyEngineException e) { + logger.warn(e.getMessage()); + } + assertNotNull(policyEngine); + } + + public void isFileAvailable(String filePath) { + Path file = Paths.get(filePath); + if (Files.notExists(file)) { + logger.error("File Doesn't Exist "+ file.toString()); + fail("File: " +filePath + " Not found"); + } + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEventExceptionTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEventExceptionTest.java new file mode 100644 index 000000000..fa8d5d1d8 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyEventExceptionTest.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyEventException; + +import static org.junit.Assert.*; + +/** + * The class PolicyEventExceptionTest contains tests for the class {@link PolicyEventException}. + * + * @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.openecomp.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.openecomp.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.openecomp.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.openecomp.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.openecomp.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/openecomp/policy/test/PolicyParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyParametersTest.java new file mode 100644 index 000000000..ca272c786 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyParametersTest.java @@ -0,0 +1,1406 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.Hashtable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.junit.*; +import org.openecomp.policy.api.AttributeType; +import org.openecomp.policy.api.PolicyClass; +import org.openecomp.policy.api.PolicyConfigType; +import org.openecomp.policy.api.PolicyParameters; +import org.openecomp.policy.api.PolicyType; + +import static org.junit.Assert.*; + +/** + * The class PolicyParametersTest contains tests for the class {@link PolicyParameters}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyParametersTest { + /** + * Run the String getActionAttribute() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetActionAttribute_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getActionAttribute(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getActionPerformer() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetActionPerformer_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getActionPerformer(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the Map> getAttributes() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetAttributes_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + Map> result = fixture.getAttributes(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the String getConfigBody() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetConfigBody_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getConfigBody(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the PolicyType getConfigBodyType() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetConfigBodyType_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + PolicyType result = fixture.getConfigBodyType(); + + // add additional test code here + assertNotNull(result); + assertEquals("json", result.toString()); + assertEquals("JSON", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the String getConfigName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetConfigName_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getConfigName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the List getDynamicRuleAlgorithmField1() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetDynamicRuleAlgorithmField1_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + List result = fixture.getDynamicRuleAlgorithmField1(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the List getDynamicRuleAlgorithmField2() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetDynamicRuleAlgorithmField2_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + List result = fixture.getDynamicRuleAlgorithmField2(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the List getDynamicRuleAlgorithmFunctions() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetDynamicRuleAlgorithmFunctions_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + List result = fixture.getDynamicRuleAlgorithmFunctions(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the List getDynamicRuleAlgorithmLabels() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetDynamicRuleAlgorithmLabels_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + List result = fixture.getDynamicRuleAlgorithmLabels(); + + // add additional test code here + assertNotNull(result); + assertEquals(0, result.size()); + } + + /** + * Run the String getEcompName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetEcompName_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getEcompName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the PolicyClass getPolicyClass() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetPolicyClass_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + PolicyClass result = fixture.getPolicyClass(); + + // add additional test code here + assertNotNull(result); + assertEquals("Action", result.toString()); + assertEquals("Action", result.name()); + assertEquals(1, result.ordinal()); + } + + /** + * Run the PolicyConfigType getPolicyConfigType() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetPolicyConfigType_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + PolicyConfigType result = fixture.getPolicyConfigType(); + + // add additional test code here + assertNotNull(result); + assertEquals("BRMS_Param", result.toString()); + assertEquals("BRMS_PARAM", result.name()); + assertEquals(5, result.ordinal()); + } + + /** + * Run the String getPolicyDescription() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetPolicyDescription_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getPolicyDescription(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getPolicyName() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetPolicyName_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getPolicyName(); + + // add additional test code here + assertEquals("", result); + } + + /** + * Run the String getPriority() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetPriority_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + String result = fixture.getPriority(); + + // 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 { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.fromString("878d319c-2799-4684-b480-99f40e1042b2")); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + + UUID result = fixture.getRequestID(); + + // add additional test code here + assertNotNull(result); + assertEquals("878d319c-2799-4684-b480-99f40e1042b2", result.toString()); + assertEquals(4, result.version()); + assertEquals(2, result.variant()); + assertEquals(-5440179076376542542L, result.getLeastSignificantBits()); + assertEquals(-8679226360124062076L, result.getMostSignificantBits()); + } + + /** + * Run the void setActionAttribute(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetActionAttribute_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String actionAttribute = ""; + + fixture.setActionAttribute(actionAttribute); + + // add additional test code here + } + + /** + * Run the void setActionPerformer(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetActionPerformer_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String actionPerformer = ""; + + fixture.setActionPerformer(actionPerformer); + + // add additional test code here + } + + /** + * Run the void setAttributes(Map>) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetAttributes_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + Map> attributes = new Hashtable(); + + fixture.setAttributes(attributes); + + // add additional test code here + } + + /** + * Run the void setConfigBody(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetConfigBody_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String configBody = ""; + + fixture.setConfigBody(configBody); + + // add additional test code here + } + + /** + * Run the void setConfigBodyType(PolicyType) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetConfigBodyType_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + PolicyType configBodyType = PolicyType.JSON; + + fixture.setConfigBodyType(configBodyType); + + // add additional test code here + } + + /** + * Run the void setConfigFirewallPolicyParameters(String,String,UUID) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetConfigFirewallPolicyParameters_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String policyName = ""; + String firewallJson = ""; + UUID requestID = UUID.randomUUID(); + + fixture.setConfigFirewallPolicyParameters(policyName, firewallJson, requestID); + + // add additional test code here + } + + /** + * Run the void setConfigName(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetConfigName_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String configName = ""; + + fixture.setConfigName(configName); + + // add additional test code here + } + + /** + * Run the void setConfigPolicyParameters(PolicyConfigType,String,String,String,String,Map>,PolicyType,String,UUID) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetConfigPolicyParameters_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + PolicyConfigType policyConfigType = PolicyConfigType.BRMS_PARAM; + String policyName = ""; + String policyDescription = ""; + String ecompName = ""; + String configName = ""; + Map> attributes = new Hashtable(); + PolicyType configBodyType = PolicyType.JSON; + String configBody = ""; + UUID requestID = UUID.randomUUID(); + + fixture.setConfigPolicyParameters(policyConfigType, policyName, policyDescription, ecompName, configName, attributes, configBodyType, configBody, requestID); + + // add additional test code here + } + + /** + * Run the void setDynamicRuleAlgorithmField1(List) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetDynamicRuleAlgorithmField1_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + List dynamicRuleAlgorithmField1 = new LinkedList(); + + fixture.setDynamicRuleAlgorithmField1(dynamicRuleAlgorithmField1); + + // add additional test code here + } + + /** + * Run the void setDynamicRuleAlgorithmField2(List) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetDynamicRuleAlgorithmField2_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + List dynamicRuleAlgorithmField2 = new LinkedList(); + + fixture.setDynamicRuleAlgorithmField2(dynamicRuleAlgorithmField2); + + // add additional test code here + } + + /** + * Run the void setDynamicRuleAlgorithmFunctions(List) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetDynamicRuleAlgorithmFunctions_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + List dynamicRuleAlgorithmFunctions = new LinkedList(); + + fixture.setDynamicRuleAlgorithmFunctions(dynamicRuleAlgorithmFunctions); + + // add additional test code here + } + + /** + * Run the void setDynamicRuleAlgorithmLabels(List) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetDynamicRuleAlgorithmLabels_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + List dynamicRuleAlgorithmLabels = new LinkedList(); + + fixture.setDynamicRuleAlgorithmLabels(dynamicRuleAlgorithmLabels); + + // add additional test code here + } + + /** + * Run the void setEcompName(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetEcompName_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String ecompName = ""; + + fixture.setEcompName(ecompName); + + // add additional test code here + } + + /** + * Run the void setPolicyClass(PolicyClass) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetPolicyClass_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + PolicyClass policyClass = PolicyClass.Action; + + fixture.setPolicyClass(policyClass); + + // add additional test code here + } + + /** + * Run the void setPolicyConfigType(PolicyConfigType) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetPolicyConfigType_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + PolicyConfigType policyConfigType = PolicyConfigType.BRMS_PARAM; + + fixture.setPolicyConfigType(policyConfigType); + + // add additional test code here + } + + /** + * Run the void setPolicyDescription(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetPolicyDescription_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String policyDescription = ""; + + fixture.setPolicyDescription(policyDescription); + + // add additional test code here + } + + /** + * Run the void setPolicyName(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetPolicyName_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String policyName = ""; + + fixture.setPolicyName(policyName); + + // add additional test code here + } + + /** + * Run the void setPriority(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testSetPriority_1() + throws Exception { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + String priority = ""; + + fixture.setPriority(priority); + + // 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 { + PolicyParameters fixture = new PolicyParameters(); + fixture.setRequestID(UUID.randomUUID()); + fixture.setActionAttribute(""); + fixture.setAttributes(new Hashtable()); + fixture.setDynamicRuleAlgorithmLabels(new LinkedList()); + fixture.setPolicyDescription(""); + + fixture.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + fixture.setDynamicRuleAlgorithmField2(new LinkedList()); + fixture.setPolicyName(""); + fixture.setConfigName(""); + fixture.setDynamicRuleAlgorithmFunctions(new LinkedList()); + fixture.setPolicyClass(PolicyClass.Action); + fixture.setEcompName(""); + fixture.setConfigBodyType(PolicyType.JSON); + fixture.setDynamicRuleAlgorithmField1(new LinkedList()); + fixture.setPriority(""); + fixture.setActionPerformer(""); + fixture.setConfigBody(""); + 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(PolicyParametersTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseStatusTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseStatusTest.java new file mode 100644 index 000000000..5841571bd --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseStatusTest.java @@ -0,0 +1,154 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyResponseStatus; + +import static org.junit.Assert.*; + +/** + * The class PolicyResponseStatusTest contains tests for the class {@link PolicyResponseStatus}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyResponseStatusTest { + /** + * Run the PolicyResponseStatus getStatus(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetStatus_1() + throws Exception { + String responseStatus = ""; + + PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus); + + // add additional test code here + assertNotNull(result); + assertEquals("no_action", result.toString()); + assertEquals("NO_ACTION_REQUIRED", result.name()); + assertEquals(0, result.ordinal()); + } + + /** + * Run the PolicyResponseStatus getStatus(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetStatus_2() + throws Exception { + String responseStatus = ""; + + PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus); + + // add additional test code here + assertNotNull(result); + assertEquals("no_action", result.toString()); + assertEquals("NO_ACTION_REQUIRED", result.name()); + assertEquals(0, result.ordinal()); + } + + /** + * Run the PolicyResponseStatus getStatus(String) method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testGetStatus_3() + throws Exception { + String responseStatus = ""; + + PolicyResponseStatus result = PolicyResponseStatus.getStatus(responseStatus); + + // add additional test code here + assertNotNull(result); + assertEquals("no_action", result.toString()); + assertEquals("NO_ACTION_REQUIRED", result.name()); + assertEquals(0, result.ordinal()); + } + + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testToString_1() + throws Exception { + PolicyResponseStatus fixture = PolicyResponseStatus.ACTION_ADVISED; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("action_advised", result); + } + + /** + * 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(PolicyResponseStatusTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseTest.java new file mode 100644 index 000000000..f99a238e5 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyResponseTest.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.Map; + +import org.junit.*; +import org.openecomp.policy.api.PolicyResponse; + +import static org.junit.Assert.*; + +/** + * The class PolicyResponseTest contains tests for the class {@link PolicyResponse}. + * + * @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 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyTypeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyTypeTest.java new file mode 100644 index 000000000..5b31e857b --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PolicyTypeTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.PolicyType; + +import static org.junit.Assert.*; + +/** + * The class PolicyTypeTest contains tests for the class {@link PolicyType}. + * + * @generatedBy CodePro at 6/1/16 1:41 PM + * @version $Revision: 1.0 $ + */ +public class PolicyTypeTest { + /** + * Run the String toString() method test. + * + * @throws Exception + * + * @generatedBy CodePro at 6/1/16 1:41 PM + */ + @Test + public void testToString_1() + throws Exception { + PolicyType fixture = PolicyType.JSON; + + String result = fixture.toString(); + + // add additional test code here + assertEquals("json", result); + } + + /** + * 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(PolicyTypeTest.class); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PushPolicyParametersTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PushPolicyParametersTest.java new file mode 100644 index 000000000..ef005f1f4 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/PushPolicyParametersTest.java @@ -0,0 +1,269 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import java.util.UUID; + +import org.junit.*; +import org.openecomp.policy.api.PushPolicyParameters; + +import static org.junit.Assert.*; + +/** + * The class PushPolicyParametersTest contains tests for the class {@link PushPolicyParameters}. + * + * @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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/RemovedPolicyTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/RemovedPolicyTest.java new file mode 100644 index 000000000..6a3bf34df --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/RemovedPolicyTest.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.RemovedPolicy; + +import static org.junit.Assert.*; + +/** + * The class RemovedPolicyTest contains tests for the class {@link RemovedPolicy}. + * + * @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 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/SendEventTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/SendEventTest.java new file mode 100644 index 000000000..6fb5137a4 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/SendEventTest.java @@ -0,0 +1,153 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +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.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.policy.api.PolicyEngine; +import org.openecomp.policy.api.PolicyEngineException; +import org.openecomp.policy.api.PolicyEventException; +import org.openecomp.policy.api.PolicyResponse; +import org.openecomp.policy.api.PolicyResponseStatus; + +import org.openecomp.policy.common.logging.flexlogger.*; + +public class SendEventTest { + + private PolicyEngine policyEngine = null; + private Map eventAttributes = new HashMap(); + private Collection 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 + public void testSendEventFail() { + eventAttributes = null; + try { + policyResponse = policyEngine.sendEvent(eventAttributes); + } catch (PolicyEventException e) { + logger.warn(e.getMessage()); + } + assertNull(policyResponse); + } + + //@Test + 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 + 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 + 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 + 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/openecomp/policy/test/TestRunner.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/TestRunner.java new file mode 100644 index 000000000..69cbd834e --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/TestRunner.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.runner.JUnitCore; +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()); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/UpdateTypeTest.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/UpdateTypeTest.java new file mode 100644 index 000000000..909a05f0e --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/UpdateTypeTest.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.policy.test; + +import org.junit.*; +import org.openecomp.policy.api.UpdateType; + +import static org.junit.Assert.*; + +/** + * The class UpdateTypeTest contains tests for the class {@link UpdateType}. + * + * @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; + + String result = fixture.toString(); + + // 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 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); + } +} diff --git a/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/package-info.java b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/package-info.java new file mode 100644 index 000000000..e678c4be2 --- /dev/null +++ b/PolicyEngineAPI/src/test/java/org/openecomp/policy/test/package-info.java @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * PolicyEngineAPI + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +/** + * API JUNIT TestCases. + */ +package org.openecomp.policy.test; -- cgit 1.2.3-korg