X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcomponents%2FBRMSPolicyTest.java;h=5c1d3dd76c742a63e28105c83a16b04e0a8e02fb;hp=333d878ca9f5ecc0277653b46e3bc4d038a1ba49;hb=577b34e9bdad94d0b1559a9917af3283124aeeda;hpb=0c20d1c294fe146e1018f14b07a8d861c29fe527 diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java index 333d878ca..5c1d3dd76 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java @@ -22,15 +22,22 @@ package org.onap.policy.pap.xacml.rest.components; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import com.att.research.xacml.api.pap.PAPException; import java.io.IOException; - +import java.nio.charset.Charset; +import java.util.HashMap; +import java.util.Map; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.Mockito; +import org.onap.policy.rest.adapter.PolicyRestAdapter; import org.onap.policy.rest.dao.CommonClassDao; public class BRMSPolicyTest { @@ -68,4 +75,42 @@ public class BRMSPolicyTest { String userID = "testID"; assertEquals(1, template.addRule(rule, ruleName, description, userID).size()); } + + @Test + public void testCreateBrmsParamPolicyAdapter() throws PAPException { + Map brmsParamBody = new HashMap(); + brmsParamBody.put("key", "value"); + + PolicyRestAdapter adapter = new PolicyRestAdapter(); + adapter.setHighestVersion(1); + adapter.setPolicyType("Config"); + adapter.setBrmsParamBody(brmsParamBody); + adapter.setNewFileName("policyName.1.xml"); + Map dynamicFieldConfigAttributes = new HashMap(); + dynamicFieldConfigAttributes.put("key", "value"); + adapter.setDynamicFieldConfigAttributes(dynamicFieldConfigAttributes); + CreateBrmsParamPolicy policy = new CreateBrmsParamPolicy(adapter); + String ruleContents = "contents"; + + assertThatCode(() -> policy.saveConfigurations("name.xml", "rules")).doesNotThrowAnyException(); + try { + policy.prepareToSave(); + policy.savePolicies(); + } catch (Exception ex) { + // Ignore + } + + assertThatThrownBy(() -> policy.expandConfigBody(ruleContents, brmsParamBody)) + .isInstanceOf(NullPointerException.class); + assertTrue(policy.validateConfigForm()); + policy.getAdviceExpressions(1, "name.1.xml"); + assertNotNull(policy.getCorrectPolicyDataObject()); + } + + @Test + public void testRead() { + Charset encoding = Charset.defaultCharset(); + assertThatCode(() -> CreateBrmsParamPolicy.readFile("xacml.pap.properties", encoding)) + .doesNotThrowAnyException(); + } }