diff options
Diffstat (limited to 'adapters/mso-adapter-utils/src/test/java')
4 files changed, 22 insertions, 12 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/utils/MsoCloudifyUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/utils/MsoCloudifyUtilsTest.java index 821522fedc..da4aebd3d9 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/utils/MsoCloudifyUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/cloudify/utils/MsoCloudifyUtilsTest.java @@ -42,7 +42,7 @@ import static org.mockito.Mockito.mock; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; -@RunWith(PowerMockRunner.class) +//@RunWith(PowerMockRunner.class) @PrepareForTest({MsoCloudifyUtils.class}) @@ -109,14 +109,15 @@ public class MsoCloudifyUtilsTest { @Test(expected = MsoCloudifyManagerNotFound.class) public void testCloudifyClient() throws MsoException { - + msoPropertiesFactory = mock(MsoPropertiesFactory.class); + cloudConfigFactory = mock(CloudConfigFactory.class); + cloudSite = mock(CloudSite.class); MsoCloudifyUtils mcu = new MsoCloudifyUtils("msoPropID", msoPropertiesFactory, cloudConfigFactory); mcu.getCloudifyClient(cloudSite); assert (mcu.getCloudifyClient(cloudSite) != null); } - @Test(expected = NullPointerException.class) public void testuploadBlueprint() throws MsoException { diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsTest.java index c50ffb03ef..9ba9b2f39d 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoHeatUtilsTest.java @@ -44,30 +44,25 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.mockito.Mockito.doReturn; -@RunWith(PowerMockRunner.class) +//@RunWith(PowerMockRunner.class) @PrepareForTest({MsoHeatUtils.class}) public class MsoHeatUtilsTest { @Mock - StackInfo stackInfo; @Mock - MsoPropertiesFactory msoPropertiesFactory; @Mock - CloudConfigFactory cloudConfigFactory; @Mock - Heat heatClient; @Mock - CloudSite cloudSite; @Test(expected = NullPointerException.class) diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtilsTest.java index 41126759ef..3e4758a8a2 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtilsTest.java @@ -44,7 +44,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import com.woorea.openstack.keystone.Keystone;
import com.woorea.openstack.keystone.model.Tenant;
-@RunWith(PowerMockRunner.class)
+//@RunWith(PowerMockRunner.class)
@PrepareForTest({MsoKeystoneUtils.class,CloudSite.class,CloudIdentity.class,Tenant.class,Keystone.class,MsoTenant.class,MsoJavaProperties.class})
public class MsoKeystoneUtilsTest {
@@ -71,6 +71,7 @@ public class MsoKeystoneUtilsTest { MsoKeystoneUtils msk = PowerMockito.spy(new MsoKeystoneUtils("ID"));
Map<String,String>metadata=new HashMap<>();
metadata.put("1", "value");
+ tenant = mock(Tenant.class);
PowerMockito.when(tenant.getId ()).thenReturn("ID");
doReturn(tenant.getId ()).when(msk).createTenant("tenantName", "cloudSiteId", metadata, true);
PowerMockito.spy(tenant.getId ());
@@ -95,6 +96,7 @@ public class MsoKeystoneUtilsTest { MsoKeystoneUtils msk = PowerMockito.spy(new MsoKeystoneUtils("ID"));
Map<String,String>metadata=new HashMap<>();
metadata.put("1", "value");
+ mst = mock(MsoTenant.class);
PowerMockito.when(mst.getTenantId()).thenReturn("tenantId");
PowerMockito.when(mst.getMetadata()).thenReturn(metadata);
PowerMockito.when(mst.getTenantName()).thenReturn("name");
@@ -107,6 +109,7 @@ public class MsoKeystoneUtilsTest { MsoKeystoneUtils msk = PowerMockito.spy(new MsoKeystoneUtils("ID"));
Map<String,String>metadata=new HashMap<>();
metadata.put("1", "value");
+ mst = mock(MsoTenant.class);
PowerMockito.when(mst.getTenantId()).thenReturn("tenantId");
PowerMockito.when(mst.getMetadata()).thenReturn(metadata);
PowerMockito.when(mst.getTenantName()).thenReturn("name");
@@ -117,6 +120,7 @@ public class MsoKeystoneUtilsTest { @Test
public void testgetKeystoneAdminClient() throws MsoException{
+ cloudIdentity = mock(CloudIdentity.class);
Keystone keystone = new Keystone (cloudIdentity.getKeystoneUrl ("region", "msoPropID"));
MsoKeystoneUtils msk = PowerMockito.spy(new MsoKeystoneUtils("ID"));
doReturn(keystone).when(msk).getKeystoneAdminClient(cs);
diff --git a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoNeutronUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoNeutronUtilsTest.java index 5c52cb514f..839da370df 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoNeutronUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/openecomp/mso/openstack/utils/MsoNeutronUtilsTest.java @@ -22,6 +22,7 @@ package org.openecomp.mso.openstack.utils; import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import java.util.ArrayList;
import java.util.List;
@@ -43,7 +44,8 @@ import com.woorea.openstack.quantum.Quantum; import com.woorea.openstack.quantum.model.Network;
import com.woorea.openstack.quantum.model.Segment;
-@RunWith(PowerMockRunner.class)
+
+//@RunWith(PowerMockRunner.class)
@PrepareForTest({MsoNeutronUtils.class,MsoCommonUtils.class,NetworkInfo.class,CloudConfigFactory.class,CloudConfig.class,Segment.class,Network.class,Quantum.class})
public class MsoNeutronUtilsTest{
@@ -79,6 +81,8 @@ CloudSite cloudSite; public void testcreateNetwork() throws MsoException{
List<Integer> vlans=new ArrayList();
vlans.add(1);
+ cloudConfigFactory = mock(CloudConfigFactory.class);
+ ninfo = mock(NetworkInfo.class);
MsoNeutronUtils mnu=PowerMockito.spy(new MsoNeutronUtils("msoProp",cloudConfigFactory));
NetworkType type=NetworkType.PROVIDER;
doReturn(ninfo).when(mnu).createNetwork("cloudSiteId", "tenantId", type, "networkName", "provider", vlans);
@@ -87,13 +91,17 @@ CloudSite cloudSite; }
@Test
public void testqueryNetwork() throws MsoException{
+ cloudConfigFactory = mock(CloudConfigFactory.class);
+ ninfo = mock(NetworkInfo.class);
MsoNeutronUtils mnu=PowerMockito.spy(new MsoNeutronUtils("msoProp",cloudConfigFactory));
doReturn(ninfo).when(mnu).queryNetwork("networkNameOrId", "tenantId", "cloudSiteId");
- assert(mnu.queryNetwork("networkNameOrId", "tenantId", "cloudSiteId")!=null);
+ NetworkInfo ni = mnu.queryNetwork("networkNameOrId", "tenantId", "cloudSiteId");
+ assert(ni!=null);
}
@Test
public void testdeleteNetwork() throws MsoException{
+ cloudConfigFactory = mock(CloudConfigFactory.class);
MsoNeutronUtils mnu=PowerMockito.spy(new MsoNeutronUtils("msoProp",cloudConfigFactory));
doReturn(true).when(mnu).deleteNetwork("networkId", "tenantId", "cloudSiteId");
assertTrue(mnu.deleteNetwork("networkId", "tenantId", "cloudSiteId"));
@@ -104,6 +112,8 @@ CloudSite cloudSite; List<Integer> vlans=new ArrayList();
vlans.add(1);
NetworkType type=NetworkType.PROVIDER;
+ cloudConfigFactory = mock(CloudConfigFactory.class);
+ ninfo = mock(NetworkInfo.class);
MsoNeutronUtils mnu=PowerMockito.spy(new MsoNeutronUtils("msoProp",cloudConfigFactory));
doReturn(ninfo).when(mnu).updateNetwork("cloudSiteId", "tenantId", "Nid", type, "provider", vlans);
assert(mnu.updateNetwork("cloudSiteId", "tenantId", "Nid", type, "provider", vlans)!=null);
|