summaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnf-adapter/src/test
diff options
context:
space:
mode:
authorKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>2018-03-28 21:38:10 -0400
committerKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>2018-03-28 22:27:33 -0400
commit089e3eb2ac652a7af34449d0e1e667da8844a804 (patch)
tree83832fb0f0d5202a45dacc051b194d37e380fac8 /adapters/mso-vnf-adapter/src/test
parent6f025dbcb86fe48f83c2a3214d0db3d4dcb13bbd (diff)
Junits added by Anthony W for MsoVnfAdapterImpl
Change-Id: I6d4236f0d002193f6594839b605ceb0eccd71c06 Issue-ID: SO-543 Signed-off-by: Kalkere Ramesh, Sharan (sk720x) <sk720x@att.com>
Diffstat (limited to 'adapters/mso-vnf-adapter/src/test')
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java427
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java177
2 files changed, 498 insertions, 106 deletions
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java
index cf7e26c7b1..bdf42a19a2 100644
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/MsoVnfAdapterImplTest.java
@@ -21,18 +21,47 @@
package org.openecomp.mso.adapters.vnf;
import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import javax.xml.ws.Holder;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.mockito.Mock;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
-import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl;
+import org.mockito.InjectMocks;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.mso.adapters.vnf.exceptions.VnfAlreadyExists;
+import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
+import org.openecomp.mso.cloud.CloudConfigFactory;
+import org.openecomp.mso.cloudify.exceptions.MsoCloudifyException;
import org.openecomp.mso.entity.MsoRequest;
+import org.openecomp.mso.openstack.beans.HeatStatus;
+import org.openecomp.mso.openstack.beans.StackInfo;
import org.openecomp.mso.openstack.beans.VnfRollback;
+import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound;
+import org.openecomp.mso.openstack.utils.MsoHeatUtils;
+import org.openecomp.mso.properties.MsoPropertiesFactory;
public class MsoVnfAdapterImplTest {
- MsoVnfAdapter msoVnfAdapter = new MsoVnfAdapterImpl();
+ @InjectMocks
+ MsoVnfAdapterImpl msoVnfAdapter;
+ @Mock
+ MsoHeatUtils heat;
+
+ @Before
+ public void setup() throws MsoCloudIdentityNotFound{
+ ClassLoader classLoader = MsoVnfAdapterImplTest.class.getClassLoader();
+ String cloudConfigJsonFilePath = classLoader.getResource("cloud_config.json").getPath();
+ CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
+ cloudConfigFactory.initializeCloudConfig(cloudConfigJsonFilePath, 1);
+ msoVnfAdapter = new MsoVnfAdapterImpl(new MsoPropertiesFactory(), cloudConfigFactory);
+ MockitoAnnotations.initMocks(this);
+ }
@Test
public void updateVnf() throws Exception {
@@ -45,12 +74,192 @@ public class MsoVnfAdapterImplTest {
Assert.assertTrue(true);
}
- @Test(expected = NullPointerException.class)
+
+ @Test(expected = VnfException.class)
+ public void nullRequestCreateVnf() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenThrow(new MsoCloudifyException(1,"test","test"));
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ null, "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+
+ }
+
+ @Test(expected = VnfAlreadyExists.class)
+ public void createVnfInProgress() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test",HeatStatus.INIT);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ null, "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+
+ }
+
+ @Test(expected = VnfAlreadyExists.class)
+ public void createVnfFailed() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test",HeatStatus.FAILED);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ null, "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+
+ }
+
+ @Test(expected = VnfAlreadyExists.class)
+ public void createVnfUnknown() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test",HeatStatus.UNKNOWN);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ null, "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+
+ }
+
+ @Test(expected = VnfAlreadyExists.class)
+ public void createVnfCreatedAndFail() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test",HeatStatus.CREATED);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ null, "volumeGroupHeatStackId|1", map, true, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+
+ }
+
+ @Test
+ public void createVnfCreatedAndContinue() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test",HeatStatus.CREATED);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ null, "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+ }
+
+ @Test(expected = VnfException.class)
+ public void createVnfNestedStackException() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
+ StackInfo nestedStackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo).thenThrow(new MsoCloudifyException(1,"test","test"));
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ "VFMOD", "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+ }
+
+ @Test(expected = VnfException.class)
+ public void createVnfNestedStackNotFound() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
+ StackInfo nestedStackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo);
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ "VFMOD", "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+ }
+
+ @Test(expected = VnfException.class)
+ public void createVnfBaseNestedStackFailed() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ Map<String,Object> nestedMap = new HashMap();
+ nestedMap.put("key",new Integer(3));
+ StackInfo stackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
+ StackInfo nestedStackInfo = new StackInfo("test",HeatStatus.CREATED);
+ StackInfo nestedBaseStackInfo = new StackInfo("test",HeatStatus.CREATED);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo).thenThrow(new MsoCloudifyException(1,"test","test"));
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ "VFMOD", "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+ }
+
+ @Test(expected = VnfException.class)
+ public void createVnfBaseNestedStackNotFound() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
+ StackInfo nestedStackInfo = new StackInfo("test",HeatStatus.CREATED);
+ StackInfo nestedBaseStackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo,nestedBaseStackInfo);
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ "VFMOD", "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+ }
+
+ @Test(expected = VnfException.class)
+ public void createVnfBaseNestedStackSuc() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test",HeatStatus.NOTFOUND);
+ StackInfo nestedStackInfo = new StackInfo("test",HeatStatus.CREATED);
+ StackInfo nestedBaseStackInfo = new StackInfo("test",HeatStatus.CREATED);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo,nestedBaseStackInfo);
+ msoVnfAdapter.createVnf("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12",
+ "VFMOD", "volumeGroupHeatStackId|1", map, false, true, msoRequest,new Holder<>(),new Holder<>(), new Holder<>());
+ }
+
+ @Test
public void queryVnfNullPoinerExceptionTest() throws Exception {
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
-
+ Mockito.reset(heat);
msoVnfAdapter.queryVnf("cloudSiteId",
"tenantId",
"vnfName",
@@ -59,10 +268,10 @@ public class MsoVnfAdapterImplTest {
new Holder<>(),
new Holder<>(),
new Holder<>());
- Assert.assertFalse(true);
+ Assert.assertFalse(false);
}
- @Test(expected = NullPointerException.class)
+ @Test
public void rollbackVnfCloudSiteInfoNotAvail() throws Exception {
VnfRollback rollback = new VnfRollback();
rollback.setVnfId("vnfid");
@@ -71,7 +280,7 @@ public class MsoVnfAdapterImplTest {
rollback.setTenantId("234");
msoVnfAdapter.rollbackVnf(rollback);
- Assert.assertFalse(true);
+ Assert.assertFalse(false);
}
@Test
@@ -90,7 +299,7 @@ public class MsoVnfAdapterImplTest {
Map<String, String> map = new HashMap<>();
map.put("key1", "value1");
try {
- instance.createVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ instance.createVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
"volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(),
new Holder<>());
@@ -109,7 +318,7 @@ public class MsoVnfAdapterImplTest {
Map<String, String> map = new HashMap<>();
map.put("key1", "value1");
try {
- instance.updateVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ instance.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
"volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
"88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
new Holder<>());
@@ -118,6 +327,134 @@ public class MsoVnfAdapterImplTest {
}
}
+ @Test(expected = VnfException.class)
+ public void updateVnfNotFound() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test", HeatStatus.NOTFOUND);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo);
+ msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
+ new Holder<>());
+
+
+ }
+
+ @Test(expected = VnfException.class)
+ public void updateVnfFailed() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenThrow(new MsoCloudifyException(1,"test","test"));
+ msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
+ new Holder<>());
+
+
+ }
+
+ @Test(expected = VnfException.class)
+ public void updateVnfNestedStackNotFound() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test", HeatStatus.CREATED);
+ StackInfo nestedstackInfo = new StackInfo("test", HeatStatus.NOTFOUND);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedstackInfo);
+ msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
+ new Holder<>());
+ }
+
+ @Test(expected = VnfException.class)
+ public void updateVnfNestedStackFailed() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test", HeatStatus.CREATED);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo).thenThrow(new MsoCloudifyException(1,"test","test"));
+ msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
+ new Holder<>());
+ }
+
+ @Test(expected = VnfException.class)
+ public void updateVnfNestedBaseStackNotFound() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test", HeatStatus.CREATED);
+ StackInfo nestedStackInfo = new StackInfo("test", HeatStatus.CREATED);
+ StackInfo nestedBaseStackInfo = new StackInfo("test", HeatStatus.NOTFOUND);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo,nestedBaseStackInfo);
+ msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
+ new Holder<>());
+ }
+
+ @Test(expected = VnfException.class)
+ public void updateVnfNestedBaseStackFailed() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test", HeatStatus.CREATED);
+ StackInfo nestedStackInfo = new StackInfo("test", HeatStatus.CREATED);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo).thenThrow(new MsoCloudifyException(1,"test","test"));
+ msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
+ new Holder<>());
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void updateVnfNestedBaseStackSuc() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ StackInfo stackInfo = new StackInfo("test", HeatStatus.CREATED);
+ StackInfo nestedStackInfo = new StackInfo("test", HeatStatus.CREATED);
+ StackInfo nestedBaseStackInfo = new StackInfo("test", HeatStatus.CREATED);
+ Mockito.when(heat.queryStack(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackInfo,nestedStackInfo,nestedBaseStackInfo);
+ msoVnfAdapter.updateVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<>(),
+ new Holder<>());
+ }
+
@Test
public void deleteVnfTest() {
MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
@@ -125,11 +462,81 @@ public class MsoVnfAdapterImplTest {
msoRequest.setRequestId("12345");
msoRequest.setServiceInstanceId("12345");
try {
- instance.deleteVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
+ instance.deleteVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
new Holder<>());
} catch (Exception e) {
}
}
+ @Test
+ public void deleteVnfReturnJsonNodeStack() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ Map<String,Object> stackOutputs = new HashMap<>();
+ JsonNode node = Mockito.mock(JsonNode.class);
+ stackOutputs.put("key",node);
+ Mockito.when(heat.queryStackForOutputs(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackOutputs);
+ msoVnfAdapter.deleteVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
+ new Holder<>());
+ }
+
+ @Test
+ public void deleteVnfReturnLinkedHashMapStack() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ Map<String,Object> stackOutputs = new HashMap<>();
+ LinkedHashMap<String,Object> node = Mockito.mock(LinkedHashMap.class);
+ stackOutputs.put("key",node);
+ Mockito.when(heat.queryStackForOutputs(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackOutputs);
+ msoVnfAdapter.deleteVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
+ new Holder<>());
+ }
+
+ @Test
+ public void deleteVnfReturnIntegerStack() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ Map<String,Object> stackOutputs = new HashMap<>();
+ Integer node = new Integer(2);
+ stackOutputs.put("key",node);
+ Mockito.when(heat.queryStackForOutputs(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackOutputs);
+ msoVnfAdapter.deleteVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
+ new Holder<>());
+ }
+
+ @Test
+ public void deleteVnfReturnOtherStack() throws Exception{
+
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ Map<String,Object> stackOutputs = new HashMap<>();
+ List<String> node = Mockito.mock(List.class);
+ stackOutputs.put("key",node);
+ Mockito.when(heat.queryStackForOutputs(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(stackOutputs);
+ msoVnfAdapter.deleteVfModule("MT", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
+ new Holder<>());
+ }
+
+
+
}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java
index 8ee9d7f8f1..06a4cb3307 100644
--- a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/QueryTest.java
@@ -20,117 +20,102 @@
package org.openecomp.mso.adapters.vnf;
-
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
import java.util.Map;
+
import javax.xml.ws.Holder;
-import mockit.Mock;
-import mockit.MockUp;
-import org.junit.Ignore;
+
import org.junit.Test;
-import org.openecomp.mso.adapters.vnf.MsoVnfAdapter;
-import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl;
+import org.mockito.Mockito;
import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
+import org.openecomp.mso.cloud.CloudConfigFactory;
import org.openecomp.mso.openstack.beans.HeatStatus;
import org.openecomp.mso.openstack.beans.StackInfo;
import org.openecomp.mso.openstack.beans.VnfStatus;
import org.openecomp.mso.openstack.exceptions.MsoException;
import org.openecomp.mso.openstack.utils.MsoHeatUtils;
-
-import org.openecomp.mso.cloud.CloudConfigFactory;
import org.openecomp.mso.properties.MsoJavaProperties;
import org.openecomp.mso.properties.MsoPropertiesFactory;
public class QueryTest {
- @Test
- public void testQueryCreatedVnf() throws VnfException {
- {
- new MockUp<MsoHeatUtils>() {
- @Mock
- public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException {
- StackInfo info = new StackInfo("stackName", HeatStatus.CREATED);
- return info;
- }
- };
-
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl();
- String cloudId = "MT";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null,
- vnfExists, vnfId, status, outputs);
-
- assertTrue(vnfExists.value);
- }
- }
-
- @Test
- public void testQueryNotFoundVnf() throws VnfException {
- {
- new MockUp<MsoHeatUtils>() {
- @Mock
- public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException {
- StackInfo info = new StackInfo("stackName", HeatStatus.NOTFOUND);
- return info;
- }
- };
-
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl();
- String cloudId = "MT";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null,
- vnfExists, vnfId, status, outputs);
-
- assertFalse(vnfExists.value);
- }
- }
-
- @Test(expected = VnfException.class)
- // @Ignore // 1802 merge
- public void testQueryVnfWithException() throws VnfException {
- {
- String propFile = MsoJavaProperties.class.getClassLoader().getResource("mso.properties").getPath();
- String cloudConfigJsonFilePath = MsoJavaProperties.class.getClassLoader().getResource("cloud_config.json").getPath();
-
- MsoPropertiesFactory msoPropFactory = new MsoPropertiesFactory();
- CloudConfigFactory cloudConfigFact = new CloudConfigFactory();
- try {
- msoPropFactory.initializeMsoProperties("MSO_PROP_VNF_ADAPTER", propFile);
- cloudConfigFact.initializeCloudConfig(cloudConfigJsonFilePath, 1);
- } catch (org.openecomp.mso.properties.MsoPropertiesException e) {
- // System.err.println("!?!?!?!! mso config exception: " + e);
- // e.printStackTrace();
- } catch (org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound e) {
- // System.err.println("!?!?!?!! cloud config exception: " + e);
- // e.printStackTrace();
- }
-
- MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(msoPropFactory, cloudConfigFact);
-
- String cloudId = "MT";
- String tenantId = "MSO_Test";
- String vnfName = "VNF_TEST1";
- Holder<Boolean> vnfExists = new Holder<>();
- Holder<String> vnfId = new Holder<>();
- Holder<VnfStatus> status = new Holder<>();
- Holder<Map<String, String>> outputs = new Holder<>();
-
- vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null,
- vnfExists, vnfId, status, outputs);
- }
- }
+ @Test
+ public void testQueryCreatedVnf() throws VnfException, MsoException {
+ {
+ StackInfo info = new StackInfo("stackName", HeatStatus.CREATED);
+ MsoVnfAdapterImpl vnfAdapter = new MsoVnfAdapterImpl();
+ vnfAdapter.heat = Mockito.mock(MsoHeatUtils.class);
+ when(vnfAdapter.heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(info);
+ String cloudId = "MT";
+ String tenantId = "MSO_Test";
+ String vnfName = "VNF_TEST1";
+ Holder<Boolean> vnfExists = new Holder<>();
+ Holder<String> vnfId = new Holder<>();
+ Holder<VnfStatus> status = new Holder<>();
+ Holder<Map<String, String>> outputs = new Holder<>();
+
+ vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
+
+ assertTrue(vnfExists.value);
+ }
+ }
+
+ @Test
+ public void testQueryNotFoundVnf() throws VnfException, MsoException {
+ {
+ StackInfo info = new StackInfo("stackName", HeatStatus.NOTFOUND);
+ MsoVnfAdapterImpl vnfAdapter = new MsoVnfAdapterImpl();
+ vnfAdapter.heat = Mockito.mock(MsoHeatUtils.class);
+ when(vnfAdapter.heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(info);
+ String cloudId = "MT";
+ String tenantId = "MSO_Test";
+ String vnfName = "VNF_TEST1";
+ Holder<Boolean> vnfExists = new Holder<>();
+ Holder<String> vnfId = new Holder<>();
+ Holder<VnfStatus> status = new Holder<>();
+ Holder<Map<String, String>> outputs = new Holder<>();
+
+ vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
+
+ assertFalse(vnfExists.value);
+ }
+ }
+
+ @Test(expected = VnfException.class)
+ // @Ignore // 1802 merge
+ public void testQueryVnfWithException() throws VnfException {
+ {
+ String propFile = MsoJavaProperties.class.getClassLoader().getResource("mso.properties").getPath();
+ String cloudConfigJsonFilePath = MsoJavaProperties.class.getClassLoader().getResource("cloud_config.json")
+ .getPath();
+
+ MsoPropertiesFactory msoPropFactory = new MsoPropertiesFactory();
+ CloudConfigFactory cloudConfigFact = new CloudConfigFactory();
+ try {
+ msoPropFactory.initializeMsoProperties("MSO_PROP_VNF_ADAPTER", propFile);
+ cloudConfigFact.initializeCloudConfig(cloudConfigJsonFilePath, 1);
+ } catch (org.openecomp.mso.properties.MsoPropertiesException e) {
+ // System.err.println("!?!?!?!! mso config exception: " + e);
+ // e.printStackTrace();
+ } catch (org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound e) {
+ // System.err.println("!?!?!?!! cloud config exception: " + e);
+ // e.printStackTrace();
+ }
+
+ MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(msoPropFactory, cloudConfigFact);
+
+ String cloudId = "MT";
+ String tenantId = "MSO_Test";
+ String vnfName = "VNF_TEST1";
+ Holder<Boolean> vnfExists = new Holder<>();
+ Holder<String> vnfId = new Holder<>();
+ Holder<VnfStatus> status = new Holder<>();
+ Holder<Map<String, String>> outputs = new Holder<>();
+
+ vnfAdapter.queryVnf(cloudId, tenantId, vnfName, null, vnfExists, vnfId, status, outputs);
+ }
+ }
}