aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorSébastien Determe <sebastien.determe@intl.att.com>2019-02-13 14:17:44 +0000
committerGerrit Code Review <gerrit@onap.org>2019-02-13 14:17:44 +0000
commit700f44182b05ef329e00ad6107dd688ce092573d (patch)
tree000cef80e744a2764e8da8556d62e1b1a3440e13 /src/test/java/org
parente8cc77e09e1cc9ec5bd47560599e9d37e48700da (diff)
parentaef5d4ba9128c0cc4418b6dd9e12533b3d76bc84 (diff)
Merge "Remove SDC query"
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java34
-rw-r--r--src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java36
-rw-r--r--src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java305
-rw-r--r--src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java106
-rw-r--r--src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java9
5 files changed, 5 insertions, 485 deletions
diff --git a/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java
index 12fa2932c..d4172c244 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsDaoItCase.java
@@ -25,30 +25,24 @@ package org.onap.clamp.clds.it;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
-import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.NotFoundException;
-import org.apache.commons.codec.DecoderException;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices;
import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.model.CldsDbServiceCache;
import org.onap.clamp.clds.model.CldsEvent;
import org.onap.clamp.clds.model.CldsModel;
import org.onap.clamp.clds.model.CldsMonitoringDetails;
-import org.onap.clamp.clds.model.CldsServiceData;
import org.onap.clamp.clds.model.CldsTemplate;
import org.onap.clamp.clds.util.ResourceFileUtil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -69,8 +63,6 @@ public class CldsDaoItCase {
private String bpmnText;
private String imageText;
private String bpmnPropText;
- @Autowired
- private SdcCatalogServices sdcCatalogServices;
/**
* Setup the variable before the tests execution.
@@ -165,30 +157,4 @@ public class CldsDaoItCase {
});
}
- @Test
- public void testCldsServiceCache() throws GeneralSecurityException, DecoderException, IOException {
- CldsServiceData cldsServiceData = sdcCatalogServices
- .getCldsServiceDataWithAlarmConditions("4cc5b45a-1f63-4194-8100-cd8e14248c92");
- // Test not in cache so should be null
- CldsServiceData cldsServiceDataCache = cldsDao.getCldsServiceCache("4cc5b45a-1f63-4194-8100-cd8e14248c92");
- assertNull(cldsServiceDataCache);
- cldsDao.setCldsServiceCache(new CldsDbServiceCache(cldsServiceData));
- cldsServiceDataCache = cldsDao.getCldsServiceCache("4cc5b45a-1f63-4194-8100-cd8e14248c92");
- assertNotNull(cldsServiceDataCache);
- assertEquals("56441b4b-0467-41dc-9a0e-e68613838219", cldsServiceDataCache.getServiceUUID());
- assertEquals("4cc5b45a-1f63-4194-8100-cd8e14248c92", cldsServiceDataCache.getServiceInvariantUUID());
- assertEquals(2, cldsServiceDataCache.getCldsVfs().size());
- assertNotNull(cldsServiceDataCache.getAgeOfRecord());
- assertEquals(4, cldsServiceDataCache.getCldsVfs().get(0).getCldsVfcs().size());
- assertEquals("07e266fc-49ab-4cd7-8378-ca4676f1b9ec",
- cldsServiceDataCache.getCldsVfs().get(0).getVfInvariantResourceUUID());
- assertEquals(0, cldsServiceDataCache.getCldsVfs().get(0).getCldsKPIList().size());
- // Second update
- cldsServiceData.setCldsVfs(null);
- cldsDao.setCldsServiceCache(new CldsDbServiceCache(cldsServiceData));
- cldsServiceDataCache = cldsDao.getCldsServiceCache("4cc5b45a-1f63-4194-8100-cd8e14248c92");
- assertNotNull(cldsServiceDataCache);
- assertNull(cldsServiceDataCache.getCldsVfs());
- cldsDao.clearServiceCache();
- }
}
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 6ab800b36..347de4a78 100644
--- a/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
@@ -26,12 +26,10 @@ package org.onap.clamp.clds.it;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
-import java.security.GeneralSecurityException;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
@@ -40,9 +38,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.NotFoundException;
import javax.xml.transform.TransformerException;
-import org.apache.commons.codec.DecoderException;
import org.apache.commons.lang3.RandomStringUtils;
-import org.json.JSONException;
import org.json.simple.parser.ParseException;
import org.junit.Before;
import org.junit.Test;
@@ -54,7 +50,6 @@ import org.onap.clamp.clds.model.CldsEvent;
import org.onap.clamp.clds.model.CldsInfo;
import org.onap.clamp.clds.model.CldsModel;
import org.onap.clamp.clds.model.CldsMonitoringDetails;
-import org.onap.clamp.clds.model.CldsServiceData;
import org.onap.clamp.clds.model.CldsTemplate;
import org.onap.clamp.clds.model.DcaeEvent;
import org.onap.clamp.clds.service.CldsService;
@@ -281,35 +276,4 @@ public class CldsServiceItCase {
ResourceFileUtil.getResourceAsString("example/sdc/expected-result/sdc-properties-global.json"),
cldsService.getSdcProperties(), true);
}
-
- @Test
- public void testGetSdcServices() throws GeneralSecurityException, DecoderException, JSONException, IOException {
- String result = cldsService.getSdcServices();
- JSONAssert.assertEquals(
- ResourceFileUtil.getResourceAsString("example/sdc/expected-result/all-sdc-services.json"), result, true);
- }
-
- @Test
- public void testGetSdcPropertiesByServiceUuidForRefresh()
- throws GeneralSecurityException, DecoderException, JSONException, IOException {
- SecurityContext securityContext = Mockito.mock(SecurityContext.class);
- Mockito.when(securityContext.getAuthentication()).thenReturn(authentication);
-
- cldsService.setSecurityContext(securityContext);
- // Test basic functionalities
- String result = cldsService.getSdcPropertiesByServiceUUIDForRefresh("4cc5b45a-1f63-4194-8100-cd8e14248c92",
- false);
- JSONAssert.assertEquals(
- ResourceFileUtil.getResourceAsString("example/sdc/expected-result/sdc-properties-4cc5b45a.json"), result,
- true);
- // Now test the Cache effect
- CldsServiceData cldsServiceDataCache = cldsDao.getCldsServiceCache("c95b0e7c-c1f0-4287-9928-7964c5377a46");
- // Should not be there, so should be null
- assertNull(cldsServiceDataCache);
- cldsService.getSdcPropertiesByServiceUUIDForRefresh("c95b0e7c-c1f0-4287-9928-7964c5377a46", true);
- // Should be there now, so should NOT be null
- cldsServiceDataCache = cldsDao.getCldsServiceCache("c95b0e7c-c1f0-4287-9928-7964c5377a46");
- assertNotNull(cldsServiceDataCache);
- cldsDao.clearServiceCache();
- }
}
diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java
deleted file mode 100644
index d36e14c2b..000000000
--- a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java
+++ /dev/null
@@ -1,305 +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.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices;
-import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.model.CldsAlarmCondition;
-import org.onap.clamp.clds.model.CldsServiceData;
-import org.onap.clamp.clds.model.sdc.SdcResource;
-import org.onap.clamp.clds.model.sdc.SdcResourceBasicInfo;
-import org.onap.clamp.clds.model.sdc.SdcServiceInfo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test SDC Catalog Service class by mocking the SDC answers.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class SdcCatalogServicesItCase {
-
- @Autowired
- private ClampProperties refProp;
- @Autowired
- private SdcCatalogServices sdcCatalogWired = new SdcCatalogServices();
-
- @Test
- public void removeDuplicateServicesTest() {
- SdcServiceInfo service1a = new SdcServiceInfo();
- service1a.setName("service1");
- service1a.setVersion("1.0");
- service1a.setInvariantUUID("invariantUUID1.0");
- List<SdcServiceInfo> rawCldsSdcServiceList = new LinkedList<>();
- rawCldsSdcServiceList.add(service1a);
- rawCldsSdcServiceList.add(service1a);
- SdcServiceInfo service1b = new SdcServiceInfo();
- service1b.setName("service1");
- service1b.setVersion("1.1");
- service1b.setInvariantUUID("invariantUUID1.1");
- rawCldsSdcServiceList.add(service1b);
- SdcServiceInfo service1c = new SdcServiceInfo();
- service1c.setName("service1");
- service1c.setVersion("1.2");
- service1c.setInvariantUUID("invariantUUID1.2");
- rawCldsSdcServiceList.add(service1c);
- SdcServiceInfo service2 = new SdcServiceInfo();
- service2.setName("service2");
- service2.setVersion("1.0");
- service2.setInvariantUUID("invariantUUID2.0");
- rawCldsSdcServiceList.add(service2);
- SdcCatalogServices catalogServices = new SdcCatalogServices();
- List<SdcServiceInfo> resultList = catalogServices.removeDuplicateServices(rawCldsSdcServiceList);
- assertTrue(resultList.size() == 2);
- SdcServiceInfo res1;
- SdcServiceInfo res2;
- if ("service1".equals(resultList.get(0).getName())) {
- res1 = resultList.get(0);
- res2 = resultList.get(1);
- } else {
- res1 = resultList.get(1);
- res2 = resultList.get(0);
- }
- assertTrue("service1".equals(res1.getName()));
- assertTrue("1.2".equals(res1.getVersion()));
- assertTrue("service2".equals(res2.getName()));
- assertTrue("1.0".equals(res2.getVersion()));
- }
-
- @Test
- public void removeDuplicateSdcResourceInstancesTest() {
- List<SdcResource> rawCldsSdcResourceList = new LinkedList<>();
- SdcResource sdcResource1a = new SdcResource();
- sdcResource1a.setResourceInstanceName("resource1");
- sdcResource1a.setResourceVersion("1.0");
- rawCldsSdcResourceList.add(sdcResource1a);
- SdcResource sdcResource1b = new SdcResource();
- sdcResource1b.setResourceInstanceName("resource1");
- sdcResource1b.setResourceVersion("1.1");
- rawCldsSdcResourceList.add(sdcResource1b);
- SdcResource sdcResource1c = new SdcResource();
- sdcResource1c.setResourceInstanceName("resource1");
- sdcResource1c.setResourceVersion("1.2");
- rawCldsSdcResourceList.add(sdcResource1c);
- SdcResource sdcResource2 = new SdcResource();
- sdcResource2.setResourceInstanceName("resource2");
- sdcResource2.setResourceVersion("1.0");
- rawCldsSdcResourceList.add(sdcResource2);
- SdcCatalogServices catalogServices = new SdcCatalogServices();
- List<SdcResource> resultList = catalogServices.removeDuplicateSdcResourceInstances(rawCldsSdcResourceList);
- SdcResource res1;
- SdcResource res2;
- if ("resource1".equals(resultList.get(0).getResourceInstanceName())) {
- res1 = resultList.get(0);
- res2 = resultList.get(1);
- } else {
- res1 = resultList.get(1);
- res2 = resultList.get(0);
- }
- assertTrue("resource1".equals(res1.getResourceInstanceName()));
- assertTrue("1.2".equals(res1.getResourceVersion()));
- assertTrue("resource2".equals(res2.getResourceInstanceName()));
- assertTrue("1.0".equals(res2.getResourceVersion()));
- }
-
- @Test
- public void removeDuplicateSdcResourceBasicInfoTest() {
- List<SdcResourceBasicInfo> rawCldsSdcResourceList = new LinkedList<>();
- SdcResourceBasicInfo sdcResource1a = new SdcResourceBasicInfo();
- sdcResource1a.setName("resource1");
- sdcResource1a.setVersion("1.0");
- rawCldsSdcResourceList.add(sdcResource1a);
- SdcResourceBasicInfo sdcResource1b = new SdcResourceBasicInfo();
- sdcResource1b.setName("resource1");
- sdcResource1b.setVersion("1.1");
- rawCldsSdcResourceList.add(sdcResource1b);
- SdcResourceBasicInfo sdcResource1c = new SdcResourceBasicInfo();
- sdcResource1c.setName("resource1");
- sdcResource1c.setVersion("1.2");
- rawCldsSdcResourceList.add(sdcResource1c);
- SdcResourceBasicInfo sdcResource2 = new SdcResourceBasicInfo();
- sdcResource2.setName("resource2");
- sdcResource2.setVersion("1.0");
- rawCldsSdcResourceList.add(sdcResource2);
- SdcCatalogServices catalogServices = new SdcCatalogServices();
- List<SdcResourceBasicInfo> resultList = catalogServices
- .removeDuplicateSdcResourceBasicInfo(rawCldsSdcResourceList);
- SdcResourceBasicInfo res1;
- SdcResourceBasicInfo res2;
- if ("resource1".equals(resultList.get(0).getName())) {
- res1 = resultList.get(0);
- res2 = resultList.get(1);
- } else {
- res1 = resultList.get(1);
- res2 = resultList.get(0);
- }
- assertTrue("resource1".equals(res1.getName()));
- assertTrue("1.2".equals(res1.getVersion()));
- assertTrue("resource2".equals(res2.getName()));
- assertTrue("1.0".equals(res2.getVersion()));
- }
-
- @Test
- public void removeDuplicateSdcFunctionShouldNotReturnNull() {
- // given
- SdcCatalogServices catalogServices = new SdcCatalogServices();
-
- // when
- List<SdcResourceBasicInfo> firstResult = catalogServices.removeDuplicateSdcResourceBasicInfo(null);
- List<SdcResourceBasicInfo> secondResult = catalogServices
- .removeDuplicateSdcResourceBasicInfo(new ArrayList<>());
-
- // then
- assertThat(firstResult).isEmpty();
- assertThat(secondResult).isEmpty();
- }
-
- @Test
- public void getServiceUuidFromServiceInvariantIdTest() throws Exception {
- SdcCatalogServices spy = Mockito.spy(sdcCatalogWired);
- Mockito.doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8"))
- .when(spy).getSdcServicesInformation(null);
- // Try the vcts4 version 1.0, this one should be replaced by 1.1 so it
- // should not exist, returning empty string
- String resUuidVcts4Null = spy.getServiceUuidFromServiceInvariantId("a33ed748-3477-4434-b3f3-b5560f5e7d9b");
- assertTrue("".equals(resUuidVcts4Null));
- // Try the vcts4 version 1.1, this one should be there as it replaces
- // the vcts4 v1.0
- String resUuidVcts4Latest = spy.getServiceUuidFromServiceInvariantId("a33ed748-3477-4434-b3f3-b5560f5e7d9c");
- assertTrue("29018914-966c-442d-9d08-251b9dc45b8f".equals(resUuidVcts4Latest));
- // Try the vcts5 version 1.0, this one should be there
- String resUuidVcts5 = spy.getServiceUuidFromServiceInvariantId("a33ed748-3477-4434-b3f3-b5560f5e7d8c");
- assertTrue("29018914-966c-442d-9d08-251b9dc45b7f".equals(resUuidVcts5));
- // try one that does not exist at all
- String resUuidUnknown = spy.getServiceUuidFromServiceInvariantId("testuuid");
- assertTrue("".equals(resUuidUnknown));
- }
-
- @Test
- public void getCldsServiceDataWithAlarmConditionsTest() throws Exception {
- SdcCatalogServices spy = Mockito.spy(sdcCatalogWired);
- Mockito.doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8"))
- .when(spy).getSdcServicesInformation(null);
- // This invariant uuid is the one from vcts4 v1.1
- String serviceResourceDetailUrl = refProp.getStringValue("sdc.serviceUrl")
- + "/29018914-966c-442d-9d08-251b9dc45b8f/metadata";
- Mockito.doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServiceDetailsExample.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(serviceResourceDetailUrl);
- String resourceDetailUrl = refProp.getStringValue("sdc.catalog.url")
- + "resources/585822c7-4027-4f84-ba50-e9248606f136/metadata";
- Mockito.doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcResourceDetailsExample.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(resourceDetailUrl);
- String securityRulesDetailUrl = refProp.getStringValue("sdc.catalog.url")
- + "resources/d57e57d2-e3c6-470d-8d16-e6ea05f536c5/metadata";
- Mockito
- .doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcSecurityRules.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(securityRulesDetailUrl);
- String cinderVolumeDetailUrl = refProp.getStringValue("sdc.catalog.url")
- + "resources/b4288e07-597a-44a2-aa98-ad36e551a39d/metadata";
- Mockito
- .doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCinderVolume.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(cinderVolumeDetailUrl);
- String vfcGenericDetailUrl = refProp.getStringValue("sdc.catalog.url")
- + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/metadata";
- Mockito.doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCGenericWithAlarms.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcGenericDetailUrl);
- String csvAlarmsDetailUrl = refProp.getStringValue("sdc.catalog.url")
- + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/resourceInstances/virc_fe_be/"
- + "artifacts/5138e316-0237-49aa-817a-b3d8eaf77392";
- Mockito
- .doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl);
- Mockito
- .doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl);
- String csvAlarmsDetailUrl2 = refProp.getStringValue("sdc.catalog.url")
- + "resources/d7646638-2572-4a94-b497-c028ac15f9ca/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392";
- Mockito
- .doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl2);
- String allVfResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VF";
- Mockito
- .doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFResources.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfResourcesDetailUrl);
- String vfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url")
- + "resources/a0475018-1e7e-4ddd-8bee-33cbf958c2e6/metadata";
- Mockito.doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCVFCResourceExample.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourcesDetailUrl);
- String allVfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VFC";
- Mockito
- .doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCResources.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfcResourcesDetailUrl);
- String allCvfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=CVFC";
- Mockito
- .doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCVFCResources.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(allCvfcResourcesDetailUrl);
- String allVfAlarms = refProp.getStringValue("sdc.catalog.url")
- + "resources/84855843-5247-4e97-a2bd-5395a510253b/artifacts/d57ac7ec-f3c3-4793-983a-c75ac3a43153";
- Mockito
- .doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcMeasurementsList.csv"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfAlarms);
- String vfcResourceExample = refProp.getStringValue("sdc.catalog.url")
- + "resources/d7646638-2572-4a94-b497-c028ac15f9ca/metadata";
- Mockito
- .doReturn(IOUtils.toString(
- SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCResourceExample.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourceExample);
- CldsServiceData cldsServiceData = spy
- .getCldsServiceDataWithAlarmConditions("a33ed748-3477-4434-b3f3-b5560f5e7d9c");
- assertTrue("a33ed748-3477-4434-b3f3-b5560f5e7d9c".equals(cldsServiceData.getServiceInvariantUUID()));
- assertTrue("29018914-966c-442d-9d08-251b9dc45b8f".equals(cldsServiceData.getServiceUUID()));
- assertTrue(cldsServiceData.getCldsVfs().size() == 1);
- List<CldsAlarmCondition> alarmsList = spy.getAllAlarmConditionsFromCldsServiceData(cldsServiceData,
- "alarmCondition");
- assertTrue(alarmsList.size() == 12);
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java b/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java
deleted file mode 100644
index 971b36f6f..000000000
--- a/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java
+++ /dev/null
@@ -1,106 +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 static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.security.GeneralSecurityException;
-import java.util.List;
-
-import org.apache.commons.codec.DecoderException;
-import org.json.JSONException;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.client.req.sdc.SdcRequests;
-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;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class SdcReqItCase {
-
- @Autowired
- private SdcRequests sdcReq;
- private String modelBpmnProp;
- private String modelBpmn;
- private String modelName;
- private String controlName;
- private ModelProperties modelProperties;
- private String jsonWithYamlInside;
-
- /**
- * Initialize Test.
- */
- @Before
- public void setUp() throws IOException {
- modelBpmnProp = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmnProperties.json");
- modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmn.json");
- modelName = "example-model01";
- controlName = "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf";
- modelProperties = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, false, modelBpmn,
- modelBpmnProp);
- jsonWithYamlInside = ResourceFileUtil.getResourceAsString("example/tca-policy-req/prop-text.json");
- }
-
- @Test
- public void formatBlueprintTest() throws IOException {
- String blueprintFormatted = sdcReq.formatBlueprint(modelProperties, jsonWithYamlInside);
- assertEquals(ResourceFileUtil.getResourceAsString("example/tca-policy-req/blueprint-expected.yaml"),
- blueprintFormatted);
- }
-
- @Test
- public void formatSdcLocationsReqTest() {
- String blueprintFormatted = sdcReq.formatSdcLocationsReq(modelProperties, "testos");
- assertEquals(
- "{\"artifactName\":\"testos\",\"locations\":[\"SNDGCA64\",\"ALPRGAED\",\"LSLEILAA\",\"MDTWNJC1\"]}",
- blueprintFormatted);
- }
-
- @Test
- public void formatSdcReqTest() throws JSONException {
- String jsonResult = sdcReq.formatSdcReq("payload", "artifactName", "artifactLabel", "artifactType");
- JSONAssert.assertEquals("{\"payloadData\" : \"cGF5bG9hZA==\",\"artifactLabel\" : \"artifactLabel\","
- + "\"artifactName\" :\"artifactName\",\"artifactType\" : \"artifactType\","
- + "\"artifactGroupType\" : \"DEPLOYMENT\",\"description\" : \"from CLAMP Cockpit\"}", jsonResult, true);
- }
-
- @Test
- public void getSdcReqUrlsListTest() throws GeneralSecurityException, DecoderException {
- List<String> listUrls = sdcReq.getSdcReqUrlsList(modelProperties);
- assertNotNull(listUrls);
- assertTrue(listUrls.size() == 1);
- assertTrue(listUrls.get(0).contains(
- "/sdc/v1/catalog/services/56441b4b-0467-41dc-9a0e-e68613838219/resourceInstances/vpacketgen0/artifacts"));
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
index 630e8c028..65aa9b44f 100644
--- a/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
@@ -101,11 +101,12 @@ public class CldsReferencePropertiesItCase {
*/
@Test
public void testGetFileContent() throws IOException {
- String content = refProp.getFileContent("sdc.decode.service_ids");
- assertEquals("{}", content);
+ String location = "{\n\t\"DC1\": \"Data Center 1\",\n\t\"DC2\": \"Data Center 2\",\n\t\"DC3\": \"Data Center 3\"\n}\n";
+ String content = refProp.getFileContent("ui.location.default");
+ assertEquals(location, content);
// Test composite key
- content = refProp.getFileContent("sdc.decode", "service_ids");
- assertEquals("{}", content);
+ content = refProp.getFileContent("ui.location", "default");
+ assertEquals(location, content);
}
@Test