aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java103
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java6
-rw-r--r--src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java2
-rw-r--r--src/test/resources/application.properties2
-rw-r--r--src/test/resources/example/sdc/blueprint-dcae/tca.yaml2
-rw-r--r--src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml2
-rw-r--r--src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml2
-rw-r--r--src/test/resources/example/sdc/expected-result/policy-data.yaml2
-rwxr-xr-xsrc/test/resources/example/sdc/service-Vloadbalancerms-csar.csarbin110668 -> 110734 bytes
-rw-r--r--src/test/resources/tosca/micro-service-policy-payload.json2
-rw-r--r--src/test/resources/tosca/tosca_example.yaml2
11 files changed, 114 insertions, 11 deletions
diff --git a/src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java
new file mode 100644
index 000000000..70edabe68
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Samsung. 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.clds.client;
+
+import org.apache.camel.Exchange;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.exception.ModelBpmnException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TcaPolicyDeleteDelegateTest {
+
+ private static final String TCA_ID_FROM_JSON = "{\"tca\":[{\"id\":\"\",\"from\":\"\"}]}";
+ private static final String HOLMES_ID_FROM_JSON = "{\"holmes\":[{\"id\":\"\",\"from\":\"\"}]}";
+ private static final String ID_JSON = "{\"id\":\"\"}";
+ private static final String NOT_JSON = "not json";
+ private static final String MODEL_BPMN_KEY = "modelBpmnProp";
+ private static final String MODEL_PROP_KEY = "modelProp";
+ private static final String TEST_KEY = "isTest";
+ private static final String PROPERTY_NAME = "tcaPolicyDeleteResponseMessage";
+ private static final String MESSAGE = "message";
+
+ @Mock
+ private Exchange camelExchange;
+
+ @Mock
+ private PolicyClient policyClient;
+
+ @InjectMocks
+ private TcaPolicyDeleteDelegate tcaPolicyDeleteDelegate;
+
+ @Test
+ public void shouldExecuteSuccessfully() {
+ //given
+ Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(TCA_ID_FROM_JSON);
+ Mockito.when(camelExchange.getProperty(MODEL_PROP_KEY)).thenReturn(ID_JSON);
+ Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false);
+
+ Mockito.when(policyClient.deleteMicrosService(Mockito.any())).thenReturn(MESSAGE);
+
+ //when
+ tcaPolicyDeleteDelegate.execute(camelExchange);
+
+ //then
+ Mockito.verify(camelExchange).setProperty(PROPERTY_NAME, MESSAGE.getBytes());
+ }
+
+ @Test
+ public void shouldExecuteTcaNotFound() {
+ //given
+ Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(HOLMES_ID_FROM_JSON);
+ Mockito.when(camelExchange.getProperty(MODEL_PROP_KEY)).thenReturn(ID_JSON);
+ Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false);
+
+ //when
+ tcaPolicyDeleteDelegate.execute(camelExchange);
+
+ //then
+ Mockito.verify(policyClient, Mockito.never()).deleteMicrosService(Mockito.any());
+ Mockito.verify(camelExchange, Mockito.never()).setProperty(Mockito.any(), Mockito.any());
+ }
+
+ @Test(expected = ModelBpmnException.class)
+ public void shouldThrowModelBpmnException() {
+ //given
+ Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(NOT_JSON);
+ Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false);
+
+ //when
+ tcaPolicyDeleteDelegate.execute(camelExchange);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void shouldThrowNullPointerException() {
+ //when
+ tcaPolicyDeleteDelegate.execute(camelExchange);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java
index e86fb27d0..211bb3906 100644
--- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java
+++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java
@@ -163,8 +163,8 @@ public class BlueprintParserTest {
@Test
public void fallBackToOneMicroServiceTCATest() {
- MicroService tcaMS = new MicroService(BlueprintParser.TCA, "onap.policy.monitoring.cdap.tca.hi.lo.app", "", "",
- "");
+ MicroService tcaMS = new MicroService(BlueprintParser.TCA, "onap.policies.monitoring.cdap.tca.hi.lo.app", "",
+ "", "");
List<MicroService> expected = Collections.singletonList(tcaMS);
List<MicroService> actual = new BlueprintParser().fallbackToOneMicroService(microServiceBlueprintOldStyleTCA);
@@ -174,7 +174,7 @@ public class BlueprintParserTest {
@Test
public void fallBackToOneMicroServiceHolmesTest() {
- MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "onap.policy.monitoring.cdap.tca.hi.lo.app",
+ MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "onap.policies.monitoring.cdap.tca.hi.lo.app",
"", "", "");
List<MicroService> expected = Collections.singletonList(holmesMS);
diff --git a/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java
index c511f3415..68925a913 100644
--- a/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java
+++ b/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java
@@ -37,7 +37,7 @@ public class MicroServicePayloadTest {
@Test
public void testPayloadConstruction() throws IOException {
- MicroServicePolicy policy = new MicroServicePolicy("testPolicy", "onap.policy.monitoring.cdap.tca.hi.lo.app",
+ MicroServicePolicy policy = new MicroServicePolicy("testPolicy", "onap.policies.monitoring.cdap.tca.hi.lo.app",
ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml"), false, new HashSet<>());
policy.setProperties(JsonUtils.GSON.fromJson(
ResourceFileUtil.getResourceAsString("tosca/micro-service-policy-properties.json"), JsonObject.class));
diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties
index 9f711e3e9..26e0b3b9d 100644
--- a/src/test/resources/application.properties
+++ b/src/test/resources/application.properties
@@ -141,7 +141,7 @@ clamp.config.dcae.deployment.template=classpath:/clds/templates/dcae-deployment-
#
#
# Configuration Settings for Policy Engine Components
-clamp.config.policy.url=http://localhost:${docker.http-cache.port.host}
+clamp.config.policy.url=http4://localhost:${docker.http-cache.port.host}
clamp.config.policy.userName=test
clamp.config.policy.password=test
clamp.config.policy.pdpUrl1=http://localhost:${docker.http-cache.port.host}/pdp/ , testpdp, alpha123
diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca.yaml
index b2bf8bb96..edaa0be28 100644
--- a/src/test/resources/example/sdc/blueprint-dcae/tca.yaml
+++ b/src/test/resources/example/sdc/blueprint-dcae/tca.yaml
@@ -17,7 +17,7 @@ node_templates:
properties:
policy_id:
get_input: policy_id
- policy_type_id: onap.policy.monitoring.cdap.tca.hi.lo.app
+ policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app
cdap_host_host:
type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure
properties:
diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml
index fb042575b..c834b1b93 100644
--- a/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml
+++ b/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml
@@ -166,5 +166,5 @@ node_templates:
properties:
policy_id:
get_input: policy_id
- policy_type_id: onap.policy.monitoring.cdap.tca.hi.lo.app
+ policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app
diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml
index b2bf8bb96..edaa0be28 100644
--- a/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml
+++ b/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml
@@ -17,7 +17,7 @@ node_templates:
properties:
policy_id:
get_input: policy_id
- policy_type_id: onap.policy.monitoring.cdap.tca.hi.lo.app
+ policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app
cdap_host_host:
type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure
properties:
diff --git a/src/test/resources/example/sdc/expected-result/policy-data.yaml b/src/test/resources/example/sdc/expected-result/policy-data.yaml
index 7f2c4847b..2d3153112 100644
--- a/src/test/resources/example/sdc/expected-result/policy-data.yaml
+++ b/src/test/resources/example/sdc/expected-result/policy-data.yaml
@@ -135,7 +135,7 @@ policy_types:
tosca.policies.Monitoring:
derived_from: tosca.policies.Root
description: A base policy type for all policies that governs monitoring provisioning
- onap.policy.monitoring.cdap.tca.hi.lo.app:
+ onap.policies.monitoring.cdap.tca.hi.lo.app:
derived_from: tosca.policies.Monitoring
version: 1.0.0
properties:
diff --git a/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar b/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar
index b5fe39d31..727ef16b7 100755
--- a/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar
+++ b/src/test/resources/example/sdc/service-Vloadbalancerms-csar.csar
Binary files differ
diff --git a/src/test/resources/tosca/micro-service-policy-payload.json b/src/test/resources/tosca/micro-service-policy-payload.json
index 01d6d275c..2de06b083 100644
--- a/src/test/resources/tosca/micro-service-policy-payload.json
+++ b/src/test/resources/tosca/micro-service-policy-payload.json
@@ -4,7 +4,7 @@
"policies": [
{
"testPolicy": {
- "type": "onap.policy.monitoring.cdap.tca.hi.lo.app",
+ "type": "onap.policies.monitoring.cdap.tca.hi.lo.app",
"version": "1.0.0",
"metadata": {
"policy-id": "testPolicy"
diff --git a/src/test/resources/tosca/tosca_example.yaml b/src/test/resources/tosca/tosca_example.yaml
index 699cffd7e..b0119f887 100644
--- a/src/test/resources/tosca/tosca_example.yaml
+++ b/src/test/resources/tosca/tosca_example.yaml
@@ -3,7 +3,7 @@ policy_types:
onap.policies.Monitoring:
derived_from: tosca.policies.Root
description: a base policy type for all policies that governs monitoring provisioning
- onap.policy.monitoring.cdap.tca.hi.lo.app:
+ onap.policies.monitoring.cdap.tca.hi.lo.app:
derived_from: onap.policies.Monitoring
version: 1.0.0
properties: