aboutsummaryrefslogtreecommitdiffstats
path: root/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getConfigTest.java
diff options
context:
space:
mode:
authorTarun Tej Velaga <tt3868@att.com>2017-07-24 17:13:43 +0000
committerTarun Tej Velaga <tt3868@att.com>2017-07-25 14:23:59 +0000
commite92ff832cf993db876f22b2d27562fedf59f5043 (patch)
tree47429eeaaf4241905d7ea1f71dbdb5c2d0504618 /ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getConfigTest.java
parent570290dc6ba8198e653022c2f6f8e5d01cfa8d1b (diff)
[Policy-52, Policy-92, Policy-93] Policy Enhancements and bugfixes
Change-Id: I5675cf4527e17963b3142cf7184c0df31a766197 Signed-off-by: Tarun Tej Velaga <tt3868@att.com>
Diffstat (limited to 'ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getConfigTest.java')
-rw-r--r--ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getConfigTest.java70
1 files changed, 70 insertions, 0 deletions
diff --git a/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getConfigTest.java b/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getConfigTest.java
new file mode 100644
index 000000000..ebe86b0d8
--- /dev/null
+++ b/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/api/test/getConfigTest.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ECOMP-PDP-REST
+ * ================================================================================
+ * 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.pdp.rest.api.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.openecomp.policy.api.ConfigRequestParameters;
+import org.openecomp.policy.api.PolicyConfigStatus;
+import org.openecomp.policy.pdp.rest.api.models.PolicyConfig;
+import org.openecomp.policy.pdp.rest.api.services.GetConfigService;
+
+public class getConfigTest {
+ private static final String TEST = "test";
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void filterMethodTest() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
+ ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
+ GetConfigService getConfigService= new GetConfigService(configRequestParameters, null);
+ Method filter = GetConfigService.class.getDeclaredMethod("filterResults", Collection.class,ConfigRequestParameters.class);
+ filter.setAccessible(true);
+ List<PolicyConfig> policyConfigs = new LinkedList<>();
+
+ List<PolicyConfig> filterResults = (List<PolicyConfig>) filter.invoke(getConfigService, policyConfigs,configRequestParameters);
+ assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus());
+ // Check again with some values
+ configRequestParameters.setPolicyName(TEST);
+ configRequestParameters.setEcompName(TEST);
+ configRequestParameters.setConfigName(TEST);
+ Map<String,String> configAttributes = new HashMap<>();
+ configAttributes.put(TEST, TEST);
+ configRequestParameters.setConfigAttributes(configAttributes);
+ PolicyConfig pConfig = new PolicyConfig();
+ pConfig.setPolicyName(TEST);
+ Map<String,String> matching = new HashMap<>();
+ matching.put("ECOMPName", TEST);
+ matching.put("ConfigName", TEST);
+ matching.put("TEST", TEST);
+ pConfig.setMatchingConditions(matching);
+ policyConfigs.add(pConfig);
+ filterResults = (List<PolicyConfig>) filter.invoke(getConfigService, policyConfigs,configRequestParameters);
+ assertEquals(PolicyConfigStatus.CONFIG_NOT_FOUND, filterResults.get(0).getPolicyConfigStatus());
+ }
+}