aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java6
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java19
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json53
3 files changed, 72 insertions, 6 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
index 4fee1f909b..173e776af9 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
@@ -34,7 +34,6 @@ import org.onap.so.adapters.nwrest.ContrailNetwork;
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
-import org.onap.so.adapters.nwrest.NetworkTechnology;
import org.onap.so.adapters.nwrest.ProviderVlanNetwork;
import org.onap.so.adapters.nwrest.RollbackNetworkRequest;
import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
@@ -261,7 +260,7 @@ public class NetworkAdapterObjectMapper {
* @param L3Network
* @return List<org.onap.so.openstack.beans.Subnet>
*/
- private List<Subnet> buildOpenstackSubnetList(L3Network l3Network) {
+ protected List<Subnet> buildOpenstackSubnetList(L3Network l3Network) {
List<org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet> subnets = l3Network.getSubnets();
List<org.onap.so.openstack.beans.Subnet> subnetList = new ArrayList<org.onap.so.openstack.beans.Subnet>();
@@ -292,9 +291,10 @@ public class NetworkAdapterObjectMapper {
.setCidr(subnet.getNetworkStartAddress().concat(FORWARD_SLASH).concat(subnet.getCidrMask()));
List<org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute> hostRouteList = subnet.getHostRoutes();
List<org.onap.so.openstack.beans.HostRoute> openstackHostRouteList = new ArrayList<>();
- org.onap.so.openstack.beans.HostRoute openstackHostRoute = new org.onap.so.openstack.beans.HostRoute();
+ org.onap.so.openstack.beans.HostRoute openstackHostRoute = null;
// TODO only 2 fields available on openstack object. Confirm it is sufficient or add as needed
for (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute hostRoute : hostRouteList) {
+ openstackHostRoute = new org.onap.so.openstack.beans.HostRoute();
openstackHostRoute.setNextHop(hostRoute.getNextHop());
openstackHostRoute.setPrefix(hostRoute.getRoutePrefix());
// add host route to the list
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
index ccd677c80e..d6485bd57f 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java
@@ -21,8 +21,7 @@ package org.onap.so.client.adapter.network.mapper;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.junit.Assert.*;
-import static org.mockito.ArgumentMatchers.isA;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doReturn;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
@@ -39,7 +38,6 @@ import org.onap.so.adapters.nwrest.ContrailNetwork;
import org.onap.so.adapters.nwrest.CreateNetworkRequest;
import org.onap.so.adapters.nwrest.CreateNetworkResponse;
import org.onap.so.adapters.nwrest.DeleteNetworkRequest;
-import org.onap.so.adapters.nwrest.NetworkTechnology;
import org.onap.so.adapters.nwrest.ProviderVlanNetwork;
import org.onap.so.adapters.nwrest.RollbackNetworkRequest;
import org.onap.so.adapters.nwrest.UpdateNetworkRequest;
@@ -385,4 +383,19 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup {
assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("messageId")
.ignoring("msoRequest.requestId").ignoring("networkParams"));
}
+
+ @Test
+ public void buildOpenstackSubnetListMultipleHostRoutesTest() throws Exception {
+
+ ObjectMapper omapper = new ObjectMapper();
+ String l3NetworkJson =
+ new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "l3-network-multiple-subnets.json")));
+ L3Network l3Network = omapper.readValue(l3NetworkJson, L3Network.class);
+
+ List<org.onap.so.openstack.beans.Subnet> subnets =
+ SPY_networkAdapterObjectMapper.buildOpenstackSubnetList(l3Network);
+ assertEquals("192.168.0.0/16", subnets.get(0).getHostRoutes().get(0).getPrefix());
+ assertEquals("192.168.1.5/16", subnets.get(0).getHostRoutes().get(1).getPrefix());
+
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json
new file mode 100644
index 0000000000..e9b25ff266
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json
@@ -0,0 +1,53 @@
+{
+ "network-id" : "aNetworkId",
+ "cascaded" : false,
+ "cloud-params" : { },
+ "network-name" : "aNetworkName",
+ "neutron-network-id" : null,
+ "network-type" : "aNetworkType",
+ "network-technology" : "aNetworkTechnology",
+ "network-role" : "",
+ "is-bound-to-vpn" : false,
+ "service-id" : "aServiceId",
+ "network-role-instance" : 0,
+ "orchestration-status" : "ACTIVE",
+ "heat-stack-id" : null,
+ "contrail-network-fqdn" : null,
+ "network-policies" : [ ],
+ "contrail-network-route-table-references" : [ ],
+ "widget-model-id" : null,
+ "widget-model-version" : null,
+ "physical-network-name" : "pNetworkName",
+ "is-provider-network" : false,
+ "is-shared-network" : false,
+ "is-external-network" : false,
+ "self-link" : "/",
+ "operational-status" : null,
+ "subnets" : [ {
+ "subnet-id" : "subnetId1",
+ "subnet-name" : "aSubnetName1",
+ "neutron-subnet-id" : null,
+ "gateway-address" : "192.168.1.1",
+ "network-start-address" : "192.168.1.2",
+ "cidr-mask" : "10",
+ "ip-version" : "4",
+ "orchestration-status" : "ACTIVE",
+ "dhcp-enabled" : true,
+ "dhcp-start" : "192.168.1.2",
+ "dhcp-end" : "192.168.1.16",
+ "subnet-role" : "",
+ "ip-assignment-direction" : "true",
+ "subnet-sequence" : null,
+ "host-routes": [{
+ "host-route-id": "hrId1",
+ "route-prefix": "192.168.0.0/16",
+ "next-hop": "192.168.1.1",
+ "next-hop-type": null
+ }, {
+ "host-route-id": "hrId2",
+ "route-prefix": "192.168.1.5/16",
+ "next-hop": "192.168.1.1",
+ "next-hop-type": null
+ }]
+ }]
+} \ No newline at end of file