aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-04-05 15:15:31 +0200
committersebdet <sebastien.determe@intl.att.com>2019-04-05 15:15:31 +0200
commitdfa86ca8a3d8380487261da22cbf582b547e3276 (patch)
treecff6e438b2d363d25935a3ed743bac97e0314fdd /src/test
parent0cb57989949080d6cc3853c432a233605c321388 (diff)
Introduce Camel route
Camel route for Submit operation using http4 component Issue-ID: CLAMP-303 Change-Id: I29804a7db6286dfa84f7eed63813f25299a385e6 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java64
-rw-r--r--src/test/resources/tosca/guard1-policy-payload.json16
-rw-r--r--src/test/resources/tosca/guard2-policy-payload.json16
-rw-r--r--src/test/resources/tosca/operational-policy-payload.yaml31
-rw-r--r--src/test/resources/tosca/operational-policy-properties.json71
5 files changed, 198 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 00000000..1f57422c
--- /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);
+ }
+}
diff --git a/src/test/resources/tosca/guard1-policy-payload.json b/src/test/resources/tosca/guard1-policy-payload.json
new file mode 100644
index 00000000..bacf174f
--- /dev/null
+++ b/src/test/resources/tosca/guard1-policy-payload.json
@@ -0,0 +1,16 @@
+{
+ "policy-id": "guard1",
+ "contents": {
+ "recipe": "Rebuild",
+ "actor": "SO",
+ "clname": "testloop",
+ "guardTargets": ".*",
+ "minGuard": "3",
+ "maxGuard": "7",
+ "limitGuard": "",
+ "timeUnitsGuard": "",
+ "timeWindowGuard": "",
+ "guardActiveStart": "00:00:01-05:00",
+ "guardActiveEnd": "23:59:01-05:00"
+ }
+} \ No newline at end of file
diff --git a/src/test/resources/tosca/guard2-policy-payload.json b/src/test/resources/tosca/guard2-policy-payload.json
new file mode 100644
index 00000000..89f7ec89
--- /dev/null
+++ b/src/test/resources/tosca/guard2-policy-payload.json
@@ -0,0 +1,16 @@
+{
+ "policy-id": "guard2",
+ "contents": {
+ "recipe": "Migrate",
+ "actor": "SO",
+ "clname": "testloop",
+ "guardTargets": ".*",
+ "minGuard": "1",
+ "maxGuard": "2",
+ "limitGuard": "",
+ "timeUnitsGuard": "",
+ "timeWindowGuard": "",
+ "guardActiveStart": "00:00:01-05:00",
+ "guardActiveEnd": "23:59:01-05:00"
+ }
+} \ No newline at end of file
diff --git a/src/test/resources/tosca/operational-policy-payload.yaml b/src/test/resources/tosca/operational-policy-payload.yaml
new file mode 100644
index 00000000..68116b00
--- /dev/null
+++ b/src/test/resources/tosca/operational-policy-payload.yaml
@@ -0,0 +1,31 @@
+tosca_definitions_version: tosca_simple_yaml_1_0_0
+topology_template:
+ policies:
+ - testPolicy:
+ type: onap.policies.controlloop.Operational
+ version: 1.0.0
+ metadata: {policy-id: testPolicy}
+ properties:
+ controlLoop: {controlLoopName: control loop, version: 2.0.0, trigger_policy: new1,
+ timeout: '30', abatement: 'true'}
+ policies:
+ - id: new1
+ recipe: Rebuild
+ retry: '10'
+ timeout: '20'
+ actor: SO
+ payload: test
+ success: new2
+ failure: new2
+ failure_timeout: new2
+ failure_retries: new2
+ failure_exception: new2
+ failure_guard: new2
+ target: {type: VFC, resourceTargetId: test}
+ - id: new2
+ recipe: Migrate
+ retry: '30'
+ timeout: '40'
+ actor: SDNC
+ payload: test
+ target: {type: VFC, resourceTargetId: test}
diff --git a/src/test/resources/tosca/operational-policy-properties.json b/src/test/resources/tosca/operational-policy-properties.json
new file mode 100644
index 00000000..50361659
--- /dev/null
+++ b/src/test/resources/tosca/operational-policy-properties.json
@@ -0,0 +1,71 @@
+{
+ "guard_policies": {
+ "guard1":{
+ "recipe": "Rebuild",
+ "actor": "SO",
+ "clname": "testloop",
+ "guardTargets": ".*",
+ "minGuard": "3",
+ "maxGuard": "7",
+ "limitGuard": "",
+ "timeUnitsGuard": "",
+ "timeWindowGuard": "",
+ "guardActiveStart": "00:00:01-05:00",
+ "guardActiveEnd": "23:59:01-05:00"
+ },
+ "guard2":{
+ "recipe": "Migrate",
+ "actor": "SO",
+ "clname": "testloop",
+ "guardTargets": ".*",
+ "minGuard": "1",
+ "maxGuard": "2",
+ "limitGuard": "",
+ "timeUnitsGuard": "",
+ "timeWindowGuard": "",
+ "guardActiveStart": "00:00:01-05:00",
+ "guardActiveEnd": "23:59:01-05:00"
+ }
+ },
+ "operational_policy": {
+ "controlLoop": {
+ "controlLoopName": "control loop",
+ "version": "2.0.0",
+ "trigger_policy": "new1",
+ "timeout": "30",
+ "abatement": "true"
+ },
+ "policies": [
+ {
+ "id": "new1",
+ "recipe": "Rebuild",
+ "retry": "10",
+ "timeout": "20",
+ "actor": "SO",
+ "payload": "test",
+ "success": "new2",
+ "failure": "new2",
+ "failure_timeout": "new2",
+ "failure_retries": "new2",
+ "failure_exception": "new2",
+ "failure_guard": "new2",
+ "target": {
+ "type": "VFC",
+ "resourceTargetId": "test"
+ }
+ },
+ {
+ "id": "new2",
+ "recipe": "Migrate",
+ "retry": "30",
+ "timeout": "40",
+ "actor": "SDNC",
+ "payload": "test",
+ "target": {
+ "type": "VFC",
+ "resourceTargetId": "test"
+ }
+ }
+ ]
+ }
+}