aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-09-10 12:25:47 +0200
committersebdet <sebastien.determe@intl.att.com>2019-09-10 12:25:47 +0200
commitf0d7a9645a2b773df5d278d3858ce36a61f23645 (patch)
tree69052ec34191afd65f8f52d6e2fc1fe289d820d0 /src/test/java/org
parent0387f232b4a56e98092519ccc2e0ee7985f6701c (diff)
Remove dead code
Removal of deprecated v1 interface code, sql cleaned up as well, old model removed from database Issue-ID: CLAMP-487 Change-Id: I4a9f14de9ea1c1b76c522581d75cf4b011c2aa01 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/clamp/clds/client/CldsEventDelegateTest.java83
-rw-r--r--src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java157
-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/client/TcaPolicyDeleteDelegateTest.java103
-rw-r--r--src/test/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructorTest.java85
-rw-r--r--src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructorTest.java147
-rw-r--r--src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatterTest.java64
-rw-r--r--src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java116
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java145
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java57
-rw-r--r--src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java99
-rw-r--r--src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java284
-rw-r--r--src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java89
-rw-r--r--src/test/java/org/onap/clamp/clds/model/CldsDbServiceCacheTest.java77
-rw-r--r--src/test/java/org/onap/clamp/clds/model/CldsModelTest.java167
-rw-r--r--src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java74
-rw-r--r--src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java61
-rw-r--r--src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java56
-rw-r--r--src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java142
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java4
-rw-r--r--src/test/java/org/onap/clamp/clds/transform/XslTransformerTest.java59
29 files changed, 2 insertions, 3044 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
deleted file mode 100644
index 3b5a9ee0..00000000
--- a/src/test/java/org/onap/clamp/clds/client/CldsEventDelegateTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * ============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/DcaeDispatcherServicesTest.java b/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java
deleted file mode 100644
index e6c634cb..00000000
--- a/src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 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.clds.client;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.gson.JsonObject;
-import java.io.IOException;
-import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Matchers;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.util.HttpConnectionManager;
-
-
-
-@RunWith(MockitoJUnitRunner.class)
-public class DcaeDispatcherServicesTest {
-
- private static final String DEPLOYMENT_STATUS_URL = "http://portal.api.simpledemo.onap.org:30297/dcae-deployments/"
- + "closedLoop_c9c8b281-6fbd-4702-ba13-affa90411152_deploymentId/"
- + "operation/a97b46f6-d77c-42a1-9449-d5ae71e8f688";
- private static final String DCAE_URL = "dcae_url";
- private static final String DEPLOY_RESPONSE_STRING = "{\"links\":"
- + "{\"status\":\"http://deployment-handler.onap:8443/dcae-deployments/"
- + "closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId/"
- + "operation/366eb098-7977-4966-ae82-abd2087edb10\"}}";
-
- @Mock
- private ClampProperties clampProperties;
-
- @Mock
- HttpConnectionManager httpConnectionManager;
-
- @InjectMocks
- DcaeDispatcherServices dcaeDispatcherServices;
-
- private static final String STATUS_RESPONSE_PROCESSING = "{\"operationType\": \"deploy\","
- + "\"status\": \"processing\"}";
- private static final String STATUS_RESPONSE_ACTIVE = "{\"operationType\": \"deploy\",\"status\": \"succeeded\"}";
-
- /**
- * Setup method.
- */
- @Before
- public void setUp() {
- ImmutableMap.<String, String>builder()
- .put("dcae.dispatcher.retry.limit", "3")
- .put("dcae.dispatcher.retry.interval", "0")
- .put("dcae.dispatcher.url", DCAE_URL)
- .build()
- .forEach((property, value) -> {
- Mockito.when(clampProperties.getStringValue(Matchers.matches(property), Matchers.any()))
- .thenReturn(value);
- Mockito.when(clampProperties.getStringValue(Matchers.matches(property))).thenReturn(value);
- });
- }
-
- @Test
- public void shouldReturnDcaeOperationSataus() throws IOException {
- //given
- Mockito.when(httpConnectionManager.doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null))
- .thenReturn(STATUS_RESPONSE_PROCESSING);
- //when
- String operationStatus = dcaeDispatcherServices.getOperationStatus(DEPLOYMENT_STATUS_URL);
-
- //then
- Assertions.assertThat(operationStatus).isEqualTo("processing");
- }
-
- @Test
- public void shouldTryMultipleTimesWhenProcessing() throws IOException, InterruptedException {
- //given
- Mockito.when(httpConnectionManager.doHttpRequest(DEPLOYMENT_STATUS_URL, "GET",
- null, null, "DCAE", null, null))
- .thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_ACTIVE);
- //when
- String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(DEPLOYMENT_STATUS_URL);
-
- //then
- Assertions.assertThat(operationStatus).isEqualTo("succeeded");
- Mockito.verify(httpConnectionManager, Mockito.times(3))
- .doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null);
-
- }
-
- @Test
- public void shouldTryOnlyAsManyTimesAsConfigured() throws IOException, InterruptedException {
- //given
- Mockito.when(httpConnectionManager
- .doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null))
- .thenReturn(STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING,
- STATUS_RESPONSE_PROCESSING, STATUS_RESPONSE_PROCESSING);
- //when
- String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(DEPLOYMENT_STATUS_URL);
-
- //then
- Assertions.assertThat(operationStatus).isEqualTo("processing");
- Mockito.verify(httpConnectionManager, Mockito.times(3))
- .doHttpRequest(DEPLOYMENT_STATUS_URL, "GET", null, null, "DCAE", null, null);
-
- }
-
- @Test
- public void shouldTriggerDeploymentCreation() throws IOException {
- //given
- String deploymentId = "closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId";
- String serviceTypeId = "e2ba40f7-bf42-41e7-acd7-48fd07586d90";
- Mockito.when(clampProperties.getJsonTemplate("dcae.deployment.template"))
- .thenReturn(new JsonObject());
-
- Mockito.when(httpConnectionManager
- .doHttpRequest(DCAE_URL
- + "/dcae-deployments/closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId",
- "PUT",
- "{\"serviceTypeId\":\"e2ba40f7-bf42-41e7-acd7-48fd07586d90\",\"inputs\":{}}",
- "application/json", "DCAE", null, null))
- .thenReturn(DEPLOY_RESPONSE_STRING);
- JsonObject blueprintInputJson = new JsonObject();
-
- //when
- String operationStatus = dcaeDispatcherServices
- .createNewDeployment(deploymentId, serviceTypeId, blueprintInputJson);
-
- //then
- Assertions.assertThat(operationStatus).isEqualTo("http://deployment-handler.onap:8443/"
- + "dcae-deployments/closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId/"
- + "operation/366eb098-7977-4966-ae82-abd2087edb10");
-
- }
-} \ 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
deleted file mode 100644
index 4b21d6f8..00000000
--- a/src/test/java/org/onap/clamp/clds/client/GuardPolicyDelegateTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 2ff8166b..00000000
--- a/src/test/java/org/onap/clamp/clds/client/GuardPolicyDeleteDelegateTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 1d3f1ce6..00000000
--- a/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDelegateTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index ccebbfbe..00000000
--- a/src/test/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegateTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 06b94225..00000000
--- a/src/test/java/org/onap/clamp/clds/client/ModelDeleteDelegateTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 75be799b..00000000
--- a/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDelegateTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 9d87e7e9..00000000
--- a/src/test/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegateTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index a8851992..00000000
--- a/src/test/java/org/onap/clamp/clds/client/TcaPolicyDelegateTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-
- * ============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/client/TcaPolicyDeleteDelegateTest.java b/src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java
deleted file mode 100644
index 70edabe6..00000000
--- a/src/test/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegateTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Samsung. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client;
-
-import org.apache.camel.Exchange;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.exception.ModelBpmnException;
-
-@RunWith(MockitoJUnitRunner.class)
-public class TcaPolicyDeleteDelegateTest {
-
- private static final String TCA_ID_FROM_JSON = "{\"tca\":[{\"id\":\"\",\"from\":\"\"}]}";
- private static final String HOLMES_ID_FROM_JSON = "{\"holmes\":[{\"id\":\"\",\"from\":\"\"}]}";
- private static final String ID_JSON = "{\"id\":\"\"}";
- private static final String NOT_JSON = "not json";
- private static final String MODEL_BPMN_KEY = "modelBpmnProp";
- private static final String MODEL_PROP_KEY = "modelProp";
- private static final String TEST_KEY = "isTest";
- private static final String PROPERTY_NAME = "tcaPolicyDeleteResponseMessage";
- private static final String MESSAGE = "message";
-
- @Mock
- private Exchange camelExchange;
-
- @Mock
- private PolicyClient policyClient;
-
- @InjectMocks
- private TcaPolicyDeleteDelegate tcaPolicyDeleteDelegate;
-
- @Test
- public void shouldExecuteSuccessfully() {
- //given
- Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(TCA_ID_FROM_JSON);
- Mockito.when(camelExchange.getProperty(MODEL_PROP_KEY)).thenReturn(ID_JSON);
- Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false);
-
- Mockito.when(policyClient.deleteMicrosService(Mockito.any())).thenReturn(MESSAGE);
-
- //when
- tcaPolicyDeleteDelegate.execute(camelExchange);
-
- //then
- Mockito.verify(camelExchange).setProperty(PROPERTY_NAME, MESSAGE.getBytes());
- }
-
- @Test
- public void shouldExecuteTcaNotFound() {
- //given
- Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(HOLMES_ID_FROM_JSON);
- Mockito.when(camelExchange.getProperty(MODEL_PROP_KEY)).thenReturn(ID_JSON);
- Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false);
-
- //when
- tcaPolicyDeleteDelegate.execute(camelExchange);
-
- //then
- Mockito.verify(policyClient, Mockito.never()).deleteMicrosService(Mockito.any());
- Mockito.verify(camelExchange, Mockito.never()).setProperty(Mockito.any(), Mockito.any());
- }
-
- @Test(expected = ModelBpmnException.class)
- public void shouldThrowModelBpmnException() {
- //given
- Mockito.when(camelExchange.getProperty(MODEL_BPMN_KEY)).thenReturn(NOT_JSON);
- Mockito.when(camelExchange.getProperty(TEST_KEY)).thenReturn(false);
-
- //when
- tcaPolicyDeleteDelegate.execute(camelExchange);
- }
-
- @Test(expected = NullPointerException.class)
- public void shouldThrowNullPointerException() {
- //when
- tcaPolicyDeleteDelegate.execute(camelExchange);
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructorTest.java b/src/test/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructorTest.java
deleted file mode 100644
index 31785801..00000000
--- a/src/test/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructorTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 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.clds.client.req.policy;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-
-public class GuardPolicyAttributesConstructorTest {
-
- private static final String CONTROL_NAME = "ClosedLoop-d4629aee-970f-11e8-86c9-02552dda865e";
- private ModelProperties modelProperties;
- private List<PolicyChain> policyChains;
-
- /**
- * @throws Exception thrown if resources not found.
- */
- @Before
- public void setUp() throws Exception {
- String modelProp = ResourceFileUtil
- .getResourceAsString("example/model-properties/tca_new/model-properties.json");
- String modelBpmnJson = ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/model-bpmn.json");
- modelProperties = new ModelProperties("CLAMPDemoVFW_v1_0_3af8daec-6f10-4027-a3540", CONTROL_NAME, "PUT", false,
- modelBpmnJson, modelProp);
-
- policyChains = modelProperties.getType(Policy.class).getPolicyChains();
- }
-
- @Test
- public void testRequestAttributes() throws IOException, BuilderException {
- List<PolicyItem> policyItemsList = GuardPolicyAttributesConstructor
- .getAllPolicyGuardsFromPolicyChain(policyChains.get(0));
-
- Assertions.assertThat(policyItemsList.size()).isEqualTo(1);
-
- // Test first entry
- Map<AttributeType, Map<String, String>> requestAttributes = GuardPolicyAttributesConstructor
- .formatAttributes(modelProperties, policyItemsList.get(0));
-
- Assertions.assertThat(requestAttributes).containsKeys(AttributeType.MATCHING);
- Map<String, String> ruleParameters = requestAttributes.get(AttributeType.MATCHING);
- Assertions.assertThat(ruleParameters).contains(Assertions.entry(GuardPolicyAttributesConstructor.ACTOR, "APPC"),
- Assertions.entry(GuardPolicyAttributesConstructor.RECIPE, "restart"),
- Assertions.entry(GuardPolicyAttributesConstructor.TARGETS, ".*"),
- Assertions.entry(GuardPolicyAttributesConstructor.CLNAME,
- modelProperties.getControlNameAndPolicyUniqueId()),
- Assertions.entry(GuardPolicyAttributesConstructor.LIMIT, "1"),
- Assertions.entry(GuardPolicyAttributesConstructor.TIME_WINDOW, "10"),
- Assertions.entry(GuardPolicyAttributesConstructor.TIME_UNITS, "minute"),
- Assertions.entry(GuardPolicyAttributesConstructor.GUARD_ACTIVE_START, "00:00:01-05:00"),
- Assertions.entry(GuardPolicyAttributesConstructor.GUARD_ACTIVE_END, "00:00:00-05:00"));
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructorTest.java b/src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructorTest.java
deleted file mode 100644
index 4d78cf81..00000000
--- a/src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructorTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 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.clds.client.req.policy;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.gson.JsonElement;
-import java.io.IOException;
-import java.net.URLDecoder;
-import java.util.Map;
-import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.util.JsonUtils;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.controlloop.policy.ControlLoopPolicy;
-import org.onap.policy.controlloop.policy.Policy;
-import org.onap.policy.controlloop.policy.Target;
-import org.onap.policy.controlloop.policy.TargetType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-import org.yaml.snakeyaml.Yaml;
-
-public class OperationalPolicyAttributesConstructorTest {
-
- private static final String CONTROL_NAME = "ClosedLoop-d4629aee-970f-11e8-86c9-02552dda865e";
- private ModelProperties modelProperties;
- private PolicyChain policyChain;
-
- /**
- * @throws Exception thrown if resource not found.
- */
- @Before
- public void setUp() throws Exception {
- String modelProp = ResourceFileUtil
- .getResourceAsString("example/model-properties/policy/modelBpmnProperties.json");
- modelProperties = new ModelProperties("CLAMPDemoVFW_v1_0_3af8daec-6f10-4027-a3540", CONTROL_NAME, "PUT", false,
- "{}", modelProp);
- policyChain = readPolicyChainFromResources();
- }
-
- @Test
- public void shouldFormatRequestAttributes() throws IOException, BuilderException {
- // given
- ClampProperties mockClampProperties = createMockClampProperties(ImmutableMap.<String, String>builder()
- .put("op.templateName", "ClosedLoopControlName").put("op.notificationTopic", "POLICY-CL-MGT")
- .put("op.controller", "amsterdam").put("op.recipeTopic", "APPC").build());
-
- // when
- Map<AttributeType, Map<String, String>> requestAttributes = OperationalPolicyAttributesConstructor
- .formatAttributes(mockClampProperties, modelProperties, "789875c1-e788-432f-9a76-eac8ed889734",
- policyChain);
- // then
- Assertions.assertThat(requestAttributes).containsKeys(AttributeType.MATCHING, AttributeType.RULE);
- Assertions.assertThat(requestAttributes.get(AttributeType.MATCHING))
- .contains(Assertions.entry(OperationalPolicyAttributesConstructor.CONTROLLER, "amsterdam"));
-
- Map<String, String> ruleParameters = requestAttributes.get(AttributeType.RULE);
- Assertions.assertThat(ruleParameters).containsExactly(
- Assertions.entry(OperationalPolicyAttributesConstructor.MAX_RETRIES, "3"),
- Assertions.entry(OperationalPolicyAttributesConstructor.TEMPLATE_NAME, "ClosedLoopControlName"),
- Assertions.entry(OperationalPolicyAttributesConstructor.NOTIFICATION_TOPIC, "POLICY-CL-MGT"),
- Assertions.entry(OperationalPolicyAttributesConstructor.RECIPE_TOPIC, "APPC"),
- Assertions.entry(OperationalPolicyAttributesConstructor.RECIPE, "healthCheck"),
- Assertions.entry(OperationalPolicyAttributesConstructor.RESOURCE_ID,
- "cdb69724-57d5-4a22-b96c-4c345150fd0e"),
- Assertions.entry(OperationalPolicyAttributesConstructor.RETRY_TIME_LIMIT, "180"),
- Assertions.entry(OperationalPolicyAttributesConstructor.CLOSED_LOOP_CONTROL_NAME, CONTROL_NAME + "_1"));
- }
-
- @Test
- public void shouldFormatRequestAttributesWithProperControlLoopYaml() throws IOException, BuilderException {
- // given
- ClampProperties mockClampProperties = createMockClampProperties(
- ImmutableMap.<String, String>builder().put("op.templateName", "ClosedLoopControlName")
- .put("op.operationTopic", "APPP-CL").put("op.notificationTopic", "POLICY-CL-MGT")
- .put("op.controller", "amsterdam").put("op.recipeTopic", "APPC").build());
-
- Policy expectedPolicy = new Policy("6f76ad0b-ea9d-4a92-8d7d-6a6367ce2c77", "healthCheck Policy",
- "healthCheck Policy - the trigger (no parent) policy - created by CLDS", "APPC", null,
- new Target(TargetType.VM, "cdb69724-57d5-4a22-b96c-4c345150fd0e"), "healthCheck", 3, 180);
-
- // when
- Map<AttributeType, Map<String, String>> requestAttributes = OperationalPolicyAttributesConstructor
- .formatAttributes(mockClampProperties, modelProperties, "789875c1-e788-432f-9a76-eac8ed889734",
- policyChain);
-
- // then
- Assertions.assertThat(requestAttributes).containsKeys(AttributeType.MATCHING, AttributeType.RULE);
- Assertions.assertThat(requestAttributes.get(AttributeType.MATCHING))
- .contains(Assertions.entry("controller", "amsterdam"));
-
- Map<String, String> ruleParameters = requestAttributes.get(AttributeType.RULE);
- Assertions.assertThat(ruleParameters).contains(
- Assertions.entry(OperationalPolicyAttributesConstructor.OPERATION_TOPIC, "APPP-CL"),
- Assertions.entry(OperationalPolicyAttributesConstructor.TEMPLATE_NAME, "ClosedLoopControlName"),
- Assertions.entry(OperationalPolicyAttributesConstructor.NOTIFICATION_TOPIC, "POLICY-CL-MGT"),
- Assertions.entry(OperationalPolicyAttributesConstructor.CLOSED_LOOP_CONTROL_NAME, CONTROL_NAME + "_1"));
-
- String controlLoopYaml = URLDecoder
- .decode(ruleParameters.get(OperationalPolicyAttributesConstructor.CONTROL_LOOP_YAML), "UTF-8");
- ControlLoopPolicy controlLoopPolicy = new Yaml().load(controlLoopYaml);
-
- Assertions.assertThat(controlLoopPolicy.getControlLoop().getControlLoopName()).isEqualTo(CONTROL_NAME);
- Assertions.assertThat(controlLoopPolicy.getPolicies()).usingElementComparatorIgnoringFields("id")
- .containsExactly(expectedPolicy);
- }
-
- private ClampProperties createMockClampProperties(ImmutableMap<String, String> propertiesMap) {
- ClampProperties props = Mockito.mock(ClampProperties.class);
- propertiesMap.forEach((property, value) -> Mockito
- .when(props.getStringValue(Matchers.matches(property), Matchers.any())).thenReturn(value));
- return props;
- }
-
- private PolicyChain readPolicyChainFromResources() throws IOException {
- String policyChainText = ResourceFileUtil
- .getResourceAsString("example/operational-policy/json-policy-chain.json");
- JsonElement policyChainNode = JsonUtils.GSON.fromJson(policyChainText, JsonElement.class);
- return new PolicyChain(policyChainNode);
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatterTest.java b/src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatterTest.java
deleted file mode 100644
index 662beb2b..00000000
--- a/src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyYamlFormatterTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.client.req.policy;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
-import org.onap.policy.controlloop.policy.PolicyResult;
-import org.onap.policy.sdc.Resource;
-import org.onap.policy.sdc.ResourceType;
-
-public class OperationalPolicyYamlFormatterTest {
-
- @Test
- public void shouldConvertGivenStringsToResourceObjects() throws SecurityException, IllegalArgumentException {
-
- // given
- List<String> stringList = Arrays.asList("test1", "test2", "test3", "test4");
-
- // when
- Resource[] resources = OperationalPolicyYamlFormatter.convertToResources(stringList, ResourceType.VF);
-
- // then
- Assertions.assertThat(resources).extracting(Resource::getResourceName).containsExactly("test1", "test2",
- "test3", "test4");
- }
-
- @Test
- public void shouldConvertGivenStringsToPolicyResults() throws SecurityException, IllegalArgumentException {
- // given
- List<String> stringList = Arrays.asList("FAILURE", "SUCCESS", "FAILURE_GUARD", "FAILURE_TIMEOUT");
-
- // when
- PolicyResult[] policyResults = OperationalPolicyYamlFormatter.convertToPolicyResults(stringList);
-
- // then
- Assertions.assertThat(policyResults).containsExactly(PolicyResult.FAILURE, PolicyResult.SUCCESS,
- PolicyResult.FAILURE_GUARD, PolicyResult.FAILURE_TIMEOUT);
- }
-} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java b/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java
deleted file mode 100644
index 429611ce..00000000
--- a/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2019 Nokia 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
- *
- * 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.req.tca;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import com.google.gson.JsonObject;
-import java.io.IOException;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.exception.TcaRequestFormatterException;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.onap.clamp.clds.model.properties.TcaItem;
-import org.onap.clamp.clds.util.JsonUtils;
-
-public class TcaRequestFormatterTest {
-
- private static final String TCA_POLICY_PROPERTIES_TEMPLATE = "{"
- + " \"domain\": \"measurementsForVfScaling\","
- + " \"metricsPerEventName\": ["
- + " {"
- + " \"eventName\": \"???\","
- + " \"controlLoopSchemaType\": \"VNF\","
- + " \"policyScope\": \"DCAE\","
- + " \"policyName\": \"???\","
- + " \"policyVersion\": \"v0.0.1\","
- + " \"thresholds\": ["
- + " ]"
- + " }"
- + " ]"
- + "}";
-
- @Test
- public void shouldReturnFormattedTcaPolicyRequest() throws IOException {
- //given
- String service = "TestService";
- String policy = "TestService_scope.PolicyName";
- ClampProperties clampProperties = mock(ClampProperties.class);
- String expectedRequestText =
- "{ "
- + " \"domain\": \"measurementsForVfScaling\", "
- + " \"metricsPerEventName\": [ "
- + " { "
- + " \"eventName\": \"vLoadBalancer\", "
- + " \"controlLoopSchemaType\": \"VNF\", "
- + " \"policyScope\": \"DCAE\", "
- + " \"policyName\": \"TestService_scope.PolicyName\", "
- + " \"policyVersion\": \"v0.0.1\", "
- + " \"thresholds\": [] "
- + " } "
- + " ] "
- + "}";
-
- JsonObject tcaPolicyPropertiesTemplate = JsonUtils.GSON
- .fromJson(TCA_POLICY_PROPERTIES_TEMPLATE, JsonObject.class);
-
- JsonObject expectedRequest = JsonUtils.GSON.fromJson(expectedRequestText, JsonObject.class);
-
- ModelProperties modelProperties = mock(ModelProperties.class);
- Tca tca = mock(Tca.class);
- TcaItem tcaItem = mock(TcaItem.class);
- when(clampProperties.getJsonTemplate(any(), any())).thenReturn(tcaPolicyPropertiesTemplate);
- when(tca.getTcaItem()).thenReturn(tcaItem);
- when(tcaItem.getEventName()).thenReturn("vLoadBalancer");
- when(tcaItem.getControlLoopSchemaType()).thenReturn("VNF");
-
- //when
- JsonObject policyContent = TcaRequestFormatter
- .createPolicyContent(clampProperties, modelProperties, service, policy, tca);
-
- //then
- assertThat(expectedRequest).isEqualTo(policyContent);
- }
-
- @Test(expected = TcaRequestFormatterException.class)
- public void shouldThrowTcaRequestFormatterException() throws IOException {
- //given
- String service = "TestService";
- String policy = "TestService_scope.PolicyName";
- ClampProperties clampProperties = mock(ClampProperties.class);
- ModelProperties modelProperties = mock(ModelProperties.class);
- Tca tca = mock(Tca.class);
- //when
- Mockito.when(clampProperties.getJsonTemplate(any(), any())).thenThrow(IOException.class);
- //then
- TcaRequestFormatter.createPolicyContent(clampProperties, modelProperties, service, policy, tca);
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java
deleted file mode 100644
index 65ab4c5e..00000000
--- a/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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.clds.it;
-
-import static org.junit.Assert.assertEquals;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.io.IOException;
-
-import javax.ws.rs.NotFoundException;
-
-import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.CldsModel;
-import org.onap.clamp.clds.model.CldsTemplate;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test CldsDAO calls through CldsModel and CldsEvent. This really test the DB
- * and stored procedures.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class CldsDaoItCase {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDaoItCase.class);
- @Autowired
- public CldsDao cldsDao;
- private String bpmnText;
- private String imageText;
- private String bpmnPropText;
-
- /**
- * Setup the variable before the tests execution.
- *
- * @throws IOException In case of issues when opening the files
- */
- @Before
- public void setupBefore() throws IOException {
- bpmnText = ResourceFileUtil.getResourceAsString("example/dao/bpmn-template.xml");
- imageText = ResourceFileUtil.getResourceAsString("example/dao/image-template.xml");
- bpmnPropText = ResourceFileUtil.getResourceAsString("example/dao/bpmn-prop.json");
- }
-
- @Test
- public void testModelSave() {
- String randomNameTemplate = RandomStringUtils.randomAlphanumeric(5);
- // Add the template first
- CldsTemplate newTemplate = new CldsTemplate();
- newTemplate.setName(randomNameTemplate);
- newTemplate.setBpmnText(bpmnText);
- newTemplate.setImageText(imageText);
- // Save the template in DB
- cldsDao.setTemplate(newTemplate, "user");
- // Test if it's well there
- CldsTemplate newTemplateRead = cldsDao.getTemplate(randomNameTemplate);
- assertEquals(bpmnText, newTemplateRead.getBpmnText());
- assertEquals(imageText, newTemplateRead.getImageText());
- // Save the model
- CldsModel newModel = new CldsModel();
- String randomNameModel = RandomStringUtils.randomAlphanumeric(5);
- newModel.setName(randomNameModel);
- newModel.setBpmnText(bpmnText);
- newModel.setImageText(imageText);
- newModel.setPropText(bpmnPropText);
- newModel.setControlNamePrefix("ClosedLoop-");
- newModel.setTemplateName(randomNameTemplate);
- newModel.setTemplateId(newTemplate.getId());
- newModel.setDocText(newTemplate.getPropText());
- // Save the model in DB
- cldsDao.setModel(newModel, "user");
- // Test if the model can be retrieved
- CldsModel newCldsModel = cldsDao.getModelTemplate(randomNameModel);
- assertEquals(bpmnText, newCldsModel.getBpmnText());
- assertEquals(imageText, newCldsModel.getImageText());
- assertEquals(bpmnPropText, newCldsModel.getPropText());
- }
-
- @Test(expected = NotFoundException.class)
- public void testGetModelNotFound() {
- CldsModel.retrieve(cldsDao, "test-model-not-found", false);
- }
-
- @Test(expected = NotFoundException.class)
- public void testGetTemplateNotFound() {
- CldsTemplate.retrieve(cldsDao, "test-template-not-found", false);
- }
-
- @Test
- public void testInsEvent() {
- // Add the template first
- CldsTemplate newTemplate = new CldsTemplate();
- newTemplate.setName("test-template-for-event");
- newTemplate.setBpmnText(bpmnText);
- newTemplate.setImageText(imageText);
- newTemplate.save(cldsDao, "user");
- // Test if it's well there
- CldsTemplate newTemplateRead = CldsTemplate.retrieve(cldsDao, "test-template-for-event", false);
- assertEquals(bpmnText, newTemplateRead.getBpmnText());
- assertEquals(imageText, newTemplateRead.getImageText());
- // Save the model
- CldsModel newModel = new CldsModel();
- newModel.setName("test-model-for-event");
- newModel.setBpmnText(bpmnText);
- newModel.setImageText(imageText);
- newModel.setPropText(bpmnPropText);
- newModel.setControlNamePrefix("ClosedLoop-");
- newModel.setTemplateName("test-template-for-event");
- newModel.setTemplateId(newTemplate.getId());
- newModel.setDocText(newTemplate.getPropText());
- CldsEvent.insEvent(cldsDao, newModel, "user", CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_COMPLETED,
- "process-instance-id");
- }
-
-}
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 963f45be..8745cc5d 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
@@ -41,7 +41,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.onap.clamp.clds.dao.CldsDao;
import org.onap.clamp.clds.model.CldsInfo;
import org.onap.clamp.clds.service.CldsService;
import org.onap.clamp.clds.util.LoggingUtils;
@@ -72,8 +71,6 @@ public class CldsServiceItCase {
private String bpmnPropText;
private String docText;
- @Autowired
- private CldsDao cldsDao;
private Authentication authentication;
private List<GrantedAuthority> authList = new LinkedList<GrantedAuthority>();
private LoggingUtils util;
diff --git a/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java b/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java
deleted file mode 100644
index 439ec7fc..00000000
--- a/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============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============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.it;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.HolmesPolicyDelegate;
-import org.onap.clamp.clds.model.properties.Holmes;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test Onap HolmesPolicyDelegate features.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class HolmesPolicyDelegateItCase {
-
- @Test
- public void testCreatePolicyJson() throws IOException {
- String modelBpmnProp = ResourceFileUtil
- .getResourceAsString("example/model-properties/holmes/modelBpmnProperties.json");
- String modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/holmes/modelBpmn.json");
- ModelProperties prop = new ModelProperties("example-model-name",
- "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf", null, true, modelBpmn, modelBpmnProp);
- Holmes holmes = prop.getType(Holmes.class);
- String result = HolmesPolicyDelegate.formatHolmesConfigBody(prop, holmes);
- assertTrue("ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf$$$blabla".equals(result));
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java b/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java
deleted file mode 100644
index 344641a7..00000000
--- a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * ============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============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.req.policy.OperationalPolicyAttributesConstructor;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyChain;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-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
-public class OperationPolicyReqItCase {
-
- @Autowired
- private ClampProperties refProp;
-
- @Test
- public void formatAttributesTest() throws IOException, BuilderException {
- String modelBpmnProp = ResourceFileUtil
- .getResourceAsString("example/model-properties/policy/modelBpmnProperties.json");
- String modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/policy/modelBpmn.json");
- ModelProperties modelProperties = new ModelProperties("testModel", "controlNameTest", CldsEvent.ACTION_SUBMIT,
- true, modelBpmn, modelBpmnProp);
- List<Map<AttributeType, Map<String, String>>> attributes = new ArrayList<>();
- if (modelProperties.getType(Policy.class).isFound()) {
- for (PolicyChain policyChain : modelProperties.getType(Policy.class).getPolicyChains()) {
- attributes.add(OperationalPolicyAttributesConstructor.formatAttributes(refProp, modelProperties,
- modelProperties.getType(Policy.class).getId(), policyChain));
- }
- }
- assertFalse(attributes.isEmpty());
- assertTrue(attributes.size() == 2);
- // now validate the Yaml, to do so we replace the dynamic ID by a known
- // key so that we can compare it
- String yaml = URLDecoder.decode(attributes.get(0).get(AttributeType.RULE).get("controlLoopYaml"), "UTF-8");
- yaml = replaceGeneratedValues(yaml);
- assertEquals(ResourceFileUtil.getResourceAsString("example/operational-policy/yaml-policy-chain-1.yaml"), yaml);
- yaml = URLDecoder.decode(attributes.get(1).get(AttributeType.RULE).get("controlLoopYaml"), "UTF-8");
- yaml = replaceGeneratedValues(yaml);
- assertEquals(ResourceFileUtil.getResourceAsString("example/operational-policy/yaml-policy-chain-2.yaml"), yaml);
- }
-
- private String replaceGeneratedValues(String yaml) {
- yaml = yaml.replaceAll("Policy - created" + System.lineSeparator() + " by CLDS", "Policy - created by CLDS");
- yaml = yaml.replaceAll("trigger_policy: (.*)", "trigger_policy: <generatedId>");
- yaml = yaml.replaceAll("id: (.*)", "id: <generatedId>");
- yaml = yaml.replaceAll("success: (.*)", "success: <generatedId>");
- // Remove this field as not always present (depends of policy api)
- yaml = yaml.replaceAll(" pnf: null" + System.lineSeparator(), "");
- yaml = yaml.replaceAll("failure: (.*)", "failure: <generatedId>");
- yaml = yaml.replaceAll("failure_exception: (.*)", "failure_exception: <generatedId>");
- yaml = yaml.replaceAll("failure_retries: (.*)", "failure_retries: <generatedId>");
- yaml = yaml.replaceAll("failure_timeout: (.*)", "failure_timeout: <generatedId>");
- yaml = yaml.substring(yaml.indexOf("controlLoop:"), yaml.length());
- return yaml;
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java
deleted file mode 100644
index 3acc439a..00000000
--- a/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*-
- * ============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============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.it;
-
-import com.google.gson.reflect.TypeToken;
-import java.io.IOException;
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.transform.TransformerException;
-
-import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.req.policy.GuardPolicyAttributesConstructor;
-import org.onap.clamp.clds.client.req.policy.OperationalPolicyAttributesConstructor;
-import org.onap.clamp.clds.client.req.policy.PolicyClient;
-import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.CldsToscaModel;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.onap.clamp.clds.transform.XslTransformer;
-import org.onap.clamp.clds.util.JsonUtils;
-import org.onap.clamp.clds.util.LoggingUtils;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.onap.policy.api.AttributeType;
-import org.onap.policy.api.PolicyConfigType;
-import org.onap.policy.api.PolicyType;
-import org.onap.policy.controlloop.policy.builder.BuilderException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test Policy API, this uses the emulator written in python that is started
- * during the tests, It returns the payload sent in the policy queries so that
- * it can be validated here.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class PolicyClientItCase {
-
- private static final Type MAP_OF_STRING_TO_OBJECT_TYPE = new TypeToken<Map<String, Object>>() {}.getType();
-
- @Autowired
- private CldsDao cldsDao;
- @Autowired
- private ClampProperties refProp;
- @Autowired
- private PolicyClient policyClient;
- @Autowired
- XslTransformer cldsBpmnTransformer;
-
- String modelProp;
- String modelName;
- String controlName;
- String modelBpmnPropJson;
- ModelProperties prop;
-
- /**
- * Setup method.
- * @throws IOException thrown if resources not found
- * @throws TransformerException thrown if invalid xml given to transformation
- */
- @Before
- public void setUp() throws IOException, TransformerException {
- modelProp = ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/model-properties.json");
- modelName = "example-model06";
- controlName = "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf";
- modelBpmnPropJson = cldsBpmnTransformer.doXslTransformToString(
- ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/tca-template.xml"));
- prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, false, modelBpmnPropJson,
- modelProp);
- }
-
- @Test
- public void testSendGuardPolicy() {
- // Normally there is only one Guard
- List<PolicyItem> policyItems = GuardPolicyAttributesConstructor
- .getAllPolicyGuardsFromPolicyChain(prop.getType(Policy.class).getPolicyChains().get(0));
- PolicyItem policyItem = policyItems.get(0);
- prop.setCurrentModelElementId(prop.getType(Policy.class).getId());
- prop.setPolicyUniqueId(prop.getType(Policy.class).getPolicyChains().get(0).getPolicyId());
- prop.setGuardUniqueId(policyItem.getId());
- String response = policyClient.sendGuardPolicy(
- GuardPolicyAttributesConstructor.formatAttributes(prop, policyItem), prop, LoggingUtils.getRequestId(),
- policyItem);
- Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
- Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Decision"),
- Assertions.entry("policyName",
- modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0_Guard_6TtHGPq"),
- Assertions.entry("policyDescription", "from clds"), Assertions.entry("onapName", "PDPD"),
- Assertions.entry("requestID", LoggingUtils.getRequestId()), Assertions.entry("ruleProvider", "GUARD_YAML"));
-
- // Check Guard attributes
- Assertions.assertThat((Map<String, Object>) mapNodes.get("attributes"))
- .containsKey(AttributeType.MATCHING.name());
- Assertions.assertThat(
- (Map<String, Object>) ((Map<String, Object>) mapNodes.get("attributes")).get(AttributeType.MATCHING.name()))
- .contains(Assertions.entry(GuardPolicyAttributesConstructor.ACTOR, "APPC"),
- Assertions.entry(GuardPolicyAttributesConstructor.CLNAME, controlName + "_0"),
- Assertions.entry(GuardPolicyAttributesConstructor.TIME_WINDOW, "10"));
- }
-
- @Test
- public void testSendBrmsPolicy() throws BuilderException, IllegalArgumentException, IOException {
- Map<AttributeType, Map<String, String>> attributes = OperationalPolicyAttributesConstructor.formatAttributes(
- refProp, prop, prop.getType(Policy.class).getId(), prop.getType(Policy.class).getPolicyChains().get(0));
- String response = policyClient.sendBrmsPolicy(attributes, prop, LoggingUtils.getRequestId());
-
- Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
-
- Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
- Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0"),
- Assertions.entry("policyConfigType", PolicyConfigType.BRMS_PARAM.name()),
- Assertions.entry("requestID", LoggingUtils.getRequestId()));
-
- // Check BRMS attributes present
- Assertions.assertThat((Map<String, Object>) mapNodes.get("attributes"))
- .containsKeys(AttributeType.MATCHING.name(), AttributeType.RULE.name());
-
- }
-
- @Test
- public void testSendMicroServiceInJson() throws IllegalArgumentException {
- prop.setCurrentModelElementId(prop.getType(Policy.class).getId());
- String jsonToSend = "{\"test\":\"test\"}";
- String response = policyClient.sendMicroServiceInJson(jsonToSend, prop, LoggingUtils.getRequestId());
-
- Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
-
- Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
- Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h"),
- Assertions.entry("policyConfigType", PolicyConfigType.MicroService.name()),
- Assertions.entry("requestID", LoggingUtils.getRequestId()),
- Assertions.entry("configBodyType", PolicyType.JSON.name()), Assertions.entry("onapName", "DCAE"),
- Assertions.entry("configBody", jsonToSend));
-
- }
-
- @Test
- public void testSendBasePolicyInOther() throws IllegalArgumentException, IOException {
- String body = "test";
- String response = policyClient.sendBasePolicyInOther(body, "myPolicy", prop, LoggingUtils.getRequestId());
- Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
-
- Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
- Assertions.entry("policyName", "myPolicy"),
- Assertions.entry("policyConfigType", PolicyConfigType.Base.name()),
- Assertions.entry("requestID", LoggingUtils.getRequestId()),
- Assertions.entry("configBodyType", PolicyType.OTHER.name()), Assertions.entry("onapName", "DCAE"),
- Assertions.entry("configBody", body));
- }
-
- @Test
- public void testSendMicroServiceInOther() throws IllegalArgumentException, IOException {
- Tca tca = prop.getType(Tca.class);
- String tcaJson = TcaRequestFormatter.createPolicyJson(refProp, prop);
- String response = policyClient.sendMicroServiceInOther(tcaJson, prop);
-
- Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
-
- Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
- Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_TCA_1d13unw"),
- Assertions.entry("policyConfigType", PolicyConfigType.MicroService.name()),
- Assertions.entry("configBody", tcaJson), Assertions.entry("onapName", "DCAE"));
- }
-
- @Test
- public void testDeleteMicrosService() throws IllegalArgumentException, IOException {
- Tca tca = prop.getType(Tca.class);
- prop.setCurrentModelElementId(tca.getId());
- String[] responses = policyClient.deleteMicrosService(prop).split("\\}\\{");
-
- // There are 2 responses appended to the result, one for PDP one for PAP !
- Map<String, Object> mapNodesPdp = JsonUtils.GSON.fromJson(responses[0] + "}",
- MAP_OF_STRING_TO_OBJECT_TYPE);
- Map<String, Object> mapNodesPap = JsonUtils.GSON.fromJson("{" + responses[1],
- MAP_OF_STRING_TO_OBJECT_TYPE);
-
- Assertions.assertThat(mapNodesPdp).contains(
- Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_TCA_1d13unw"),
- Assertions.entry("policyType", PolicyConfigType.MicroService.name()),
- Assertions.entry("policyComponent", "PDP"), Assertions.entry("deleteCondition", "ALL"));
-
- Assertions.assertThat(mapNodesPap).contains(
- Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_TCA_1d13unw"),
- Assertions.entry("policyType", PolicyConfigType.MicroService.name()),
- Assertions.entry("policyComponent", "PAP"), Assertions.entry("deleteCondition", "ALL"));
- }
-
- @Test
- public void testDeleteGuard() throws IllegalArgumentException, IOException {
- List<PolicyItem> policyItems = GuardPolicyAttributesConstructor
- .getAllPolicyGuardsFromPolicyChain(prop.getType(Policy.class).getPolicyChains().get(0));
- prop.setCurrentModelElementId(prop.getType(Policy.class).getId());
- prop.setPolicyUniqueId(prop.getType(Policy.class).getPolicyChains().get(0).getPolicyId());
- prop.setGuardUniqueId(policyItems.get(0).getId());
- String[] responses = policyClient.deleteGuard(prop).split("\\}\\{");
-
- Map<String, Object> mapNodesPdp = JsonUtils.GSON.fromJson(responses[0] + "}",
- MAP_OF_STRING_TO_OBJECT_TYPE);
- Map<String, Object> mapNodesPap = JsonUtils.GSON.fromJson("{" + responses[1],
- MAP_OF_STRING_TO_OBJECT_TYPE);
-
- Assertions.assertThat(mapNodesPdp).contains(
- Assertions.entry("policyName",
- modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0_Guard_6TtHGPq"),
- Assertions.entry("policyType", "Decision"), Assertions.entry("policyComponent", "PDP"),
- Assertions.entry("deleteCondition", "ALL"));
- Assertions.assertThat(mapNodesPap).contains(
- Assertions.entry("policyName",
- modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0_Guard_6TtHGPq"),
- Assertions.entry("policyType", "Decision"), Assertions.entry("policyComponent", "PAP"),
- Assertions.entry("deleteCondition", "ALL"));
- }
-
- @Test
- public void testDeleteBrms() throws IllegalArgumentException, IOException {
- prop.setPolicyUniqueId(prop.getType(Policy.class).getPolicyChains().get(0).getPolicyId());
- prop.setCurrentModelElementId(prop.getType(Policy.class).getId());
- String[] responses = policyClient.deleteBrms(prop).split("\\}\\{");
-
- Map<String, Object> mapNodesPdp = JsonUtils.GSON.fromJson(responses[0] + "}",
- MAP_OF_STRING_TO_OBJECT_TYPE);
- Map<String, Object> mapNodesPap = JsonUtils.GSON.fromJson("{" + responses[1],
- MAP_OF_STRING_TO_OBJECT_TYPE);
-
- Assertions.assertThat(mapNodesPdp).contains(
- Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0"),
- Assertions.entry("policyType", "BRMS_Param"), Assertions.entry("policyComponent", "PDP"),
- Assertions.entry("deleteCondition", "ALL"));
- Assertions.assertThat(mapNodesPap).contains(
- Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0"),
- Assertions.entry("policyType", "BRMS_Param"), Assertions.entry("policyComponent", "PAP"),
- Assertions.entry("deleteCondition", "ALL"));
- }
-
- @Test
- public void testImportToscaModel() throws IOException {
- String toscaModelYaml = ResourceFileUtil.getResourceAsString("tosca/tca-policy-test.yaml");
- CldsToscaModel cldsToscaModel = new CldsToscaModel();
- cldsToscaModel.setToscaModelName("tca-policy-test");
- cldsToscaModel.setToscaModelYaml(toscaModelYaml);
- cldsToscaModel.setUserId("admin");
- cldsToscaModel.setPolicyType("tca");
- cldsToscaModel = cldsToscaModel.save(cldsDao, refProp, policyClient, "test");
- String tosca = policyClient.importToscaModel(cldsToscaModel);
-
- Assertions.assertThat(tosca).contains(
- "{\"serviceName\":\"tca-policy-test\",\"description\":\"tca-policy-test\","
- + "\"requestID\":null,\"filePath\":\"/tmp/tosca-models/tca-policy-test.yml\",");
- Assertions.assertThat(tosca).contains(toscaModelYaml);
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java b/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java
deleted file mode 100644
index abc744e7..00000000
--- a/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * ============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============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-
-import org.json.JSONException;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.skyscreamer.jsonassert.JSONAssert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test Onap TcaRequestFormatter features.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class TcaRequestFormatterItCase {
-
- @Autowired
- private ClampProperties refProp;
- private String modelProp;
- private String modelBpmn;
- private String modelName;
- private String controlName;
- private String yamlInput;
- private ModelProperties modelProperties;
-
- /**
- * Initialize Test.
- */
- @Before
- public void setUp() throws IOException {
- modelProp = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmnProperties.json");
- modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmn.json");
- yamlInput = ResourceFileUtil.getResourceAsString("example/tca-policy-req/blueprint-input.yaml");
- modelName = "example-model01";
- controlName = "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf";
- modelProperties = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, false, modelBpmn,
- modelProp);
- }
-
- @Test
- public void testCreatePolicyJson() throws IOException, JSONException {
- String result = TcaRequestFormatter.createPolicyJson(refProp, modelProperties);
- assertNotNull(result);
- JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("example/tca-policy-req/tca-policy-expected.json"),
- result, true);
- }
-
- @Test
- public void testUpdatedBlueprintWithConfiguration() throws IOException {
- String result = TcaRequestFormatter.updatedBlueprintWithConfiguration(refProp, modelProperties, yamlInput);
- assertNotNull(result);
- assertEquals(ResourceFileUtil.getResourceAsString("example/tca-policy-req/blueprint-expected.yaml"), result);
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/model/CldsDbServiceCacheTest.java b/src/test/java/org/onap/clamp/clds/model/CldsDbServiceCacheTest.java
deleted file mode 100644
index 3fe29dc0..00000000
--- a/src/test/java/org/onap/clamp/clds/model/CldsDbServiceCacheTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 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============================================
- * Modifications copyright (c) 2018 Nokia
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Test;
-
-public class CldsDbServiceCacheTest {
-
- @Test
- public void testConstructor() throws IOException, ClassNotFoundException {
- // given
- CldsServiceData cldsServiceData = new CldsServiceData();
- cldsServiceData.setServiceUUID("testUUID");
- cldsServiceData.setAgeOfRecord(100L);
- cldsServiceData.setServiceInvariantUUID("testInvariantUUID");
-
- CldsVfData cldsVfData = new CldsVfData();
- cldsVfData.setVfName("vf");
-
- CldsVfKPIData cldsVfKpiData = new CldsVfKPIData();
- cldsVfKpiData.setFieldPath("fieldPath");
- cldsVfKpiData.setFieldPathValue("fieldValue");
-
- List<CldsVfKPIData> cldsKpiList = new ArrayList<>();
- cldsKpiList.add(cldsVfKpiData);
- cldsVfData.setCldsKPIList(cldsKpiList);
-
- List<CldsVfData> cldsVfs = new ArrayList<>();
- cldsVfs.add(cldsVfData);
- cldsServiceData.setCldsVfs(cldsVfs);
-
- CldsDbServiceCache cldsDbServiceCache = new CldsDbServiceCache(cldsServiceData);
-
- // when
- ObjectInputStream reader = new ObjectInputStream(cldsDbServiceCache.getCldsDataInstream());
- CldsServiceData cldsServiceDataResult = (CldsServiceData) reader.readObject();
-
- // then
- assertThat(cldsServiceDataResult).isNotNull();
- assertThat(cldsServiceDataResult.getCldsVfs()).hasSize(1);
- assertThat(cldsServiceDataResult.getCldsVfs().get(0).getCldsKPIList()).hasSize(1);
-
- assertThat(cldsServiceDataResult.getServiceInvariantUUID()).isEqualTo("testInvariantUUID");
- assertThat(cldsServiceDataResult.getServiceUUID()).isEqualTo("testUUID");
- assertThat(cldsServiceDataResult.getAgeOfRecord()).isEqualTo(100L);
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java b/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java
deleted file mode 100644
index 0a601854..00000000
--- a/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 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.clds.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import javax.ws.rs.BadRequestException;
-
-import org.junit.Test;
-
-/**
- * Test org.onap.clamp.ClampDesigner.model.Model
- */
-public class CldsModelTest {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsModelTest.class);
-
- @Test
- public void testCreateUsingControlName() {
- utilCreateUsingControlName("abc-", "7c42aceb-2350-11e6-8131-fa163ea8d2da");
- utilCreateUsingControlName("", "7c42aceb-2350-11e6-8131-fa163ea8d2da");
- }
-
- @Test(expected = BadRequestException.class)
- public void testExceptionCreateUsingControlName() {
- utilCreateUsingControlName("", "c42aceb-2350-11e6-8131-fa163ea8d2da");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testValidateActionEmptyEvent() {
- CldsModel cldsModel = new CldsModel();
- cldsModel.validateAction(CldsEvent.ACTION_CREATE);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testValidateActionNotExist() {
- CldsModel cldsModel = new CldsModel();
- cldsModel.validateAction("unknown");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testValidateActionFromCreate() {
- CldsModel cldsModel = new CldsModel();
- cldsModel.getEvent().setActionCd(CldsEvent.ACTION_CREATE);
- cldsModel.validateAction(CldsEvent.ACTION_SUBMIT);
- cldsModel.validateAction(CldsEvent.ACTION_TEST);
- cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
- fail("Exception should have been sent");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testValidateActionFromSubmitOrReSubmit() {
- CldsModel cldsModel = new CldsModel();
- cldsModel.getEvent().setActionCd(CldsEvent.ACTION_SUBMIT);
- cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT);
- try {
- cldsModel.validateAction(CldsEvent.ACTION_RESTART);
- fail("Exception should have been sent");
- } catch (IllegalArgumentException e) {
- logger.error("Exception caught IllegalArgumentException as expected", e);
- }
- cldsModel.getEvent().setActionCd(CldsEvent.ACTION_RESUBMIT);
- cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT);
- cldsModel.validateAction(CldsEvent.ACTION_RESTART);
- fail("Exception should have been sent");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testValidateActionFromDistribute() {
- CldsModel cldsModel = new CldsModel();
- cldsModel.getEvent().setActionCd(CldsEvent.ACTION_DISTRIBUTE);
- cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT);
- cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
- cldsModel.validateAction(CldsEvent.ACTION_CREATE);
- fail("Exception should have been sent");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testValidateActionFromUndeploy() {
- CldsModel cldsModel = new CldsModel();
- cldsModel.getEvent().setActionCd(CldsEvent.ACTION_UNDEPLOY);
- cldsModel.validateAction(CldsEvent.ACTION_UPDATE);
- cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
- cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT);
- cldsModel.validateAction(CldsEvent.ACTION_CREATE);
- fail("Exception should have been sent");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testValidateActionFromDeploy() {
- CldsModel cldsModel = new CldsModel();
- cldsModel.getEvent().setActionCd(CldsEvent.ACTION_DEPLOY);
- cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
- cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY);
- cldsModel.validateAction(CldsEvent.ACTION_UPDATE);
- cldsModel.validateAction(CldsEvent.ACTION_STOP);
- cldsModel.validateAction(CldsEvent.ACTION_CREATE);
- fail("Exception should have been sent");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testValidateActionFromRestartOrUpdate() {
- CldsModel cldsModel = new CldsModel();
- cldsModel.getEvent().setActionCd(CldsEvent.ACTION_RESTART);
- cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
- cldsModel.validateAction(CldsEvent.ACTION_UPDATE);
- cldsModel.validateAction(CldsEvent.ACTION_STOP);
- cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY);
- try {
- cldsModel.validateAction(CldsEvent.ACTION_CREATE);
- fail("Exception should have been sent");
- } catch (IllegalArgumentException e) {
- System.out.println("Exception caught IllegalArgumentException as expected");
- }
- cldsModel.getEvent().setActionCd(CldsEvent.ACTION_UPDATE);
- cldsModel.validateAction(CldsEvent.ACTION_DEPLOY);
- cldsModel.validateAction(CldsEvent.ACTION_UPDATE);
- cldsModel.validateAction(CldsEvent.ACTION_STOP);
- cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY);
- cldsModel.validateAction(CldsEvent.ACTION_CREATE);
- fail("Exception should have been sent");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testValidateActionFromStop() {
- CldsModel cldsModel = new CldsModel();
- cldsModel.getEvent().setActionCd(CldsEvent.ACTION_STOP);
- cldsModel.validateAction(CldsEvent.ACTION_UPDATE);
- cldsModel.validateAction(CldsEvent.ACTION_RESTART);
- cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY);
- cldsModel.validateAction(CldsEvent.ACTION_CREATE);
- fail("Exception should have been sent");
- }
-
- /**
- * Utility Method to create model from controlname and uuid.
- */
- public void utilCreateUsingControlName(String controlNamePrefix, String controlNameUuid) {
- CldsModel model = CldsModel.createUsingControlName(controlNamePrefix + controlNameUuid);
- assertEquals(controlNamePrefix, model.getControlNamePrefix());
- assertEquals(controlNameUuid, model.getControlNameUuid());
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java b/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java
deleted file mode 100644
index 315e656d..00000000
--- a/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============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/model/prop/CustomModelElement.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java
deleted file mode 100644
index 31d0be88..00000000
--- a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-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
- *
- * 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.prop;
-
-import com.google.gson.JsonObject;
-import org.onap.clamp.clds.model.properties.AbstractModelElement;
-import org.onap.clamp.clds.model.properties.ModelBpmn;
-import org.onap.clamp.clds.util.JsonUtils;
-
-/**
- * A CustomModelElement to test the capability to add new elements on the fly.
- */
-public class CustomModelElement extends AbstractModelElement {
-
- private String test;
- private static final String CUSTOM_TYPE = "customType";
-
- /**
- * Main Constructor.
- */
- public CustomModelElement(ModelBpmn modelBpmn, JsonObject modelJson) {
- super(CUSTOM_TYPE, modelBpmn, modelJson);
- topicPublishes = JsonUtils.getStringValueByName(modelElementJsonNode, "topicPublishes");
- test = JsonUtils.getStringValueByName(modelElementJsonNode, "test");
- }
-
- public static final String getType() {
- return CUSTOM_TYPE;
- }
-
- public String getTest() {
- return test;
- }
-
- public void setTest(String test) {
- this.test = test;
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java
deleted file mode 100644
index de3126aa..00000000
--- a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============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============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.prop;
-
-import java.io.IOException;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onap.clamp.clds.model.properties.ModelProperties;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-
-public class CustomModelElementTest {
-
- public CustomModelElementTest() {
- }
-
- @Test
- public void testCustomElement() throws IOException {
- String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/model-properties/custom/modelBpmn.json");
- String modelProp = ResourceFileUtil
- .getResourceAsString("example/model-properties/custom/modelBpmnProperties.json");
- String modName = "example-model-name";
- String controlName = "example-control-name";
- CustomModelElement customModelElement = null;
- // Instantiate first, we should not have our CustomModelElement yet
- ModelProperties prop = new ModelProperties(modName, controlName, null, true, modelBpmnProp, modelProp);
- Assert.assertNotNull(prop);
- customModelElement = prop.getType(CustomModelElement.class);
- Assert.assertNull(customModelElement);
- ModelProperties.registerModelElement(CustomModelElement.class, CustomModelElement.getType());
- customModelElement = prop.getType(CustomModelElement.class);
- Assert.assertNotNull(customModelElement);
- Assert.assertEquals("This is a test", customModelElement.getTest());
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java
deleted file mode 100644
index 4195f907..00000000
--- a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*-
- * ============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============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.model.prop;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.junit.Before;
-import org.junit.Test;
-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.model.properties.Policy;
-import org.onap.clamp.clds.model.properties.PolicyItem;
-import org.onap.clamp.clds.model.properties.Tca;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-
-/**
- * Test org.onap.clamp.ClampDesigner.model.prop package using ModelProperties.
- */
-public class ModelPropertiesTest {
-
- @Before
- public void registerNewClasses() {
- ModelProperties.registerModelElement(Holmes.class, Holmes.getType());
- }
-
- @Test
- public void testTcaModelDecoding() throws IOException {
- String modelBpmnProp = ResourceFileUtil
- .getResourceAsString("example/model-properties/tca/modelBpmnProperties.json");
- String modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmn.json");
- ModelProperties prop = new ModelProperties("example-model-name", "example-control-name", null, true, modelBpmn,
- modelBpmnProp);
- Policy policy = prop.getType(Policy.class);
- assertTrue(policy.isFound());
- assertEquals(1, policy.getPolicyChains().size());
- assertEquals("0", policy.getPolicyChains().get(0).getPolicyId());
- assertEquals(1, policy.getPolicyChains().get(0).getPolicyItems().size());
- PolicyItem firstPolicyItem = policy.getPolicyChains().get(0).getPolicyItems().get(0);
- assertEquals("resourceid", firstPolicyItem.getTargetResourceId());
- assertEquals(180, firstPolicyItem.getRetryTimeLimit());
- assertEquals(3, firstPolicyItem.getMaxRetries());
- assertEquals("", firstPolicyItem.getParentPolicy());
- assertThat(firstPolicyItem.getParentPolicyConditions()).isEmpty();
- Tca tca = prop.getType(Tca.class);
- assertNotNull(tca);
- assertTrue(tca.isFound());
- assertEquals("vFirewallBroadcastPackets", tca.getTcaItem().getEventName());
- assertEquals("VNF", tca.getTcaItem().getControlLoopSchemaType());
- assertEquals("policy1", tca.getTcaItem().getPolicyId());
- assertEquals("f734f031-10aa-t8fb-330f-04dde2886325", tca.getTcaItem().getTcaUuId());
- assertEquals(2, tca.getTcaItem().getTcaThresholds().size());
- assertEquals("ABATED", tca.getTcaItem().getTcaThresholds().get(0).getClosedLoopEventStatus());
- assertEquals("$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
- tca.getTcaItem().getTcaThresholds().get(0).getFieldPath());
- assertEquals("LESS_OR_EQUAL", tca.getTcaItem().getTcaThresholds().get(0).getOperator());
- assertEquals(Integer.valueOf(123), tca.getTcaItem().getTcaThresholds().get(0).getThreshold());
- assertEquals("ONSET", tca.getTcaItem().getTcaThresholds().get(1).getClosedLoopEventStatus());
- assertEquals("$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
- tca.getTcaItem().getTcaThresholds().get(1).getFieldPath());
- assertEquals("GREATER_OR_EQUAL", tca.getTcaItem().getTcaThresholds().get(1).getOperator());
- assertEquals(Integer.valueOf(123), tca.getTcaItem().getTcaThresholds().get(1).getThreshold());
- // Test global prop
- assertEquals("vnfRecipe", prop.getGlobal().getActionSet());
- assertEquals("4cc5b45a-1f63-4194-8100-cd8e14248c92", prop.getGlobal().getService());
- assertTrue(Arrays.equals(new String[] { "023a3f0d-1161-45ff-b4cf-8918a8ccf3ad" },
- prop.getGlobal().getResourceVf().toArray()));
- assertTrue(Arrays.equals(new String[] { "SNDGCA64", "ALPRGAED", "LSLEILAA", "MDTWNJC1" },
- prop.getGlobal().getLocation().toArray()));
- assertEquals("value1", prop.getGlobal().getDeployParameters().get("input1").getAsString());
- assertEquals("value2", prop.getGlobal().getDeployParameters().get("input2").getAsString());
- }
-
- @Test
- public void testHolmesModelDecoding() throws IOException {
- String modelBpmnProp = ResourceFileUtil
- .getResourceAsString("example/model-properties/holmes/modelBpmnProperties.json");
- String modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/holmes/modelBpmn.json");
- ModelProperties prop = new ModelProperties("example-model-name", "example-control-name", null, true, modelBpmn,
- modelBpmnProp);
- Policy policy = prop.getType(Policy.class);
- assertTrue(policy.isFound());
- assertEquals(1, policy.getPolicyChains().size());
- assertEquals("0", policy.getPolicyChains().get(0).getPolicyId());
- assertEquals(1, policy.getPolicyChains().get(0).getPolicyItems().size());
- PolicyItem firstPolicyItem = policy.getPolicyChains().get(0).getPolicyItems().get(0);
- assertEquals("resourceid", firstPolicyItem.getTargetResourceId());
- assertEquals(180, firstPolicyItem.getRetryTimeLimit());
- assertEquals(3, firstPolicyItem.getMaxRetries());
- assertEquals("", firstPolicyItem.getParentPolicy());
- assertThat(firstPolicyItem.getParentPolicyConditions()).isEmpty();
- Holmes holmes = prop.getType(Holmes.class);
- assertNotNull(holmes);
- assertTrue(holmes.isFound());
- assertEquals("configPolicy1", holmes.getConfigPolicyName());
- assertEquals("blabla", holmes.getCorrelationLogic());
- // Test global prop
- assertEquals("vnfRecipe", prop.getGlobal().getActionSet());
- assertEquals("4cc5b45a-1f63-4194-8100-cd8e14248c92", prop.getGlobal().getService());
- assertTrue(Arrays.equals(new String[] { "f5213e3a-9191-4362-93b5-b67f8d770e44" },
- prop.getGlobal().getResourceVf().toArray()));
- assertTrue(Arrays.equals(new String[] { "SNDGCA64", "ALPRGAED", "LSLEILAA", "MDTWNJC1" },
- prop.getGlobal().getLocation().toArray()));
- assertEquals("value1", prop.getGlobal().getDeployParameters().get("input1").getAsString());
- assertEquals("value2", prop.getGlobal().getDeployParameters().get("input2").getAsString());
- }
-
- @Test
- public void testGetVf() throws IOException {
- CldsModel cldsModel = new CldsModel();
- cldsModel
- .setPropText(ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmnProperties.json"));
- assertEquals("023a3f0d-1161-45ff-b4cf-8918a8ccf3ad", ModelProperties.getVf(cldsModel));
- }
-} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java b/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java
index 199d0537..65b95a10 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTest.java
@@ -43,11 +43,11 @@ public class ToscaYamlToJsonConvertorTest {
@Test
public final void testParseToscaYaml() throws IOException {
String toscaModelYaml = ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml");
- ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(null);
+ ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor();
String parsedJsonSchema = convertor.parseToscaYaml(toscaModelYaml);
assertNotNull(parsedJsonSchema);
JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json.json"),
- parsedJsonSchema, true);
+ parsedJsonSchema, true);
}
}
diff --git a/src/test/java/org/onap/clamp/clds/transform/XslTransformerTest.java b/src/test/java/org/onap/clamp/clds/transform/XslTransformerTest.java
deleted file mode 100644
index 5cfa4fa7..00000000
--- a/src/test/java/org/onap/clamp/clds/transform/XslTransformerTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============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============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.transform;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-
-import javax.xml.transform.TransformerException;
-
-import org.json.JSONException;
-import org.junit.Test;
-import org.onap.clamp.clds.util.ResourceFileUtil;
-import org.skyscreamer.jsonassert.JSONAssert;
-
-public class XslTransformerTest {
-
- /**
- * This test validates the XSLT to convert BPMN xml to BPMN JSON.
- *
- * @throws TransformerException
- * In case of issues
- * @throws IOException
- * In case of issues
- * @throws JSONException
- * In case of issues to decode Json
- */
- @Test
- public void xslTransformTest() throws TransformerException, IOException, JSONException {
- XslTransformer xslTransformer = new XslTransformer();
- xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl");
- String bpmnJson = xslTransformer
- .doXslTransformToString(ResourceFileUtil.getResourceAsString("example/xsl-validation/modelBpmn.xml"));
- assertNotNull(bpmnJson);
- JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("example/xsl-validation/modelBpmnForVerif.json"),
- bpmnJson, true);
- }
-}