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/CldsEventDelegateTest.java83
-rw-r--r--src/test/java/org/onap/clamp/clds/client/GuardPolicyDelegateTest.java108
-rw-r--r--src/test/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegateTest.java117
-rw-r--r--src/test/java/org/onap/clamp/clds/client/HolmesPolicyDelegateTest.java183
-rw-r--r--src/test/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegateTest.java104
-rw-r--r--src/test/java/org/onap/clamp/clds/client/ModelDeleteDelegateTest.java63
-rw-r--r--src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java125
-rw-r--r--src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java108
-rw-r--r--src/test/java/org/onap/clamp/clds/client/TcaPolicyDelegateTest.java166
-rw-r--r--src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java13
-rw-r--r--src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java80
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsHealthcheckServiceItCase.java2
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java1
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java2
-rw-r--r--src/test/java/org/onap/clamp/clds/it/PermissionTestDefaultHelper.java61
-rw-r--r--src/test/java/org/onap/clamp/clds/it/PermissionTestHelper.java79
-rw-r--r--src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java51
-rw-r--r--src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java7
-rw-r--r--src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java74
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java14
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java24
-rw-r--r--src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java48
-rw-r--r--src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java7
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java8
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java3
-rw-r--r--src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java99
-rw-r--r--src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java24
-rw-r--r--src/test/java/org/onap/clamp/loop/DcaeComponentTest.java93
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopOperationTestItCase.java250
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java6
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java2
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopToJsonTest.java13
-rw-r--r--src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java11
-rw-r--r--src/test/javascript/propertyController.test.js12
-rw-r--r--src/test/resources/application.properties438
-rw-r--r--src/test/resources/clds/blueprint-with-microservice-chain.yaml6
-rw-r--r--src/test/resources/clds/clds-parse-exception.json1
-rw-r--r--src/test/resources/clds/single-microservice-fragment-valid.yaml2
-rw-r--r--src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json25
-rw-r--r--src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json48
-rw-r--r--src/test/resources/example/sdc/blueprint-dcae/tca.yaml2
-rw-r--r--src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml160
-rw-r--r--src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml240
-rwxr-xr-xsrc/test/resources/http-cache/third_party_proxy.py94
-rw-r--r--src/test/resources/https/https-test.properties1
-rw-r--r--src/test/resources/tosca/guard1-policy-payload.json14
-rw-r--r--src/test/resources/tosca/guard2-policy-payload.json14
-rw-r--r--src/test/resources/tosca/operational-policy-no-guard-properties.json2
-rw-r--r--src/test/resources/tosca/operational-policy-payload-legacy.yaml39
-rw-r--r--src/test/resources/tosca/operational-policy-payload.json2
-rw-r--r--src/test/resources/tosca/operational-policy-payload.yaml25
-rw-r--r--src/test/resources/tosca/operational-policy-properties.json28
52 files changed, 2373 insertions, 809 deletions
diff --git a/src/test/java/org/onap/clamp/clds/client/CldsEventDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/CldsEventDelegateTest.java
new file mode 100644
index 00000000..3b5a9ee0
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/client/CldsEventDelegateTest.java
@@ -0,0 +1,83 @@
+/*-
+ * ============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 static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+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.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.dao.CldsDao;
+
+@RunWith(MockitoJUnitRunner.class)
+public class CldsEventDelegateTest {
+
+ private static final String CONTROL_NAME_KEY = "controlName";
+ private static final String TEST_KEY = "isTest";
+ private static final String INSERT_TEST_EVENT_KEY = "isInsertTestEvent";
+ private static final String PREFIX = "abcdef-";
+ private static final String UUID = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-123456789";
+
+ @Mock
+ private Exchange exchange;
+
+ @Mock
+ private CldsDao cldsDao;
+
+ @InjectMocks
+ private CldsEventDelegate cldsEventDelegate;
+
+ @Test
+ public void shouldExecuteSuccessfully() {
+ // given
+ when(exchange.getProperty(eq(CONTROL_NAME_KEY))).thenReturn(PREFIX + UUID);
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+ when(exchange.getProperty(eq(INSERT_TEST_EVENT_KEY))).thenReturn(false);
+
+ // when
+ cldsEventDelegate.addEvent(exchange, null);
+
+ // then
+ verify(cldsDao).insEvent(eq(null), eq(PREFIX), eq(UUID), any());
+ }
+
+ @Test
+ public void shouldExecuteWithoutInsertingEventIntoDatabase() {
+ // given
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true);
+ when(exchange.getProperty(eq(INSERT_TEST_EVENT_KEY))).thenReturn(false);
+
+ // when
+ cldsEventDelegate.addEvent(exchange, null);
+
+ // then
+ verify(cldsDao, never()).insEvent(any(), any(), any(), any());
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/client/GuardPolicyDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/GuardPolicyDelegateTest.java
new file mode 100644
index 00000000..4b21d6f8
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/client/GuardPolicyDelegateTest.java
@@ -0,0 +1,108 @@
+/*-
+ * ============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 static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+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.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.exception.ModelBpmnException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class GuardPolicyDelegateTest {
+
+ private static final String TEST_KEY = "isTest";
+ private static final String MODEL_BPMN_KEY = "modelBpmnProp";
+ private static final String MODEL_PROP_KEY = "modelProp";
+ private static final String POLICY_ID_FROM_JSON = "{policy:[{id:guard,from:''}]}";
+ private static final String ID_WITH_CHAIN_JSON = "{guard:{q:["
+ + "{name:timeout,value:200},"
+ + "{policyConfigurations:["
+ + "[{name:maxRetries,value:3},"
+ + "{name:retryTimeLimit,value:800},"
+ + "{name:enableGuardPolicy,value:on}]]}]}}";
+ private static final String SIMPLE_JSON = "{}";
+ private static final String NOT_JSON = "not json";
+
+ @Mock
+ private Exchange exchange;
+
+ @Mock
+ private PolicyClient policyClient;
+
+ @InjectMocks
+ private GuardPolicyDelegate guardPolicyDelegate;
+
+ @Test
+ public void shouldExecuteSuccessfully() {
+ // given
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_WITH_CHAIN_JSON);
+
+ // when
+ guardPolicyDelegate.execute(exchange);
+
+ // then
+ verify(policyClient).sendGuardPolicy(any(), any(), any(), any());
+ }
+
+ @Test
+ public void shouldExecutePolicyNotFound() {
+ // given
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(SIMPLE_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(SIMPLE_JSON);
+
+ // when
+ guardPolicyDelegate.execute(exchange);
+
+ // then
+ verify(policyClient, never()).sendGuardPolicy(any(), any(), any(), any());
+ }
+
+ @Test(expected = ModelBpmnException.class)
+ public void shouldThrowModelBpmnException() {
+ // given
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true);
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
+
+ // when
+ guardPolicyDelegate.execute(exchange);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void shouldThrowNullPointerException() {
+ // when
+ guardPolicyDelegate.execute(exchange);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegateTest.java
new file mode 100644
index 00000000..2ff8166b
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegateTest.java
@@ -0,0 +1,117 @@
+/*-
+ * ============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 static org.mockito.Mockito.any;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+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.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.exception.ModelBpmnException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class GuardPolicyDeleteDelegateTest {
+
+ 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 EVENT_ACTION_KEY = "eventAction";
+
+ private static final String POLICY_ID_FROM_JSON = "{policy:[{id:Policy_7,from:''}]}";
+ private static final String TCA_ID_FROM_JSON = "{tca:[{id:'',from:''}]}";
+ private static final String ID_JSON = "{Policy_7:{r:["
+ + "{name:pid,value:pid334},"
+ + "{name:timeout,value:50},"
+ + "{name:policyType,value:pt},"
+ + "{policyConfigurations:[["
+ + "{name:_id,value:ret345},"
+ + "{name:recipe,value:make},"
+ + "{name:maxRetries,value:5},"
+ + "{name:retryTimeLimit,value:100},"
+ + "{name:enableGuardPolicy,value:on}]]}]}}";
+ private static final String NOT_JSON = "not json";
+ private static final String EVENT_ACTION_VALUE = "action";
+
+ @Mock
+ private Exchange exchange;
+
+ @Mock
+ private PolicyClient policyClient;
+
+ @InjectMocks
+ private GuardPolicyDeleteDelegate guardPolicyDeleteDelegate;
+
+ @Test
+ public void shouldExecuteSuccessfully() {
+ // given
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+ when(exchange.getProperty(eq(EVENT_ACTION_KEY))).thenReturn(EVENT_ACTION_VALUE);
+
+ // when
+ guardPolicyDeleteDelegate.execute(exchange);
+
+ // then
+ verify(policyClient).deleteGuard(any());
+ }
+
+ @Test
+ public void shouldExecutePolicyNotFound() {
+ // given
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(TCA_ID_FROM_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+ when(exchange.getProperty(eq(EVENT_ACTION_KEY))).thenReturn(EVENT_ACTION_VALUE);
+
+ // when
+ guardPolicyDeleteDelegate.execute(exchange);
+
+ // then
+ verify(policyClient, never()).deleteGuard(any());
+ }
+
+ @Test(expected = ModelBpmnException.class)
+ public void shouldThrowModelBpmnException() {
+ // given
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+
+ // when
+ guardPolicyDeleteDelegate.execute(exchange);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void shouldThrowNullPointerException() {
+ // when
+ guardPolicyDeleteDelegate.execute(exchange);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDelegateTest.java
new file mode 100644
index 00000000..1d3f1ce6
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDelegateTest.java
@@ -0,0 +1,183 @@
+/*-
+ * ============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 static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+import java.io.IOException;
+
+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.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.exception.ModelBpmnException;
+import org.onap.clamp.clds.model.CldsModel;
+import org.onap.clamp.clds.model.properties.Holmes;
+import org.onap.clamp.clds.model.properties.ModelProperties;
+import org.onap.clamp.clds.util.JsonUtils;
+
+@RunWith(MockitoJUnitRunner.class)
+public class HolmesPolicyDelegateTest {
+
+ private static final String ID_JSON = "{\"id\":{\"r\":[{},{\"serviceConfigurations\":"
+ + "[[\"x\",\"+\",\"2\",\"y\"]]}]}}";
+ private static final String METRICS_JSON = "{\"metricsPerEventName\":[{\"thresholds\":[]}]}";
+ private static final String CONTENT_JSON = "{\"content\":{}}";
+ private static final String NULL_JSON = "{}";
+ private static final String HOLMES_ID_FROM_JSON = "{\"holmes\":[{\"id\":\"id\",\"from\":\"\"}]}";
+ private static final String TCA_ID_FROM_JSON = "{\"tca\":[{\"id\":\"\",\"from\":\"\"}]}";
+ private static final String CORRELATION_LOGIC_JSON = "{\"name\":\"correlationalLogic\"}";
+ 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 MODEL_NAME_KEY = "modelName";
+ private static final String TEST_KEY = "isTest";
+ private static final String USERID_KEY = "userid";
+ private static final String TCA_TEMPLATE_KEY = "tca.template";
+ private static final String TCA_POLICY_TEMPLATE_KEY = "tca.policy.template";
+ private static final String TCA_THRESHOLDS_TEMPLATE_KEY = "tca.thresholds.template";
+ private static final String HOLMES_POLICY_RESPONSE_MESSAGE_KEY = "holmesPolicyResponseMessage";
+ private static final String RESPONSE_MESSAGE_VALUE = "responseMessage";
+ private static final String MODEL_NAME_VALUE = "model.name";
+ private static final String CONTROL_NAME_VALUE = "control.name";
+ private static final String USERID_VALUE = "user";
+ private static final String CLDS_MODEL_ID = "id";
+ private static final String CLDS_MODEL_PROP_TEXT = "propText";
+
+ @Mock
+ private Exchange exchange;
+
+ @Mock
+ private PolicyClient policyClient;
+
+ @Mock
+ private ClampProperties clampProperties;
+
+ @Mock
+ private CldsDao cldsDao;
+
+ @InjectMocks
+ private HolmesPolicyDelegate holmesPolicyDelegateTest;
+
+ @Test
+ public void shouldExecuteSuccessfully() throws IOException {
+ // given
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(HOLMES_ID_FROM_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
+ when(exchange.getProperty(eq(MODEL_NAME_KEY))).thenReturn(MODEL_NAME_VALUE);
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+ when(exchange.getProperty(eq(USERID_KEY))).thenReturn(USERID_VALUE);
+
+ JsonElement jsonTemplateA = mock(JsonElement.class);
+ when(clampProperties.getJsonTemplate(eq(TCA_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplateA);
+ when(jsonTemplateA.getAsJsonObject()).thenReturn(getJsonObject(METRICS_JSON));
+
+ JsonElement jsonTemplateB = mock(JsonElement.class);
+ when(clampProperties.getJsonTemplate(eq(TCA_POLICY_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplateB);
+ when(jsonTemplateB.getAsJsonObject()).thenReturn(getJsonObject(CONTENT_JSON));
+
+ JsonElement jsonTemplateC = mock(JsonElement.class);
+ when(clampProperties.getJsonTemplate(eq(TCA_THRESHOLDS_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplateC);
+ when(jsonTemplateC.getAsJsonObject()).thenReturn(getJsonObject(NULL_JSON));
+
+ when(policyClient.sendBasePolicyInOther(anyString(), anyString(), any(), anyString()))
+ .thenReturn(RESPONSE_MESSAGE_VALUE);
+
+ CldsModel cldsModel = new CldsModel();
+ cldsModel.setId(CLDS_MODEL_ID);
+ cldsModel.setPropText(CLDS_MODEL_PROP_TEXT);
+ when(cldsDao.getModelTemplate(eq(MODEL_NAME_VALUE))).thenReturn(cldsModel);
+
+ // when
+ holmesPolicyDelegateTest.execute(exchange);
+
+ // then
+ verify(exchange).setProperty(eq(HOLMES_POLICY_RESPONSE_MESSAGE_KEY), eq(RESPONSE_MESSAGE_VALUE.getBytes()));
+ verify(cldsDao).setModel(eq(cldsModel), eq(USERID_VALUE));
+ }
+
+ @Test
+ public void shouldExecuteHolmesNotFound() {
+ // given
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(TCA_ID_FROM_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+
+ // when
+ holmesPolicyDelegateTest.execute(exchange);
+
+ // then
+ verify(policyClient, never()).sendBasePolicyInOther(anyString(), anyString(), any(), anyString());
+ verify(exchange, never()).setProperty(eq(HOLMES_POLICY_RESPONSE_MESSAGE_KEY), any());
+ verify(cldsDao, never()).setModel(any(), anyString());
+ }
+
+ @Test(expected = ModelBpmnException.class)
+ public void shouldThrowModelBpmnException() {
+ // given
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+
+ // when
+ holmesPolicyDelegateTest.execute(exchange);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void shouldThrowNullPointerException() {
+ // when
+ holmesPolicyDelegateTest.execute(exchange);
+ }
+
+ @Test
+ public void shouldDoFormatHolmesConfigBodySuccessfully() {
+ // given
+ ModelProperties prop = new ModelProperties(null, CONTROL_NAME_VALUE, null, false,
+ HOLMES_ID_FROM_JSON, "{\"id\":" + CORRELATION_LOGIC_JSON + "}");
+ Holmes holmes = prop.getType(Holmes.class);
+
+ // when
+ String result = HolmesPolicyDelegate.formatHolmesConfigBody(prop, holmes);
+
+ // then
+ assertEquals(CONTROL_NAME_VALUE + "$$$" + CORRELATION_LOGIC_JSON, result);
+ }
+
+ private static JsonObject getJsonObject(String jsonText) {
+ return JsonUtils.GSON.fromJson(jsonText, JsonObject.class);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegateTest.java
new file mode 100644
index 00000000..ccebbfbe
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegateTest.java
@@ -0,0 +1,104 @@
+/*-
+ * ============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 static org.mockito.Mockito.any;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+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.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.exception.ModelBpmnException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class HolmesPolicyDeleteDelegateTest {
+
+ 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 HOLMES_ID_FROM_JSON = "{\"holmes\":[{\"id\":\"\",\"from\":\"\"}]}";
+ private static final String TCA_ID_FROM_JSON = "{\"tca\":[{\"id\":\"\",\"from\":\"\"}]}";
+ private static final String ID_JSON = "{\"id\":\"\"}";
+ private static final String NOT_JSON = "not json";
+
+ @Mock
+ private Exchange exchange;
+
+ @Mock
+ private PolicyClient policyClient;
+
+ @InjectMocks
+ private HolmesPolicyDeleteDelegate holmesPolicyDeleteDelegate;
+
+ @Test
+ public void shouldExecuteSuccessfully() {
+ // given
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(HOLMES_ID_FROM_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+
+ // when
+ holmesPolicyDeleteDelegate.execute(exchange);
+
+ // then
+ verify(policyClient).deleteBasePolicy(any());
+ }
+
+ @Test
+ public void shouldExecuteHolmesNotFound() {
+ // given
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(TCA_ID_FROM_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+
+ // when
+ holmesPolicyDeleteDelegate.execute(exchange);
+
+ // then
+ verify(policyClient, never()).deleteBasePolicy(any());
+ }
+
+ @Test(expected = ModelBpmnException.class)
+ public void shouldThrowModelBpmnException() {
+ // given
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+
+ // when
+ holmesPolicyDeleteDelegate.execute(exchange);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void shouldThrowNullPointerException() {
+ // when
+ holmesPolicyDeleteDelegate.execute(exchange);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/client/ModelDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/ModelDeleteDelegateTest.java
new file mode 100644
index 00000000..06b94225
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/client/ModelDeleteDelegateTest.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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 static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+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.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.dao.CldsDao;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ModelDeleteDelegateTest {
+
+ private static final String NAME_KEY = "modelName";
+ private static final String NAME_VALUE = "model.name";
+
+ @Mock
+ private Exchange exchange;
+
+ @Mock
+ private CldsDao cldsDao;
+
+ @InjectMocks
+ private ModelDeleteDelegate modelDeleteDelegate;
+
+ @Test
+ public void shouldExecuteSuccessfully() {
+ // given
+ when(exchange.getProperty(eq(NAME_KEY))).thenReturn(NAME_VALUE);
+
+ // when
+ modelDeleteDelegate.execute(exchange);
+
+ // then
+ verify(cldsDao).deleteModel(eq(NAME_VALUE));
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java
new file mode 100644
index 00000000..75be799b
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java
@@ -0,0 +1,125 @@
+/*-
+ * ============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 static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.UnsupportedEncodingException;
+
+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.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.clds.exception.ModelBpmnException;
+import org.onap.policy.controlloop.policy.builder.BuilderException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class OperationalPolicyDelegateTest {
+
+ private static final String TEST_KEY = "isTest";
+ private static final String MODEL_BPMN_KEY = "modelBpmnProp";
+ private static final String MODEL_PROP_KEY = "modelProp";
+ private static final String RECIPE_TOPIC_KEY = "op.recipeTopic";
+ private static final String MESSAGE_KEY = "operationalPolicyResponseMessage";
+ private static final String SERVICE_NAME = "service.name";
+ private static final String POLICY_ID_FROM_JSON = "{policy:[{id:Oper12,from:''}]}";
+ private static final String ID_WITH_CHAIN_JSON = "{Oper12:{ab:["
+ + "{name:timeout,value:500},"
+ + "{policyConfigurations:["
+ + "[{name:maxRetries,value:5},"
+ + "{name:retryTimeLimit,value:1000},"
+ + "{name:recipe,value:go},"
+ + "{name:targetResourceId,"
+ + "value:resid234}]]}]},"
+ + "global:[{name:service,value:" + SERVICE_NAME + "}]}";
+ private static final String SIMPLE_JSON = "{}";
+ private static final String NOT_JSON = "not json";
+ private static final String MESSAGE_VALUE = "message";
+ private static final String RECIPE_TOPIC_VALUE = "recipe.topic";
+
+ @Mock
+ private Exchange exchange;
+
+ @Mock
+ private PolicyClient policyClient;
+
+ @Mock
+ private ClampProperties refProp;
+
+ @InjectMocks
+ private OperationalPolicyDelegate operationalPolicyDelegate;
+
+ @Test
+ public void shouldExecuteSuccessfully() throws BuilderException, UnsupportedEncodingException {
+ // given
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true);
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_WITH_CHAIN_JSON);
+ when(policyClient.sendBrmsPolicy(any(), any(), any())).thenReturn(MESSAGE_VALUE);
+ when(refProp.getStringValue(eq(RECIPE_TOPIC_KEY), eq(SERVICE_NAME))).thenReturn(RECIPE_TOPIC_VALUE);
+
+ // when
+ operationalPolicyDelegate.execute(exchange);
+
+ // then
+ verify(exchange).setProperty(eq(MESSAGE_KEY), eq(MESSAGE_VALUE.getBytes()));
+ }
+
+ @Test
+ public void shouldExecutePolicyNotFound() throws BuilderException, UnsupportedEncodingException {
+ // given
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(SIMPLE_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(SIMPLE_JSON);
+
+ // when
+ operationalPolicyDelegate.execute(exchange);
+
+ // then
+ verify(policyClient, never()).sendBrmsPolicy(any(), any(), any());
+ }
+
+ @Test(expected = ModelBpmnException.class)
+ public void shouldThrowModelBpmnException() throws BuilderException, UnsupportedEncodingException {
+ // given
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true);
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
+
+ // when
+ operationalPolicyDelegate.execute(exchange);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void shouldThrowNullPointerException() throws BuilderException, UnsupportedEncodingException {
+ // when
+ operationalPolicyDelegate.execute(exchange);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java
new file mode 100644
index 00000000..9d87e7e9
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java
@@ -0,0 +1,108 @@
+/*-
+ * ============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 static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+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.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.exception.ModelBpmnException;
+import org.onap.clamp.clds.model.properties.ModelProperties;
+
+@RunWith(MockitoJUnitRunner.class)
+public class OperationalPolicyDeleteDelegateTest {
+
+ private static final String TEST_KEY = "isTest";
+ private static final String MODEL_BPMN_KEY = "modelBpmnProp";
+ private static final String MODEL_PROP_KEY = "modelProp";
+ private static final String EVENT_ACTION_KEY = "eventAction";
+ private static final String POLICY_ID_FROM_JSON = "{policy:[{id:Poli2,from:''}]}";
+ private static final String ID_WITH_CHAIN_JSON = "{Poli2:{ab:c,xy:z}}";
+ private static final String ID_NO_CHAIN_JSON = "{Poli2:{}}";
+ private static final String EVENT_ACTION_VALUE = "still";
+ private static final String NOT_JSON = "23e";
+
+ @Mock
+ private Exchange exchange;
+
+ @Mock
+ private PolicyClient policyClient;
+
+ @InjectMocks
+ private OperationalPolicyDeleteDelegate operationalPolicyDeleteDelegate;
+
+ @Test
+ public void shouldExecuteSuccessfully() {
+ // given
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_WITH_CHAIN_JSON);
+ when(exchange.getProperty(eq(EVENT_ACTION_KEY))).thenReturn(EVENT_ACTION_VALUE);
+
+ // when
+ operationalPolicyDeleteDelegate.execute(exchange);
+
+ // then
+ verify(policyClient, times(2)).deleteBrms(any(ModelProperties.class));
+ }
+
+ @Test
+ public void shouldExecuteTcaNotFound() {
+ // given
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(true);
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(POLICY_ID_FROM_JSON);
+ when(exchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_NO_CHAIN_JSON);
+
+ // when
+ operationalPolicyDeleteDelegate.execute(exchange);
+
+ // then
+ verify(policyClient, never()).deleteBrms(any(ModelProperties.class));
+ }
+
+ @Test(expected = ModelBpmnException.class)
+ public void shouldThrowModelBpmnException() {
+ // given
+ when(exchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+ when(exchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
+
+ // when
+ operationalPolicyDeleteDelegate.execute(exchange);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void shouldThrowNullPointerException() {
+ // when
+ operationalPolicyDeleteDelegate.execute(exchange);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/client/TcaPolicyDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/TcaPolicyDelegateTest.java
new file mode 100644
index 00000000..a8851992
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/client/TcaPolicyDelegateTest.java
@@ -0,0 +1,166 @@
+/*-
+ * ============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 static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+
+import java.io.IOException;
+
+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.runners.MockitoJUnitRunner;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.clds.dao.CldsDao;
+import org.onap.clamp.clds.exception.ModelBpmnException;
+import org.onap.clamp.clds.model.CldsModel;
+import org.onap.clamp.clds.util.JsonUtils;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TcaPolicyDelegateTest {
+
+ private static final String MODEL_BPMN_KEY = "modelBpmnProp";
+ private static final String MODEL_PROP_KEY = "modelProp";
+ private static final String MODEL_NAME_KEY = "modelName";
+ private static final String TEST_KEY = "isTest";
+ private static final String USERID_KEY = "userid";
+ private static final String TCA_TEMPLATE_KEY = "tca.template";
+ private static final String TCA_POLICY_TEMPLATE_KEY = "tca.policy.template";
+ private static final String TCA_THRESHOLDS_TEMPLATE_KEY = "tca.thresholds.template";
+ private static final String TCA_POLICY_RESPONSE_MESSAGE_KEY = "tcaPolicyResponseMessage";
+
+ private static final String TCA_ID_FROM_JSON = "{\"tca\":[{\"id\":\"id\",\"from\":\"\"}]}";
+ private static final String ID_JSON = "{\"id\":{\"r\":[{},{\"serviceConfigurations\":"
+ + "[[\"x\",\"+\",\"2\",\"y\"]]}]}}";
+ private static final String TCA_TEMPLATE_JSON = "{\"metricsPerEventName\":[{\"thresholds\":[]}]}";
+ private static final String TCA_POLICY_TEMPLATE_JSON = "{\"content\":{}}";
+ private static final String TCA_THRESHOLDS_TEMPLATE_JSON = "{}";
+ private static final String HOLMES_ID_FROM_JSON = "{\"holmes\":[{\"id\":\"\",\"from\":\"\"}]}";
+ private static final String NOT_JSON = "not json";
+
+ private static final String RESPONSE_MESSAGE_VALUE = "responseMessage";
+ private static final String MODEL_NAME_VALUE = "ModelName";
+ private static final String USERID_VALUE = "user";
+
+ private static final String CLDS_MODEL_ID = "id";
+ private static final String CLDS_MODEL_PROP_TEXT = "propText";
+
+ @Mock
+ private Exchange camelExchange;
+
+ @Mock
+ private ClampProperties refProp;
+
+ @Mock
+ private PolicyClient policyClient;
+
+ @Mock
+ private CldsDao cldsDao;
+
+ @InjectMocks
+ private TcaPolicyDelegate tcaPolicyDelegate;
+
+ @Test
+ public void shouldExecuteSuccessfully() throws IOException {
+ //given
+ when(camelExchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(TCA_ID_FROM_JSON);
+ when(camelExchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
+ when(camelExchange.getProperty(eq(MODEL_NAME_KEY))).thenReturn(MODEL_NAME_VALUE);
+ when(camelExchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+ when(camelExchange.getProperty(eq(USERID_KEY))).thenReturn(USERID_VALUE);
+
+ JsonElement jsonTemplate;
+ JsonObject jsonObject;
+
+ jsonTemplate = mock(JsonElement.class);
+ when(refProp.getJsonTemplate(eq(TCA_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplate);
+ jsonObject = JsonUtils.GSON.fromJson(TCA_TEMPLATE_JSON, JsonObject.class);
+ when(jsonTemplate.getAsJsonObject()).thenReturn(jsonObject);
+
+ jsonTemplate = mock(JsonElement.class);
+ when(refProp.getJsonTemplate(eq(TCA_POLICY_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplate);
+ jsonObject = JsonUtils.GSON.fromJson(TCA_POLICY_TEMPLATE_JSON, JsonObject.class);
+ when(jsonTemplate.getAsJsonObject()).thenReturn(jsonObject);
+
+ jsonTemplate = mock(JsonElement.class);
+ when(refProp.getJsonTemplate(eq(TCA_THRESHOLDS_TEMPLATE_KEY), anyString())).thenReturn(jsonTemplate);
+ jsonObject = JsonUtils.GSON.fromJson(TCA_THRESHOLDS_TEMPLATE_JSON, JsonObject.class);
+ when(jsonTemplate.getAsJsonObject()).thenReturn(jsonObject);
+
+ when(policyClient.sendMicroServiceInOther(anyString(), any())).thenReturn(RESPONSE_MESSAGE_VALUE);
+
+ CldsModel cldsModel = new CldsModel();
+ cldsModel.setId(CLDS_MODEL_ID);
+ cldsModel.setPropText(CLDS_MODEL_PROP_TEXT);
+ when(cldsDao.getModelTemplate(eq(MODEL_NAME_VALUE))).thenReturn(cldsModel);
+
+ //when
+ tcaPolicyDelegate.execute(camelExchange);
+
+ //then
+ verify(camelExchange).setProperty(eq(TCA_POLICY_RESPONSE_MESSAGE_KEY), eq(RESPONSE_MESSAGE_VALUE.getBytes()));
+ verify(cldsDao).setModel(eq(cldsModel), eq(USERID_VALUE));
+ }
+
+ @Test
+ public void shouldExecuteTcaNotFound() {
+ //given
+ when(camelExchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(HOLMES_ID_FROM_JSON);
+ when(camelExchange.getProperty(eq(MODEL_PROP_KEY))).thenReturn(ID_JSON);
+ when(camelExchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+
+ //when
+ tcaPolicyDelegate.execute(camelExchange);
+
+ //then
+ verify(policyClient, never()).sendMicroServiceInOther(any(), any());
+ }
+
+ @Test(expected = ModelBpmnException.class)
+ public void shouldThrowModelBpmnException() {
+ //given
+ when(camelExchange.getProperty(eq(MODEL_BPMN_KEY))).thenReturn(NOT_JSON);
+ when(camelExchange.getProperty(eq(TEST_KEY))).thenReturn(false);
+
+ //when
+ tcaPolicyDelegate.execute(camelExchange);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void shouldThrowNullPointerException() {
+ //when
+ tcaPolicyDelegate.execute(camelExchange);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java b/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java
index a32a6035..549c9132 100644
--- a/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java
+++ b/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -25,10 +27,11 @@
package org.onap.clamp.clds.config;
import static org.assertj.core.api.Assertions.assertThat;
-
import org.junit.Test;
+import org.onap.clamp.clds.exception.CldsUsersException;
import org.onap.clamp.clds.service.CldsUser;
+
public class CldsUserJsonDecoderTest {
private String user1 = "admin1";
@@ -92,4 +95,12 @@ public class CldsUserJsonDecoderTest {
assertThat(user.getPassword()).isEqualTo(password);
assertThat(user.getPermissionsString()).isEqualTo(incompletePermissionsArray);
}
+
+ @Test(expected = CldsUsersException.class)
+ public void shouldThrowCldsUsersException() {
+ //when
+ CldsUserJsonDecoder
+ .decodeJson(this.getClass().getResourceAsStream("/clds/clds-parse-exception.json"));
+ }
+
}
diff --git a/src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java b/src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java
index 58d94685..ab4421fc 100644
--- a/src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/AuthorizationControllerItCase.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -25,26 +27,26 @@ package org.onap.clamp.clds.it;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.IOException;
-import java.util.LinkedList;
import java.util.List;
+import org.apache.camel.Exchange;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
import org.mockito.Mockito;
+import org.mockito.Spy;
import org.onap.clamp.authorization.AuthorizationController;
+import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.clds.exception.NotAuthorizedException;
import org.onap.clamp.clds.service.SecureServicePermission;
import org.onap.clamp.util.PrincipalUtils;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.mock.env.MockEnvironment;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.userdetails.User;
import org.springframework.test.context.junit4.SpringRunner;
@@ -57,39 +59,59 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest
public class AuthorizationControllerItCase {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AuthorizationControllerItCase.class);
- private Authentication authentication;
- private List<GrantedAuthority> authList = new LinkedList<GrantedAuthority>();
+ private PermissionTestDefaultHelper permissionTestHelper = new PermissionTestDefaultHelper();
+
+ @Spy
+ MockEnvironment env;
+
+ @Spy
+ @InjectMocks
+ private ClampProperties clampProp = new ClampProperties();
+
+ @InjectMocks
+ private AuthorizationController auth;
/**
* Setup the variable before the tests execution.
- *
- * @throws IOException
- * In case of issues when opening the files
*/
@Before
- public void setupBefore() throws IOException {
- authList.add(new SimpleGrantedAuthority("permission-type-cl-manage|dev|*"));
- authList.add(new SimpleGrantedAuthority("permission-type-cl|dev|read"));
- authList.add(new SimpleGrantedAuthority("permission-type-cl|dev|update"));
- authList.add(new SimpleGrantedAuthority("permission-type-template|dev|read"));
- authList.add(new SimpleGrantedAuthority("permission-type-template|dev|update"));
- authList.add(new SimpleGrantedAuthority("permission-type-filter-vf|dev|*"));
- authList.add(new SimpleGrantedAuthority("permission-type-cl-event|dev|*"));
-
- authentication = new UsernamePasswordAuthenticationToken(new User("admin", "", authList), "", authList);
- }
+ public void setupBefore() {
+ permissionTestHelper.setupMockEnv(env);
+ List<GrantedAuthority> authList = permissionTestHelper.getAuthList();
- @Test
- public void testIsUserPermittedNoException() {
SecurityContext securityContext = Mockito.mock(SecurityContext.class);
- Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
+ Mockito.when(securityContext.getAuthentication()).thenReturn(
+ new UsernamePasswordAuthenticationToken(new User("admin", "", authList),
+ "", authList)
+ );
PrincipalUtils.setSecurityContext(securityContext);
+ }
- AuthorizationController auth = new AuthorizationController();
+ @Test
+ public void testIsUserPermitted() {
assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl","dev","read")));
assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl-manage","dev","DEPLOY")));
- assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-filter-vf","dev","12345-55555-55555-5555")));
+ assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-filter-vf","dev",
+ "12345-55555-55555-5555")));
assertFalse(auth.isUserPermitted(new SecureServicePermission("permission-type-cl","test","read")));
}
+
+ @Test
+ public void testIfUserAuthorize() {
+ Exchange ex = Mockito.mock(Exchange.class);
+ try {
+ permissionTestHelper.doActionOnAllPermissions(((type, instance, action) ->
+ auth.authorize(ex, type, instance, action)
+ )
+ );
+ } catch (NotAuthorizedException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test(expected = NotAuthorizedException.class)
+ public void testIfAuthorizeThrowException() {
+ Exchange ex = Mockito.mock(Exchange.class);
+ auth.authorize(ex,"permission-type-cl","test","read");
+ }
}
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsHealthcheckServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsHealthcheckServiceItCase.java
index 5d891035..1dbea376 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsHealthcheckServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsHealthcheckServiceItCase.java
@@ -25,8 +25,6 @@ package org.onap.clamp.clds.it;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import javax.ws.rs.core.Response;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.clamp.clds.model.CldsHealthCheck;
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
index 347de4a7..faeb0418 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
@@ -149,6 +149,7 @@ public class CldsServiceItCase {
Properties prop = new Properties();
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("clds-version.properties");
prop.load(in);
+ assertNotNull(in);
in.close();
assertEquals(cldsInfo.getCldsVersion(), prop.getProperty("clds.version"));
assertEquals(cldsInfo.getUserName(), "admin");
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
index 7d48086c..992c06e8 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsToscaServiceItCase.java
@@ -69,7 +69,7 @@ public class CldsToscaServiceItCase {
private String toscaModelYaml;
private Authentication authentication;
private CldsToscaModel cldsToscaModel;
- private List<GrantedAuthority> authList = new LinkedList<GrantedAuthority>();
+ private List<GrantedAuthority> authList = new LinkedList<>();
private LoggingUtils util;
/**
diff --git a/src/test/java/org/onap/clamp/clds/it/PermissionTestDefaultHelper.java b/src/test/java/org/onap/clamp/clds/it/PermissionTestDefaultHelper.java
new file mode 100644
index 00000000..fa22b02b
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/it/PermissionTestDefaultHelper.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.it;
+
+import com.google.common.collect.ImmutableMap;
+
+import java.util.Map;
+
+public class PermissionTestDefaultHelper extends PermissionTestHelper {
+
+ private static final String[] ALL_ACTION = new String[] {"*"};
+ private static final String[] READ_UPDATE_ACTION = new String[] {"read", "update"};
+
+ private static final String DEV_INSTANCE = "dev";
+ private static final String TEST_INSTANCE = "test";
+
+ private static final Map<String, Map> defaultPermission = ImmutableMap.of(
+ "permission-type-cl", ImmutableMap.of(
+ DEV_INSTANCE, ALL_ACTION),
+ "permission-type-cl-event", ImmutableMap.of(
+ DEV_INSTANCE, ALL_ACTION,
+ TEST_INSTANCE, READ_UPDATE_ACTION),
+ "permission-type-cl-manage", ImmutableMap.of(
+ DEV_INSTANCE, ALL_ACTION,
+ TEST_INSTANCE, READ_UPDATE_ACTION),
+ "permission-type-filter-vf", ImmutableMap.of(
+ DEV_INSTANCE, ALL_ACTION,
+ TEST_INSTANCE, READ_UPDATE_ACTION),
+ "permission-type-template", ImmutableMap.of(
+ DEV_INSTANCE, ALL_ACTION,
+ TEST_INSTANCE, READ_UPDATE_ACTION)
+ );
+
+ /**
+ * Permission test default helper constructor.
+ * This class setup the default permission in the parent PermissionTestHelper class.
+ */
+ public PermissionTestDefaultHelper() {
+ super(defaultPermission);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/it/PermissionTestHelper.java b/src/test/java/org/onap/clamp/clds/it/PermissionTestHelper.java
new file mode 100644
index 00000000..ee073b01
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/it/PermissionTestHelper.java
@@ -0,0 +1,79 @@
+/*-
+ * ============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.it;
+
+import static org.onap.clamp.authorization.AuthorizationController.PERM_PREFIX;
+import static org.onap.clamp.clds.config.ClampProperties.CONFIG_PREFIX;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.mock.env.MockEnvironment;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+
+public class PermissionTestHelper {
+
+ private static final String securityPrefix = CONFIG_PREFIX + PERM_PREFIX;
+ private final Map<String, Map> permission;
+ private static final List<GrantedAuthority> authList = new LinkedList<>();
+
+ /**
+ * Permission Test Helper constructor
+ * Generate authList base on general permission collection
+ */
+ public PermissionTestHelper(Map<String, Map> permission) {
+ this.permission = permission;
+ this.createAuthList();
+ }
+
+ private void createAuthList() {
+ permission.forEach((type, instanceMap) -> instanceMap.forEach((instance, actionList) -> {
+ for (String action : (String[]) actionList) {
+ authList.add(new SimpleGrantedAuthority(type + "|" + instance + "|" + action));
+ }
+ }));
+ }
+
+ List<GrantedAuthority> getAuthList() {
+ return authList;
+ }
+
+ void setupMockEnv(MockEnvironment env) {
+ permission.forEach((type, instanceMap) -> env.withProperty(securityPrefix + type, type));
+ }
+
+ void doActionOnAllPermissions(PermissionAction action) {
+ permission.forEach((type, instanceMap) -> instanceMap.forEach((instance, actionList) -> {
+ for (String actionName : (String[]) actionList) {
+ action.doAction(type, (String) instance, actionName);
+ }
+ }));
+ }
+
+ @FunctionalInterface
+ public interface PermissionAction {
+ void doAction(String type, String instance, String action);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java
index 55657c97..0f0ecaed 100644
--- a/src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java
@@ -5,6 +5,8 @@
* Copyright (C) 2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -23,9 +25,13 @@
package org.onap.clamp.clds.it.sdc.controller;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
-
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
@@ -33,12 +39,16 @@ import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.config.sdc.SdcSingleControllerConfigurationTest;
+import org.onap.clamp.clds.exception.sdc.controller.SdcControllerException;
import org.onap.clamp.clds.sdc.controller.SdcSingleController;
+import org.onap.clamp.clds.sdc.controller.SdcSingleControllerStatus;
import org.onap.clamp.clds.sdc.controller.installer.CsarHandler;
import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.notification.IResourceInstance;
+import org.slf4j.MDC;
+import org.slf4j.spi.MDCAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
@@ -59,24 +69,26 @@ public class SdcSingleControllerItCase {
private SdcSingleController sdcSingleController;
+ private CsarInstaller csarInstaller = mock(CsarInstaller.class);
+
private INotificationData buildFakeSdcNotification() {
// BUild what is needed for CSAR
- IArtifactInfo serviceArtifact = Mockito.mock(IArtifactInfo.class);
+ IArtifactInfo serviceArtifact = mock(IArtifactInfo.class);
Mockito.when(serviceArtifact.getArtifactType()).thenReturn(CsarHandler.CSAR_TYPE);
Mockito.when(serviceArtifact.getArtifactName()).thenReturn(CSAR_ARTIFACT_NAME);
List<IArtifactInfo> servicesList = new ArrayList<>();
servicesList.add(serviceArtifact);
- INotificationData notifData = Mockito.mock(INotificationData.class);
+ INotificationData notifData = mock(INotificationData.class);
Mockito.when(notifData.getServiceArtifacts()).thenReturn(servicesList);
// Build what is needed for UUID
Mockito.when(notifData.getServiceInvariantUUID()).thenReturn(SERVICE_UUID);
// Build fake resource with one artifact BLUEPRINT
- IResourceInstance resource1 = Mockito.mock(IResourceInstance.class);
+ IResourceInstance resource1 = mock(IResourceInstance.class);
Mockito.when(resource1.getResourceType()).thenReturn("VF");
Mockito.when(resource1.getResourceInvariantUUID()).thenReturn(RESOURCE1_UUID);
Mockito.when(resource1.getResourceInstanceName()).thenReturn(RESOURCE1_INSTANCE_NAME);
// Create a fake artifact for resource
- IArtifactInfo blueprintArtifact = Mockito.mock(IArtifactInfo.class);
+ IArtifactInfo blueprintArtifact = mock(IArtifactInfo.class);
Mockito.when(blueprintArtifact.getArtifactType()).thenReturn(CsarHandler.BLUEPRINT_TYPE);
List<IArtifactInfo> artifactsListForResource = new ArrayList<>();
artifactsListForResource.add(blueprintArtifact);
@@ -92,7 +104,7 @@ public class SdcSingleControllerItCase {
*/
@Before
public void init() {
- sdcSingleController = new SdcSingleController(clampProp, Mockito.mock(CsarInstaller.class),
+ sdcSingleController = new SdcSingleController(clampProp, csarInstaller,
SdcSingleControllerConfigurationTest.loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
"sdc-controller1"),
null) {
@@ -101,9 +113,36 @@ public class SdcSingleControllerItCase {
@Test
public void testTreatNotification() {
+ //when
sdcSingleController.treatNotification(buildFakeSdcNotification());
+ //then
Assertions.assertThat(sdcSingleController.getNbOfNotificationsOngoing()).isEqualTo(0);
+ }
+ @Test
+ public void testCloseSdc() throws SdcControllerException {
+ //when
+ sdcSingleController.closeSdc();
+ //then
+ assertThat(sdcSingleController.getControllerStatus()).isEqualTo(SdcSingleControllerStatus.STOPPED);
}
+ @Test
+ public void testActivateCallback() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException, InstantiationException, ClassNotFoundException {
+ //given
+ MDCAdapter mdcAdapter = MDC.getMDCAdapter();
+ Class<?> innerClass = Class.forName("org.onap.clamp.clds.sdc.controller.SdcSingleController$SdcNotificationCallBack");
+ Constructor<?> constructor = innerClass.getDeclaredConstructor(SdcSingleController.class, SdcSingleController.class);
+ constructor.setAccessible(true);
+ Object child = constructor.newInstance(sdcSingleController,sdcSingleController);
+ Method method = child.getClass().getDeclaredMethod("activateCallback",INotificationData.class);
+ method.setAccessible(true);
+ //when
+ method.invoke(child,buildFakeSdcNotification());
+ //then
+ assertThat(mdcAdapter.get("ResponseCode")).isEqualTo("0");
+ assertThat(mdcAdapter.get("StatusCode")).isEqualTo("COMPLETE");
+ assertThat(mdcAdapter.get("ResponseDescription")).isEqualTo("SDC Notification received and processed successfully");
+ assertThat(mdcAdapter.get("ClassName")).isEqualTo(child.getClass().getName());
+ }
}
diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
index 36d4eb82..e1b963cc 100644
--- a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
@@ -179,10 +179,9 @@ public class CsarInstallerItCase {
ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca-2.json"),
StandardCharsets.UTF_8), cldsModel2.getPropText(), true);
CldsModel cldsModel3 = verifyClosedLoopModelLoadedInDb(csar, "tca_3.yaml");
- JSONAssert.assertEquals(
- IOUtils.toString(ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca.json"),
- StandardCharsets.UTF_8),
- cldsModel3.getPropText(), true);
+ JSONAssert.assertEquals(IOUtils.toString(
+ ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca-3.json"),
+ StandardCharsets.UTF_8), cldsModel3.getPropText(), true);
}
private CldsModel verifyClosedLoopModelLoadedInDb(CsarHandler csar, String artifactName)
diff --git a/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java b/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java
new file mode 100644
index 00000000..315e656d
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java
@@ -0,0 +1,74 @@
+/*-
+ * ============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.model;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import javax.ws.rs.BadRequestException;
+import java.util.Arrays;
+
+public class DcaeEventTest {
+
+ @Test
+ public void testGetCldsActionId() {
+ //given
+ DcaeEvent dcaeEvent = new DcaeEvent();
+ dcaeEvent.setEvent(DcaeEvent.EVENT_CREATED);
+ dcaeEvent.setResourceUUID("1");
+ dcaeEvent.setServiceUUID("2");
+
+ //when
+ String cldsAction = dcaeEvent.getCldsActionCd();
+ dcaeEvent.setInstances(Arrays.asList(new CldsModelInstance()));
+ //then
+ assertEquals(CldsEvent.ACTION_CREATE, cldsAction);
+
+ //when
+ dcaeEvent.setEvent(DcaeEvent.EVENT_DEPLOYMENT);
+ //then
+ assertEquals(CldsEvent.ACTION_DEPLOY, dcaeEvent.getCldsActionCd());
+
+ //when
+ dcaeEvent.setInstances(null);
+ //then
+ assertEquals(CldsEvent.ACTION_DEPLOY, dcaeEvent.getCldsActionCd());
+
+ //when
+ dcaeEvent.setEvent(DcaeEvent.EVENT_UNDEPLOYMENT);
+ //then
+ assertEquals(CldsEvent.ACTION_UNDEPLOY, dcaeEvent.getCldsActionCd());
+
+ }
+
+ @Test(expected = BadRequestException.class)
+ public void shouldReturnBadRequestException() {
+ //given
+ DcaeEvent dcaeEvent = new DcaeEvent();
+ dcaeEvent.setResourceUUID("1");
+ dcaeEvent.setServiceUUID("2");
+ //when
+ dcaeEvent.setEvent("BadEvent");
+ //then
+ dcaeEvent.getCldsActionCd();
+ }
+}
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 211bb390..dec63977 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
@@ -142,18 +142,18 @@ public class BlueprintParserTest {
public void getNodeRepresentationFromCompleteYaml() {
final JsonObject jsonObject = jsonObjectBlueprintValid;
- MicroService expected = new MicroService(SECOND_APPP, MODEL_TYPE1, FIRST_APPP, "", SECOND_APPP);
+ MicroService expected = new MicroService(SECOND_APPP, MODEL_TYPE1, FIRST_APPP, "");
Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next();
- MicroService actual = new BlueprintParser().getNodeRepresentation(entry);
+ MicroService actual = new BlueprintParser().getNodeRepresentation(entry, jsonObject, null);
Assert.assertEquals(expected, actual);
}
@Test
public void getMicroServicesFromBlueprintTest() {
- MicroService thirdApp = new MicroService(THIRD_APPP, MODEL_TYPE3, "", "", THIRD_APPP);
- MicroService firstApp = new MicroService(FIRST_APPP, MODEL_TYPE1, THIRD_APPP, "", FIRST_APPP);
- MicroService secondApp = new MicroService(SECOND_APPP, MODEL_TYPE2, FIRST_APPP, "", SECOND_APPP);
+ MicroService thirdApp = new MicroService(THIRD_APPP, MODEL_TYPE3, "", "");
+ MicroService firstApp = new MicroService(FIRST_APPP, MODEL_TYPE1, THIRD_APPP, "");
+ MicroService secondApp = new MicroService(SECOND_APPP, MODEL_TYPE2, FIRST_APPP, "");
Set<MicroService> expected = new HashSet<>(Arrays.asList(firstApp, secondApp, thirdApp));
Set<MicroService> actual = new BlueprintParser().getMicroServices(microServiceTheWholeBlueprintValid);
@@ -164,7 +164,7 @@ public class BlueprintParserTest {
@Test
public void fallBackToOneMicroServiceTCATest() {
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);
@@ -175,7 +175,7 @@ public class BlueprintParserTest {
@Test
public void fallBackToOneMicroServiceHolmesTest() {
MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "onap.policies.monitoring.cdap.tca.hi.lo.app",
- "", "", "");
+ "", "");
List<MicroService> expected = Collections.singletonList(holmesMS);
List<MicroService> actual = new BlueprintParser()
diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java
index 1eb66ead..4b41ee81 100644
--- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java
+++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java
@@ -38,10 +38,10 @@ public class ChainGeneratorTest {
@Test
public void getChainOfMicroServicesTest() {
- MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", "");
- MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, "", "");
- MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, "", "");
- MicroService ms4 = new MicroService(FOURTH_APPP, "", THIRD_APPP, "", "");
+ MicroService ms1 = new MicroService(FIRST_APPP, "", "", "");
+ MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, "");
+ MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, "");
+ MicroService ms4 = new MicroService(FOURTH_APPP, "", THIRD_APPP, "");
List<MicroService> expectedList = Arrays.asList(ms1, ms2, ms3, ms4);
Set<MicroService> inputSet = new HashSet<>(expectedList);
@@ -52,10 +52,10 @@ public class ChainGeneratorTest {
@Test
public void getChainOfMicroServicesTwiceNoInputTest() {
- MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", "");
- MicroService ms2 = new MicroService(SECOND_APPP, "", "", "", "");
- MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, "", "");
- MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, "", "");
+ MicroService ms1 = new MicroService(FIRST_APPP, "", "", "");
+ MicroService ms2 = new MicroService(SECOND_APPP, "", "", "");
+ MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, "");
+ MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, "");
Set<MicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4));
List<MicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet);
@@ -64,10 +64,10 @@ public class ChainGeneratorTest {
@Test
public void getChainOfMicroServicesBranchingTest() {
- MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", "");
- MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, "", "");
- MicroService ms3 = new MicroService(THIRD_APPP, "", FIRST_APPP, "", "");
- MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, "", "");
+ MicroService ms1 = new MicroService(FIRST_APPP, "", "", "");
+ MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, "");
+ MicroService ms3 = new MicroService(THIRD_APPP, "", FIRST_APPP, "");
+ MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, "");
Set<MicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4));
List<MicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet);
diff --git a/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java b/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java
index 603d2d28..1e6742c9 100644
--- a/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java
+++ b/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java
@@ -5,7 +5,9 @@
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * 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
*
@@ -26,17 +28,30 @@ package org.onap.clamp.clds.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.eq;
+
+import java.security.InvalidKeyException;
+
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
-
+@RunWith(PowerMockRunner.class)
+@PowerMockIgnore({"javax.crypto.*"})
public class CryptoUtilsTest {
private final String data = "This is a test string";
@Test
+ @PrepareForTest({CryptoUtils.class})
public final void testEncryption() throws Exception {
String encodedString = CryptoUtils.encrypt(data);
assertNotNull(encodedString);
@@ -44,6 +59,7 @@ public class CryptoUtilsTest {
}
@Test
+ @PrepareForTest({CryptoUtils.class})
public final void testEncryptedStringIsDifferent() throws Exception {
String encodedString1 = CryptoUtils.encrypt(data);
String encodedString2 = CryptoUtils.encrypt(data);
@@ -56,4 +72,30 @@ public class CryptoUtilsTest {
byte[] subData2 = ArrayUtils.subarray(encryptedMessage2, 16, encryptedMessage2.length);
assertNotEquals(subData1, subData2);
}
-} \ No newline at end of file
+
+ @Test
+ @PrepareForTest({CryptoUtils.class})
+ public final void testEncryptionBaseOnRandomKey() throws Exception {
+ SecretKey secretKey = KeyGenerator.getInstance("AES").generateKey();
+ final String encryptionKey = String.valueOf(Hex.encodeHex(secretKey.getEncoded()));
+ setAesEncryptionKeyEnv(encryptionKey);
+
+ String encodedString = CryptoUtils.encrypt(data);
+ String decodedString = CryptoUtils.decrypt(encodedString);
+ assertEquals(data, decodedString);
+ }
+
+ @Test(expected = InvalidKeyException.class)
+ @PrepareForTest({CryptoUtils.class})
+ public final void testEncryptionBadKey() throws Exception {
+ final String badEncryptionKey = "93210sd";
+ setAesEncryptionKeyEnv(badEncryptionKey);
+
+ CryptoUtils.encrypt(data);
+ }
+
+ private static void setAesEncryptionKeyEnv(String value) {
+ PowerMockito.mockStatic(System.class);
+ PowerMockito.when(System.getenv(eq("AES_ENCRYPTION_KEY"))).thenReturn(value);
+ }
+}
diff --git a/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java b/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java
index 82c2162a..d1adc166 100644
--- a/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java
+++ b/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java
@@ -5,6 +5,8 @@
* Copyright (C) 2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -155,4 +157,9 @@ public class JsonUtilsTest {
// then
assertThat(timeoutValue).isEqualTo(500);
}
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldThrowExceptionFileNotExists() throws IOException {
+ ResourceFileUtil.getResourceAsString("example/notExist.json");
+ }
}
diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java
index 5eb664fe..ff6e1b5d 100644
--- a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java
+++ b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java
@@ -56,8 +56,8 @@ public class ClampGraphBuilderTest {
@Test
public void clampGraphBuilderCompleteChainTest() {
String collector = "VES";
- MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id", "");
- MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id", "");
+ MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id");
+ MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id");
String policy = "OperationalPolicy";
List<MicroService> microServices = Arrays.asList(ms1, ms2);
@@ -76,8 +76,8 @@ public class ClampGraphBuilderTest {
@Test(expected = InvalidStateException.class)
public void clampGraphBuilderNoPolicyGivenTest() {
String collector = "VES";
- MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id", "");
- MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id", "");
+ MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id");
+ MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id");
ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter);
clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).build();
diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java
index 6546553c..63a1fa3e 100644
--- a/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java
+++ b/src/test/java/org/onap/clamp/clds/util/drawing/DocumentBuilderTest.java
@@ -47,9 +47,6 @@ public class DocumentBuilderTest {
@Mock
private SVGGraphics2D mockG2d;
- @Mock
- private Document mockDomImpl;
-
@Test
public void pushChangestoDocumentTest() throws IOException, ParserConfigurationException, SAXException {
String dataElementId = "someId";
diff --git a/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java b/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java
new file mode 100644
index 00000000..16136ae2
--- /dev/null
+++ b/src/test/java/org/onap/clamp/flow/FlowLogOperationTest.java
@@ -0,0 +1,99 @@
+/*-
+ * ============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.flow;
+
+import static junit.framework.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.clamp.clds.util.LoggingUtils;
+import org.onap.clamp.clds.util.ONAPLogConstants;
+import org.onap.clamp.flow.log.FlowLogOperation;
+import org.slf4j.MDC;
+import org.slf4j.spi.MDCAdapter;
+import org.springframework.test.util.ReflectionTestUtils;
+
+public class FlowLogOperationTest {
+
+ private FlowLogOperation flowLogOperation = new FlowLogOperation();
+
+ @Test
+ public void testStratLog() {
+ //given
+ Exchange exchange = new DefaultExchange(mock(CamelContext.class));
+ LoggingUtils loggingUtils = mock(LoggingUtils.class);
+ ReflectionTestUtils.setField(flowLogOperation, "util", loggingUtils);
+
+ //when
+ Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.REQUEST_ID)).thenReturn("MockRequestId");
+ Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.INVOCATION_ID)).thenReturn("MockInvocationId");
+ Mockito.when(loggingUtils.getProperties(ONAPLogConstants.MDCs.PARTNER_NAME)).thenReturn("MockPartnerName");
+ flowLogOperation.startLog(exchange, "serviceName");
+
+ //then
+ assertThat(exchange.getProperty(ONAPLogConstants.Headers.REQUEST_ID)).isEqualTo("MockRequestId");
+ assertThat(exchange.getProperty(ONAPLogConstants.Headers.INVOCATION_ID)).isEqualTo("MockInvocationId");
+ assertThat(exchange.getProperty(ONAPLogConstants.Headers.PARTNER_NAME)).isEqualTo("MockPartnerName");
+ }
+
+ @Test
+ public void testInvokeLog() {
+ //given
+ final String mockEntity = "mockEntity";
+ final String mockServiceName = "mockSerivceName";
+ MDCAdapter mdcAdapter = MDC.getMDCAdapter();
+ //when
+ flowLogOperation.invokeLog(mockEntity, mockServiceName);
+ //then
+ String entity = mdcAdapter.get(ONAPLogConstants.MDCs.TARGET_ENTITY);
+ String serviceName = mdcAdapter.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME);
+ assertEquals(entity,mockEntity);
+ assertEquals(serviceName,mockServiceName);
+ }
+
+ @Test
+ public void testEndLog() {
+ //given
+ MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, "2019-05-19T00:00:00.007Z");
+ MDCAdapter mdcAdapter = MDC.getMDCAdapter();
+ ///when
+ flowLogOperation.endLog();
+ //then
+ assertThat(mdcAdapter.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)).isNull();
+ }
+
+ @Test
+ public void testErrorLog() {
+ //given
+ MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, "2019-05-19T00:00:00.007Z");
+ MDCAdapter mdcAdapter = MDC.getMDCAdapter();
+ //when
+ flowLogOperation.errorLog();
+ //then
+ assertThat(mdcAdapter.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)).isNull();
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
index 3bf85009..773332dd 100644
--- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
@@ -6,7 +6,8 @@
* reserved.
* ================================================================================
* Modifications copyright (c) 2019 Nokia
- * ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -51,6 +52,7 @@ import org.onap.clamp.clds.sdc.controller.installer.CsarHandler;
import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.notification.IResourceInstance;
@@ -206,6 +208,26 @@ public class CsarInstallerItCase {
assertThat(loop.getModelPropertiesJson().get("resourceDetails")).isNotNull();
JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"),
JsonUtils.GSON.toJson(loop.getModelPropertiesJson()), true);
+ assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty();
+
+ loop = loopsRepo
+ .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca_3.yaml"))
+ .get();
+ assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty();
+
+ loop = loopsRepo
+ .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE2, "tca_2.yaml"))
+ .get();
+ assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty();
}
+ @Test(expected = SdcArtifactInstallerException.class)
+ @Transactional
+ public void shouldThrowSdcArtifactInstallerException() throws SdcArtifactInstallerException,
+ SdcToscaParserException, IOException, InterruptedException, PolicyModelException {
+ String generatedName = RandomStringUtils.randomAlphanumeric(5);
+ CsarHandler csarHandler = buildFakeCsarHandler(generatedName);
+ Mockito.when(csarHandler.getMapOfBlueprints()).thenThrow(IOException.class);
+ csarInstaller.installTheCsar(csarHandler);
+ }
}
diff --git a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
new file mode 100644
index 00000000..0a3c1e16
--- /dev/null
+++ b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
@@ -0,0 +1,93 @@
+/*-
+ * ============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.loop;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+
+import java.io.IOException;
+import java.util.HashSet;
+
+import org.junit.Test;
+import org.onap.clamp.clds.model.dcae.DcaeOperationStatusResponse;
+import org.onap.clamp.loop.components.external.DcaeComponent;
+import org.onap.clamp.policy.microservice.MicroServicePolicy;
+
+public class DcaeComponentTest {
+
+ private Loop createTestLoop() {
+ String yaml = "imports:\n" + " - \"http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\"\n"
+ + "node_templates:\n" + " docker_service_host:\n" + " type: dcae.nodes.SelectedDockerHost";
+
+ Loop loopTest = new Loop("ControlLoopTest", yaml, "<xml></xml>");
+ loopTest.setGlobalPropertiesJson(
+ new Gson().fromJson("{\"dcaeDeployParameters\":" + "{\"policy_id\": \"name\"}}", JsonObject.class));
+ loopTest.setLastComputedState(LoopState.DESIGN);
+ loopTest.setDcaeDeploymentId("123456789");
+ loopTest.setDcaeDeploymentStatusUrl("http4://localhost:8085");
+ loopTest.setDcaeBlueprintId("UUID-blueprint");
+
+ MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", "",
+ "tosca_definitions_version: tosca_simple_yaml_1_0_0", true,
+ new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), new HashSet<>());
+ microServicePolicy.setProperties(new Gson().fromJson("{\"param1\":\"value1\"}", JsonObject.class));
+
+ loopTest.addMicroServicePolicy(microServicePolicy);
+ return loopTest;
+ }
+
+ @Test
+ public void convertDcaeResponseTest() throws IOException {
+ String dcaeFakeResponse = "{'requestId':'testId','operationType':'install','status':'state','error':'errorMessage', 'links':{'self':'selfUrl','uninstall':'uninstallUrl'}}";
+ DcaeOperationStatusResponse responseObject = DcaeComponent.convertDcaeResponse(dcaeFakeResponse);
+ assertThat(responseObject.getRequestId()).isEqualTo("testId");
+ assertThat(responseObject.getOperationType()).isEqualTo("install");
+ assertThat(responseObject.getStatus()).isEqualTo("state");
+ assertThat(responseObject.getError()).isEqualTo("errorMessage");
+ assertThat(responseObject.getLinks()).isNotNull();
+ assertThat(responseObject.getLinks().getSelf()).isEqualTo("selfUrl");
+ assertThat(responseObject.getLinks().getUninstall()).isEqualTo("uninstallUrl");
+
+ assertThat(responseObject.getLinks().getStatus()).isNull();
+ }
+
+ @Test
+ public void testGetDeployPayload() throws IOException {
+ Loop loop = this.createTestLoop();
+ String deploymentPayload = DcaeComponent.getDeployPayload(loop);
+ String expectedPayload = "{\"serviceTypeId\":\"UUID-blueprint\",\"inputs\":{\"policy_id\":\"name\"}}";
+ assertThat(deploymentPayload).isEqualTo(expectedPayload);
+ }
+
+ @Test
+ public void testGetUndeployPayload() throws IOException {
+ Loop loop = this.createTestLoop();
+ String unDeploymentPayload = DcaeComponent.getUndeployPayload(loop);
+ String expectedPayload = "{\"serviceTypeId\":\"UUID-blueprint\"}";
+ assertThat(unDeploymentPayload).isEqualTo(expectedPayload);
+ }
+
+}
diff --git a/src/test/java/org/onap/clamp/loop/LoopOperationTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopOperationTestItCase.java
deleted file mode 100644
index e71b4982..00000000
--- a/src/test/java/org/onap/clamp/loop/LoopOperationTestItCase.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Nokia 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.loop;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
-
-import java.io.IOException;
-import java.util.HashSet;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Message;
-import org.json.simple.parser.ParseException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.onap.clamp.clds.Application;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.loop.LoopOperation.TempLoopState;
-import org.onap.clamp.policy.microservice.MicroServicePolicy;
-import org.onap.clamp.policy.operational.OperationalPolicy;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = Application.class)
-public class LoopOperationTestItCase {
-
- private Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create();
- @Autowired
- LoopService loopService;
-
- @Autowired
- ClampProperties property;
-
- private Loop createTestLoop() {
- String yaml = "imports:\n"
- + " - \"http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\"\n"
- + "node_templates:\n"
- + " docker_service_host:\n"
- + " type: dcae.nodes.SelectedDockerHost";
-
- Loop loopTest = new Loop("ControlLoopTest", yaml, "<xml></xml>");
- loopTest.setGlobalPropertiesJson(new Gson().fromJson("{\"testname\":\"testvalue\"}", JsonObject.class));
- loopTest.setLastComputedState(LoopState.DESIGN);
- loopTest.setDcaeDeploymentId("123456789");
- loopTest.setDcaeDeploymentStatusUrl("http4://localhost:8085");
- loopTest.setDcaeBlueprintId("UUID-blueprint");
-
- MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", "",
- "tosca_definitions_version: tosca_simple_yaml_1_0_0", true,
- gson.fromJson("{\"configtype\":\"json\"}", JsonObject.class), new HashSet<>());
- microServicePolicy.setProperties(new Gson().fromJson("{\"param1\":\"value1\"}", JsonObject.class));
-
- loopTest.addMicroServicePolicy(microServicePolicy);
- return loopTest;
- }
-
-
- @Test
- public void testAnalysePolicyResponse() {
- LoopOperation loopOp = new LoopOperation(loopService, property);
- String status1 = loopOp.analysePolicyResponse(200);
- String status2 = loopOp.analysePolicyResponse(404);
- String status3 = loopOp.analysePolicyResponse(500);
- String status4 = loopOp.analysePolicyResponse(503);
-
- // then
- assertThat(status1).isEqualTo("SUBMITTED");
- assertThat(status2).isEqualTo("NOT_SUBMITTED");
- assertThat(status3).isEqualTo("IN_ERROR");
- assertThat(status4).isEqualTo("IN_ERROR");
- }
-
- @Test
- public void testGetOperationalPolicyName() {
- LoopOperation loopOp = new LoopOperation(loopService, property);
- Loop loop = this.createTestLoop();
- String opName1 = loopOp.getOperationalPolicyName(loop);
- assertThat(opName1).isNull();
-
- OperationalPolicy opPolicy1 = new OperationalPolicy("OperationalPolicyTest1", null,
- gson.fromJson("{\"type\":\"Operational\"}", JsonObject.class));
- loop.addOperationalPolicy(opPolicy1);
- String opName2 = loopOp.getOperationalPolicyName(loop);
- assertThat(opName2).isEqualTo("OperationalPolicyTest1");
- }
-
- @Test
- public void testAnalyseDcaeResponse() throws ParseException {
- LoopOperation loopOp = new LoopOperation(loopService, property);
- String dcaeStatus1 = loopOp.analyseDcaeResponse(null, null);
- assertThat(dcaeStatus1).isEqualTo("NOT_DEPLOYED");
-
- String dcaeStatus2 = loopOp.analyseDcaeResponse(null, 500);
- assertThat(dcaeStatus2).isEqualTo("IN_ERROR");
-
- String dcaeStatus3 = loopOp.analyseDcaeResponse(null, 404);
- assertThat(dcaeStatus3).isEqualTo("NOT_DEPLOYED");
-
- Exchange camelExchange = Mockito.mock(Exchange.class);
- Message mockMessage = Mockito.mock(Message.class);
- Mockito.when(camelExchange.getIn()).thenReturn(mockMessage);
- Mockito.when(mockMessage.getBody(String.class))
- .thenReturn("{\"operationType\":\"install\",\"status\":\"succeeded\"}");
- String dcaeStatus4 = loopOp.analyseDcaeResponse(camelExchange, 200);
- assertThat(dcaeStatus4).isEqualTo("DEPLOYED");
-
- Mockito.when(mockMessage.getBody(String.class))
- .thenReturn("{\"operationType\":\"install\",\"status\":\"processing\"}");
- String dcaeStatus5 = loopOp.analyseDcaeResponse(camelExchange, 200);
- assertThat(dcaeStatus5).isEqualTo("PROCESSING");
-
- Mockito.when(mockMessage.getBody(String.class))
- .thenReturn("{\"operationType\":\"install\",\"status\":\"failed\"}");
- String dcaeStatus6 = loopOp.analyseDcaeResponse(camelExchange, 200);
- assertThat(dcaeStatus6).isEqualTo("IN_ERROR");
-
- Mockito.when(mockMessage.getBody(String.class))
- .thenReturn("{\"operationType\":\"uninstall\",\"status\":\"succeeded\"}");
- String dcaeStatus7 = loopOp.analyseDcaeResponse(camelExchange, 200);
- assertThat(dcaeStatus7).isEqualTo("NOT_DEPLOYED");
-
- Mockito.when(mockMessage.getBody(String.class))
- .thenReturn("{\"operationType\":\"uninstall\",\"status\":\"processing\"}");
- String dcaeStatus8 = loopOp.analyseDcaeResponse(camelExchange, 200);
- assertThat(dcaeStatus8).isEqualTo("PROCESSING");
-
- Mockito.when(mockMessage.getBody(String.class))
- .thenReturn("{\"operationType\":\"uninstall\",\"status\":\"failed\"}");
- String dcaeStatus9 = loopOp.analyseDcaeResponse(camelExchange, 200);
- assertThat(dcaeStatus9).isEqualTo("IN_ERROR");
- }
-
- @Test
- public void testUpdateLoopStatus() {
- LoopOperation loopOp = new LoopOperation(loopService, property);
- Loop loop = this.createTestLoop();
- loopService.saveOrUpdateLoop(loop);
- LoopState newState1 = loopOp.updateLoopStatus(loop, TempLoopState.SUBMITTED, TempLoopState.DEPLOYED);
- LoopState dbState1 = loopService.getLoop(loop.getName()).getLastComputedState();
- assertThat(newState1).isEqualTo(LoopState.DEPLOYED);
- assertThat(dbState1).isEqualTo(LoopState.DEPLOYED);
-
- LoopState newState2 = loopOp.updateLoopStatus(loop, TempLoopState.SUBMITTED, TempLoopState.NOT_DEPLOYED);
- LoopState dbState2 = loopService.getLoop(loop.getName()).getLastComputedState();
- assertThat(newState2).isEqualTo(LoopState.SUBMITTED);
- assertThat(dbState2).isEqualTo(LoopState.SUBMITTED);
-
- LoopState newState3 = loopOp.updateLoopStatus(loop, TempLoopState.SUBMITTED, TempLoopState.PROCESSING);
- assertThat(newState3).isEqualTo(LoopState.WAITING);
-
- LoopState newState4 = loopOp.updateLoopStatus(loop, TempLoopState.SUBMITTED, TempLoopState.IN_ERROR);
- assertThat(newState4).isEqualTo(LoopState.IN_ERROR);
-
- LoopState newState5 = loopOp.updateLoopStatus(loop, TempLoopState.NOT_SUBMITTED, TempLoopState.DEPLOYED);
- assertThat(newState5).isEqualTo(LoopState.IN_ERROR);
-
- LoopState newState6 = loopOp.updateLoopStatus(loop, TempLoopState.NOT_SUBMITTED, TempLoopState.PROCESSING);
- assertThat(newState6).isEqualTo(LoopState.IN_ERROR);
-
- LoopState newState7 = loopOp.updateLoopStatus(loop, TempLoopState.NOT_SUBMITTED, TempLoopState.NOT_DEPLOYED);
- assertThat(newState7).isEqualTo(LoopState.DESIGN);
-
- LoopState newState8 = loopOp.updateLoopStatus(loop, TempLoopState.IN_ERROR, TempLoopState.DEPLOYED);
- assertThat(newState8).isEqualTo(LoopState.IN_ERROR);
-
- LoopState newState9 = loopOp.updateLoopStatus(loop, TempLoopState.IN_ERROR, TempLoopState.NOT_DEPLOYED);
- assertThat(newState9).isEqualTo(LoopState.IN_ERROR);
-
- LoopState newState10 = loopOp.updateLoopStatus(loop, TempLoopState.IN_ERROR, TempLoopState.PROCESSING);
- assertThat(newState10).isEqualTo(LoopState.IN_ERROR);
-
- LoopState newState11 = loopOp.updateLoopStatus(loop, TempLoopState.IN_ERROR, TempLoopState.IN_ERROR);
- assertThat(newState11).isEqualTo(LoopState.IN_ERROR);
- }
-
- @Test
- public void testUpdateLoopInfo() throws ParseException {
- Loop loop = this.createTestLoop();
- loopService.saveOrUpdateLoop(loop);
-
- Exchange camelExchange = Mockito.mock(Exchange.class);
- Message mockMessage = Mockito.mock(Message.class);
- Mockito.when(camelExchange.getIn()).thenReturn(mockMessage);
- Mockito.when(mockMessage.getBody(String.class))
- .thenReturn("{\"links\":{\"status\":\"http://testhost/dcae-operationstatus\",\"test2\":\"test2\"}}");
-
- LoopOperation loopOp = new LoopOperation(loopService, property);
- loopOp.updateLoopInfo(camelExchange, loop, "testNewId");
-
- Loop newLoop = loopService.getLoop(loop.getName());
- String newDeployId = newLoop.getDcaeDeploymentId();
- String newDeploymentStatusUrl = newLoop.getDcaeDeploymentStatusUrl();
-
- assertThat(newDeployId).isEqualTo("testNewId");
- assertThat(newDeploymentStatusUrl).isEqualTo("http4://testhost/dcae-operationstatus");
- }
-
- @Test
- public void testGetDeploymentId() {
- Loop loop = this.createTestLoop();
- LoopOperation loopOp = new LoopOperation(loopService, property);
- String deploymentId1 = loopOp.getDeploymentId(loop);
- assertThat(deploymentId1).isEqualTo("123456789");
-
- loop.setDcaeDeploymentId(null);
- String deploymentId2 = loopOp.getDeploymentId(loop);
- assertThat(deploymentId2).isEqualTo("closedLoop_ControlLoopTest_deploymentId");
-
- loop.setDcaeDeploymentId("");
- String deploymentId3 = loopOp.getDeploymentId(loop);
- assertThat(deploymentId3).isEqualTo("closedLoop_ControlLoopTest_deploymentId");
- }
-
- @Test
- public void testGetDeployPayload() throws IOException {
- Loop loop = this.createTestLoop();
- LoopOperation loopOp = new LoopOperation(loopService, property);
- String deploymentPayload = loopOp.getDeployPayload(loop);
-
- String expectedPayload = "{\"serviceTypeId\":\"UUID-blueprint\",\"inputs\":{\"imports\":[\"http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\"],\"node_templates\":{\"docker_service_host\":{\"type\":\"dcae.nodes.SelectedDockerHost\"}}}}";
- assertThat(deploymentPayload).isEqualTo(expectedPayload);
- }
-} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java
index a935808a..9a82ec09 100644
--- a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java
@@ -92,7 +92,7 @@ public class LoopRepositoriesItCase {
}
private LoopLog getLoopLog(LogType type, String message, Loop loop) {
- return new LoopLog(message, type, loop);
+ return new LoopLog(message, type, "CLAMP", loop);
}
@Test
@@ -116,7 +116,7 @@ public class LoopRepositoriesItCase {
// Now set the ID in the previous model so that we can compare the objects
loopLog.setId(((LoopLog) loopInDb.getLoopLogs().toArray()[0]).getId());
- assertThat(loopInDb).isEqualToComparingFieldByField(loopTest);
+ assertThat(loopInDb).isEqualToIgnoringGivenFields(loopTest, "components");
assertThat(loopRepository.existsById(loopTest.getName())).isEqualTo(true);
assertThat(operationalPolicyService.isExisting(opPolicy.getName())).isEqualTo(true);
assertThat(microServicePolicyService.isExisting(microServicePolicy.getName())).isEqualTo(true);
@@ -124,7 +124,7 @@ public class LoopRepositoriesItCase {
// Now attempt to read from database
Loop loopInDbRetrieved = loopRepository.findById(loopTest.getName()).get();
- assertThat(loopInDbRetrieved).isEqualToComparingFieldByField(loopTest);
+ assertThat(loopInDbRetrieved).isEqualToIgnoringGivenFields(loopTest, "components");
assertThat((LoopLog) loopInDbRetrieved.getLoopLogs().toArray()[0]).isEqualToComparingFieldByField(loopLog);
assertThat((OperationalPolicy) loopInDbRetrieved.getOperationalPolicies().toArray()[0])
.isEqualToComparingFieldByField(opPolicy);
diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
index c4254ec8..8add1a7b 100644
--- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
@@ -296,7 +296,7 @@ public class LoopServiceTestItCase {
saveTestLoopToDb();
// Add log
Loop loop = loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null);
- loop.addLog(new LoopLog("test", LogType.INFO, loop));
+ loop.addLog(new LoopLog("test", LogType.INFO, "CLAMP", loop));
loop = loopService.saveOrUpdateLoop(loop);
// Add op policy
OperationalPolicy operationalPolicy = new OperationalPolicy("opPolicy", null,
diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
index dcad1a51..8899a36c 100644
--- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
+++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java
@@ -36,6 +36,7 @@ import java.util.Random;
import org.junit.Test;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.clamp.loop.components.external.PolicyComponent;
import org.onap.clamp.loop.log.LogType;
import org.onap.clamp.loop.log.LoopLog;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
@@ -71,7 +72,7 @@ public class LoopToJsonTest {
}
private LoopLog getLoopLog(LogType type, String message, Loop loop) {
- LoopLog log = new LoopLog(message, type, loop);
+ LoopLog log = new LoopLog(message, type, "CLAMP", loop);
log.setId(Long.valueOf(new Random().nextInt()));
return log;
}
@@ -95,8 +96,12 @@ public class LoopToJsonTest {
System.out.println(jsonSerialized);
Loop loopTestDeserialized = JsonUtils.GSON_JPA_MODEL.fromJson(jsonSerialized, Loop.class);
assertNotNull(loopTestDeserialized);
- assertThat(loopTestDeserialized).isEqualToIgnoringGivenFields(loopTest, "svgRepresentation", "blueprint");
-
+ assertThat(loopTestDeserialized).isEqualToIgnoringGivenFields(loopTest, "svgRepresentation", "blueprint",
+ "components");
+ assertThat(loopTestDeserialized.getComponent("DCAE").getState())
+ .isEqualToComparingFieldByField(loopTest.getComponent("DCAE").getState());
+ assertThat(loopTestDeserialized.getComponent("POLICY").getState())
+ .isEqualToComparingFieldByField(loopTest.getComponent("POLICY").getState());
// svg and blueprint not exposed so wont be deserialized
assertThat(loopTestDeserialized.getBlueprint()).isEqualTo(null);
assertThat(loopTestDeserialized.getSvgRepresentation()).isEqualTo(null);
@@ -121,6 +126,6 @@ public class LoopToJsonTest {
loopTest.addMicroServicePolicy(microServicePolicy);
JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/pdp-group-policy-payload.json"),
- loopTest.createPoliciesPayloadPdpGroup(), false);
+ PolicyComponent.createPoliciesPayloadPdpGroup(loopTest), false);
}
}
diff --git a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
index b12ca89f..8972e511 100644
--- a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
+++ b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java
@@ -33,6 +33,7 @@ import java.util.Map;
import org.junit.Test;
import org.onap.clamp.clds.util.ResourceFileUtil;
+import org.onap.clamp.policy.operational.LegacyOperationalPolicy;
import org.onap.clamp.policy.operational.OperationalPolicy;
import org.skyscreamer.jsonassert.JSONAssert;
@@ -43,13 +44,23 @@ public class OperationalPolicyPayloadTest {
JsonObject jsonConfig = new GsonBuilder().create().fromJson(
ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class);
OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig);
+
assertThat(policy.createPolicyPayloadYaml())
.isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload.yaml"));
+
assertThat(policy.createPolicyPayload())
.isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload.json"));
}
@Test
+ public void testLegacyOperationalPolicyPayloadConstruction() throws IOException {
+ JsonObject jsonConfig = new GsonBuilder().create().fromJson(
+ ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class);
+ assertThat(LegacyOperationalPolicy.createPolicyPayloadYamlLegacy(jsonConfig.get("operational_policy")))
+ .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload-legacy.yaml"));
+ }
+
+ @Test
public void testGuardPolicyEmptyPayloadConstruction() throws IOException {
JsonObject jsonConfig = new GsonBuilder().create().fromJson(
ResourceFileUtil.getResourceAsString("tosca/operational-policy-no-guard-properties.json"),
diff --git a/src/test/javascript/propertyController.test.js b/src/test/javascript/propertyController.test.js
index fbbc6bec..e7199966 100644
--- a/src/test/javascript/propertyController.test.js
+++ b/src/test/javascript/propertyController.test.js
@@ -30,16 +30,4 @@ describe('Property controller tests', function() {
test('getMsUINotExist', () => {
expect(propertyController.getMsUI("test")).toEqual(null);
});
-
- test('getLastUpdatedStatus', () => {
- expect(propertyController.getLastUpdatedStatus()).toEqual('DESIGN');
- });
-
- test('getDeploymentID', () => {
- expect(propertyController.getDeploymentID()).toEqual('testId');
- });
-
- test('getDeploymentStatusURL', () => {
- expect(propertyController.getDeploymentStatusURL()).toEqual('testUrl');
- });
}); \ No newline at end of file
diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties
index 061505a1..7b29e179 100644
--- a/src/test/resources/application.properties
+++ b/src/test/resources/application.properties
@@ -1,109 +1,109 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP CLAMP
-# ================================================================================
-# Copyright (C) 2017-2018 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============================================
-# ===================================================================
-#
-###
-
-info.build.artifact=@project.artifactId@
-info.build.name=@project.name@
-info.build.description=@project.description@
-info.build.version=@project.version@
-
-### Set the port for HTTP or HTTPS protocol (Controlled by Spring framework, only one at a time).
-### (See below for the parameter 'server.http.port' if you want to have both enabled)
-### To have only HTTP, keep the lines server.ssl.* commented
-### To have only HTTPS enabled, uncomment the server.ssl.* lines and specify a right keystore location
-server.port=${clamp.it.tests.http}
-### Settings for HTTPS (this automatically enables the HTTPS on the port 'server.port')
-#server.ssl.key-store=file:/tmp/mykey.jks
-#server.ssl.key-store-password=pass
-#server.ssl.key-password=pass
-
-### In order to be user friendly when HTTPS is enabled,
-### you can add another HTTP port that will be automatically redirected to HTTPS
-### by enabling this parameter (server.http.port) and set it to another port (80 or 8080, 8090, etc ...)
-#server.http-to-https-redirection.port=8090
-
-### HTTP Example:
-###--------------
-### server.port=8080
-
-### HTTPS Example:
-### --------------
-### server.port=8443
-### server.ssl.key-store=file:/tmp/mykey.jks
-### server.ssl.key-store-password=mypass
-### server.ssl.key-password=mypass
-
-### HTTP (Redirected to HTTPS) and HTTPS Example:
-### --------------------------------------------
-### server.port=8443 <-- The HTTPS port
-### server.ssl.key-store=file:/tmp/mykey.jks
-### server.ssl.key-store-password=mypass
-### server.ssl.key-password=mypass
-### server.http-to-https-redirection.port=8090 <-- The HTTP port
-
-server.servlet.context-path=/
-#Modified engine-rest applicationpath
-spring.profiles.active=clamp-default,clamp-default-user
-spring.http.converters.preferred-json-mapper=gson
-
-#The max number of active threads in this pool
-server.tomcat.max-threads=200
-#The minimum number of threads always kept alive
-server.tomcat.min-Spare-Threads=25
-#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads
-server.tomcat.max-idle-time=60000
-
-#Servlet context parameters
-server.context_parameters.p-name=value #context parameter with p-name as key and value as value.
-
-camel.springboot.consumer-template-cache-size=1000
-camel.springboot.producer-template-cache-size=1000
-# JMX enabled to have Camel Swagger runtime working
-camel.springboot.jmx-enabled=true
-camel.defaultthreadpool.poolsize=10
-camel.defaultthreadpool.maxpoolsize=20
-camel.defaultthreadpool.maxqueuesize=1000
-camel.defaultthreadpool.keepaliveTime=60
-camel.defaultthreadpool.rejectpolicy=CallerRuns
-#camel.springboot.xmlRoutes = false
-camel.springboot.xmlRoutes=classpath:/clds/camel/routes/*.xml
-camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml
-#camel.springboot.typeConversion = false
-
-#clds datasource connection details
-spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver
-spring.datasource.cldsdb.url=jdbc:mariadb:sequential://localhost:3306,localhost:${docker.mariadb.port.host}/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3
-spring.datasource.cldsdb.username=clds
-spring.datasource.cldsdb.password=4c90a0b48204383f4283448d23e0b885a47237b2a23588e7c4651604f51c1067
-spring.datasource.cldsdb.validationQuery=SELECT 1
-spring.datasource.cldsdb.validationQueryTimeout=20000
-spring.datasource.cldsdb.validationInterval=30000
-spring.datasource.cldsdb.testWhileIdle = true
-spring.datasource.cldsdb.minIdle = 0
-spring.datasource.cldsdb.initialSize=0
-# Automatically test whether a connection provided is good or not
-spring.datasource.cldsdb.testOnBorrow=true
-spring.datasource.cldsdb.ignoreExceptionOnPreLoad=true
-
+###
+# ============LICENSE_START=======================================================
+# ONAP CLAMP
+# ================================================================================
+# Copyright (C) 2017-2018 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============================================
+# ===================================================================
+#
+###
+
+info.build.artifact=@project.artifactId@
+info.build.name=@project.name@
+info.build.description=@project.description@
+info.build.version=@project.version@
+
+### Set the port for HTTP or HTTPS protocol (Controlled by Spring framework, only one at a time).
+### (See below for the parameter 'server.http.port' if you want to have both enabled)
+### To have only HTTP, keep the lines server.ssl.* commented
+### To have only HTTPS enabled, uncomment the server.ssl.* lines and specify a right keystore location
+server.port=${clamp.it.tests.http}
+### Settings for HTTPS (this automatically enables the HTTPS on the port 'server.port')
+#server.ssl.key-store=file:/tmp/mykey.jks
+#server.ssl.key-store-password=pass
+#server.ssl.key-password=pass
+
+### In order to be user friendly when HTTPS is enabled,
+### you can add another HTTP port that will be automatically redirected to HTTPS
+### by enabling this parameter (server.http.port) and set it to another port (80 or 8080, 8090, etc ...)
+#server.http-to-https-redirection.port=8090
+
+### HTTP Example:
+###--------------
+### server.port=8080
+
+### HTTPS Example:
+### --------------
+### server.port=8443
+### server.ssl.key-store=file:/tmp/mykey.jks
+### server.ssl.key-store-password=mypass
+### server.ssl.key-password=mypass
+
+### HTTP (Redirected to HTTPS) and HTTPS Example:
+### --------------------------------------------
+### server.port=8443 <-- The HTTPS port
+### server.ssl.key-store=file:/tmp/mykey.jks
+### server.ssl.key-store-password=mypass
+### server.ssl.key-password=mypass
+### server.http-to-https-redirection.port=8090 <-- The HTTP port
+
+server.servlet.context-path=/
+#Modified engine-rest applicationpath
+spring.profiles.active=clamp-default,clamp-default-user
+spring.http.converters.preferred-json-mapper=gson
+
+#The max number of active threads in this pool
+server.tomcat.max-threads=200
+#The minimum number of threads always kept alive
+server.tomcat.min-Spare-Threads=25
+#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads
+server.tomcat.max-idle-time=60000
+
+#Servlet context parameters
+server.context_parameters.p-name=value #context parameter with p-name as key and value as value.
+
+camel.springboot.consumer-template-cache-size=1000
+camel.springboot.producer-template-cache-size=1000
+# JMX enabled to have Camel Swagger runtime working
+camel.springboot.jmx-enabled=true
+camel.defaultthreadpool.poolsize=10
+camel.defaultthreadpool.maxpoolsize=20
+camel.defaultthreadpool.maxqueuesize=1000
+camel.defaultthreadpool.keepaliveTime=60
+camel.defaultthreadpool.rejectpolicy=CallerRuns
+#camel.springboot.xmlRoutes = false
+camel.springboot.xmlRoutes=classpath:/clds/camel/routes/*.xml
+camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml
+#camel.springboot.typeConversion = false
+
+#clds datasource connection details
+spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver
+spring.datasource.cldsdb.url=jdbc:mariadb:sequential://localhost:3306,localhost:${docker.mariadb.port.host}/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3
+spring.datasource.cldsdb.username=clds
+spring.datasource.cldsdb.password=4c90a0b48204383f4283448d23e0b885a47237b2a23588e7c4651604f51c1067
+spring.datasource.cldsdb.validationQuery=SELECT 1
+spring.datasource.cldsdb.validationQueryTimeout=20000
+spring.datasource.cldsdb.validationInterval=30000
+spring.datasource.cldsdb.testWhileIdle = true
+spring.datasource.cldsdb.minIdle = 0
+spring.datasource.cldsdb.initialSize=0
+# Automatically test whether a connection provided is good or not
+spring.datasource.cldsdb.testOnBorrow=true
+spring.datasource.cldsdb.ignoreExceptionOnPreLoad=true
+
spring.jpa.properties.javax.persistence.schema-generation.database.action=drop-and-create
#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
@@ -118,117 +118,117 @@ spring.jpa.properties.hibernate.use-new-id-generator-mappings=true
# Whether to enable logging of SQL statements.
spring.jpa.show-sql=true
-#Async Executor default Parameters
-async.core.pool.size=10
-async.max.pool.size=20
-async.queue.capacity=500
-
-#For EELF logback file
-#com.att.eelf.logging.path=
-clamp.config.logback.filename=logback-default.xml
-#The log folder that will be used in logback.xml file
-clamp.config.log.path=log
-clamp.config.files.systemProperties=classpath:/system.properties
-clamp.config.files.cldsUsers=classpath:/clds/clds-users.json
-clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json
-clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json
-
-# Properties for Clamp
-# DCAE request build properties
-#
-clamp.config.dcae.template=classpath:/clds/templates/dcae-template.json
-clamp.config.dcae.deployment.template=classpath:/clds/templates/dcae-deployment-template.json
-#
-#
-# Configuration Settings for Policy Engine Components
-clamp.config.policy.api.url=http4://localhost:${docker.http-cache.port.host}
-clamp.config.policy.api.userName=healthcheck
-clamp.config.policy.api.password=zb!XztG34
-clamp.config.policy.pap.url=http4://localhost:${docker.http-cache.port.host}
-clamp.config.policy.pap.userName=healthcheck
-clamp.config.policy.pap.password=zb!XztG34
-
-clamp.config.policy.pdpUrl1=http://localhost:${docker.http-cache.port.host}/pdp/ , testpdp, alpha123
-clamp.config.policy.pdpUrl2=http://localhost:${docker.http-cache.port.host}/pdp/ , testpdp, alpha123
-clamp.config.policy.papUrl=http://localhost:${docker.http-cache.port.host}/pap/ , testpap, alpha123
-clamp.config.policy.notificationType=websocket
-clamp.config.policy.notificationUebServers=localhost
-clamp.config.policy.notificationTopic=
-clamp.config.policy.clientId=python
-# base64 encoding
-clamp.config.policy.clientKey=dGVzdA==
-#DEVL for development
-#TEST for Test environments
-#PROD for prod environments
-clamp.config.policy.policyEnvironment=DEVL
-# General Policy request properties
-#
-clamp.config.policy.onap.name=DCAE
-clamp.config.policy.pdp.group=default
-clamp.config.policy.ms.type=MicroService
-clamp.config.policy.ms.policyNamePrefix=Config_MS_
-clamp.config.policy.op.policyNamePrefix=Config_BRMS_Param_
-clamp.config.policy.base.policyNamePrefix=Config_
-clamp.config.policy.op.type=BRMS_Param
-
-clamp.config.import.tosca.model=false
-clamp.config.tosca.policyTypes=tca
-clamp.config.tosca.filePath=/tmp/tosca-models
-
-# TCA MicroService Policy request build properties
-#
-clamp.config.tca.policyid.prefix=DCAE.Config_
-clamp.config.tca.policy.template=classpath:/clds/templates/tca-policy-template.json
-clamp.config.tca.template=classpath:/clds/templates/tca-template.json
-clamp.config.tca.thresholds.template=classpath:/clds/templates/tca-thresholds-template.json
-
-#
-#
-# Operational Policy request build properties
-#
-clamp.config.op.policyDescription=from clds
-# default
-clamp.config.op.templateName=ClosedLoopControlName
-clamp.config.op.operationTopic=APPC-CL
-clamp.config.op.notificationTopic=POLICY-CL-MGT
-clamp.config.op.controller=amsterdam
-clamp.config.op.policy.appc=APPC
-#
-# Sdc service properties
-#
-clamp.config.sdc.csarFolder = ${project.build.directory}/sdc-tests
-clamp.config.sdc.blueprint.parser.mapping = classpath:/clds/blueprint-parser-mapping.json
-#
-clamp.config.ui.location.default=classpath:/clds/templates/ui-location-default.json
-#
-# if action.test.override is true, then any action will be marked as test=true (even if incoming action request had test=false); otherwise, test flag will be unchanged on the action request
-clamp.config.action.test.override=false
-# if action.insert.test.event is true, then insert event even if the action is set to test
-clamp.config.action.insert.test.event=false
-clamp.config.clds.service.cache.invalidate.after.seconds=120
-
-#DCAE Inventory Url Properties
-clamp.config.dcae.inventory.url=http://localhost:${docker.http-cache.port.host}
-clamp.config.dcae.intentory.retry.interval=100
-clamp.config.dcae.intentory.retry.limit=1
-
-#DCAE Dispatcher Url Properties
-clamp.config.dcae.dispatcher.url=http://localhost:${docker.http-cache.port.host}
-clamp.config.dcae.dispatcher.retry.interval=100
-clamp.config.dcae.dispatcher.retry.limit=1
-
-#DCAE Deployment Url Properties
-clamp.config.dcae.deployment.url=http4://localhost:${docker.http-cache.port.host}
-clamp.config.dcae.deployment.userName=test
-clamp.config.dcae.deployment.password=test
-
-#Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case !
-clamp.config.security.permission.type.cl=permission-type-cl
-clamp.config.security.permission.type.cl.manage=permission-type-cl-manage
-clamp.config.security.permission.type.cl.event=permission-type-cl-event
-clamp.config.security.permission.type.filter.vf=permission-type-filter-vf
-clamp.config.security.permission.type.template=permission-type-template
-clamp.config.security.permission.type.tosca=permission-type-tosca
-#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties
-clamp.config.security.permission.instance=dev
+#Async Executor default Parameters
+async.core.pool.size=10
+async.max.pool.size=20
+async.queue.capacity=500
+
+#For EELF logback file
+#com.att.eelf.logging.path=
+clamp.config.logback.filename=logback-default.xml
+#The log folder that will be used in logback.xml file
+clamp.config.log.path=log
+clamp.config.files.systemProperties=classpath:/system.properties
+clamp.config.files.cldsUsers=classpath:/clds/clds-users.json
+clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json
+clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json
+
+# Properties for Clamp
+# DCAE request build properties
+#
+clamp.config.dcae.template=classpath:/clds/templates/dcae-template.json
+clamp.config.dcae.deployment.template=classpath:/clds/templates/dcae-deployment-template.json
+#
+#
+# Configuration Settings for Policy Engine Components
+clamp.config.policy.api.url=http4://localhost:${docker.http-cache.port.host}
+clamp.config.policy.api.userName=healthcheck
+clamp.config.policy.api.password=zb!XztG34
+clamp.config.policy.pap.url=http4://localhost:${docker.http-cache.port.host}
+clamp.config.policy.pap.userName=healthcheck
+clamp.config.policy.pap.password=zb!XztG34
+
+clamp.config.policy.pdpUrl1=http://localhost:${docker.http-cache.port.host}/pdp/ , testpdp, alpha123
+clamp.config.policy.pdpUrl2=http://localhost:${docker.http-cache.port.host}/pdp/ , testpdp, alpha123
+clamp.config.policy.papUrl=http://localhost:${docker.http-cache.port.host}/pap/ , testpap, alpha123
+clamp.config.policy.notificationType=websocket
+clamp.config.policy.notificationUebServers=localhost
+clamp.config.policy.notificationTopic=
+clamp.config.policy.clientId=python
+# base64 encoding
+clamp.config.policy.clientKey=dGVzdA==
+#DEVL for development
+#TEST for Test environments
+#PROD for prod environments
+clamp.config.policy.policyEnvironment=DEVL
+# General Policy request properties
+#
+clamp.config.policy.onap.name=DCAE
+clamp.config.policy.pdp.group=default
+clamp.config.policy.ms.type=MicroService
+clamp.config.policy.ms.policyNamePrefix=Config_MS_
+clamp.config.policy.op.policyNamePrefix=Config_BRMS_Param_
+clamp.config.policy.base.policyNamePrefix=Config_
+clamp.config.policy.op.type=BRMS_Param
+
+clamp.config.import.tosca.model=false
+clamp.config.tosca.policyTypes=tca
+clamp.config.tosca.filePath=/tmp/tosca-models
+
+# TCA MicroService Policy request build properties
+#
+clamp.config.tca.policyid.prefix=DCAE.Config_
+clamp.config.tca.policy.template=classpath:/clds/templates/tca-policy-template.json
+clamp.config.tca.template=classpath:/clds/templates/tca-template.json
+clamp.config.tca.thresholds.template=classpath:/clds/templates/tca-thresholds-template.json
+
+#
+#
+# Operational Policy request build properties
+#
+clamp.config.op.policyDescription=from clds
+# default
+clamp.config.op.templateName=ClosedLoopControlName
+clamp.config.op.operationTopic=APPC-CL
+clamp.config.op.notificationTopic=POLICY-CL-MGT
+clamp.config.op.controller=amsterdam
+clamp.config.op.policy.appc=APPC
+#
+# Sdc service properties
+#
+clamp.config.sdc.csarFolder = ${project.build.directory}/sdc-tests
+clamp.config.sdc.blueprint.parser.mapping = classpath:/clds/blueprint-parser-mapping.json
+#
+clamp.config.ui.location.default=classpath:/clds/templates/ui-location-default.json
+#
+# if action.test.override is true, then any action will be marked as test=true (even if incoming action request had test=false); otherwise, test flag will be unchanged on the action request
+clamp.config.action.test.override=false
+# if action.insert.test.event is true, then insert event even if the action is set to test
+clamp.config.action.insert.test.event=false
+clamp.config.clds.service.cache.invalidate.after.seconds=120
+
+#DCAE Inventory Url Properties
+clamp.config.dcae.inventory.url=http://localhost:${docker.http-cache.port.host}
+clamp.config.dcae.intentory.retry.interval=100
+clamp.config.dcae.intentory.retry.limit=1
+
+#DCAE Dispatcher Url Properties
+clamp.config.dcae.dispatcher.url=http://localhost:${docker.http-cache.port.host}
+clamp.config.dcae.dispatcher.retry.interval=100
+clamp.config.dcae.dispatcher.retry.limit=1
+
+#DCAE Deployment Url Properties
+clamp.config.dcae.deployment.url=http4://localhost:${docker.http-cache.port.host}
+clamp.config.dcae.deployment.userName=test
+clamp.config.dcae.deployment.password=test
+
+#Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case !
+clamp.config.security.permission.type.cl=permission-type-cl
+clamp.config.security.permission.type.cl.manage=permission-type-cl-manage
+clamp.config.security.permission.type.cl.event=permission-type-cl-event
+clamp.config.security.permission.type.filter.vf=permission-type-filter-vf
+clamp.config.security.permission.type.template=permission-type-template
+clamp.config.security.permission.type.tosca=permission-type-tosca
+#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties
+clamp.config.security.permission.instance=dev
clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal \ No newline at end of file
diff --git a/src/test/resources/clds/blueprint-with-microservice-chain.yaml b/src/test/resources/clds/blueprint-with-microservice-chain.yaml
index 4a7e5d7a..fa2d7205 100644
--- a/src/test/resources/clds/blueprint-with-microservice-chain.yaml
+++ b/src/test/resources/clds/blueprint-with-microservice-chain.yaml
@@ -31,7 +31,7 @@ node_templates:
service_component_name_override: second_app
image: { get_input: second_app_docker_image }
policy_id:
- policy_type_id: type2
+ policy_model_id: "type2"
interfaces:
cloudify.interfaces.lifecycle:
start:
@@ -56,7 +56,7 @@ node_templates:
image: { get_input: first_app_docker_image }
container_port: 6565
policy_id:
- policy_type_id: type1
+ policy_model_id: "type1"
interfaces:
cloudify.interfaces.lifecycle:
start:
@@ -81,7 +81,7 @@ node_templates:
image: { get_input: third_app_docker_image }
container_port: 443
policy_id:
- policy_type_id: type3
+ policy_model_id: "type3"
interfaces:
cloudify.interfaces.lifecycle:
start:
diff --git a/src/test/resources/clds/clds-parse-exception.json b/src/test/resources/clds/clds-parse-exception.json
new file mode 100644
index 00000000..1c06a394
--- /dev/null
+++ b/src/test/resources/clds/clds-parse-exception.json
@@ -0,0 +1 @@
+This is not json \ No newline at end of file
diff --git a/src/test/resources/clds/single-microservice-fragment-valid.yaml b/src/test/resources/clds/single-microservice-fragment-valid.yaml
index 269ee506..2c168071 100644
--- a/src/test/resources/clds/single-microservice-fragment-valid.yaml
+++ b/src/test/resources/clds/single-microservice-fragment-valid.yaml
@@ -6,7 +6,7 @@ second_app:
image: { get_input: second_app_docker_image }
name: second_app
policy_id:
- policy_type_id: type1
+ policy_model_id: "type1"
interfaces:
cloudify.interfaces.lifecycle:
start:
diff --git a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json
index 41ca2de2..d7a54162 100644
--- a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json
+++ b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json
@@ -27,23 +27,22 @@
{
"name": "deployParameters",
"value": {
- "dh_override": "component_dockerhost",
- "dh_location_id": "zone1",
- "aaiEnrichmentHost": "none",
- "aaiEnrichmentPort": 8443,
- "enableAAIEnrichment": false,
- "dmaap_host": "dmaap.onap-message-router",
- "dmaap_port": 3904,
+ "aaiEnrichmentHost": "aai.onap.svc.cluster.local",
+ "aaiEnrichmentPort": "8443",
+ "enableAAIEnrichment": true,
+ "dmaap_host": "message-router.onap",
+ "dmaap_port": "3904",
"enableRedisCaching": false,
- "redisHosts": "",
- "tag_version": "nexus3.onap.org:10001/onap//onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.0.0",
- "consul_host": "consul-server.onap-consul",
+ "redisHosts": "dcae-redis.onap.svc.cluster.local:6379",
+ "tag_version": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.1",
+ "consul_host": "consul-server.onap",
"consul_port": "8500",
- "cbs_host": "config-binding-service.dcae",
+ "cbs_host": "config-binding-servicel",
"cbs_port": "10000",
- "external_port": "32010",
+ "external_port": "32012",
+ "policy_model_id": "onap.policies.monitoring.cdap.tca.hi.lo.app",
"policy_id": "AUTO_GENERATED_POLICY_ID_AT_SUBMIT"
}
}
]
-}
+} \ No newline at end of file
diff --git a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json
new file mode 100644
index 00000000..012c46e9
--- /dev/null
+++ b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json
@@ -0,0 +1,48 @@
+{
+ "global": [
+ {
+ "name": "service",
+ "value": [
+ "4cc5b45a-1f63-4194-8100-cd8e14248c92"
+ ]
+ },
+ {
+ "name": "vf",
+ "value": [
+ "07e266fc-49ab-4cd7-8378-ca4676f1b9ec"
+ ]
+ },
+ {
+ "name": "actionSet",
+ "value": [
+ "vnfRecipe"
+ ]
+ },
+ {
+ "name": "location",
+ "value": [
+ "DC1"
+ ]
+ },
+ {
+ "name": "deployParameters",
+ "value": {
+ "aaiEnrichmentHost": "aai.onap.svc.cluster.local",
+ "aaiEnrichmentPort": "8443",
+ "enableAAIEnrichment": true,
+ "dmaap_host": "message-router.onap.svc.cluster.local",
+ "dmaap_port": "3904",
+ "enableRedisCaching": false,
+ "redisHosts": "dcae-redis.onap.svc.cluster.local:6379",
+ "tag_version": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0-STAGING-latest",
+ "consul_host": "consul-server.onap.svc.cluster.local",
+ "consul_port": "8500",
+ "cbs_host": "config-binding-service.dcae.svc.cluster.local",
+ "cbs_port": "10000",
+ "external_port": "32012",
+ "policy_id": "AUTO_GENERATED_POLICY_ID_AT_SUBMIT",
+ "policy_model_id": "onap.policies.monitoring.cdap.tca.hi.lo.app"
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/src/test/resources/example/sdc/blueprint-dcae/tca.yaml b/src/test/resources/example/sdc/blueprint-dcae/tca.yaml
index edaa0be2..0cb9cdb6 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.policies.monitoring.cdap.tca.hi.lo.app
+ policy_model_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 c834b1b9..00ebfe7f 100644
--- a/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml
+++ b/src/test/resources/example/sdc/blueprint-dcae/tca_2.yaml
@@ -1,76 +1,92 @@
+#
+# ============LICENSE_START====================================================
+# =============================================================================
+# 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======================================================
+
tosca_definitions_version: cloudify_dsl_1_3
-imports:
- - "http://www.getcloudify.org/spec/cloudify/3.4/types.yaml"
- - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/dockerplugin/3.2.0/dockerplugin_types.yaml
- - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/relationshipplugin/1.0.0/relationshipplugin_types.yaml
- - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml
+description: >
+ This blueprint deploys/manages the TCA module as a Docker container
+
+imports:
+ - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
+ - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.12/k8splugin_types.yaml
+# - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml
+ - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/clamppolicyplugin/1.0.0/clamppolicyplugin_types.yaml
inputs:
- dh_override:
- type: string
- default: "component_dockerhost"
- dh_location_id:
- type: string
- default: "zone1"
aaiEnrichmentHost:
type: string
- default: "none"
+ default: "aai.onap.svc.cluster.local"
aaiEnrichmentPort:
- type: string
- default: 8443
+ type: string
+ default: "8443"
enableAAIEnrichment:
type: string
- default: false
+ default: true
dmaap_host:
type: string
- default: dmaap.onap-message-router
+ default: message-router.onap
dmaap_port:
type: string
- default: 3904
+ default: "3904"
enableRedisCaching:
type: string
- default: false
+ default: false
redisHosts:
- type: string
+ type: string
+ default: dcae-redis.onap.svc.cluster.local:6379
tag_version:
type: string
- default: "nexus3.onap.org:10001/onap//onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.0.0"
+ default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.1"
consul_host:
type: string
- default: consul-server.onap-consul
+ default: consul-server.onap
consul_port:
type: string
default: "8500"
cbs_host:
type: string
- default: "config-binding-service.dcae"
+ default: "config-binding-servicel"
cbs_port:
type: string
default: "10000"
policy_id:
type: string
- default: "none"
+ default: "onap.restart.tca"
external_port:
type: string
- description: "Port for CDAPgui to be exposed"
- default: "32010"
-
+ description: Kubernetes node port on which CDAPgui is exposed
+ default: "32012"
+ policy_model_id:
+ type: string
+ default: "onap.policies.monitoring.cdap.tca.hi.lo.app"
node_templates:
- docker_service_host:
- properties:
- docker_host_override:
- get_input: dh_override
- location_id:
- get_input: dh_location_id
- type: dcae.nodes.SelectedDockerHost
- tca_docker:
+ tca_k8s:
+ type: dcae.nodes.ContainerizedServiceComponent
relationships:
- - type: dcae.relationships.component_contained_in
- target: docker_service_host
- - target: tca_policy
- type: cloudify.relationships.depends_on
- type: dcae.nodes.DockerContainerForComponentsUsingDmaap
+ - target: tca_policy
+ type: cloudify.relationships.depends_on
properties:
+ service_component_type: 'dcaegen2-analytics-tca'
+ application_config: {}
+ docker_config: {}
+ image:
+ get_input: tag_version
+ log_info:
+ log_directory: "/opt/app/TCAnalytics/logs"
application_config:
app_config:
appDescription: DCAE Analytics Threshold Crossing Alert Application
@@ -84,87 +100,75 @@ node_templates:
tcaVESMessageStatusTableTTLSeconds: '86400'
thresholdCalculatorFlowletInstances: '2'
app_preferences:
- aaiEnrichmentHost:
+ aaiEnrichmentHost:
get_input: aaiEnrichmentHost
aaiEnrichmentIgnoreSSLCertificateErrors: 'true'
aaiEnrichmentPortNumber: '8443'
aaiEnrichmentProtocol: https
- aaiEnrichmentUserName: DCAE
- aaiEnrichmentUserPassword: DCAE
+ aaiEnrichmentUserName: dcae@dcae.onap.org
+ aaiEnrichmentUserPassword: demo123456!
aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query
aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf
- enableAAIEnrichment:
+ enableAAIEnrichment:
get_input: enableAAIEnrichment
- enableRedisCaching:
+ enableRedisCaching:
get_input: enableRedisCaching
- redisHosts:
+ redisHosts:
get_input: redisHosts
enableAlertCEFFormat: 'false'
publisherContentType: application/json
- publisherHostName:
+ publisherHostName:
get_input: dmaap_host
- publisherHostPort:
- get_input: dmaap_port
+ publisherHostPort:
+ get_input: dmaap_port
publisherMaxBatchSize: '1'
publisherMaxRecoveryQueueSize: '100000'
publisherPollingInterval: '20000'
publisherProtocol: http
publisherTopicName: unauthenticated.DCAE_CL_OUTPUT
- subscriberConsumerGroup: OpenDCAE-c12
+ subscriberConsumerGroup: OpenDCAE-clamp
subscriberConsumerId: c12
subscriberContentType: application/json
- subscriberHostName:
+ subscriberHostName:
get_input: dmaap_host
subscriberHostPort:
- get_input: dmaap_port
+ get_input: dmaap_port
subscriberMessageLimit: '-1'
subscriberPollingInterval: '30000'
subscriberProtocol: http
subscriberTimeoutMS: '-1'
- subscriberTopicName: unauthenticated.SEC_MEASUREMENT_OUTPUT
- tca_policy_default: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"},{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta","thresholdValue":700,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"Measurement_vGMUX","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"GREATER","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]}]}'
- service_component_type: dcaegen2-analytics_tca
- docker_config:
- healthcheck:
- endpoint: /healthcheck
- interval: 15s
- timeout: 1s
- type: http
- image:
- get_input: tag_version
+ subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT
+# tca_policy: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"},{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":700,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"Measurement_vGMUX","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"GREATER","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]}]}'
+ service_component_type: dcaegen2-analytics_tca
interfaces:
cloudify.interfaces.lifecycle:
start:
inputs:
envs:
- DMAAPHOST:
+ DMAAPHOST:
{ get_input: dmaap_host }
DMAAPPORT:
{ get_input: dmaap_port }
DMAAPPUBTOPIC: "unauthenticated.DCAE_CL_OUTPUT"
- DMAAPSUBTOPIC: "unauthenticated.SEC_MEASUREMENT_OUTPUT"
- AAIHOST:
+ DMAAPSUBTOPIC: "unauthenticated.VES_MEASUREMENT_OUTPUT"
+ AAIHOST:
{ get_input: aaiEnrichmentHost }
- AAIPORT:
+ AAIPORT:
{ get_input: aaiEnrichmentPort }
- CONSUL_HOST:
+ CONSUL_HOST:
{ get_input: consul_host }
- CONSUL_PORT:
+ CONSUL_PORT:
{ get_input: consul_port }
- CBS_HOST:
+ CBS_HOST:
{ get_input: cbs_host }
- CBS_PORT:
+ CBS_PORT:
{ get_input: cbs_port }
- CONFIG_BINDING_SERVICE: "config_binding_service"
+ CONFIG_BINDING_SERVICE: "config_binding_service"
ports:
- - concat: ["11011:", { get_input: external_port }]
- stop:
- inputs:
- cleanup_image: true
+ - concat: ["11011:", { get_input: external_port }]
tca_policy:
- type: dcae.nodes.policy
+ type: clamp.nodes.policy
properties:
policy_id:
get_input: policy_id
- policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app
-
+ policy_model_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 edaa0be2..6fab504b 100644
--- a/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml
+++ b/src/test/resources/example/sdc/blueprint-dcae/tca_3.yaml
@@ -1,105 +1,157 @@
tosca_definitions_version: cloudify_dsl_1_3
+
+description: >
+ This blueprint deploys/manages the TCA module as a Docker container
+
imports:
-- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
-- https://onap.org:8443/repository/solutioning01-mte2-raw/type_files/docker/2.2.0/node-type.yaml
-- https://onap.org:8443/repository/solutioning01-mte2-raw/type_files/relationship/1.0.0/node-type.yaml
-- http://onap.org:8081/repository/solutioning01-mte2-raw/type_files/dmaap/dmaap_mr.yaml
+ - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
+ - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.12/k8splugin_types.yaml
+ - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml
inputs:
- location_id:
+ aaiEnrichmentHost:
type: string
- service_id:
+ default: "aai.onap.svc.cluster.local"
+ aaiEnrichmentPort:
type: string
+ default: "8443"
+ enableAAIEnrichment:
+ type: string
+ default: true
+ dmaap_host:
+ type: string
+ default: message-router.onap.svc.cluster.local
+ dmaap_port:
+ type: string
+ default: "3904"
+ enableRedisCaching:
+ type: string
+ default: false
+ redisHosts:
+ type: string
+ default: dcae-redis.onap.svc.cluster.local:6379
+ tag_version:
+ type: string
+ default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0-STAGING-latest"
+ consul_host:
+ type: string
+ default: consul-server.onap.svc.cluster.local
+ consul_port:
+ type: string
+ default: "8500"
+ cbs_host:
+ type: string
+ default: "config-binding-service.dcae.svc.cluster.local"
+ cbs_port:
+ type: string
+ default: "10000"
policy_id:
type: string
+ default: "none"
+ external_port:
+ type: string
+ description: Kubernetes node port on which CDAPgui is exposed
+ default: "32012"
+ policy_model_id:
+ type: string
+ default: "onap.policies.monitoring.cdap.tca.hi.lo.app"
+
node_templates:
- policy_0:
- type: dcae.nodes.policy
- properties:
- policy_id:
- get_input: policy_id
- policy_type_id: onap.policies.monitoring.cdap.tca.hi.lo.app
- cdap_host_host:
- type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure
- properties:
- location_id:
- get_input: location_id
- scn_override: cdap_broker.solutioning-central.dcae.onap.org
- interfaces:
- cloudify.interfaces.lifecycle: {
- }
- tca_tca:
- type: dcae.nodes.MicroService.cdap
- properties:
- app_config:
- appDescription: DCAE Analytics Threshold Crossing Alert Application
- appName: dcae-tca
- tcaSubscriberOutputStreamName: TCASubscriberOutputStream
- tcaVESAlertsTableName: TCAVESAlertsTable
- tcaVESAlertsTableTTLSeconds: '1728000'
- tcaVESMessageStatusTableName: TCAVESMessageStatusTable
- tcaVESMessageStatusTableTTLSeconds: '86400'
- thresholdCalculatorFlowletInstances: '2'
- app_preferences:
- publisherContentType: application/json
- publisherHostName: mrlocal-mtnjftle01.onap.org
- publisherHostPort: '3905'
- publisherMaxBatchSize: '10'
- publisherMaxRecoveryQueueSize: '100000'
- publisherPollingInterval: '20000'
- publisherProtocol: https
- publisherTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESPub
- publisherUserName: test@tca.af.dcae.onap.org
- publisherUserPassword: password
- subscriberConsumerGroup: OpenDCAE-c12
- subscriberConsumerId: c12
- subscriberContentType: application/json
- subscriberHostName: mrlocal-mtnjftle01.onap.org
- subscriberHostPort: '3905'
- subscriberMessageLimit: '-1'
- subscriberPollingInterval: '20000'
- subscriberProtocol: https
- subscriberTimeoutMS: '-1'
- subscriberTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESSub
- subscriberUserName: test@tca.af.dcae.onap.org
- subscriberUserPassword: password
- tca_policy: null
- artifact_name: dcae-analytics-tca
- artifact_version: 1.0.0
- connections:
- streams_publishes: [
- ]
- streams_subscribes: [
- ]
- jar_url: http://somejar
- location_id:
- get_input: location_id
- namespace: cdap_tca_hi_lo
- programs:
- - program_id: TCAVESCollectorFlow
- program_type: flows
- - program_id: TCADMaaPMRSubscriberWorker
- program_type: workers
- - program_id: TCADMaaPMRPublisherWorker
- program_type: workers
- service_component_type: cdap_app_tca
- service_id:
- get_input: service_id
- streamname: TCASubscriberOutputStream
+ tca_k8s:
+ type: dcae.nodes.ContainerizedServiceComponent
relationships:
- - target: topic0
- type: dcae.relationships.subscribe_to_events
- - target: topic1
- type: dcae.relationships.publish_events
- - target: cdap_host_host
- type: dcae.relationships.component_contained_in
- - target: policy_0
- type: dcae.relationships.depends_on
- topic0:
- type: dcae.nodes.Topic
+ - target: tca_policy
+ type: cloudify.relationships.depends_on
properties:
- topic_name: ''
- topic1:
- type: dcae.nodes.Topic
+ service_component_type: 'dcaegen2-analytics-tca'
+ application_config: {}
+ docker_config: {}
+ image:
+ get_input: tag_version
+ log_info:
+ log_directory: "/opt/app/TCAnalytics/logs"
+ application_config:
+ app_config:
+ appDescription: DCAE Analytics Threshold Crossing Alert Application
+ appName: dcae-tca
+ tcaAlertsAbatementTableName: TCAAlertsAbatementTable
+ tcaAlertsAbatementTableTTLSeconds: '1728000'
+ tcaSubscriberOutputStreamName: TCASubscriberOutputStream
+ tcaVESAlertsTableName: TCAVESAlertsTable
+ tcaVESAlertsTableTTLSeconds: '1728000'
+ tcaVESMessageStatusTableName: TCAVESMessageStatusTable
+ tcaVESMessageStatusTableTTLSeconds: '86400'
+ thresholdCalculatorFlowletInstances: '2'
+ app_preferences:
+ aaiEnrichmentHost:
+ get_input: aaiEnrichmentHost
+ aaiEnrichmentIgnoreSSLCertificateErrors: 'true'
+ aaiEnrichmentPortNumber: '8443'
+ aaiEnrichmentProtocol: https
+ aaiEnrichmentUserName: dcae@dcae.onap.org
+ aaiEnrichmentUserPassword: demo123456!
+ aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query
+ aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf
+ enableAAIEnrichment:
+ get_input: enableAAIEnrichment
+ enableRedisCaching:
+ get_input: enableRedisCaching
+ redisHosts:
+ get_input: redisHosts
+ enableAlertCEFFormat: 'false'
+ publisherContentType: application/json
+ publisherHostName:
+ get_input: dmaap_host
+ publisherHostPort:
+ get_input: dmaap_port
+ publisherMaxBatchSize: '1'
+ publisherMaxRecoveryQueueSize: '100000'
+ publisherPollingInterval: '20000'
+ publisherProtocol: http
+ publisherTopicName: unauthenticated.DCAE_CL_OUTPUT
+ subscriberConsumerGroup: OpenDCAE-c12
+ subscriberConsumerId: c12
+ subscriberContentType: application/json
+ subscriberHostName:
+ get_input: dmaap_host
+ subscriberHostPort:
+ get_input: dmaap_port
+ subscriberMessageLimit: '-1'
+ subscriberPollingInterval: '30000'
+ subscriberProtocol: http
+ subscriberTimeoutMS: '-1'
+ subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT
+ tca_policy: ''
+ service_component_type: dcaegen2-analytics_tca
+ interfaces:
+ cloudify.interfaces.lifecycle:
+ start:
+ inputs:
+ envs:
+ DMAAPHOST:
+ { get_input: dmaap_host }
+ DMAAPPORT:
+ { get_input: dmaap_port }
+ DMAAPPUBTOPIC: "unauthenticated.DCAE_CL_OUTPUT"
+ DMAAPSUBTOPIC: "unauthenticated.VES_MEASUREMENT_OUTPUT"
+ AAIHOST:
+ { get_input: aaiEnrichmentHost }
+ AAIPORT:
+ { get_input: aaiEnrichmentPort }
+ CONSUL_HOST:
+ { get_input: consul_host }
+ CONSUL_PORT:
+ { get_input: consul_port }
+ CBS_HOST:
+ { get_input: cbs_host }
+ CBS_PORT:
+ { get_input: cbs_port }
+ CONFIG_BINDING_SERVICE: "config_binding_service"
+ ports:
+ - concat: ["11011:", { get_input: external_port }]
+ tca_policy:
+ type: dcae.nodes.policy
properties:
- topic_name: ''
-
+ policy_id:
+ get_input: policy_id
+ policy_model_id:
+ get_input: policy_model_id
diff --git a/src/test/resources/http-cache/third_party_proxy.py b/src/test/resources/http-cache/third_party_proxy.py
index 0db977bb..0381ab18 100755
--- a/src/test/resources/http-cache/third_party_proxy.py
+++ b/src/test/resources/http-cache/third_party_proxy.py
@@ -127,10 +127,10 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
with open(cached_file_content, 'w') as f:
f.write(jsonGenerated)
return True
- elif self.path.startswith("/dcae-operationstatus") and http_type == "GET":
+ elif self.path.startswith("/dcae-operationstatus/install") and http_type == "GET":
if not _file_available:
- print "self.path start with /dcae-operationstatus, generating response json..."
- jsonGenerated = "{\"operationType\": \"operationType1\", \"status\": \"succeeded\"}"
+ print "self.path start with /dcae-operationstatus/install, generating response json..."
+ jsonGenerated = "{\"operationType\": \"install\", \"status\": \"succeeded\"}"
print "jsonGenerated: " + jsonGenerated
try:
@@ -145,24 +145,29 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
with open(cached_file_content, 'w') as f:
f.write(jsonGenerated)
return True
- elif self.path.startswith("/sdc/v1/catalog/services/") and http_type == "POST":
+ elif self.path.startswith("/dcae-operationstatus/uninstall") and http_type == "GET":
if not _file_available:
- print "self.path start with /sdc/v1/catalog/services/, generating response json..."
- jsondata = json.loads(self.data_string)
- jsonGenerated = "{\"artifactName\":\"" + jsondata['artifactName'] + "\",\"artifactType\":\"" + jsondata['artifactType'] + "\",\"artifactURL\":\"" + self.path + "\",\"artifactDescription\":\"" + jsondata['description'] + "\",\"artifactChecksum\":\"ZjJlMjVmMWE2M2M1OTM2MDZlODlmNTVmZmYzNjViYzM=\",\"artifactUUID\":\"" + str(uuid.uuid4()) + "\",\"artifactVersion\":\"1\"}"
+ print "self.path start with /dcae-operationstatus/uninstall, generating response json..."
+ jsonGenerated = "{\"operationType\": \"uninstall\", \"status\": \"succeeded\"}"
print "jsonGenerated: " + jsonGenerated
- os.makedirs(cached_file_folder, 0777)
+ try:
+ os.makedirs(cached_file_folder, 0777)
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
+ print(cached_file_folder+" already exists")
+
with open(cached_file_header, 'w') as f:
f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
with open(cached_file_content, 'w') as f:
f.write(jsonGenerated)
- return True;
- elif self.path.startswith("/dcae-deployments/") and (http_type == "PUT" or http_type == "DELETE"):
+ return True
+ elif self.path.startswith("/sdc/v1/catalog/services/") and http_type == "POST":
if not _file_available:
- print "self.path start with /dcae-deployments/, generating response json..."
- #jsondata = json.loads(self.data_string)
- jsonGenerated = "{\"links\":{\"status\":\"http:\/\/" + PROXY_ADDRESS + "\/dcae-operationstatus\",\"test2\":\"test2\"}}"
+ print "self.path start with /sdc/v1/catalog/services/, generating response json..."
+ jsondata = json.loads(self.data_string)
+ jsonGenerated = "{\"artifactName\":\"" + jsondata['artifactName'] + "\",\"artifactType\":\"" + jsondata['artifactType'] + "\",\"artifactURL\":\"" + self.path + "\",\"artifactDescription\":\"" + jsondata['description'] + "\",\"artifactChecksum\":\"ZjJlMjVmMWE2M2M1OTM2MDZlODlmNTVmZmYzNjViYzM=\",\"artifactUUID\":\"" + str(uuid.uuid4()) + "\",\"artifactVersion\":\"1\"}"
print "jsonGenerated: " + jsonGenerated
os.makedirs(cached_file_folder, 0777)
@@ -171,6 +176,30 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
with open(cached_file_content, 'w') as f:
f.write(jsonGenerated)
return True
+ elif self.path.startswith("/dcae-deployments/") and http_type == "PUT":
+ print "self.path start with /dcae-deployments/ DEPLOY, generating response json..."
+ #jsondata = json.loads(self.data_string)
+ jsonGenerated = "{\"operationType\":\"install\",\"status\":\"processing\",\"links\":{\"status\":\"http:\/\/" + PROXY_ADDRESS + "\/dcae-operationstatus/install\"}}"
+ print "jsonGenerated: " + jsonGenerated
+ if not os.path.exists(cached_file_folder):
+ os.makedirs(cached_file_folder, 0777)
+ with open(cached_file_header, 'w+') as f:
+ f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
+ with open(cached_file_content, 'w+') as f:
+ f.write(jsonGenerated)
+ return True
+ elif self.path.startswith("/dcae-deployments/") and http_type == "DELETE":
+ print "self.path start with /dcae-deployments/ UNDEPLOY, generating response json..."
+ #jsondata = json.loads(self.data_string)
+ jsonGenerated = "{\"operationType\":\"uninstall\",\"status\":\"processing\",\"links\":{\"status\":\"http:\/\/" + PROXY_ADDRESS + "\/dcae-operationstatus/uninstall\"}}"
+ print "jsonGenerated: " + jsonGenerated
+ if not os.path.exists(cached_file_folder):
+ os.makedirs(cached_file_folder, 0777)
+ with open(cached_file_header, 'w+') as f:
+ f.write("{\"Content-Length\": \"" + str(len(jsonGenerated)) + "\", \"Content-Type\": \"application/json\"}")
+ with open(cached_file_content, 'w+') as f:
+ f.write(jsonGenerated)
+ return True
elif (self.path.startswith("/pdp/api/") and (http_type == "PUT" or http_type == "DELETE")) or (self.path.startswith("/pdp/api/policyEngineImport") and http_type == "POST"):
print "self.path start with /pdp/api/, copying body to response ..."
if not os.path.exists(cached_file_folder):
@@ -180,7 +209,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
with open(cached_file_content, 'w+') as f:
f.write(self.data_string)
return True
- elif self.path.startswith("/policy/api/v1/policyTypes/") and http_type == "POST":
+ elif self.path.startswith("/policy/api/v1/policytypes/") and http_type == "POST":
print "self.path start with POST new policy API /pdp/api/, copying body to response ..."
if not os.path.exists(cached_file_folder):
os.makedirs(cached_file_folder, 0777)
@@ -189,8 +218,8 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
with open(cached_file_content, 'w+') as f:
f.write(self.data_string)
return True
- elif self.path.startswith("/policy/api/v1/policyTypes/") and http_type == "DELETE":
- print "self.path start with DELETE new policy API /policy/api/v1/policyTypes/ ..."
+ elif self.path.startswith("/policy/api/v1/policytypes/") and http_type == "DELETE":
+ print "self.path start with DELETE new policy API /policy/api/v1/policytypes/ ..."
if not os.path.exists(cached_file_folder):
os.makedirs(cached_file_folder, 0777)
@@ -199,6 +228,15 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
with open(cached_file_content, 'w+') as f:
f.write(self.data_string)
return True
+ elif self.path.startswith("/policy/pap/v1/pdps/policies") and http_type == "POST":
+ print "self.path start with POST new policy API /policy/pap/v1/pdps/ ..."
+ if not os.path.exists(cached_file_folder):
+ os.makedirs(cached_file_folder, 0777)
+ with open(cached_file_header, 'w+') as f:
+ f.write("{\"Content-Length\": \"" + str(len("")) + "\", \"Content-Type\": \""+str("")+"\"}")
+ with open(cached_file_content, 'w+') as f:
+ f.write(self.data_string)
+ return True
elif self.path.startswith("/policy/api/v1/policytypes/") and http_type == "GET":
print "self.path start with /policy/api/v1/policytypes/, generating response json..."
jsonGenerated = "{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}"
@@ -241,7 +279,9 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
if not HOST:
self.send_response(404)
- return "404 Not found"
+ self.end_headers()
+ self.wfile.write('404 Not found, no remote HOST specified on the emulator !!!')
+ return "404 Not found, no remote HOST specified on the emulator !!!"
url = '%s%s' % (HOST, self.path)
response = requests.get(url, auth=AUTH, headers=HEADERS, stream=True)
@@ -254,6 +294,8 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
print('Status code : %s' % (response.status_code,))
print('Content : %s' % (response.content,))
self.send_response(response.status_code)
+ self.end_headers()
+ self.wfile.write('404 Not found, nothing found on the remote server !!!')
return response.content
else:
print("Request for data currently present in cache: %s" % (cached_file_folder,))
@@ -292,7 +334,9 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
if not HOST:
self.send_response(404)
- return "404 Not found"
+ self.end_headers()
+ self.wfile.write('404 Not found, no remote HOST specified on the emulator !!!')
+ return "404 Not found, no remote HOST specified on the emulator !!!"
print("Request for data currently not present in cache: %s" % (cached_file_folder,))
@@ -308,6 +352,8 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
print('Status code : %s' % (response.status_code,))
print('Content : %s' % (response.content,))
self.send_response(response.status_code)
+ self.end_headers()
+ self.wfile.write('404 Not found, nothing found on the remote server !!!')
return response.content
else:
print("Request for data present in cache: %s" % (cached_file_folder,))
@@ -339,7 +385,9 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
if not _file_available:
if not HOST:
self.send_response(404)
- return "404 Not found"
+ self.end_headers()
+ self.wfile.write('404 Not found, no remote HOST specified on the emulator !!!')
+ return "404 Not found, no remote HOST specified on the emulator !!!"
print("Request for data currently not present in cache: %s" % (cached_file_folder,))
@@ -355,6 +403,8 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
print('Status code : %s' % (response.status_code,))
print('Content : %s' % (response.content,))
self.send_response(response.status_code)
+ self.end_headers()
+ self.wfile.write('404 Not found, nothing found on the remote server !!!')
return response.content
else:
print("Request for data present in cache: %s" % (cached_file_folder,))
@@ -389,7 +439,9 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
if not _file_available:
if not HOST:
self.send_response(404)
- return "404 Not found"
+ self.end_headers()
+ self.wfile.write('404 Not found, no remote HOST specified on the emulator !!!')
+ return "404 Not found, no remote HOST specified on the emulator !!!"
print("Request for data currently not present in cache: %s" % (cached_file_folder,))
@@ -405,6 +457,8 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
print('Status code : %s' % (response.status_code,))
print('Content : %s' % (response.content,))
self.send_response(response.status_code)
+ self.end_headers()
+ self.wfile.write('404 Not found, nothing found on the remote server !!!')
return response.content
else:
print("Request for data present in cache: %s" % (cached_file_folder,))
diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties
index 7614e177..0be9e298 100644
--- a/src/test/resources/https/https-test.properties
+++ b/src/test/resources/https/https-test.properties
@@ -30,6 +30,7 @@ server.port=${clamp.it.tests.https}
server.ssl.key-store=classpath:https/keystore-test.jks
server.ssl.key-store-password=testpass
server.ssl.key-password=testpass
+server.ssl.key-store-type=JKS
### In order to be user friendly when HTTPS is enabled,
### you can add another HTTP port that will be automatically redirected to HTTPS
diff --git a/src/test/resources/tosca/guard1-policy-payload.json b/src/test/resources/tosca/guard1-policy-payload.json
index bacf174f..b4e0809c 100644
--- a/src/test/resources/tosca/guard1-policy-payload.json
+++ b/src/test/resources/tosca/guard1-policy-payload.json
@@ -1,15 +1,15 @@
{
"policy-id": "guard1",
- "contents": {
+ "content": {
"recipe": "Rebuild",
"actor": "SO",
"clname": "testloop",
- "guardTargets": ".*",
- "minGuard": "3",
- "maxGuard": "7",
- "limitGuard": "",
- "timeUnitsGuard": "",
- "timeWindowGuard": "",
+ "targets": ".*",
+ "min": "3",
+ "max": "7",
+ "limit": "",
+ "timeUnits": "",
+ "timeWindow": "",
"guardActiveStart": "00:00:01-05:00",
"guardActiveEnd": "23:59:01-05:00"
}
diff --git a/src/test/resources/tosca/guard2-policy-payload.json b/src/test/resources/tosca/guard2-policy-payload.json
index 89f7ec89..29beb6b9 100644
--- a/src/test/resources/tosca/guard2-policy-payload.json
+++ b/src/test/resources/tosca/guard2-policy-payload.json
@@ -1,15 +1,15 @@
{
"policy-id": "guard2",
- "contents": {
+ "content": {
"recipe": "Migrate",
"actor": "SO",
"clname": "testloop",
- "guardTargets": ".*",
- "minGuard": "1",
- "maxGuard": "2",
- "limitGuard": "",
- "timeUnitsGuard": "",
- "timeWindowGuard": "",
+ "targets": ".*",
+ "min": "1",
+ "max": "2",
+ "limit": "",
+ "timeUnits": "",
+ "timeWindow": "",
"guardActiveStart": "00:00:01-05:00",
"guardActiveEnd": "23:59:01-05:00"
}
diff --git a/src/test/resources/tosca/operational-policy-no-guard-properties.json b/src/test/resources/tosca/operational-policy-no-guard-properties.json
index 30c04404..fdb1906a 100644
--- a/src/test/resources/tosca/operational-policy-no-guard-properties.json
+++ b/src/test/resources/tosca/operational-policy-no-guard-properties.json
@@ -22,7 +22,7 @@
"failure_guard": "",
"target": {
"type": "VM",
- "resourceId": "",
+ "resourceID": "",
"modelInvariantId": "",
"modelVersionId": "",
"modelName": "",
diff --git a/src/test/resources/tosca/operational-policy-payload-legacy.yaml b/src/test/resources/tosca/operational-policy-payload-legacy.yaml
new file mode 100644
index 00000000..41184c9c
--- /dev/null
+++ b/src/test/resources/tosca/operational-policy-payload-legacy.yaml
@@ -0,0 +1,39 @@
+controlLoop:
+ abatement: true
+ controlLoopName: control loop
+ timeout: 30
+ trigger_policy: new1
+ version: 2.0.0
+policies:
+- actor: SO
+ failure: new2
+ failure_exception: new2
+ failure_guard: new2
+ failure_retries: new2
+ failure_timeout: new2
+ id: new1
+ payload:
+ configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[10].value","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[15].value","enabled":"$.vf-module-topology.vf-module-parameters.param[22].value"}]'
+ requestParameters: '{"usePreload":true,"userParams":[]}'
+ recipe: Rebuild
+ retry: 10
+ success: new2
+ target:
+ resourceTargetId: test
+ type: VFC
+ timeout: 20
+- actor: SDNC
+ failure: final_failure
+ failure_exception: final_failure_exception
+ failure_guard: final_failure_guard
+ failure_retries: final_failure_retries
+ failure_timeout: final_failure_timeout
+ id: new2
+ payload: ''
+ recipe: Migrate
+ retry: 30
+ success: final_success
+ target:
+ resourceTargetId: test
+ type: VFC
+ timeout: 40
diff --git a/src/test/resources/tosca/operational-policy-payload.json b/src/test/resources/tosca/operational-policy-payload.json
index 1017d0a2..5097654d 100644
--- a/src/test/resources/tosca/operational-policy-payload.json
+++ b/src/test/resources/tosca/operational-policy-payload.json
@@ -1,4 +1,4 @@
{
"policy-id": "testPolicy",
- "content": "tosca_definitions_version%3A+tosca_simple_yaml_1_0_0%0Atopology_template%3A%0A++policies%3A%0A++-+testPolicy%3A%0A++++++type%3A+onap.policies.controlloop.Operational%0A++++++version%3A+1.0.0%0A++++++metadata%3A+%7Bpolicy-id%3A+testPolicy%7D%0A++++++properties%3A%0A++++++++controlLoop%3A+%7BcontrolLoopName%3A+control+loop%2C+version%3A+2.0.0%2C+trigger_policy%3A+new1%2C%0A++++++++++timeout%3A+%2730%27%2C+abatement%3A+%27true%27%7D%0A++++++++policies%3A%0A++++++++-+id%3A+new1%0A++++++++++recipe%3A+Rebuild%0A++++++++++retry%3A+%2710%27%0A++++++++++timeout%3A+%2720%27%0A++++++++++actor%3A+SO%0A++++++++++payload%3A+test%0A++++++++++success%3A+new2%0A++++++++++failure%3A+new2%0A++++++++++failure_timeout%3A+new2%0A++++++++++failure_retries%3A+new2%0A++++++++++failure_exception%3A+new2%0A++++++++++failure_guard%3A+new2%0A++++++++++target%3A+%7Btype%3A+VFC%2C+resourceTargetId%3A+test%7D%0A++++++++-+id%3A+new2%0A++++++++++recipe%3A+Migrate%0A++++++++++retry%3A+%2730%27%0A++++++++++timeout%3A+%2740%27%0A++++++++++actor%3A+SDNC%0A++++++++++payload%3A+test%0A++++++++++target%3A+%7Btype%3A+VFC%2C+resourceTargetId%3A+test%7D%0A"
+ "content": "controlLoop%3A%0A++abatement%3A+true%0A++controlLoopName%3A+control+loop%0A++timeout%3A+30%0A++trigger_policy%3A+new1%0A++version%3A+2.0.0%0Apolicies%3A%0A-+actor%3A+SO%0A++failure%3A+new2%0A++failure_exception%3A+new2%0A++failure_guard%3A+new2%0A++failure_retries%3A+new2%0A++failure_timeout%3A+new2%0A++id%3A+new1%0A++payload%3A%0A++++configurationParameters%3A+%27%5B%7B%22ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B10%5D.value%22%2C%22oam-ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B15%5D.value%22%2C%22enabled%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B22%5D.value%22%7D%5D%27%0A++++requestParameters%3A+%27%7B%22usePreload%22%3Atrue%2C%22userParams%22%3A%5B%5D%7D%27%0A++recipe%3A+Rebuild%0A++retry%3A+10%0A++success%3A+new2%0A++target%3A%0A++++resourceTargetId%3A+test%0A++++type%3A+VFC%0A++timeout%3A+20%0A-+actor%3A+SDNC%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+new2%0A++payload%3A+%27%27%0A++recipe%3A+Migrate%0A++retry%3A+30%0A++success%3A+final_success%0A++target%3A%0A++++resourceTargetId%3A+test%0A++++type%3A+VFC%0A++timeout%3A+40%0A"
} \ 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
index 68116b00..c3a6b5c2 100644
--- a/src/test/resources/tosca/operational-policy-payload.yaml
+++ b/src/test/resources/tosca/operational-policy-payload.yaml
@@ -4,28 +4,39 @@ topology_template:
- testPolicy:
type: onap.policies.controlloop.Operational
version: 1.0.0
- metadata: {policy-id: testPolicy}
+ metadata:
+ policy-id: testPolicy
properties:
- controlLoop: {controlLoopName: control loop, version: 2.0.0, trigger_policy: new1,
- timeout: '30', abatement: 'true'}
+ 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
+ payload:
+ requestParameters: '{"usePreload":true,"userParams":[]}'
+ configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[10].value","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[15].value","enabled":"$.vf-module-topology.vf-module-parameters.param[22].value"}]'
success: new2
failure: new2
failure_timeout: new2
failure_retries: new2
failure_exception: new2
failure_guard: new2
- target: {type: VFC, resourceTargetId: test}
+ target:
+ type: VFC
+ resourceTargetId: test
- id: new2
recipe: Migrate
retry: '30'
timeout: '40'
actor: SDNC
- payload: test
- target: {type: VFC, resourceTargetId: test}
+ payload: ''
+ 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
index 50361659..bfce6b33 100644
--- a/src/test/resources/tosca/operational-policy-properties.json
+++ b/src/test/resources/tosca/operational-policy-properties.json
@@ -4,12 +4,12 @@
"recipe": "Rebuild",
"actor": "SO",
"clname": "testloop",
- "guardTargets": ".*",
- "minGuard": "3",
- "maxGuard": "7",
- "limitGuard": "",
- "timeUnitsGuard": "",
- "timeWindowGuard": "",
+ "targets": ".*",
+ "min": "3",
+ "max": "7",
+ "limit": "",
+ "timeUnits": "",
+ "timeWindow": "",
"guardActiveStart": "00:00:01-05:00",
"guardActiveEnd": "23:59:01-05:00"
},
@@ -17,12 +17,12 @@
"recipe": "Migrate",
"actor": "SO",
"clname": "testloop",
- "guardTargets": ".*",
- "minGuard": "1",
- "maxGuard": "2",
- "limitGuard": "",
- "timeUnitsGuard": "",
- "timeWindowGuard": "",
+ "targets": ".*",
+ "min": "1",
+ "max": "2",
+ "limit": "",
+ "timeUnits": "",
+ "timeWindow": "",
"guardActiveStart": "00:00:01-05:00",
"guardActiveEnd": "23:59:01-05:00"
}
@@ -42,7 +42,7 @@
"retry": "10",
"timeout": "20",
"actor": "SO",
- "payload": "test",
+ "payload": "requestParameters: '{\"usePreload\":true,\"userParams\":[]}'\r\nconfigurationParameters: '[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[10].value\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[15].value\",\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[22].value\"}]'",
"success": "new2",
"failure": "new2",
"failure_timeout": "new2",
@@ -60,7 +60,7 @@
"retry": "30",
"timeout": "40",
"actor": "SDNC",
- "payload": "test",
+ "payload": "",
"target": {
"type": "VFC",
"resourceTargetId": "test"