diff options
author | Michael Mokry <mm117s@att.com> | 2018-09-10 15:23:15 -0500 |
---|---|---|
committer | Michael Mokry <mm117s@att.com> | 2018-09-11 10:31:26 -0500 |
commit | e957a1d9a9fa6bd0f9f8348d1e864c09cfe2cb92 (patch) | |
tree | a09024bc2c7e6a3b69affd95de9352c7d4d5c468 /ONAP-PAP-REST/src/test/java/org/onap | |
parent | 1134bd40da28d3833a0dd4f821e75ec938f6061f (diff) |
New min/max Guard Policy
Made changes to support Guard policy create/update and other policy manager
functions including deletePolicy and pushPolicy.
Includes changes for new Guard policy support using GUI and API (Rest and Java Client)
Made changes to address Jim's comments
Made changes to address Liam's comments
Change-Id: I133fe1fd9287ea77ea41a2788de90c7642c36b6a
Issue-ID: POLICY-1038
Signed-off-by: Mike Mokry <mm117s@att.com>
Diffstat (limited to 'ONAP-PAP-REST/src/test/java/org/onap')
-rw-r--r-- | ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java index 4ba72afcb..00553e0ee 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java @@ -408,6 +408,43 @@ public class XACMLPAPTest { Mockito.verify(httpServletResponse).addHeader("successMapKey", "success"); Mockito.verify(httpServletResponse).addHeader("policyName", "test.Decision_testGuard.1.xml"); } + + @Test + public void testDecisonGuardMinMaxPolicy() throws IOException, ServletException, SQLException { + httpServletRequest = Mockito.mock(HttpServletRequest.class); + Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn("DEVL"); + Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT"); + Mockito.when(httpServletRequest.getParameter("apiflag")).thenReturn("api"); + Mockito.when(httpServletRequest.getParameter("operation")).thenReturn("create"); + Mockito.when(httpServletRequest.getParameter("policyType")).thenReturn("Decision"); + Map<String, String> matchingAttributes = new HashMap<>(); + matchingAttributes.put("actor", "test"); + matchingAttributes.put("recipe", "scaleOut"); + matchingAttributes.put("targets", "test,test1"); + matchingAttributes.put("clname", "test"); + matchingAttributes.put("min", "1"); + matchingAttributes.put("max", "5"); + matchingAttributes.put("guardActiveStart", "05:00"); + matchingAttributes.put("guardActiveEnd", "10:00"); + StdPAPPolicy newPAPPolicy = + + new StdPAPPolicy( + StdPAPPolicyParams.builder().policyName("testGuard").description("test rule").onapName("PDPD") + .providerComboBox("GUARD_MIN_MAX").dynamicFieldConfigAttributes(matchingAttributes) + .editPolicy(false).domain("test").highestVersion(0).build()); + MockServletInputStream mockInput = new MockServletInputStream( + PolicyUtils.objectToJsonString(newPAPPolicy).getBytes()); + Mockito.when(httpServletRequest.getInputStream()).thenReturn(mockInput); + + // set DBDao + setDBDao(); + pap.service(httpServletRequest, httpServletResponse); + + Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK); + Mockito.verify(httpServletResponse).addHeader("successMapKey", "success"); + Mockito.verify(httpServletResponse).addHeader("policyName", "test.Decision_testGuard.1.xml"); + } + @Test public void testDecisonBLGuardPolicy() throws IOException, ServletException, SQLException { |