aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-network-adapter/src
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-05-02 16:46:14 -0400
committerRob Daugherty <rd472p@att.com>2018-05-04 15:28:51 +0000
commit3ee4ec41ac18e51a16eafa767e090502b1a33fb5 (patch)
tree11a4d7b6c3bc5b88ce8dd67f12c7726c9f7dd80f /adapters/mso-network-adapter/src
parent13999df2b5cbcfd29d479e20970b39ba876725f3 (diff)
Fix CloudConfig junits
...for some definition of the word "fix". There is still a lot that's less than ideal about how CloudConfig is handled, and with how the unit tests are written. Change-Id: Ic8c66c64d336f22c141687cf41a4828810bf1aec Issue-ID: SO-584 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'adapters/mso-network-adapter/src')
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java16
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java9
2 files changed, 18 insertions, 7 deletions
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
index c0df4fe880..7f0f988a4f 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
@@ -91,7 +91,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
private static final String NEUTRON_MODE = "NEUTRON";
private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
- protected CloudConfig cloudConfig;
/**
* Health Check web method. Does nothing but return to show the adapter is deployed.
@@ -117,7 +116,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
public MsoNetworkAdapterImpl(MsoPropertiesFactory msoPropFactory,CloudConfigFactory cloudConfigFact) {
this.msoPropertiesFactory = msoPropFactory;
this.cloudConfigFactory=cloudConfigFact;
- cloudConfig = cloudConfigFactory.getCloudConfig ();
neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory, cloudConfigFactory);
heatWithUpdate = new MsoHeatUtilsWithUpdate(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
@@ -282,7 +280,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// If the tenant doesn’t exist, the Heat calls will fail anyway (when the HeatUtils try to obtain a token).
// So this is just catching that error in a bit more obvious way up front.
- cloudConfig = cloudConfigFactory.getCloudConfig ();
+ CloudConfig cloudConfig = getCloudConfigFactory().getCloudConfig ();
Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId);
if (!cloudSiteOpt.isPresent())
{
@@ -829,7 +827,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
networkRollback.setTenantId (tenantId);
networkRollback.setMsoRequest (msoRequest);
- cloudConfig = cloudConfigFactory.getCloudConfig ();
+ CloudConfig cloudConfig = getCloudConfigFactory().getCloudConfig ();
Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite (cloudSiteId);
if (!cloudSiteOpt.isPresent()) {
String error = "UpdateNetwork: Configuration Error. Stack " + networkName + " in "
@@ -1384,7 +1382,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throw new NetworkException (error, MsoExceptionCategory.USERDATA);
}
- cloudConfig = cloudConfigFactory.getCloudConfig();
+ CloudConfig cloudConfig = getCloudConfigFactory().getCloudConfig();
Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId);
if (!cloudSiteOpt.isPresent())
{
@@ -1646,6 +1644,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
return CatalogDatabase.getInstance();
}
+ public CloudConfigFactory getCloudConfigFactory() {
+ return cloudConfigFactory;
+ }
+
/**
* This web service endpoint will rollback a previous Create VNF operation.
* A rollback object is returned to the client in a successful creation
@@ -1703,7 +1705,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Rolling back a newly created network, so delete it.
if (NEUTRON_MODE.equals(mode)) {
// Use MsoNeutronUtils for all NEUTRON commands
- MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
+ MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, getCloudConfigFactory());
long deleteNetworkStarttime = System.currentTimeMillis();
try {
// The deleteNetwork function in MsoNeutronUtils returns success if the network
@@ -1734,7 +1736,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
} else { // DEFAULT to if ("HEAT".equals (mode))
// Use MsoHeatUtils for all HEAT commands
MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
- cloudConfigFactory);
+ getCloudConfigFactory());
long deleteStackStarttime = System.currentTimeMillis();
try {
// The deleteStack function in MsoHeatUtils returns success if the stack
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
index 1106c5543d..417ea80e59 100644
--- 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
@@ -34,6 +34,8 @@ 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;
@@ -50,11 +52,15 @@ public class NetworkAdapterTest {
@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);
@@ -65,6 +71,9 @@ public class NetworkAdapterTest {
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