aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java')
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java50
1 files changed, 49 insertions, 1 deletions
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 39586ba1b..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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Modifications Copyright (C) 2019 Samsung
* ================================================================================
@@ -19,15 +19,25 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
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 {
@@ -65,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<String, String> brmsParamBody = new HashMap<String, String>();
+ brmsParamBody.put("key", "value");
+
+ PolicyRestAdapter adapter = new PolicyRestAdapter();
+ adapter.setHighestVersion(1);
+ adapter.setPolicyType("Config");
+ adapter.setBrmsParamBody(brmsParamBody);
+ adapter.setNewFileName("policyName.1.xml");
+ Map<String, String> dynamicFieldConfigAttributes = new HashMap<String, String>();
+ 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();
+ }
}