aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-network-adapter/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-network-adapter/src/test/java/org')
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/BpelRestClientTest.java97
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeqTest.java36
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefTest.java39
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRouteTest.java40
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutesTest.java40
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImplTest.java92
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImplTest.java1193
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java657
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java298
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java111
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBeanTest.java41
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionTest.java48
12 files changed, 0 insertions, 2692 deletions
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/BpelRestClientTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/BpelRestClientTest.java
deleted file mode 100644
index 9ab6ce6a70..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/BpelRestClientTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei 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.adapters.network;
-
-import org.junit.Test;
-
-public class BpelRestClientTest {
-
- BpelRestClient bpelRestClient = new BpelRestClient();
-
- @Test
- public void getSocketTimeoutTest() throws Exception {
- bpelRestClient.getSocketTimeout();
- }
-
- @Test
- public void setSocketTimeoutTest() throws Exception {
- bpelRestClient.setSocketTimeout(300);
- }
-
- @Test
- public void getConnectTimeoutTest() throws Exception {
- bpelRestClient.getConnectTimeout();
- }
-
- @Test
- public void setConnectTimeoutTest() throws Exception {
- bpelRestClient.setConnectTimeout(200);
- }
-
- @Test
- public void getRetryCountTest() throws Exception {
- bpelRestClient.getRetryCount();
- }
-
- @Test
- public void setRetryCountTest() throws Exception {
- bpelRestClient.setRetryCount(3);
- }
-
- @Test
- public void getRetryIntervalTest() throws Exception {
- bpelRestClient.getRetryInterval();
- }
-
- @Test
- public void setRetryIntervalTest() throws Exception {
- bpelRestClient.setRetryInterval(3);
- }
-
- @Test
- public void getCredentialsTest() throws Exception {
- bpelRestClient.getCredentials();
- }
-
- @Test
- public void setCredentialsTest() throws Exception {
- bpelRestClient.setCredentials("test");
- }
-
- @Test
- public void getRetryListTest() throws Exception {
- bpelRestClient.getRetryList();
- }
-
- @Test
- public void setRetryListTest() throws Exception {
- bpelRestClient.setRetryList("retry list");
- }
-
- @Test
- public void getLastResponseCodeTest() throws Exception {
- bpelRestClient.getLastResponseCode();
- }
-
- @Test
- public void getLastResponseTest() throws Exception {
- bpelRestClient.getLastResponse();
- }
-} \ No newline at end of file
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeqTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeqTest.java
deleted file mode 100644
index e407df8267..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeqTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * ============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.adapters.network;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-public class ContrailPolicyRefSeqTest {
- @Test
- public void ContrailPolicyRefSeqJson_Test()
- {
- ContrailPolicyRefSeq cprs = new ContrailPolicyRefSeq("majorVersion 1","minorVersion 0.02");
- assertTrue(cprs.toString().contains("majorVersion 1"));
- assertTrue(cprs.toString().contains("minorVersion 0.02"));
- }
-
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefTest.java
deleted file mode 100644
index 674dd35974..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailPolicyRefTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * ============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.adapters.network;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-public class ContrailPolicyRefTest {
-
- @Test
- public void ContrailPolicyRef_Test()
- {
- ContrailPolicyRef ref = new ContrailPolicyRef();
- ref.populate("majorVersion 1", "minorVersion 0.02");
- String strJson = ref.toJsonString();
- assertTrue(strJson.contains("majorVersion 1"));
- assertTrue(strJson.contains("minorVersion 0.02"));
- }
-
-} \ No newline at end of file
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRouteTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRouteTest.java
deleted file mode 100644
index ea173f0553..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRouteTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.adapters.network;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.openecomp.mso.openstack.beans.HostRoute;
-
-public class ContrailSubnetHostRouteTest {
-
- private ContrailSubnetHostRoute cshr = new ContrailSubnetHostRoute();
- HostRoute hr = new HostRoute();
- @Test
- public void testContrailSubnetHostRoute() {
-
- cshr.setPrefix("prefix");
- cshr.setNextHop("nextHop");
- assertEquals(cshr.getPrefix(), "prefix");
- assertEquals(cshr.getNextHop(), "nextHop");
- assert (cshr.toString() != null);
- cshr.populateWith(hr);
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutesTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutesTest.java
deleted file mode 100644
index df345d83be..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutesTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.adapters.network;
-
-import static org.junit.Assert.*;
-
-import java.util.List;
-
-import org.junit.Test;
-
-public class ContrailSubnetHostRoutesTest {
-
- ContrailSubnetHostRoutes cshr = new ContrailSubnetHostRoutes();
- List<ContrailSubnetHostRoute> host_routes;
- StringBuilder buf = new StringBuilder();
- @Test
- public void testContrailSubnetHostRoutes() {
- cshr.setHost_routes(host_routes);
- assertEquals(cshr.getHost_routes(), host_routes);
- assert (cshr.toString() != null);
- }
-} \ No newline at end of file
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImplTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImplTest.java
deleted file mode 100644
index 197840fdc9..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImplTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.adapters.network;
-
-import java.util.ArrayList;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-
-public class MsoNetworkAdapterAsyncImplTest {
-
- @Test
- public void healthCheckATest() {
- MsoNetworkAdapterAsyncImpl mNAAimpl = new MsoNetworkAdapterAsyncImpl();
- mNAAimpl.healthCheckA();
- }
-
- @Test
- @Ignore // 1802 merge
- public void rollbackNetworkATest() {
- NetworkRollback nrb = new NetworkRollback();
- nrb.setCloudId("cloudId");
- nrb.setMsoRequest(new MsoRequest());
- nrb.setModelCustomizationUuid("modelCustomizationUuid");
- nrb.setNetworkCreated(true);
- nrb.setNetworkId("networkId");
- nrb.setNetworkName("networkName");
- nrb.setNetworkStackId("networkStackId");
- nrb.setNetworkType("networkType");
- nrb.setNeutronNetworkId("neutronNetworkId");
- nrb.setPhysicalNetwork("physicalNetwork");
- nrb.setTenantId("tenantId");
- nrb.setVlans(new ArrayList<>());
-
- MsoNetworkAdapterAsyncImpl impl = new MsoNetworkAdapterAsyncImpl();
- impl.rollbackNetworkA(nrb, "messageId", "/notificationUrl");
- }
-
- @Test
- @Ignore // 1802 merge
- public void deleteNetworkATest() {
- MsoNetworkAdapterAsyncImpl impl = new MsoNetworkAdapterAsyncImpl();
- impl.deleteNetworkA("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "messageId", new MsoRequest(), "/notificationUrl");
- }
-
- @Test
- @Ignore // 1802 merge
- public void updateNetworkATest() {
- MsoNetworkAdapterAsyncImpl impl = new MsoNetworkAdapterAsyncImpl();
- impl.updateNetworkA("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), "messageId",
- new MsoRequest(), "/notificationUrl");
- }
-
- @Test
- @Ignore // 1802 merge
- public void queryNetworkATest() {
- MsoNetworkAdapterAsyncImpl impl = new MsoNetworkAdapterAsyncImpl();
- impl.queryNetworkA("cloudSiteId", "tenantId", "networkNameOrId", "messageId", new MsoRequest(),
- "/notificationUrl");
- }
-
- @Test
- @Ignore // 1802 merge
- public void createNetworkATest() {
- MsoNetworkAdapterAsyncImpl impl = new MsoNetworkAdapterAsyncImpl();
- impl.createNetworkA("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), "messageId",
- new MsoRequest(), "/notificationUrl");
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImplTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImplTest.java
deleted file mode 100644
index 1692c0bcfa..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImplTest.java
+++ /dev/null
@@ -1,1193 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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=========================================================
- */
-
-package org.openecomp.mso.adapters.network;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyList;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import javax.xml.ws.Holder;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.adapters.network.exceptions.NetworkException;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.cloud.CloudSite;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.openstack.beans.HeatStatus;
-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.StackInfo;
-import org.openecomp.mso.openstack.beans.Subnet;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.utils.MsoHeatUtils;
-import org.openecomp.mso.openstack.utils.MsoHeatUtilsWithUpdate;
-import org.openecomp.mso.openstack.utils.MsoNeutronUtils;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesException;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-public class MsoNetworkAdapterImplTest {
-
- @Test
- public void createNetworkImplTest_CloudSiteNotPresent() throws NetworkException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkThrowsException()
- throws NetworkException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenThrow(exception);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkExists_FailIfExistsTrue()
- throws NetworkException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = Mockito.mock(NetworkInfo.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkExists_FailIfExistsNotTrue()
- throws NetworkException, MsoException {
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = Mockito.mock(NetworkInfo.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, false, true, null, null, networkId, neutronNetworkId, subnetIdMap,
- rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_NetInfoDoesntExist_CreateNetworkException()
- throws NetworkException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = null;
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- when(impl.neutron.createNetwork(any(), any(), any(), any(), any(), any())).thenThrow(exception);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_NetInfoDoesntExist_CreateNetwork()
- throws NetworkException, MsoException {
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = Mockito.mock(NetworkInfo.class);
- when(netInfo.getId()).thenReturn("Id");
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(null);
- when(impl.neutron.createNetwork(any(), any(), any(), any(), any(), anyList())).thenReturn(netInfo);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, networkId, neutronNetworkId, subnetIdMap,
- rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_NeutronMode_NetInfoExists()
- throws NetworkException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = null;
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNull() throws NetworkException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_ThrowMsoPropsException()
- throws NetworkException, MsoPropertiesException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplate");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoPropertiesException exception = Mockito.mock(MsoPropertiesException.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenThrow(exception);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull()
- throws NetworkException, MsoPropertiesException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoPropertiesException exception = Mockito.mock(MsoPropertiesException.class);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_QueryStackThrowsException()
- throws NetworkException, MsoPropertiesException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- MsoException exception = Mockito.mock(MsoException.class);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(anyString(), anyString(), anyString())).thenThrow(exception);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_QueryStack_HeatStackNull()
- throws NetworkException, MsoPropertiesException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- StackInfo heatStack = null;
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(anyString(), anyString(), anyString())).thenReturn(heatStack);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_QueryStack_HeatStackNotNull_FailIfExists()
- throws NetworkException, MsoPropertiesException, MsoException {
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- StackInfo heatStack = Mockito.mock(StackInfo.class);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(anyString(), anyString(), anyString())).thenReturn(heatStack);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, true, true, null, null, null, null, null, null);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_QueryStack_HeatStackNotNull_DontFailIfExists()
- throws NetworkException, MsoPropertiesException, MsoException {
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- StackInfo heatStack = Mockito.mock(StackInfo.class);
- Map<String, Object> outputs = new HashMap<>();
- outputs.put("subnet", "");
- when(heatStack.getOutputs()).thenReturn(outputs);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(anyString(), anyString(), anyString())).thenReturn(heatStack);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, false, true, null, null, networkId, neutronNetworkId, subnetIdMap,
- rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void createNetworkImplTest_CloudSitePresent_HeatMode_HeatTemplateNotNull_QueryStack_HeatStackNotNull_DontFailIfExists_Validate()
- throws NetworkException, MsoPropertiesException, MsoException {
- List<Subnet> subnets = new ArrayList<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- HeatTemplate heatTemplate = Mockito.mock(HeatTemplate.class);
- when(heatTemplate.toString()).thenReturn("heatTemplate");
- when(heatTemplate.getHeatTemplate()).thenReturn("heatTemplateaic");
- when(catalogDB.getHeatTemplateByArtifactUuidRegularQuery(any())).thenReturn(heatTemplate);
- MsoJavaProperties props = Mockito.mock(MsoJavaProperties.class);
- when(impl.msoPropertiesFactory.getMsoJavaProperties(any())).thenReturn(props);
- when(props.getProperty(anyString(), anyString())).thenReturn("aic");
- StackInfo heatStack = Mockito.mock(StackInfo.class);
- Map<String, Object> outputs = new HashMap<>();
- outputs.put("subnet", "");
- when(heatStack.getOutputs()).thenReturn(outputs);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(anyString(), anyString(), anyString())).thenReturn(heatStack);
- try {
- impl.createNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkName",
- "physicalNetworkName", null, false, true, subnets, null, networkId, neutronNetworkId, subnetIdMap,
- rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSiteNotPresent() throws NetworkException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkThrowsException()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenThrow(exception);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkReturnsNull()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(null);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkDoesntExist_UpdateNetworkException()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = new NetworkInfo(null);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- when(impl.neutron.updateNetwork(any(), any(), any(), any(), any(), anyList())).thenThrow(exception);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkDoesntExist_UpdateNetwork()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo netInfo = new NetworkInfo(null);
- NetworkInfo mockedNetworkInfo = Mockito.mock(NetworkInfo.class);
- when(mockedNetworkInfo.getId()).thenReturn("Id");
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(netInfo);
- when(impl.neutron.updateNetwork(any(), any(), any(), any(), any(), anyList())).thenReturn(mockedNetworkInfo);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_HeatMode_QueryStackThrowException()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heatWithUpdate = Mockito.mock(MsoHeatUtilsWithUpdate.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.heatWithUpdate.queryStack(any(), any(), any())).thenThrow(exception);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_HeatMode_QueryStackReturnNull()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heatWithUpdate = Mockito.mock(MsoHeatUtilsWithUpdate.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.heatWithUpdate.queryStack(any(), any(), any())).thenReturn(null);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void updateNetworkImplTest_CloudSitePresent_HeatMode_QueryStackReturnInfo()
- throws NetworkException, MsoException {
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- Holder<NetworkRollback> rollback = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("HEAT");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heatWithUpdate = Mockito.mock(MsoHeatUtilsWithUpdate.class);
- MsoException exception = Mockito.mock(MsoException.class);
- StackInfo stackInfo = Mockito.mock(StackInfo.class);
- when(impl.heatWithUpdate.queryStack(any(), any(), any())).thenReturn(stackInfo);
- try {
- impl.updateNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId",
- "networkName", "physicalNetworkName", null, null, null, subnetIdMap, rollback);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSiteNotPresent() throws NetworkException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkThrowsException()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.heat.queryStack(any(), any(), any())).thenThrow(exception);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkHeatStackNull()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(null);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkHeatStackReturned()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- StackInfo stackInfo = Mockito.mock(StackInfo.class);
- when(stackInfo.getStatus()).thenReturn(HeatStatus.CREATED);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(stackInfo);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkHeatStackNull_QueryNeutronNetworkThrows()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(null);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenThrow(exception);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkHeatStackNull_QueryNeutronNetworkReturns()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(null);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- NetworkInfo networkInfo = Mockito.mock(NetworkInfo.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(networkInfo);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void queryNetworkImplTest_CloudSitePresent_NeutronMode_QueryNetworkHeatStackNull_QueryNeutronNetworkNull()
- throws NetworkException, MsoException {
- Holder<Boolean> networkExists = new Holder<>();
- Holder<String> networkId = new Holder<>();
- Holder<String> neutronNetworkId = new Holder<>();
- Holder<NetworkStatus> status = new Holder<>();
- Holder<List<Integer>> vlans = new Holder<>();
- Holder<Map<String, String>> subnetIdMap = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- CloudSite cloudSite = new CloudSite();
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(cloudSite);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase catalogDB = Mockito.mock(CatalogDatabase.class);
- NetworkResource networkResource = Mockito.mock(NetworkResource.class);
- when(networkResource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(networkResource.getNeutronNetworkType()).thenReturn("BASIC");
- doReturn(catalogDB).when(impl).getCatalogDB();
- doReturn(networkResource).when(impl).networkCheck(any(), anyLong(), anyString(), anyString(), anyString(),
- anyString(), anyList(), anyList(), any());
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(null);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.queryNetwork(any(), any(), any())).thenReturn(null);
- try {
- impl.queryNetwork("cloudSiteId", "tenantId", "networkNameOrId", null, networkExists, networkId,
- neutronNetworkId, status, vlans, subnetIdMap);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent_NullOrNotPresentCondition() throws NetworkException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- try {
- impl.deleteNetwork(null, null, "networkType", "modelCustomizationUuid", null, null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent() throws NetworkException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
-
- try {
- impl.deleteNetwork("cloudSiteId", "tenantId", "networkType", "modelCustomizationUuid", "networkId", null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent_DBGetNetworkResource_DeleteNetworkThrows() throws NetworkException, MsoException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase db = Mockito.mock(CatalogDatabase.class);
- when(impl.getCatalogDB()).thenReturn(db);
- NetworkResource resource = Mockito.mock(NetworkResource.class);
- when(resource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(db.getNetworkResource(any())).thenReturn(resource);
- MsoException exception = Mockito.mock(MsoException.class);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.deleteNetwork(any(), any(), any())).thenThrow(exception);
- try {
- impl.deleteNetwork("cloudSiteId", "tenantId", "networkType", null, "networkId", null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent_DBGetNetworkResource_NeutronDeleteNetwork() throws NetworkException, MsoException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase db = Mockito.mock(CatalogDatabase.class);
- when(impl.getCatalogDB()).thenReturn(db);
- NetworkResource resource = Mockito.mock(NetworkResource.class);
- when(resource.getOrchestrationMode()).thenReturn("NEUTRON");
- when(db.getNetworkResource(any())).thenReturn(resource);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.deleteNetwork(any(), any(), any())).thenReturn(true);
- try {
- impl.deleteNetwork("cloudSiteId", "tenantId", "networkType", null, "networkId", null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent_DBGetNetworkResource_ModeHeat_QueryStack_DeleteStack() throws NetworkException, MsoException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase db = Mockito.mock(CatalogDatabase.class);
- when(impl.getCatalogDB()).thenReturn(db);
- NetworkResource resource = Mockito.mock(NetworkResource.class);
- when(resource.getOrchestrationMode()).thenReturn("HEAT");
- when(db.getNetworkResource(any())).thenReturn(resource);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.deleteNetwork(any(), any(), any())).thenReturn(true);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- StackInfo stackInfo = new StackInfo();
- stackInfo.setStatus(HeatStatus.CREATED);
- when(impl.heat.queryStack(any(), any(), any())).thenReturn(stackInfo);
- StackInfo stackInfoDeleted = new StackInfo();
- stackInfo.setStatus(HeatStatus.DELETING);
- when(impl.heat.deleteStack(any(), any(), any(), anyBoolean())).thenReturn(stackInfoDeleted);
- try {
- impl.deleteNetwork("cloudSiteId", "tenantId", "networkType", null, "networkId", null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-
- @Test
- public void deleteNetworkImplTest_CloudSiteNotPresent_DBGetNetworkResource_ModeHeat_QueryStackException() throws NetworkException, MsoException {
- Holder<Boolean> networkDeleted = new Holder<>();
- MsoNetworkAdapterImpl impl = Mockito.spy(MsoNetworkAdapterImpl.class);
- impl.cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- when(impl.cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(null);
- when(cloudConfig.getCloudSite(any())).thenReturn(cloudSiteOpt);
- impl.msoPropertiesFactory = Mockito.mock(MsoPropertiesFactory.class);
- CatalogDatabase db = Mockito.mock(CatalogDatabase.class);
- when(impl.getCatalogDB()).thenReturn(db);
- NetworkResource resource = Mockito.mock(NetworkResource.class);
- when(resource.getOrchestrationMode()).thenReturn("HEAT");
- when(db.getNetworkResource(any())).thenReturn(resource);
- impl.neutron = Mockito.mock(MsoNeutronUtils.class);
- when(impl.neutron.deleteNetwork(any(), any(), any())).thenReturn(true);
- impl.heat = Mockito.mock(MsoHeatUtils.class);
- StackInfo stackInfo = new StackInfo();
- stackInfo.setStatus(HeatStatus.CREATED);
- MsoException exception = Mockito.mock(MsoException.class);
- when(impl.heat.queryStack(any(), any(), any())).thenThrow(exception);
- try {
- impl.deleteNetwork("cloudSiteId", "tenantId", "networkType", null, "networkId", null,
- networkDeleted);
- } catch (Exception e) {
-
- }
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java
deleted file mode 100644
index 182190b1a7..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java
+++ /dev/null
@@ -1,657 +0,0 @@
-/*-
- * ============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.adapters.network;
-
-import static org.junit.Assert.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.Response;
-import javax.xml.ws.Holder;
-
-import org.apache.http.HttpStatus;
-import org.apache.http.protocol.HTTP;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.openecomp.mso.adapters.network.NetworkAdapterRest.CreateNetworkTask;
-import org.openecomp.mso.adapters.network.NetworkAdapterRest.DeleteNetworkTask;
-import org.openecomp.mso.adapters.network.NetworkAdapterRest.RollbackNetworkTask;
-import org.openecomp.mso.adapters.network.NetworkAdapterRest.UpdateNetworkTask;
-import org.openecomp.mso.adapters.network.exceptions.NetworkException;
-import org.openecomp.mso.adapters.nwrest.ContrailNetwork;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.NetworkTechnology;
-import org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork;
-import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
-import org.openecomp.mso.openstack.beans.RouteTarget;
-import org.openecomp.mso.openstack.beans.Subnet;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-//@RunWith(PowerMockRunner.class)
-@PrepareForTest({NetworkAdapterRest.class, CreateNetworkTask.class, CreateNetworkRequest.class, DeleteNetworkTask.class, DeleteNetworkRequest.class})
-public class NetworkAdapterRestTest {
- @Mock
- private static CreateNetworkTask taskMock;
- @Mock
- private static CreateNetworkRequest reqMock;
- @Mock
- private static DeleteNetworkRequest delReqMock;
- @Mock
- private static DeleteNetworkTask delTaskMock;
- @Mock
- private static RollbackNetworkRequest rollbackReqMock;
- @Mock
- private static RollbackNetworkTask rollbackTaskMock;
-
- private static final String TESTING_KEYWORD = "___TESTING___";
-
- @Test
- public void NetworkAdapterRest_createNetwork_async_Test()
- {
- NetworkAdapterRest api = new NetworkAdapterRest();
- taskMock = PowerMockito.mock(CreateNetworkTask.class);
- reqMock = PowerMockito.mock(CreateNetworkRequest.class);
-
- try {
- PowerMockito.whenNew(CreateNetworkRequest.class).withAnyArguments().thenReturn(reqMock);
- PowerMockito.when(reqMock.isSynchronous()).thenReturn(false);
- PowerMockito.when(reqMock.getNetworkId()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- PowerMockito.when(reqMock.getCloudSiteId()).thenReturn(TESTING_KEYWORD);
- PowerMockito.when(reqMock.getTenantId()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- PowerMockito.when(reqMock.getNetworkType()).thenReturn("PROVIDER");
- PowerMockito.when(reqMock.getModelCustomizationUuid()).thenReturn("modelCustUuid");
- PowerMockito.when(reqMock.getNetworkName()).thenReturn("networkName");
-
- ProviderVlanNetwork vlan = new ProviderVlanNetwork();
- vlan.setPhysicalNetworkName("PhysicalNetworkName");
- vlan.setVlans(new ArrayList<Integer>(Arrays.asList(123,456,654,321)));
- PowerMockito.when(reqMock.getProviderVlanNetwork()).thenReturn(vlan);
-
- PowerMockito.when(reqMock.getFailIfExists()).thenReturn(true);
- PowerMockito.when(reqMock.getBackout()).thenReturn(false);
-
- List<Subnet> subnets = new ArrayList<Subnet>();
- Subnet s1 = new Subnet();
- s1.setSubnetName("Subnet1");
- subnets.add(s1);
- Subnet s2 = new Subnet();
- s1.setSubnetName("Subnet2");
- subnets.add(s2);
- Subnet s3 = new Subnet();
- s1.setSubnetName("Subnet3");
- subnets.add(s3);
- PowerMockito.when(reqMock.getSubnets()).thenReturn(subnets);
-
- MsoRequest msoRequest = new MsoRequest ();
- msoRequest.setRequestId("MSORequestID123");
- PowerMockito.when(reqMock.getMsoRequest()).thenReturn(msoRequest);
- // setup spy on CreateNetworkTask
-
- PowerMockito.whenNew(CreateNetworkTask.class).withArguments(reqMock).thenReturn(taskMock);
- PowerMockito.spy(taskMock);
-
- Response resp = api.createNetwork(new CreateNetworkRequest());
- assertEquals(resp.getStatus(),HttpStatus.SC_ACCEPTED);
-
- // test if another thread has executed run method
- //Mockito.verify(taskMock, Mockito.times(1)).run();
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
-
- }
-
- @Test
- public void NetworkAdapterRest_createNetwork_sync_Test()
- {
- NetworkAdapterRest api = new NetworkAdapterRest();
- // setup createNetwork parameter
- // setup sync to spy on run method
- CreateNetworkRequest req = new CreateNetworkRequest();
- req.setNetworkId("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- req.setCloudSiteId(TESTING_KEYWORD);
- req.setTenantId("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- req.setNetworkType("PROVIDER");
- req.setModelCustomizationUuid("modelCustUuid");
- req.setNetworkName("networkName");
- ProviderVlanNetwork vlan = new ProviderVlanNetwork();
- vlan.setPhysicalNetworkName("PhysicalNetworkName");
- vlan.setVlans(new ArrayList<Integer>(Arrays.asList(123,456,654,321)));
- req.setProviderVlanNetwork(vlan);
- req.setFailIfExists(true);
- req.setBackout(false);
- List<Subnet> subnets = new ArrayList<Subnet>();
- Subnet s1 = new Subnet();
- s1.setSubnetName("Subnet1");
- subnets.add(s1);
- Subnet s2 = new Subnet();
- s1.setSubnetName("Subnet2");
- subnets.add(s2);
- Subnet s3 = new Subnet();
- s1.setSubnetName("Subnet3");
- subnets.add(s3);
- req.setSubnets(subnets);
- MsoRequest msoRequest = new MsoRequest ();
- msoRequest.setRequestId("MSORequestID123");
- req.setMsoRequest(msoRequest);
- // set sync
- req.setNotificationUrl(null);
- // setup spy on CreateNetworkTask
- CreateNetworkTask task = api.new CreateNetworkTask(req);
-
- try {
- PowerMockito.whenNew(CreateNetworkTask.class).withArguments(req).thenReturn(task);
- Response resp = api.createNetwork(req);
-
- CreateNetworkResponse cnresp = (CreateNetworkResponse) resp.getEntity();
-
- assertEquals(cnresp.getNetworkFqdn(), "086f70b6-28fb-11e6-8260-0017f20fe1b8");
- assertEquals(cnresp.getNetworkId(), "b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- assertEquals(cnresp.getNeutronNetworkId(), "55e55884-28fa-11e6-8971-0017f20fe1b8");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void NetworkAdapterRest_deleteNetwork_async_Test()
- {
- NetworkAdapterRest api = new NetworkAdapterRest();
- delTaskMock = PowerMockito.mock(DeleteNetworkTask.class);
- delReqMock = PowerMockito.mock(DeleteNetworkRequest.class);
-
- try{
- PowerMockito.whenNew(DeleteNetworkRequest.class).withAnyArguments().thenReturn(delReqMock);
- PowerMockito.when(delReqMock.isSynchronous()).thenReturn(false);
- PowerMockito.when(delReqMock.getCloudSiteId()).thenReturn(TESTING_KEYWORD);
- PowerMockito.when(delReqMock.getNetworkId()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- PowerMockito.when(delReqMock.getMessageId()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
-
- PowerMockito.whenNew(DeleteNetworkTask.class).withArguments(delReqMock).thenReturn(delTaskMock);
- PowerMockito.spy(delTaskMock);
-
- Response resp = api.deleteNetwork("b4a6af8c-a22b-45d5-a880-29527f8f59a7", delReqMock);
- assertEquals(resp.getStatus(), HttpStatus.SC_ACCEPTED);
-
- // test if another thread has executed run method
- // Mockito.verify(delTaskMock, Mockito.times(1)).run();
-
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
-
- @Test
- public void NetworkAdapterRest_deleteNetwork_sync_Test()
- {
- NetworkAdapterRest api = new NetworkAdapterRest();
- DeleteNetworkRequest req = new DeleteNetworkRequest();
- req.setNotificationUrl(null);
- req.setCloudSiteId(TESTING_KEYWORD);
- req.setNetworkId("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- req.setMessageId("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
-
- DeleteNetworkTask task = api.new DeleteNetworkTask(req);
-
- try {
- PowerMockito.whenNew(DeleteNetworkTask.class).withArguments(req).thenReturn(task);
- PowerMockito.spy(task);
- Response resp = api.deleteNetwork("b4a6af8c-a22b-45d5-a880-29527f8f59a7", req);
-
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void NetworkAdapterRest_queryNetwork_Test()
- {
- /*
- * test when network found as well as network not found
- */
- String networkStackId = "networkStackId";
- String skipAAI = "skipAAI";
- String requestId = "msoRequest.requestId";
- String serviceInstanceId = "msoRequest.serviceInstanceId";
- String aaiNetworkId = "aaiNetworkId";
- String cloudSiteId = "cloudSiteId";
- String tenantId = "tenantId";
- String networkNameOrId = "networkNameOrId";
- MsoRequest msoRequestMock = Mockito.mock(MsoRequest.class);
- try {
- PowerMockito.whenNew(MsoRequest.class).withArguments("msoRequest.requestId", "msoRequest.serviceInstanceId").thenReturn(msoRequestMock);
-
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- MsoRequest msoRequest = new MsoRequest("msoRequest.requestId", "msoRequest.serviceInstanceId");
- Holder<Boolean> networkExists = new Holder<Boolean>();
- Holder<String> networkId = new Holder<String>();
- Holder<String> neutronNetworkId = new Holder<String>();
- Holder<NetworkStatus> status = new Holder<NetworkStatus>();
- Holder<List<String>> routeTargets = new Holder<List<String>>();
- Holder<Map<String, String>> subnetIdMap = new Holder<Map<String, String>>();
-
- MsoNetworkAdapterImpl mockImpl = Mockito.mock(MsoNetworkAdapterImpl.class);
- CloudConfigFactory cloudConfigMock = Mockito.mock(CloudConfigFactory.class);
- MsoPropertiesFactory msoPropertiesFactoryMock = Mockito.mock(MsoPropertiesFactory.class);
-
- try {
- PowerMockito.whenNew(MsoPropertiesFactory.class).withAnyArguments().thenReturn(msoPropertiesFactoryMock);
- PowerMockito.whenNew(CloudConfigFactory.class).withAnyArguments().thenReturn(cloudConfigMock);
- PowerMockito.whenNew(MsoNetworkAdapterImpl.class).withArguments(msoPropertiesFactoryMock, cloudConfigMock).thenReturn(mockImpl);
-
- Mockito.doAnswer(new Answer<Void>() {
- @SuppressWarnings("unchecked")
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- System.out.println("called with arguments: " + Arrays.toString(args));
- Holder<Boolean> networkExists = (Holder<Boolean>) args[4];
- networkExists.value = Boolean.TRUE;
-
- Holder<String> networkId = (Holder<String>) args[5];
- networkId.value = "networkId";
-
- Holder<String> neutronNetworkId = (Holder<String>) args[6];
- neutronNetworkId.value = "neutronNetworkId";
-
- Holder<NetworkStatus> status = (Holder<NetworkStatus>) args[7];
- status.value = NetworkStatus.ACTIVE;
-
- Holder<List<String>> routeTargets = (Holder<List<String>>) args[8];
- routeTargets.value = new ArrayList<String>(Arrays.asList("routeTarget1","routeTarget2"));
-
- Holder<Map<String, String>> subnetIdMap = (Holder<Map<String, String>>) args[9];
- subnetIdMap.value = new HashMap<String,String>();
- subnetIdMap.value.put("Key1", "Val1");
- subnetIdMap.value.put("Key2", "Val2");
- subnetIdMap.value.put("Key3", "Val3");
-
- return null;
- }
- }).when(mockImpl).queryNetworkContrail(Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.any(MsoRequest.class),
- Mockito.anyObject(),
- Mockito.anyObject(),
- Mockito.anyObject(),
- Mockito.anyObject(),
- Mockito.anyObject(),
- Mockito.anyObject());
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- Response resp = api.queryNetwork(cloudSiteId, tenantId, networkStackId, skipAAI, requestId, serviceInstanceId, aaiNetworkId);
- QueryNetworkResponse entity = (QueryNetworkResponse) resp.getEntity();
-
- assertEquals(entity.getNetworkExists(), Boolean.TRUE);
- assertEquals(entity.getNetworkId(), "networkId");
- assertEquals(entity.getNeutronNetworkId(), "neutronNetworkId");
- assertEquals(entity.getNetworkStatus(), NetworkStatus.ACTIVE);
- assertEquals(entity.getRouteTargets().size(), 2);
- assertEquals(entity.getRouteTargets().get(0), "routeTarget1");
- assertEquals(entity.getRouteTargets().get(1), "routeTarget2");
-
- assertEquals(entity.getSubnetIdMap().size(), 3);
- assertEquals(entity.getSubnetIdMap().get("Key1"), "Val1");
- assertEquals(entity.getSubnetIdMap().get("Key2"), "Val2");
- assertEquals(entity.getSubnetIdMap().get("Key3"), "Val3");
- assertEquals(resp.getStatus(), HttpStatus.SC_OK);
- }
- catch (NetworkException e)
- {
- e.printStackTrace();
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- public void NetworkAdapterRest_rollBackNetwork_async_Test()
- {
- rollbackReqMock = PowerMockito.mock(RollbackNetworkRequest.class);
- rollbackTaskMock = PowerMockito.mock(RollbackNetworkTask.class);
- NetworkRollback ntRollbackMock = PowerMockito.mock(NetworkRollback.class);
- MsoNetworkAdapterImpl adapterImplMock = PowerMockito.mock(MsoNetworkAdapterImpl.class);
-
- try{
- PowerMockito.whenNew(RollbackNetworkRequest.class).withAnyArguments().thenReturn(rollbackReqMock);
- PowerMockito.when(rollbackReqMock.isSynchronous()).thenReturn(false);
- PowerMockito.when(rollbackReqMock.getMessageId()).thenReturn("Rollback succeeded !");
-
- PowerMockito.whenNew(RollbackNetworkTask.class).withArguments(rollbackReqMock).thenReturn(rollbackTaskMock);
- PowerMockito.spy(rollbackTaskMock);
-
- // PowerMockito.whenNew(NetworkRollback.class).withAnyArguments().thenReturn(ntRollbackMock);
- PowerMockito.when(rollbackReqMock.getNetworkRollback()).thenReturn(ntRollbackMock);
-
- PowerMockito.whenNew(MsoNetworkAdapterImpl.class).withAnyArguments().thenReturn(adapterImplMock);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- System.out.println("called with arguments: " + Arrays.toString(args));
- return null;
- }
- }).when(adapterImplMock).rollbackNetwork(ntRollbackMock);
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- Response resp = api.rollbackNetwork(new RollbackNetworkRequest());
-
- assertEquals(resp.getStatus(), HttpStatus.SC_ACCEPTED);
- // test if another thread has executed run method
- // Mockito.verify(rollbackTaskMock, Mockito.times(1)).run();
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- @Test
- public void NetworkAdapterRest_rollBackNetwork_sync_Test()
- {
- rollbackReqMock = PowerMockito.mock(RollbackNetworkRequest.class);
- rollbackTaskMock = PowerMockito.mock(RollbackNetworkTask.class);
-
- try
- {
- PowerMockito.whenNew(RollbackNetworkRequest.class).withAnyArguments().thenReturn(rollbackReqMock);
- PowerMockito.when(rollbackReqMock.isSynchronous()).thenReturn(true);
-
- PowerMockito.whenNew(RollbackNetworkTask.class).withArguments(rollbackReqMock).thenReturn(rollbackTaskMock);
- PowerMockito.when(rollbackTaskMock.getStatusCode()).thenReturn(HttpStatus.SC_OK);
- PowerMockito.when(rollbackTaskMock.getGenericEntityResponse()).thenReturn(null);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- System.out.println("run method called ");
- return null;
- }
- }).when(rollbackTaskMock).run();
- PowerMockito.spy(rollbackTaskMock);
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- Response resp = api.rollbackNetwork(new RollbackNetworkRequest());
-
- assertEquals(resp.getStatus(),HttpStatus.SC_OK);
- Mockito.verify(rollbackTaskMock, Mockito.times(1)).run();
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
-
-
- }
-
- @Test
- public void NetworkAdapterRest_updateNetwork_sync_TestString_Test()
- {
- UpdateNetworkRequest req = new UpdateNetworkRequest();
- req.setCloudSiteId(TESTING_KEYWORD);
- req.setTenantId("tenantId");
- req.setNotificationUrl(null);
- MsoRequest msoReq = new MsoRequest();
- msoReq.setRequestId("MsoRequestId");
- msoReq.setServiceInstanceId("serviceInstanceId");
- req.setMsoRequest(msoReq);
- req.setNetworkId("UpdateNetworkRequestNetworkId");
- req.setMessageId("UpdateNetworkMessageWithTestString");
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- UpdateNetworkTask task = api.new UpdateNetworkTask(req);
-
- try {
- PowerMockito.whenNew(UpdateNetworkTask.class).withArguments(req).thenReturn(task);
- Response resp = api.updateNetwork("UpdateNetworkRequestNetworkId", req);
-
- assertEquals(resp.getStatus(),HttpStatus.SC_OK);
- UpdateNetworkResponse unResp = (UpdateNetworkResponse) resp.getEntity();
- assertEquals(unResp.getNetworkId(),"UpdateNetworkRequestNetworkId");
- assertEquals(unResp.getMessageId(),"UpdateNetworkMessageWithTestString");
-
- Map<String, String> map = unResp.getSubnetMap();
- for (Map.Entry<String, String> entry : map.entrySet()) {
- String key = entry.getKey();
- if(key.equalsIgnoreCase("mickey"))
- {
- Object value = entry.getValue();
- assertEquals((String)value, "7");
- }
-
- if(key.equalsIgnoreCase("clyde"))
- {
- Object value = entry.getValue();
- assertEquals((String)value, "10");
- }
-
- if(key.equalsIgnoreCase("wayne"))
- {
- Object value = entry.getValue();
- assertEquals((String)value, "99");
- }
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void NetworkAdapterRest_updateNetwork_sync_ContrailRequest_Test()
- {
- try {
- MsoRequest msoReq = new MsoRequest();
- msoReq.setRequestId("MsoRequestId");
- msoReq.setServiceInstanceId("serviceInstanceId");
-
- UpdateNetworkRequest reqMock = PowerMockito.mock(UpdateNetworkRequest.class);
- PowerMockito.whenNew(UpdateNetworkRequest.class).withAnyArguments().thenReturn(reqMock);
- PowerMockito.when(reqMock.getCloudSiteId()).thenReturn("NON_"+TESTING_KEYWORD);
- PowerMockito.when(reqMock.getTenantId()).thenReturn("tenantId");
- PowerMockito.when(reqMock.getNetworkType()).thenReturn("NetworkType");
- PowerMockito.when(reqMock.getModelCustomizationUuid()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- PowerMockito.when(reqMock.getNetworkStackId()).thenReturn("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- PowerMockito.when(reqMock.getNetworkName()).thenReturn("NetworkName");
- PowerMockito.when(reqMock.getSubnets()).thenReturn(new ArrayList<Subnet>());
-
- PowerMockito.when(reqMock.isSynchronous()).thenReturn(true);
- PowerMockito.when(reqMock.getNetworkId()).thenReturn("UpdateNetworkRequestNetworkId");
- PowerMockito.when(reqMock.getMessageId()).thenReturn("UpdateNetworkMessageWithTestString");
- PowerMockito.when(reqMock.getMsoRequest()).thenReturn(msoReq);
- PowerMockito.when(reqMock.isContrailRequest()).thenReturn(true);
- ContrailNetwork cn = new ContrailNetwork();
- cn.setRouteTargets(new ArrayList<RouteTarget>());
- cn.setPolicyFqdns(new ArrayList<String>());
- cn.setRouteTableFqdns(new ArrayList<String>());
-
- PowerMockito.when(reqMock.getContrailNetwork()).thenReturn(cn);
-
- MsoNetworkAdapterImpl msoImplMock = PowerMockito.mock(MsoNetworkAdapterImpl.class);
- PowerMockito.whenNew(MsoNetworkAdapterImpl.class).withAnyArguments().thenReturn(msoImplMock);
-
- Mockito.doAnswer(new Answer<Void>() {
- @SuppressWarnings("unchecked")
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- System.out.println("updateNetworkContrail called with arguments: " + Arrays.toString(args));
-
- return null;
- }
- }).when(msoImplMock).updateNetworkContrail
- (Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(RouteTarget.class),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(Subnet.class),
- Mockito.anyListOf(String.class),
- Mockito.anyListOf(String.class),
- Mockito.any(MsoRequest.class),
- Mockito.any(Holder.class),
- Mockito.any(Holder.class)
- );
- PowerMockito.spy(msoImplMock);
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- Response resp = api.updateNetwork("UpdateNetworkRequestNetworkId", reqMock);
-
- Mockito.verify(msoImplMock, Mockito.times(1)).updateNetworkContrail
- (Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(RouteTarget.class),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(Subnet.class),
- Mockito.anyListOf(String.class),
- Mockito.anyListOf(String.class),
- Mockito.any(MsoRequest.class),
- Mockito.any(Holder.class),
- Mockito.any(Holder.class)
- );
-
- assertEquals(resp.getStatus(),HttpStatus.SC_OK);
- UpdateNetworkResponse unResp = (UpdateNetworkResponse) resp.getEntity();
- assertEquals(unResp.getNetworkId(),"UpdateNetworkRequestNetworkId");
- assertEquals(unResp.getMessageId(),"UpdateNetworkMessageWithTestString");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void NetworkAdapterRest_updateNetwork_async_Test()
- {
- UpdateNetworkRequest updateReqMock = PowerMockito.mock(UpdateNetworkRequest.class);
- UpdateNetworkTask updateTaskMock = PowerMockito.mock(UpdateNetworkTask.class);
- MsoNetworkAdapterImpl adapterImplMock = PowerMockito.mock(MsoNetworkAdapterImpl.class);
-
- try{
- PowerMockito.whenNew(UpdateNetworkRequest.class).withAnyArguments().thenReturn(updateReqMock);
- PowerMockito.when(updateReqMock.isSynchronous()).thenReturn(false);
- PowerMockito.when(updateReqMock.getMessageId()).thenReturn("Update succeeded !");
- PowerMockito.when(updateReqMock.getNetworkId()).thenReturn("UpdateNetworkRequestNetworkId");
-
- PowerMockito.whenNew(UpdateNetworkTask.class).withArguments(updateReqMock).thenReturn(updateTaskMock);
- PowerMockito.spy(updateTaskMock);
-
- PowerMockito.whenNew(MsoNetworkAdapterImpl.class).withAnyArguments().thenReturn(adapterImplMock);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- System.out.println("updateNetworkContrail called with arguments: " + Arrays.toString(args));
- return null;
- }
- }).when(adapterImplMock).updateNetworkContrail
- (
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(RouteTarget.class),
- Mockito.anyString(),
- Mockito.anyString(),
- Mockito.anyListOf(Subnet.class),
- Mockito.anyListOf(String.class),
- Mockito.anyListOf(String.class),
- Mockito.any(MsoRequest.class),
- Mockito.any(Holder.class),
- Mockito.any(Holder.class)
- );
-
- NetworkAdapterRest api = new NetworkAdapterRest();
- Response resp = api.updateNetwork("UpdateNetworkRequestNetworkId", updateReqMock);
-
- assertEquals(resp.getStatus(), HttpStatus.SC_ACCEPTED);
- // test if another thread has executed run method
- // Mockito.verify(updateTaskMock, Mockito.times(1)).run();
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java
deleted file mode 100644
index 417ea80e59..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*-
- * ============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.adapters.network;
-
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.ws.Holder;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.openecomp.mso.adapters.network.exceptions.NetworkException;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-import org.openecomp.mso.openstack.beans.NetworkStatus;
-import org.openecomp.mso.openstack.beans.RouteTarget;
-import org.openecomp.mso.openstack.beans.Subnet;
-
-public class NetworkAdapterTest {
-
- @Mock
- private static MsoNetworkAdapterImpl adapter;
-
- @Mock
- private static CatalogDatabase db;
-
- @Mock
- private static CloudConfigFactory cloudConfigFactory;
-
- @BeforeClass
- public static final void prepare () {
- adapter = Mockito.spy (new MsoNetworkAdapterImpl ());
- db = Mockito.mock (CatalogDatabase.class);
- cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- NetworkResource networkResource = new NetworkResource ();
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- nrc.setNetworkResource(networkResource);
- nrc.setNetworkType("PROVIDER");
- networkResource.setNeutronNetworkType ("PROVIDER");
- networkResource.setModelUUID("b4a6af8c-a22b-45d5-a880-29527f8f59a7");
- nrc.setNetworkResourceModelUuid(networkResource.getModelUUID());
- networkResource.setOrchestrationMode ("toto");
- Mockito.when (db.getNetworkResource ("PROVIDER")).thenReturn (networkResource);
- Mockito.when (adapter.getCatalogDB ()).thenReturn (db);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- Mockito.when(cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- Mockito.when (adapter.getCloudConfigFactory()).thenReturn(cloudConfigFactory);
- }
-
- @Test
- public void createTest () {
-
- List <Integer> vlans = new LinkedList <> ();
- vlans.add (1);
- vlans.add (2);
- List <Subnet> subnets = new LinkedList <> ();
- subnets.add (new Subnet ());
- MsoRequest msoRequest = new MsoRequest ();
- Holder <String> networkId = new Holder <> ();
- Holder <String> neutronNetworkId = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- Holder <NetworkRollback> rollback = new Holder <> ();
- try {
- adapter.createNetwork ("toto",
- "tenant",
- "PROVIDER",
- "modelCustUuid",
- "networkName",
- "physicalNetworkName",
- vlans,
- Boolean.TRUE,
- Boolean.TRUE,
- subnets,
- msoRequest,
- networkId,
- neutronNetworkId,
- subnetIdMap,
- rollback);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Configuration Error"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void createTest2 () {
- List <Integer> vlans = new LinkedList <> ();
- vlans.add (1);
- vlans.add (2);
- List <Subnet> subnets = new LinkedList <> ();
- List <RouteTarget> routeTargets = new LinkedList <> ();
- subnets.add (new Subnet ());
- List <String> policyFqdns = new LinkedList <> ();
- policyFqdns.add("pfqdn1");
- policyFqdns.add("pfqdn2");
- List <String> routeTableFqdns = new LinkedList <> ();
- routeTableFqdns.add("rtfqdn1");
- routeTableFqdns.add("rtfqdn2");
- MsoRequest msoRequest = new MsoRequest ();
- Holder <String> networkId = new Holder <> ();
- Holder <String> neutronNetworkId = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- Holder <NetworkRollback> rollback = new Holder <> ();
- Holder <String> networkFqdn= new Holder <> ();
- try {
- adapter.createNetworkContrail ("toto",
- "tenant",
- "PROVIDER",
- "modelCustUuid",
- "networkName",
- routeTargets,
- "shared",
- "external",
- Boolean.TRUE,
- Boolean.TRUE,
- subnets,
- policyFqdns,
- routeTableFqdns,
- msoRequest,
- networkId,
- neutronNetworkId,
- networkFqdn,
- subnetIdMap,
- rollback);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Configuration Error"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void updateTest () {
- List <Integer> vlans = new LinkedList <> ();
- vlans.add (1);
- vlans.add (2);
- List <Subnet> subnets = new LinkedList <> ();
- subnets.add (new Subnet ());
- MsoRequest msoRequest = new MsoRequest ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- Holder <NetworkRollback> rollback = new Holder <> ();
- try {
- adapter.updateNetwork ("toto",
- "tenant",
- "PROVIDER",
- "modelCustUuid",
- "networkId",
- "networkName",
- "physicalNetworkName",
- vlans,
- subnets,
- msoRequest,
- subnetIdMap,
- rollback);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Configuration Error"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void updateTest2 () {
- List <Integer> vlans = new LinkedList <> ();
- vlans.add (1);
- vlans.add (2);
- List <Subnet> subnets = new LinkedList <> ();
- List <RouteTarget> routeTargets = new LinkedList <> ();
- subnets.add (new Subnet ());
- List <String> policyFqdns = new LinkedList <> ();
- policyFqdns.add("pfqdn1");
- List <String> routeTableFqdns = new LinkedList <> ();
- routeTableFqdns.add("rtfqdn1");
- routeTableFqdns.add("rtfqdn2");
- MsoRequest msoRequest = new MsoRequest ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- Holder <NetworkRollback> rollback = new Holder <> ();
- try {
- adapter.updateNetworkContrail ("toto",
- "tenant",
- "PROVIDER",
- "modelCustUuid",
- "networkId",
- "networkName",
- routeTargets,
- "shared",
- "external",
- subnets,
- policyFqdns,
- routeTableFqdns,
- msoRequest,
- subnetIdMap,
- rollback);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Configuration Error"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void queryTest () {
- Holder <List <Integer>> vlans = new Holder <> ();
- Holder <NetworkStatus> status = new Holder <> ();
- MsoRequest msoRequest = new MsoRequest ();
- Holder <String> networkId = new Holder <> ();
- Holder <Boolean> result = new Holder <> ();
- Holder <String> neutronNetworkId = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- try {
- adapter.queryNetwork (null,
- "tenant",
- "networkName",
- msoRequest,
- result,
- networkId,
- neutronNetworkId,
- status,
- vlans,
- subnetIdMap);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Missing mandatory parameter"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void queryTest2 () {
- Holder <List <RouteTarget>> routeTargets = new Holder <> ();
- Holder <NetworkStatus> status = new Holder <> ();
- MsoRequest msoRequest = new MsoRequest ();
- Holder <String> networkId = new Holder <> ();
- Holder <Boolean> result = new Holder <> ();
- Holder <String> neutronNetworkId = new Holder <> ();
- Holder <Map <String, String>> subnetIdMap = new Holder <> ();
- try {
- adapter.queryNetworkContrail (null,
- "tenant",
- "networkName",
- msoRequest,
- result,
- networkId,
- neutronNetworkId,
- status,
- routeTargets,
- subnetIdMap);
- } catch (NetworkException e) {
- assertTrue (e.getMessage ().contains ("Missing mandatory parameter"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-
- @Test
- public void deleteTest () {
- Holder <Boolean> networkDeleted = new Holder<> ();
- MsoRequest msoRequest = new MsoRequest ();
- try {
- adapter.deleteNetwork ("toto", "tenant", "PROVIDER", "modelCustUuid", "networkId", msoRequest, networkDeleted);
- } catch (NetworkException e) {
- e.printStackTrace();
- assertTrue (e.getMessage ().contains ("Cloud Site [toto] not found"));
- } catch (java.lang.NullPointerException npe) {
-
- }
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java
deleted file mode 100644
index ae198142bd..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkBeansTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei 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.adapters.network;
-
-import java.util.ArrayList;
-
-import org.junit.Test;
-import org.openecomp.mso.openstack.beans.Pool;
-import org.openecomp.mso.openstack.beans.Subnet;
-
-public class NetworkBeansTest {
-
- /**
- * Test case for coverage
- */
- @Test()
- public final void bpelRestClientPOJOTest() {
- try {
- BpelRestClient bpelRestClient = new BpelRestClient();
- bpelRestClient.setConnectTimeout(180);
- bpelRestClient.setCredentials("credentials");
- bpelRestClient.setRetryCount(-1);
- bpelRestClient.setRetryInterval(2);
- bpelRestClient.setSocketTimeout(10);
- bpelRestClient.equals(bpelRestClient);
- bpelRestClient.bpelPost("toBpelStr", "bpelUrl", true);
- bpelRestClient.getConnectTimeout();
- bpelRestClient.getCredentials();
- bpelRestClient.getLastResponse();
- bpelRestClient.getLastResponseCode();
- bpelRestClient.getRetryCount();
- bpelRestClient.getRetryInterval();
- bpelRestClient.getRetryList();
- bpelRestClient.getSocketTimeout();
- bpelRestClient.hashCode();
- bpelRestClient.toString();
-
- ContrailPolicyRef contrailPolicyRef = new ContrailPolicyRef();
- contrailPolicyRef.populate("major", "minor");
- contrailPolicyRef.toJsonNode();
- contrailPolicyRef.toJsonString();
- contrailPolicyRef.toString();
-
- ContrailPolicyRefSeq contrailPolicyRefSeq = new ContrailPolicyRefSeq();
- ContrailPolicyRefSeq contrailPolicyRefSeq2 = new ContrailPolicyRefSeq("", "");
- contrailPolicyRefSeq.setMajor("major");
- contrailPolicyRefSeq.setMinor("minor");
- contrailPolicyRefSeq.getMajor();
- contrailPolicyRefSeq.getMinor();
- contrailPolicyRefSeq.toString();
-
- ContrailSubnet contrailSubnet = new ContrailSubnet();
- contrailSubnet.setAddrFromStart(true);
- contrailSubnet.setDefaultGateway("defaultGateway");
- contrailSubnet.setEnableDhcp(true);
- contrailSubnet.setPools(new ArrayList<>());
- contrailSubnet.setSubnet(new ContrailSubnetIp());
- contrailSubnet.setSubnetName("subnetName");
- contrailSubnet.getAllocationPools();
- contrailSubnet.getDefaultGateway();
- contrailSubnet.getSubnet();
- contrailSubnet.getSubnetName();
- contrailSubnet.isAddrFromStart();
- contrailSubnet.isEnableDhcp();
- contrailSubnet.populateWith(new Subnet());
- contrailSubnet.toJsonNode();
- contrailSubnet.toJsonString();
- contrailSubnet.toString();
-
- ContrailSubnetIp contrailSubnetIp = new ContrailSubnetIp();
- contrailSubnetIp.setIpPrefix("ipPrefix");
- contrailSubnetIp.setIpPrefixLen("ipPrefixLen");
- contrailSubnetIp.getIpPrefix();
- contrailSubnetIp.getIpPrefixLen();
- contrailSubnetIp.toString();
-
- ContrailSubnetPool contrailSubnetPool = new ContrailSubnetPool();
- contrailSubnetPool.setEnd("end");
- contrailSubnetPool.setStart("start");
- contrailSubnetPool.getEnd();
- contrailSubnetPool.getStart();
- contrailSubnetPool.populateWith(new Pool());
- contrailSubnetPool.toString();
-
- // HealthCheckHandler healthCheckHandler = new HealthCheckHandler();
- // healthCheckHandler.healthcheck("60c3e96e-0970-4871-b6e0-3b6de7561519");
- // healthCheckHandler.healthcheck("requestId");
- } catch (Exception e) {
- assert (false);
-
- }
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBeanTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBeanTest.java
deleted file mode 100644
index 0ea4dd4fca..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionBeanTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.adapters.network.exceptions;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-public class NetworkExceptionBeanTest {
-
- NetworkExceptionBean neb=new NetworkExceptionBean();
- MsoExceptionCategory msc=MsoExceptionCategory.INTERNAL;
-
- @Test
- public void test() {
- neb.setRolledBack(true);
- neb.setMessage("message");
- neb.setCategory(msc);
- assertEquals(neb.getMessage(),"message");
- assertEquals(neb.getCategory(), msc);
- assertEquals(neb.isRolledBack(), true);
- }
-}
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionTest.java
deleted file mode 100644
index 9790ec676d..0000000000
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/exceptions/NetworkExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.adapters.network.exceptions;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-public class NetworkExceptionTest{
-
- NetworkException ne=new NetworkException("msg");
- NetworkExceptionBean neb =new NetworkExceptionBean();
- MsoException msoException= new MsoException("msoException") {};
- MsoExceptionCategory msc=MsoExceptionCategory.INTERNAL;
- NetworkException ne1=new NetworkException(msoException);
- NetworkException ne2=new NetworkException(ne);
- NetworkException ne3=new NetworkException("msg", ne);
- NetworkException ne4=new NetworkException("msg", msoException);
- NetworkException ne5=new NetworkException("msg", msc);
- NetworkException ne6=new NetworkException("msg", msc, ne);
-
- @Test
- public void test() {
- ne.setFaultInfo(neb);
- assertEquals(ne.getFaultInfo(), neb);
- }
-
-}