summaryrefslogtreecommitdiffstats
path: root/ONAP-PDP-REST/src/test
diff options
context:
space:
mode:
authorMichael Mokry <mm117s@att.com>2017-11-14 15:01:13 -0600
committerMichael Mokry <mm117s@att.com>2017-12-04 15:19:21 +0000
commitb3828de54af94f66e3a6e22bcaeb3372d14eab34 (patch)
tree8f89a097cb8979f1e1cbb3dcc4df61a695a0db27 /ONAP-PDP-REST/src/test
parentdb597fe2163c073e37ad2ddc0d7fe386517e21e0 (diff)
Refactor to provide Common Policy Validation
Provides a common class to perform policy validation during create/udpate of policies by the GUI and API for consistency. Change-Id: Ied459e73d48517bb50064cd10d6a1c871b8311e5 Issue-ID: POLICY-449 Signed-off-by: Michael Mokry <mm117s@att.com>
Diffstat (limited to 'ONAP-PDP-REST/src/test')
-rw-r--r--ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java42
1 files changed, 21 insertions, 21 deletions
diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java
index ac8b269eb..8fea627c9 100644
--- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java
+++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/api/test/PolicyEngineServicesTest.java
@@ -453,9 +453,9 @@ public class PolicyEngineServicesTest {
pep.setAttributes(attributes);
pep.setRiskLevel("5");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
// Checks for BRMS Raw Policy
pep.setPolicyConfigType(PolicyConfigType.BRMS_RAW);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
@@ -469,9 +469,9 @@ public class PolicyEngineServicesTest {
.headers(headers)).andExpect(status().isBadRequest());
pep.setRiskLevel("5");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
}
@Test
@@ -505,11 +505,11 @@ public class PolicyEngineServicesTest {
.headers(headers)).andExpect(status().isBadRequest());
pep.setConfigName("configName");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
pep.setConfigBody("{'test':'test}");
pep.setConfigBodyType(PolicyType.JSON);
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
Map<AttributeType, Map<String,String>> attributes = new HashMap<>();
Map<String,String> matching = new HashMap<>();
matching.put("key", "value");
@@ -517,7 +517,7 @@ public class PolicyEngineServicesTest {
pep.setAttributes(attributes);
pep.setConfigBody("testBody");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
}
@Test
@@ -546,15 +546,15 @@ public class PolicyEngineServicesTest {
.headers(headers)).andExpect(status().isBadRequest());
pep.setConfigBody("{\"onapname\":\"test\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
pep.setRiskLevel("test");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
.headers(headers)).andExpect(status().isBadRequest());
pep.setRiskLevel("4");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
}
@Test
@@ -588,15 +588,15 @@ public class PolicyEngineServicesTest {
.headers(headers)).andExpect(status().isBadRequest());
pep.setConfigBody("{\"onapname\":\"test\", \"serviceTypePolicyName\":\"value\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
pep.setRiskLevel("test");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
.headers(headers)).andExpect(status().isBadRequest());
pep.setRiskLevel("4");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
}
@Test
@@ -626,9 +626,9 @@ public class PolicyEngineServicesTest {
.headers(headers)).andExpect(status().isBadRequest());
pep.setConfigBody("{\"configName\":\"test\"}");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
}
@Test
@@ -659,10 +659,10 @@ public class PolicyEngineServicesTest {
.headers(headers)).andExpect(status().isBadRequest());
pep.setRiskLevel("4");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
pep.setConfigBody("{\"service\":\"test\",\"uuid\":\"test\",\"location\":\"test\",\"configName\":\"test\",\"description\":\"test\",\"priority\":\"test\",\"version\":\"test\"}");
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
}
@Test
@@ -708,18 +708,18 @@ public class PolicyEngineServicesTest {
.headers(headers)).andExpect(status().isBadRequest());
pep.setOnapName("xyz");
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
attributes.remove(AttributeType.MATCHING);
attributes.put(AttributeType.SETTINGS, matching);
pep.setAttributes(attributes);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
attributes.put(AttributeType.MATCHING, matching);
pep.setAttributes(attributes);
mockMvc.perform(put("/createPolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
mockMvc.perform(put("/updatePolicy").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
- .headers(headers)).andExpect(status().isInternalServerError());
+ .headers(headers)).andExpect(status().isBadRequest());
}
@Test