summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/HeatStatus.java1
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java76
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/AdapterBeansTest.java33
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoTest.java158
-rw-r--r--adapters/mso-adapters-rest-interface/pom.xml6
-rw-r--r--adapters/pom.xml7
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java3
-rw-r--r--bpmn/MSOCoreBPMN/pom.xml7
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java438
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java1
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/utils/CamundaDBSetup.java (renamed from bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java)5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java18
12 files changed, 413 insertions, 340 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/HeatStatus.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/HeatStatus.java
index 8e223b7bcb..3e4ea27d5f 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/HeatStatus.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/HeatStatus.java
@@ -20,7 +20,6 @@
package org.openecomp.mso.openstack.beans;
-
/*
* Enum status values to mirror the Openstack Heat stack status values
*/
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java
index 9f2c275670..2cda8f99e2 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/beans/NetworkInfo.java
@@ -20,8 +20,6 @@
package org.openecomp.mso.openstack.beans;
-
-
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -35,7 +33,6 @@ import com.woorea.openstack.quantum.model.Segment;
*
* This bean is returned by all Network-specific adapter operations (create, query, delete)
*/
-
public class NetworkInfo {
// Set defaults for everything
private String name = "";
@@ -44,7 +41,6 @@ public class NetworkInfo {
private String provider = "";
private List<Integer> vlans = new ArrayList<>();
private List<String> subnets = new ArrayList<>();
- private String shared = "";
static Map<String,NetworkStatus> NetworkStatusMap;
static {
@@ -55,15 +51,6 @@ public class NetworkInfo {
NetworkStatusMap.put("ERROR", NetworkStatus.ERROR);
}
- public NetworkInfo () {
- }
-
- public NetworkInfo (String name, NetworkStatus status) {
- this.name = name;
- this.id = name; // Don't have an ID, so just use name
- this.status = status;
- }
-
/**
* Capture the data from a Neutron Network object.
*
@@ -75,41 +62,35 @@ public class NetworkInfo {
*
* @param network
*/
- public NetworkInfo (Network network)
- {
- if (network == null) {
- this.status = NetworkStatus.NOTFOUND;
- return;
+ public NetworkInfo(Network network) {
+ if (network != null) {
+ initFieldsWithDataFromNetwork(network);
+ } else {
+ status = NetworkStatus.NOTFOUND;
}
+ }
- this.name = network.getName();
- this.id = network.getId();
+ private void initFieldsWithDataFromNetwork(Network network){
+ name = network.getName();
+ id = network.getId();
- if (network.getStatus() == null) {
- // Can this happen on a newly created network?
- this.status = NetworkStatus.UNKNOWN;
- } else if (NetworkStatusMap.containsKey(network.getStatus())) {
- this.status = NetworkStatusMap.get(network.getStatus());
- } else {
- this.status = NetworkStatus.UNKNOWN;
+ if (network.getStatus() != null && NetworkStatusMap.containsKey(network.getStatus())) {
+ status = NetworkStatusMap.get(network.getStatus());
}
-
if (network.getProviderPhysicalNetwork() != null) {
- this.provider = network.getProviderPhysicalNetwork();
+ provider = network.getProviderPhysicalNetwork();
if ("vlan".equals(network.getProviderNetworkType())) {
- this.vlans.add(network.getProviderSegmentationId());
+ vlans.add(network.getProviderSegmentationId());
}
}
else if (network.getSegments() != null && !network.getSegments().isEmpty()) {
Segment s = network.getSegments().get(0);
- this.provider = s.getProviderPhysicalNetwork();
+ provider = s.getProviderPhysicalNetwork();
if ("vlan".equals(s.getProviderNetworkType())) {
- for (Segment s1 : network.getSegments()) {
- this.vlans.add(s1.getProviderSegmentationId());
- }
+ network.getSegments().forEach(segment -> vlans.add(segment.getProviderSegmentationId()));
}
}
- this.subnets = network.getSubnets();
+ subnets = network.getSubnets();
}
public String getName() {
@@ -156,22 +137,17 @@ public class NetworkInfo {
return subnets;
}
- public void setSubnets (List<String> subnets) {
- this.subnets = subnets;
- }
-
- public String getShared() {
- return shared;
- }
-
- public void setShared(String shared) {
- this.shared = shared;
- }
-
@Override
- public String toString () {
- return "Network: name=" + name + ",id=" + id + ",status=" + status +
- ",provider=" + provider + ",vlans=" + vlans + ",subnets=" + subnets + ",shared=" + shared;
+ public String toString() {
+ final StringBuilder sb = new StringBuilder("NetworkInfo{");
+ sb.append("name='").append(name).append('\'');
+ sb.append(", id='").append(id).append('\'');
+ sb.append(", status=").append(status);
+ sb.append(", provider='").append(provider).append('\'');
+ sb.append(", vlans=").append(vlans);
+ sb.append(", subnets=").append(subnets);
+ sb.append('}');
+ return sb.toString();
}
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/AdapterBeansTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/AdapterBeansTest.java
index f231c75211..6bd78153b6 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/AdapterBeansTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/adapter_utils/tests/AdapterBeansTest.java
@@ -22,25 +22,21 @@ package org.openecomp.mso.adapter_utils.tests;
import static org.junit.Assert.assertTrue;
+import com.woorea.openstack.heat.model.Stack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.Test;
import org.openecomp.mso.entity.MsoRequest;
import org.openecomp.mso.openstack.beans.HeatStatus;
import org.openecomp.mso.openstack.beans.MsoTenant;
-import org.openecomp.mso.openstack.beans.NetworkInfo;
import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
import org.openecomp.mso.openstack.beans.Pool;
import org.openecomp.mso.openstack.beans.StackInfo;
import org.openecomp.mso.openstack.beans.Subnet;
import org.openecomp.mso.openstack.beans.VnfRollback;
-import com.woorea.openstack.heat.model.Stack;
-
public class AdapterBeansTest {
@Test
public final void msoTenantTest() {
@@ -58,33 +54,6 @@ public class AdapterBeansTest {
}
@Test
- public final void networkInfoTest() {
- NetworkInfo networkInfo = new NetworkInfo();
- networkInfo.setName("name");
- assertTrue(networkInfo.getName().equalsIgnoreCase("name"));
- networkInfo.setId("1");
- assertTrue(networkInfo.getId().equalsIgnoreCase("1"));
- networkInfo.setStatus(NetworkStatus.ACTIVE);
- assertTrue(networkInfo.getStatus().equals(NetworkStatus.ACTIVE));
- networkInfo.setProvider("provider");
- networkInfo.getProvider().equalsIgnoreCase("provider");
- List<Integer> al = new ArrayList<>();
- al.add(1);
- al.add(2);
- networkInfo.setVlans(al);
- assertTrue(networkInfo.getVlans() != null);
- networkInfo.setShared("shared");
- assertTrue(networkInfo.getShared().equalsIgnoreCase("shared"));
- List<String> als = new ArrayList<>();
- als.add("1");
- als.add("2");
- networkInfo.setSubnets(als);
- assertTrue(networkInfo.getSubnets() != null);
- new NetworkInfo("string", NetworkStatus.ACTIVE);
- assertTrue(networkInfo.toString() != null);
- }
-
- @Test
public final void networkRollbackTest() {
NetworkRollback networkRollback = new NetworkRollback();
networkRollback.setCloudId("cloudId");
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoTest.java
new file mode 100644
index 0000000000..0f357e5555
--- /dev/null
+++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/beans/NetworkInfoTest.java
@@ -0,0 +1,158 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * 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.openecomp.mso.openstack.beans;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import com.woorea.openstack.quantum.model.Network;
+import com.woorea.openstack.quantum.model.Segment;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+
+public class NetworkInfoTest {
+
+ private static final String NETWORK_STATUS_ACTIVE = "ACTIVE";
+ private static final String NETWORK_STATUS_ID = "networkIdTest";
+ private static final String NETWORK_STATUS_NAME = "networkNameTest";
+ private static final String SUBNET_NAME = "subnetTest";
+ private static final String PROVIDER = "providerTest";
+ private static final String PROVIDER_NETWORK_TYPE_VLAN = "vlan";
+ private static final String PROVIDER_NETWORK_TYPE_OTHER = "providerTypeTest";
+ private static final Integer PROVIDER_SEGMENTATION_ID = 777;
+ private static final String PROVIDER_FOR_SEGMENT = "providerSegmentTest";
+ private static final Integer PROVIDER_SEGMENTATION_ID_FOR_SEGMENT = 123;
+
+ @Test
+ public void networkStatusUnknownWhenIsNullInNetwork() {
+ NetworkInfo networkInfo = new NetworkInfo(prepareNetwork(null));
+ assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.UNKNOWN);
+ checkCommonPartWhenProviderIsNotPresent(networkInfo);
+ }
+
+ @Test
+ public void networkStatusUnknownWhenNotFoundInNetworkStatusMap() {
+ NetworkInfo networkInfo = new NetworkInfo(prepareNetwork("notExistingNetworkStatus"));
+ assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.UNKNOWN);
+ checkCommonPartWhenProviderIsNotPresent(networkInfo);
+ }
+
+ @Test
+ public void setNetworkStatusWhenNetworkStatusFoundInNetworkStatusMap() {
+ NetworkInfo networkInfo = new NetworkInfo(prepareNetwork(NETWORK_STATUS_ACTIVE));
+ assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.ACTIVE);
+ checkCommonPartWhenProviderIsNotPresent(networkInfo);
+ }
+
+ @Test
+ public void setVLANProviderFromTheNetwork() {
+ NetworkInfo networkInfo = new NetworkInfo(prepareNetworkWithProvider(NETWORK_STATUS_ACTIVE, PROVIDER,
+ PROVIDER_NETWORK_TYPE_VLAN));
+ assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.ACTIVE);
+ assertThat(networkInfo.getProvider()).isEqualTo(PROVIDER);
+ assertThat(networkInfo.getVlans()).hasSize(1).contains(PROVIDER_SEGMENTATION_ID);
+ checkCommonPart(networkInfo);
+ }
+
+ @Test
+ public void setOtherProviderFromTheNetwork() {
+ NetworkInfo networkInfo = new NetworkInfo(prepareNetworkWithProvider(NETWORK_STATUS_ACTIVE, PROVIDER,
+ PROVIDER_NETWORK_TYPE_OTHER));
+ assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.ACTIVE);
+ assertThat(networkInfo.getProvider()).isEqualTo(PROVIDER);
+ assertThat(networkInfo.getVlans()).isEmpty();
+ checkCommonPart(networkInfo);
+ }
+
+ @Test
+ public void setVLANProviderFromTheNetworkSegments() {
+ NetworkInfo networkInfo = new NetworkInfo(prepareNetworkWithSegments(NETWORK_STATUS_ACTIVE,
+ prepareSegment(PROVIDER_NETWORK_TYPE_VLAN)));
+ assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.ACTIVE);
+ assertThat(networkInfo.getProvider()).isEqualTo(PROVIDER_FOR_SEGMENT);
+ assertThat(networkInfo.getVlans()).hasSize(1).contains(PROVIDER_SEGMENTATION_ID_FOR_SEGMENT);
+ checkCommonPart(networkInfo);
+ }
+
+ @Test
+ public void setOtherProviderFromTheNetworkSegments() {
+ NetworkInfo networkInfo = new NetworkInfo(prepareNetworkWithSegments(NETWORK_STATUS_ACTIVE,
+ prepareSegment(PROVIDER_NETWORK_TYPE_OTHER)));
+ assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.ACTIVE);
+ assertThat(networkInfo.getProvider()).isEqualTo(PROVIDER_FOR_SEGMENT);
+ assertThat(networkInfo.getVlans()).isEmpty();
+ checkCommonPart(networkInfo);
+ }
+
+ @Test
+ public void setNetworkStatusNotFoundWhenNetworkIsNull() {
+ NetworkInfo networkInfo = new NetworkInfo(null);
+ assertThat(networkInfo.getStatus()).isEqualTo(NetworkStatus.NOTFOUND);
+ }
+
+ private void checkCommonPartWhenProviderIsNotPresent(NetworkInfo networkInfo) {
+ assertThat(networkInfo.getProvider()).isEmpty();
+ assertThat(networkInfo.getVlans()).isEmpty();
+ checkCommonPart(networkInfo);
+ }
+
+ private void checkCommonPart(NetworkInfo networkInfo) {
+ assertThat(networkInfo.getId()).isEqualTo(NETWORK_STATUS_ID);
+ assertThat(networkInfo.getName()).isEqualTo(NETWORK_STATUS_NAME);
+ assertThat(networkInfo.getSubnets()).hasSize(1).contains(SUBNET_NAME);
+ }
+
+ private Network prepareNetwork(String networkStatus) {
+ Network network = new Network();
+ network.setId(NETWORK_STATUS_ID);
+ network.setName(NETWORK_STATUS_NAME);
+ network.setStatus(networkStatus);
+ List<String> subnets = new ArrayList<>();
+ subnets.add(SUBNET_NAME);
+ network.setSubnets(subnets);
+ return network;
+ }
+
+ private Network prepareNetworkWithProvider(String networkStatus, String providerPhysicalNetwork, String providerNetworkType) {
+ Network network = prepareNetwork(networkStatus);
+ network.setProviderPhysicalNetwork(providerPhysicalNetwork);
+ network.setProviderNetworkType(providerNetworkType);
+ network.setProviderSegmentationId(PROVIDER_SEGMENTATION_ID);
+ return network;
+ }
+
+ private Network prepareNetworkWithSegments(String networkStatus, Segment segment) {
+ Network network = prepareNetwork(networkStatus);
+ List<Segment> segments = new ArrayList<>();
+ segments.add(segment);
+ network.setSegments(segments);
+ return network;
+ }
+
+ private Segment prepareSegment(String providerNetworkType) {
+ Segment segment = new Segment();
+ segment.setProviderPhysicalNetwork(PROVIDER_FOR_SEGMENT);
+ segment.setProviderNetworkType(providerNetworkType);
+ segment.setProviderSegmentationId(PROVIDER_SEGMENTATION_ID_FOR_SEGMENT);
+ return segment;
+ }
+
+}
diff --git a/adapters/mso-adapters-rest-interface/pom.xml b/adapters/mso-adapters-rest-interface/pom.xml
index bbf614a644..f10500d2ca 100644
--- a/adapters/mso-adapters-rest-interface/pom.xml
+++ b/adapters/mso-adapters-rest-interface/pom.xml
@@ -54,11 +54,5 @@
<version>1.10.19</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>3.8.0</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/adapters/pom.xml b/adapters/pom.xml
index 80244a62cc..97c2506bcc 100644
--- a/adapters/pom.xml
+++ b/adapters/pom.xml
@@ -28,7 +28,6 @@
<module>mso-workflow-message-adapter</module>
<module>mso-vfc-adapter</module>
</modules>
-
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
@@ -38,5 +37,11 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.9.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java
index 15dc4f4609..ce8eb7afec 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java
@@ -61,7 +61,6 @@ import org.custommonkey.xmlunit.DetailedDiff;
import org.custommonkey.xmlunit.XMLUnit;
import org.jboss.resteasy.spi.AsynchronousResponse;
import org.json.JSONArray;
-import org.json.JSONObject;
import org.junit.Before;
import org.junit.Rule;
import org.openecomp.mso.bpmn.common.adapter.sdnc.CallbackHeader;
@@ -78,7 +77,7 @@ import org.openecomp.mso.bpmn.common.workflow.service.VnfAdapterNotifyServiceImp
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
-import org.openecomp.mso.bpmn.core.CamundaDBSetup;
+import org.openecomp.mso.bpmn.core.utils.CamundaDBSetup;
import org.openecomp.mso.bpmn.core.PropertyConfigurationSetup;
import org.openecomp.mso.bpmn.core.domain.Resource;
import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition;
diff --git a/bpmn/MSOCoreBPMN/pom.xml b/bpmn/MSOCoreBPMN/pom.xml
index 6884c1e33b..267f175533 100644
--- a/bpmn/MSOCoreBPMN/pom.xml
+++ b/bpmn/MSOCoreBPMN/pom.xml
@@ -158,9 +158,10 @@
<version>20160212</version>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <version>1.6</version>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-core</artifactId>
+ <version>2.5.1</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.openecomp.so</groupId>
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java
index 7f922ce30e..58f1ae264d 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/JsonUtilsTest.java
@@ -36,26 +36,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.openecomp.mso.bpmn.core;
-import java.io.BufferedReader;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.CharBuffer;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import org.junit.BeforeClass;
import org.junit.Test;
-import org.xml.sax.SAXException;
-import org.custommonkey.xmlunit.Diff;
-
import org.openecomp.mso.bpmn.core.json.JsonUtils;
import org.openecomp.mso.bpmn.core.xml.XmlTool;
+import org.xmlunit.builder.DiffBuilder;
+import org.xmlunit.diff.DefaultNodeMatcher;
+import org.xmlunit.diff.Diff;
+import org.xmlunit.diff.ElementSelectors;
/**
* @version 1.0
@@ -63,8 +61,8 @@ import org.openecomp.mso.bpmn.core.xml.XmlTool;
public class JsonUtilsTest {
private static final String EOL = "\n";
- private String xmlReq =
- "<vnf-request xmlns=\"http://org.openecomp/mso/infra/vnf-request/v1\">" + EOL +
+ private static final String XML_REQ =
+ "<vnf-request xmlns=\"http://org.openecomp/mso/infra/vnf-request/v1\">" + EOL +
" <request-info>" + EOL +
" <request-id>DEV-VF-0021</request-id>" + EOL +
" <action>CREATE_VF_MODULE</action>" + EOL +
@@ -93,9 +91,9 @@ public class JsonUtilsTest {
" <param name=\"server\">server1111</param>" + EOL +
" </vnf-params> " + EOL +
"</vnf-request>" + EOL;
-
- private String xmlReqNoAttrs =
- "<vnf-request xmlns=\"http://org.openecomp/mso/infra/vnf-request/v1\">" + EOL +
+
+ private static final String XML_REQ_NO_ATTRS =
+ "<vnf-request xmlns=\"http://org.openecomp/mso/infra/vnf-request/v1\">" + EOL +
" <request-info>" + EOL +
" <action>DELETE_VF_MODULE</action>" + EOL +
" <source>PORTAL</source>" + EOL +
@@ -115,246 +113,214 @@ public class JsonUtilsTest {
" <vnf-params xmlns:tns=\"http://org.openecomp/mso/infra/vnf-request/v1\"/>" + EOL +
"</vnf-request>" + EOL;
- private String xmlArrayReq =
- "<ucpeInfo>" + EOL +
+ private static final String XML_ARRAY_REQ =
+ "<ucpeInfo>" + EOL +
" <outOfBandManagementModem>BROADBAND</outOfBandManagementModem>" + EOL +
- " <internetTopology>IVLAN</internetTopology>" + EOL +
- " <ucpeAliasHostName>SHELLUCPE31</ucpeAliasHostName>" + EOL +
- " <wanList>" + EOL +
- " <wanInfo>" + EOL +
- " <wanType>AVPN</wanType>" + EOL +
- " <interfaceType>1000BASE-T</interfaceType>" + EOL +
- " <transportProviderName>ATT</transportProviderName>" + EOL +
- " <circuitId>BT/SLIR/70911</circuitId>" + EOL +
- " <dualMode>Active</dualMode>" + EOL +
- " <wanPortNumber>WAN1</wanPortNumber>" + EOL +
- " <transportManagementOption>ATT</transportManagementOption>" + EOL +
- " <transportVendorTotalBandwidth>100</transportVendorTotalBandwidth>" + EOL +
- " <mediaType>ELECTRICAL</mediaType>" + EOL +
- " </wanInfo>" + EOL +
- " <wanInfo>" + EOL +
- " <wanType>AVPN</wanType>" + EOL +
- " <interfaceType>10/100/1000BASE-T</interfaceType>" + EOL +
- " <transportProviderName>ATT</transportProviderName>" + EOL +
- " <circuitId>AS/KRFN/34611</circuitId>" + EOL +
- " <dualMode>Active</dualMode>" + EOL +
- " <wanPortNumber>WAN2</wanPortNumber>" + EOL +
- " <transportManagementOption>ATT</transportManagementOption>" + EOL +
- " <transportVendorTotalBandwidth>10000</transportVendorTotalBandwidth>" + EOL +
- " <mediaType>MMF</mediaType>" + EOL +
- " </wanInfo>" + EOL +
- " </wanList>" + EOL +
- " <ucpeActivationCode>ASD-987-M31</ucpeActivationCode>" + EOL +
- " <ucpeHostName>USOSTCDALTX0101UJZZ31</ucpeHostName>" + EOL +
- " <ucpePartNumber>FG-VM00*</ucpePartNumber>" + EOL +
+ " <internetTopology>IVLAN</internetTopology>" + EOL +
+ " <ucpeAliasHostName>SHELLUCPE31</ucpeAliasHostName>" + EOL +
+ " <wanList>" + EOL +
+ " <wanInfo>" + EOL +
+ " <wanType>AVPN</wanType>" + EOL +
+ " <interfaceType>1000BASE-T</interfaceType>" + EOL +
+ " <transportProviderName>ATT</transportProviderName>" + EOL +
+ " <circuitId>BT/SLIR/70911</circuitId>" + EOL +
+ " <dualMode>Active</dualMode>" + EOL +
+ " <wanPortNumber>WAN1</wanPortNumber>" + EOL +
+ " <transportManagementOption>ATT</transportManagementOption>" + EOL +
+ " <transportVendorTotalBandwidth>100</transportVendorTotalBandwidth>" + EOL +
+ " <mediaType>ELECTRICAL</mediaType>" + EOL +
+ " </wanInfo>" + EOL +
+ " <wanInfo>" + EOL +
+ " <wanType>AVPN</wanType>" + EOL +
+ " <interfaceType>10/100/1000BASE-T</interfaceType>" + EOL +
+ " <transportProviderName>ATT</transportProviderName>" + EOL +
+ " <circuitId>AS/KRFN/34611</circuitId>" + EOL +
+ " <dualMode>Active</dualMode>" + EOL +
+ " <wanPortNumber>WAN2</wanPortNumber>" + EOL +
+ " <transportManagementOption>ATT</transportManagementOption>" + EOL +
+ " <transportVendorTotalBandwidth>10000</transportVendorTotalBandwidth>" + EOL +
+ " <mediaType>MMF</mediaType>" + EOL +
+ " </wanInfo>" + EOL +
+ " </wanList>" + EOL +
+ " <ucpeActivationCode>ASD-987-M31</ucpeActivationCode>" + EOL +
+ " <ucpeHostName>USOSTCDALTX0101UJZZ31</ucpeHostName>" + EOL +
+ " <ucpePartNumber>FG-VM00*</ucpePartNumber>" + EOL +
"</ucpeInfo>";
// JSON request w/ embedded XML will be read from a file
- private String jsonReq = null;
- private String jsonReqArray = null;
-
- @Before
- public void initialize() {
- File file = new File("src/test/resources/request.json");
- File file2 = new File("src/test/resources/requestArray.json");
- FileInputStream fis = null;
+ private static String jsonReq;
+ private static String jsonReqArray;
+
+ @BeforeClass
+ public static void initialize() throws Exception {
+ jsonReq = readFileToString("src/test/resources/request.json");
+ jsonReqArray = readFileToString("src/test/resources/requestArray.json");
+ }
- try {
- fis = new FileInputStream(file);
- BufferedReader br = new BufferedReader(new InputStreamReader(fis));
- CharBuffer cbuf = CharBuffer.allocate((int)file.length()+1);
- br.read(cbuf);
- cbuf.flip();
- jsonReq = cbuf.toString();
- if (jsonReq != null) {
- System.out.println("initialize(): json request: " + jsonReq);
- } else {
- System.out.println("initialize(): failed to read json request from src/test/resources/request.json");
- }
- fis.close();
- fis = new FileInputStream(file2);
- br = new BufferedReader(new InputStreamReader(fis));
- cbuf = CharBuffer.allocate((int)file.length()+1);
- br.read(cbuf);
- cbuf.flip();
- jsonReqArray = cbuf.toString();
- if (jsonReq != null) {
- System.out.println("initialize(): json request w/ array: " + jsonReqArray);
- } else {
- System.out.println("initialize(): failed to read json request from src/test/resources/request2.json");
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- if (fis != null)
- fis.close();
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
+ private static String readFileToString(String path) throws IOException {
+ File file = new File(path);
+ return new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
}
-
- @After
- public void cleanup(){
+
+ @Test
+ public void shouldConvertXmlToJsonAndBackToSameXml() throws Exception {
+ // Note: the current version of the JsonUtils.json2xml() method
+ // does not support converting the JSONObject representation
+ // of XML attributes (JSONArray) back to XML. So this test will
+ // only succeed if the original XML does not contain attributes
+
+ // given
+ String xmlIn = XmlTool.removeNamespaces(XML_REQ_NO_ATTRS);
+ // when
+ String json = JsonUtils.xml2json(XML_REQ_NO_ATTRS);
+ String xmlOut = JsonUtils.json2xml(json);
+ // then
+ Diff diffXml = DiffBuilder.compare(xmlIn).withTest(xmlOut).ignoreWhitespace()
+ .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build();
+
+ assertThat(diffXml.hasDifferences()).withFailMessage(diffXml.toString()).isFalse();
}
@Test
-// @Ignore
- public void testConversion() {
- // Note: the current version of the JsonUtils.json2xml() method
- // does not support converting the JSONObject representation
- // of XML attributes (JSONArray) back to XML. So this test will
- // only succeed if the original XML does not contain attributes
-
- // save a copy of the xml with the namespaces removed
- String xmlIn = XmlTool.removeNamespaces(xmlReqNoAttrs);
- // strip all the non-data whitespace
- xmlIn = xmlIn.replaceAll(">\\s*<", "><");
- String json = JsonUtils.xml2json(xmlReqNoAttrs);
- System.out.println("testConversion(): xml request to json: " + json);
- String xmlOut = JsonUtils.json2xml(json);
- System.out.println("testConversion(): json request back to xml: " + xmlOut);
-
- // strip all the non-data whitespace
- xmlOut = xmlOut.replaceAll(">\\s*<", "><");
+ public void shouldReadValuesForAbsoluteJsonPaths() throws Exception {
+ // given
+ String json = JsonUtils.xml2json(XML_REQ);
+ // when, then
+ assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-name")).isEqualTo("STMTN5MMSC21");
+ assertThat(JsonUtils.getJsonValue(json, "vnf-request.request-info.action")).isEqualTo("CREATE_VF_MODULE");
+ assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.persona-model-version")).isEqualTo("1");
+ assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-persona-model-version")).isEqualTo("1.5");
+ assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.is-base-module")).isEqualTo("true");
+ }
- Diff diffXml;
- try {
- diffXml = new Diff(xmlIn, xmlOut);
- Assert.assertTrue(diffXml.similar());
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ @Test
+ public void shouldReturnValueForJsonKey() throws Exception {
+ // given
+ String json = JsonUtils.xml2json(XML_REQ);
+ // when, then
+ assertThat(JsonUtils.getJsonValueForKey(json, "source")).isEqualTo("PORTAL");
}
@Test
-// @Ignore
- public void testRetrieval() {
- String json = JsonUtils.xml2json(xmlReq);
- System.out.println("testRetrieval(): xml request to json: " + json);
- // full JSON path
- String value = JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-name");
- Assert.assertEquals(value, "STMTN5MMSC21");
- value = JsonUtils.getJsonValue(json, "vnf-request.request-info.action");
- Assert.assertEquals(value, "CREATE_VF_MODULE");
- // retrieving an integer
- value = JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.persona-model-version");
- Assert.assertEquals(value, "1");
- // retrieving a float
- value = JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.vnf-persona-model-version");
- Assert.assertEquals(value, "1.5");
- // retrieving a boolean
- value = JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.is-base-module");
- Assert.assertEquals(value, "true");
- // attempt to retrieve a value for a non-existent field
- value = JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.bad");
- Assert.assertEquals(value, null);
- // retrieving a parameter/array value (originally a XML attribute)
- value = JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name");
- Assert.assertEquals(value, "network");
- value = JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content");
- Assert.assertEquals(value, "network1111");
- // retrieving a parameter/array value by index
- value = JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content", 1);
- Assert.assertEquals(value, "server1111");
- value = JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 1);
- Assert.assertEquals(value, "server");
- // failure due to invalid parameter name
- value = JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "badParam");
- Assert.assertEquals(value, null);
- // failure due to array index out of bounds
- value = JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 2);
- Assert.assertEquals(value, null);
- // by field name/key
- value = JsonUtils.getJsonValueForKey(json, "source");
- Assert.assertEquals(value, "PORTAL");
- value = JsonUtils.getJsonValueForKey(json, "vnf-module");
- Assert.assertEquals(value, null);
+ public void shouldReturnNullForNonexistentJsonNode() throws Exception {
+ // given
+ String json = JsonUtils.xml2json(XML_REQ);
+ // when, then
+ assertThat(JsonUtils.getJsonValueForKey(json, "nonexistent-node")).isNull();
}
@Test
-// @Ignore
- public void testUpdate() {
- String json = JsonUtils.xml2json(xmlReq);
- System.out.println("testUpdate(): xml request to json: " + json);
- // the add should be successful
- String jsonUpd = JsonUtils.addJsonValue(json, "vnf-request.request-info.comment", "Some comment");
- String value = JsonUtils.getJsonValue(jsonUpd, "vnf-request.request-info.comment");
- Assert.assertEquals(value, "Some comment");
- // the add should be ignored as the field already exists
- jsonUpd = JsonUtils.addJsonValue(jsonUpd, "vnf-request.vnf-inputs.vnf-name", "STMTN5MMSC22");
- value = JsonUtils.getJsonValue(jsonUpd, "vnf-request.vnf-inputs.vnf-name");
- Assert.assertEquals(value, "STMTN5MMSC21");
- // the update should be successful
- jsonUpd = JsonUtils.updJsonValue(jsonUpd, "vnf-request.vnf-inputs.vnf-name", "STMTN5MMSC22");
- value = JsonUtils.getJsonValue(jsonUpd, "vnf-request.vnf-inputs.vnf-name");
- Assert.assertEquals(value, "STMTN5MMSC22");
- // the delete should be successful
- jsonUpd = JsonUtils.delJsonValue(jsonUpd, "vnf-request.request-info.comment");
- value = JsonUtils.getJsonValue(jsonUpd, "vnf-request.request-info.comment");
- Assert.assertEquals(value, null);
- // the delete should fail as field 'vnf-model' does not exist
- String jsonCur = jsonUpd;
- jsonUpd = JsonUtils.delJsonValue(jsonUpd, "vnf-request.vnf-inputs.vnf-module");
- Assert.assertEquals(jsonCur, jsonUpd);
+ public void shouldReturnNullForNonExistentParameter() throws Exception {
+ // given
+ String json = JsonUtils.xml2json(XML_REQ);
+ // when, then
+ assertThat(JsonUtils.getJsonValue(json, "vnf-request.vnf-inputs.bad")).isNull();
}
-
+
@Test
-// @Ignore
- public void testEmbededXmlRetrievalConversion() {
- try {
- // extract the embedded XML from the request
- String value = JsonUtils.getJsonValue(jsonReq, "variables.bpmnRequest.value");
- String xmlReq = XmlTool.removeNamespaces(XmlTool.normalize(value));
- System.out.println("testEmbededXmlRetrievalConversion(): xml payload: " + xmlReq);
- String json = JsonUtils.xml2json(xmlReq);
- System.out.println("testEmbededXmlRetrievalConversion(): xml request to json: " + json);
- String xmlOut = JsonUtils.json2xml(json);
- System.out.println("testEmbededXmlRetrievalConversion(): json request back to xml: " + xmlOut);
- Diff diffXml;
- try {
- // compare the XML before and after
- diffXml = new Diff(xmlReq, xmlOut);
- Assert.assertTrue(diffXml.similar());
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
+ public void shouldGetJasonParametersFromArray() throws Exception {
+ // given
+ String json = JsonUtils.xml2json(XML_REQ);
+ // when, then
+ assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name")).isEqualTo("network");
+ assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content"))
+ .isEqualTo("network1111");
+ assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 1)).isEqualTo("server");
+ assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "content", 1))
+ .isEqualTo("server1111");
+ assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "badParam"))
+ .withFailMessage("Expected null for nonexistent param").isNull();
+ assertThat(JsonUtils.getJsonParamValue(json, "vnf-request.vnf-params.param", "name", 2))
+ .withFailMessage("Expected null for index out of bound").isNull();
}
@Test
-// @Ignore
- // Tests the conversion of a JSON Doc containing a JSON Array to XML
- public void testConversionArray() {
- try {
- String jsonParm = JsonUtils.getJsonNodeValue(jsonReqArray, "requestDetails.requestParameters.ucpeInfo");
- System.out.println("testConversionArray(): json value: " + JsonUtils.prettyJson(jsonParm));
- String xmlOut = JsonUtils.json2xml(jsonParm);
- System.out.println("testConversionArray(): json parameters to xml: " + xmlOut);
- // strip all the non-data whitespace
- xmlOut = xmlOut.replaceAll(">\\s*<", "><");
- System.out.println("testConversionArray(): XML after removing whitespace:" + xmlOut);
- String xmlTest = xmlArrayReq.replaceAll(">\\s*<", "><");
+ public void shouldAddJsonValue() throws Exception {
+ // given
+ String json = JsonUtils.xml2json(XML_REQ);
+ String key = "vnf-request.request-info.comment";
+ String value = "Some comment";
+ // when
+ String jsonUpd = JsonUtils.addJsonValue(json, key, value);
+ // then
+ String extractedValue = JsonUtils.getJsonValue(jsonUpd, key);
+ assertThat(extractedValue).isEqualTo(value);
+ }
- Diff diffXml;
- try {
- diffXml = new Diff(xmlTest, xmlOut);
- Assert.assertTrue(diffXml.similar());
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
+ @Test
+ public void shouldIgnoreAddIfFieldAlreadyExists() throws Exception {
+ // given
+ String json = JsonUtils.xml2json(XML_REQ);
+ String key = "vnf-request.vnf-inputs.vnf-name";
+ String newValue = "STMTN5MMSC22";
+ String oldValue = JsonUtils.getJsonValue(json, key);
+ // when
+ String jsonUpd = JsonUtils.addJsonValue(json, key, newValue);
+ // then
+ String extractedValue = JsonUtils.getJsonValue(jsonUpd, key);
+ assertThat(extractedValue).isEqualTo(oldValue).isNotEqualTo(newValue);
+ }
+
+ @Test
+ public void shouldUpdateValueInJson() throws Exception {
+ // given
+ String json = JsonUtils.xml2json(XML_REQ);
+ String key = "vnf-request.vnf-inputs.vnf-name";
+ String newValue = "STMTN5MMSC22";
+ String oldValue = JsonUtils.getJsonValue(json, key);
+ // when
+ String jsonUpd = JsonUtils.updJsonValue(json, key, newValue);
+ // then
+ String extractedValue = JsonUtils.getJsonValue(jsonUpd, key);
+ assertThat(extractedValue).isNotEqualTo(oldValue).isEqualTo(newValue);
+ }
+
+ @Test
+ public void shouldDeleteValue() throws Exception {
+ // given
+ String json = JsonUtils.xml2json(XML_REQ);
+ String key = "vnf-request.vnf-inputs.vnf-name";
+ String oldValue = JsonUtils.getJsonValue(json, key);
+ // when
+ String jsonUpd = JsonUtils.delJsonValue(json, key);
+ // then
+ String extractedValue = JsonUtils.getJsonValue(jsonUpd, key);
+ assertThat(extractedValue).isNotEqualTo(oldValue).isNull();
+ }
+
+ @Test
+ public void shouldReturnOriginalJsonWhenTryingToRemoveNonexistentField() throws Exception {
+ // given
+ String json = JsonUtils.xml2json(XML_REQ);
+ String key = "vnf-request.vnf-inputs.does-not-exist";
+ // when
+ String jsonUpd = JsonUtils.delJsonValue(json, key);
+ // then
+ assertThat(jsonUpd).isEqualTo(json);
+ }
+
+ @Test
+ public void shouldConvertXmlToJsonAndBackToSameXmlExtractedFromTheRequest() throws Exception {
+ // given
+ String value = JsonUtils.getJsonValue(jsonReq, "variables.bpmnRequest.value");
+ String xmlReq = XmlTool.removeNamespaces(XmlTool.normalize(value));
+ // when
+ String json = JsonUtils.xml2json(xmlReq);
+ String xmlOut = JsonUtils.json2xml(json);
+ // then
+ Diff diffXml = DiffBuilder.compare(xmlReq).withTest(xmlOut).ignoreWhitespace()
+ .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build();
+ assertThat(diffXml.hasDifferences()).withFailMessage(diffXml.toString()).isFalse();
+ }
+
+ @Test
+ public void shouldConvertJsonContainingArrayToXml() throws Exception {
+ // when
+ String jsonParm = JsonUtils.getJsonNodeValue(jsonReqArray, "requestDetails.requestParameters.ucpeInfo");
+ String xmlOut = JsonUtils.json2xml(jsonParm);
+ // then
+ Diff diffXml = DiffBuilder.compare(XML_ARRAY_REQ).withTest(xmlOut).ignoreWhitespace()
+ .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName)).checkForSimilar().build();
+ assertThat(diffXml.hasDifferences()).withFailMessage(diffXml.toString()).isFalse();
}
}
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java
index 862cb76146..9730b129be 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/TestBaseTask.java
@@ -35,6 +35,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.openecomp.mso.bpmn.core.utils.CamundaDBSetup;
import org.openecomp.mso.logger.MsoLogger;
/**
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/utils/CamundaDBSetup.java
index 9a8cad6b86..f29ccc75e0 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/utils/CamundaDBSetup.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.bpmn.core;
+package org.openecomp.mso.bpmn.core.utils;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -35,9 +35,6 @@ public class CamundaDBSetup {
private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
private CamundaDBSetup() {
- /**
- * Constructor.
- */
}
public static synchronized void configure() throws SQLException {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
index 3c40003dd0..6f6d2972d1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
@@ -757,12 +757,16 @@ public class ServiceInstances {
// }
// TODO need to make this a configurable property
- String defaultServiceModelName = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
+ String defaultServiceModelName = "*";
+ String defaultSourceServiceModelName = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
Service serviceRecord;
ModelInfo modelInfo = msoRequest.getModelInfo();
if(msoRequest.getALaCarteFlag()){
- serviceRecord = db.getServiceByModelName(defaultServiceModelName);
+ serviceRecord = db.getServiceByModelName(defaultSourceServiceModelName);
+ if (serviceRecord == null) {
+ serviceRecord = db.getServiceByModelName(defaultServiceModelName);
+ }
}else{
serviceRecord = db.getServiceByModelUUID(modelInfo.getModelVersionId()); // ModelVersionId is not required in v3
if(serviceRecord == null) {
@@ -778,12 +782,16 @@ public class ServiceInstances {
RequestParameters reqParam = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters();
if(reqParam!=null && reqParam.isaLaCarteSet() && recipe==null){
return null;
- }else if (recipe == null) { //aLaCarte wasn't sent, so we'll try the default
+ }
+
+ //aLaCarte wasn't sent, so we'll try the default
+ serviceRecord = db.getServiceByModelName(defaultSourceServiceModelName);
+ if (serviceRecord == null) {
serviceRecord = db.getServiceByModelName(defaultServiceModelName);
- recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
}
- if(modelInfo.getModelVersionId() == null) {
+ recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
+ if(modelInfo.getModelVersionId() == null) {
modelInfo.setModelVersionId(serviceRecord.getModelUUID());
}
if(recipe==null){