aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorXue Gao <xg353y@intl.att.com>2019-04-05 14:34:04 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-05 14:34:04 +0000
commita9f66923cddf2263ebbeb24825b95875c6932281 (patch)
tree6253fdfebe8dfa8e41d74461a4a4253edf5c2085 /src/test/java/org
parent8ca701623868f201f4248131ff7a5b26f547385d (diff)
parentdfa86ca8a3d8380487261da22cbf582b547e3276 (diff)
Merge "Introduce Camel route"
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
new file mode 100644
index 000000000..1f57422c5
--- /dev/null
+++ b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.policy.microservice;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonObject;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.clamp.policy.operational.OperationalPolicy;
+import org.skyscreamer.jsonassert.JSONAssert;
+
+public class OperationalPolicyPayloadTest {
+
+ @Test
+ public void testOperationalPolicyPayloadConstruction() throws IOException {
+ JsonObject jsonConfig = new GsonBuilder().create().fromJson(
+ ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class);
+ OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig);
+ assertThat(policy.createPolicyPayload())
+ .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload.yaml"));
+ }
+
+ @Test
+ public void testGuardPolicyPayloadConstruction() throws IOException {
+ JsonObject jsonConfig = new GsonBuilder().create().fromJson(
+ ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class);
+ OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig);
+
+ List<String> guardsList = policy.createGuardPolicyPayloads();
+
+ JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/guard1-policy-payload.json"),
+ guardsList.get(0), false);
+
+ JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/guard2-policy-payload.json"),
+ guardsList.get(1), false);
+ }
+}