summaryrefslogtreecommitdiffstats
path: root/runtime/src/test/java
diff options
context:
space:
mode:
authorsaul.gill <saul.gill@est.tech>2021-06-29 12:57:29 +0100
committersaul.gill <saul.gill@est.tech>2021-07-02 12:34:08 +0100
commitc19601d2080baa401cd17286985b6a0ee47d9a07 (patch)
treee8e69ef79f3ea1ff8bb0d6a3efe7da8a8d88914a /runtime/src/test/java
parent7d04c23c7c51738d68f325e450ac408c1ae9905f (diff)
Added ITs for Commissioning Camel Endpoints
Changed emulator to deal with new endpoint tests Added spring property to deal with camel endpoint issue Fixed lingering checkstyle violations Issue-ID: POLICY-3440 Change-Id: I5810913c4418e7893f3ad848618deec1b1a85a0f Signed-off-by: saul.gill <saul.gill@est.tech>
Diffstat (limited to 'runtime/src/test/java')
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/downloader/PolicyEngineControllerTestItCase.java14
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java91
2 files changed, 98 insertions, 7 deletions
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/downloader/PolicyEngineControllerTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/policy/downloader/PolicyEngineControllerTestItCase.java
index 4dd620c4b..8fbd2712b 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/downloader/PolicyEngineControllerTestItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/downloader/PolicyEngineControllerTestItCase.java
@@ -72,15 +72,15 @@ public class PolicyEngineControllerTestItCase {
List<PolicyModel> policyModelsList = policyModelsRepository.findAll();
assertThat(policyModelsList.size()).isGreaterThanOrEqualTo(5);
assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.common.Drools",
- null, "1.0.0"));
+ null, "1.0.0"));
assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.common.Apex",
- null, "1.0.0"));
+ null, "1.0.0"));
assertThat(policyModelsList)
- .contains(new PolicyModel("onap.policies.controlloop.guard.common.FrequencyLimiter", null, "1.0.0"));
+ .contains(new PolicyModel("onap.policies.controlloop.guard.common.FrequencyLimiter", null, "1.0.0"));
assertThat(policyModelsList)
- .contains(new PolicyModel("onap.policies.controlloop.guard.common.Blacklist", null, "1.0.0"));
+ .contains(new PolicyModel("onap.policies.controlloop.guard.common.Blacklist", null, "1.0.0"));
assertThat(policyModelsList)
- .contains(new PolicyModel("onap.policies.controlloop.guard.common.MinMax", null, "2.0.0"));
+ .contains(new PolicyModel("onap.policies.controlloop.guard.common.MinMax", null, "2.0.0"));
// Re-do it to check that there is no issue with duplicate key
policyController.synchronizeAllPolicies();
@@ -104,9 +104,9 @@ public class PolicyEngineControllerTestItCase {
assertThat(policyModelsList.size()).isGreaterThanOrEqualTo(2);
PolicyModel policy1 = policyModelsRepository
- .getOne(new PolicyModelId("onap.policies.monitoring.test", "1.0.0"));
+ .getOne(new PolicyModelId("onap.policies.monitoring.test", "1.0.0"));
PolicyModel policy2 = policyModelsRepository
- .getOne(new PolicyModelId("onap.policies.controlloop.Operational", "1.0.0"));
+ .getOne(new PolicyModelId("onap.policies.controlloop.Operational", "1.0.0"));
String expectedRes1 = "{\"supportedPdpGroups\":[{\"monitoring\":[\"xacml\"]}]}";
JsonObject expectedJson1 = JsonUtils.GSON.fromJson(expectedRes1, JsonObject.class);
diff --git a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java
new file mode 100644
index 000000000..0ba1486bb
--- /dev/null
+++ b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.runtime;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.ExchangeBuilder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.policy.clamp.clds.Application;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.HttpStatus;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class RuntimeCommissioningResponseTestItCase {
+ @Autowired
+ CamelContext camelContext;
+
+ private static final String SAMPLE_TOSCA_TEMPLATE =
+ "{\"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\","
+ + "\"data_types\": {},\"node_types\": {}, \"policy_types\": {},"
+ + " \"topology_template\": {},"
+ + " \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\", \"metadata\": {}}";
+
+ @Test
+ public void testToscaServiceTemplateStatus() {
+ ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
+
+ Exchange exchangeResponse =
+ prodTemplate.send("direct:get-service-template", ExchangeBuilder.anExchange(camelContext)
+ .withProperty("name", "ToscaServiceTemplate")
+ .withProperty("version", "1.0.0")
+ .withProperty("raiseHttpExceptionFlag", "true")
+ .build());
+
+ assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
+ .is2xxSuccessful()).isTrue();
+ }
+
+ @Test
+ public void testToscaServiceTemplateGetResponseBody() {
+ ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
+
+ Exchange exchangeResponse =
+ prodTemplate.send("direct:get-service-template", ExchangeBuilder.anExchange(camelContext)
+ .withProperty("name", "ToscaServiceTemplate")
+ .withProperty("version", "1.0.0")
+ .withProperty("raiseHttpExceptionFlag", "true")
+ .build());
+
+ assertThat(exchangeResponse.getIn().getBody().toString()).isEqualTo(SAMPLE_TOSCA_TEMPLATE);
+ }
+
+ @Test
+ public void testCommissioningOfToscaServiceTemplateStatus() {
+ ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
+
+ Exchange exchangeResponse =
+ prodTemplate.send("direct:commission-service-template", ExchangeBuilder.anExchange(camelContext)
+ .withBody(SAMPLE_TOSCA_TEMPLATE)
+ .withProperty("raiseHttpExceptionFlag", "true")
+ .build());
+
+ assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
+ .is2xxSuccessful()).isTrue();
+ }
+}