diff options
author | Liam Fallon <liam.fallon@est.tech> | 2021-07-05 07:54:46 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-07-05 07:54:46 +0000 |
commit | 68599cace010d09d3a0a8a767241186df078a49d (patch) | |
tree | 1b1a9e8cec0fcd774c70fa497826c24cf0214efa /runtime/src/test/java | |
parent | 72d882f65031518e9d1b1a6d6e53c7d42ab8495f (diff) | |
parent | c19601d2080baa401cd17286985b6a0ee47d9a07 (diff) |
Merge "Added ITs for Commissioning Camel Endpoints"
Diffstat (limited to 'runtime/src/test/java')
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(); + } +} |