X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Ftest%2FXACMLPAPTest.java;fp=ONAP-PAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Ftest%2FXACMLPAPTest.java;h=00553e0eeed1c3d33fb526262f71aba945b934ad;hb=e957a1d9a9fa6bd0f9f8348d1e864c09cfe2cb92;hp=4ba72afcb97f67c132d0519335aaabbac1787358;hpb=1134bd40da28d3833a0dd4f821e75ec938f6061f;p=policy%2Fengine.git 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 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 {