aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguochuyicmri <guochuyi@chinamobile.com>2019-02-20 17:50:17 +0800
committerguochuyicmri <guochuyi@chinamobile.com>2019-02-20 17:50:28 +0800
commit9810f110a7a04aa5f214bc49403de1640de2321f (patch)
treeb7a70436bf14ca71f80c2483916df76bfd3573db
parente34f9371bb5af9bdc647d564a66a097b0e9c4df9 (diff)
Increase UT coverage for UUI server
Change-Id: Ia917650945dec071c6daf1609b2e1bab1a246218 Issue-ID: USECASEUI-238 Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionControllerTest.java252
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java152
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java7
-rw-r--r--server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/SOTNServiceImplTest.java42
4 files changed, 408 insertions, 45 deletions
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionControllerTest.java
index d7db3218..1f19216f 100644
--- a/server/src/test/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionControllerTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionControllerTest.java
@@ -20,10 +20,14 @@ import org.junit.Test;
import org.onap.usecaseui.server.service.lcm.PackageDistributionService;
import org.onap.usecaseui.server.service.lcm.domain.vfc.beans.Csar;
+import javax.servlet.ReadListener;
+import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import static org.mockito.Mockito.*;
+import java.io.IOException;
+
public class PackageDistributionControllerTest {
private PackageDistributionService service;
@@ -34,7 +38,35 @@ public class PackageDistributionControllerTest {
service = mock(PackageDistributionService.class);
controller.setPackageDistributionService(service);
}
+
+ private HttpServletRequest mockRequest() throws IOException {
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ when(request.getContentLength()).thenReturn(0);
+ ServletInputStream inStream = new ServletInputStream() {
+ @Override
+ public boolean isFinished() {
+ return false;
+ }
+
+ @Override
+ public boolean isReady() {
+ return false;
+ }
+ @Override
+ public void setReadListener(ReadListener readListener) {
+
+ }
+
+ @Override
+ public int read() throws IOException {
+ return 0;
+ }
+ };
+ when(request.getInputStream()).thenReturn(inStream);
+ return request;
+ }
+
@Test
public void retrievePackageInfo() throws Exception {
controller.retrievePackageInfo();
@@ -84,4 +116,224 @@ public class PackageDistributionControllerTest {
verify(service, times(1)).deleteVfPackage(csarId);
}
+
+ @Test
+ public void testGetNsLcmJobStatus() throws IOException {
+ String csarId = "1";
+ String responseId="1";
+ HttpServletRequest request = mockRequest();
+ controller.getNsLcmJobStatus(csarId,request);
+
+ verify(service, times(1)).getNsLcmJobStatus(csarId,responseId);
+ }
+
+ @Test
+ public void testFetchNsTemplateData() throws IOException {
+ HttpServletRequest request = mockRequest();
+ controller.fetchNsTemplateData(request);
+
+ verify(service, times(1)).fetchNsTemplateData(request);
+ }
+
+ @Test
+ public void testListNsTemplates(){
+ controller.listNsTemplates();
+
+ verify(service, times(1)).listNsTemplates();
+ }
+
+ @Test
+ public void testGetNsPackages(){
+ controller.getNsPackages();
+
+ verify(service, times(1)).getNetworkServicePackages();
+ }
+
+ @Test
+ public void testGetVnfPackages(){
+ controller.getVnfPackages();
+
+ verify(service, times(1)).getVnfPackages();
+ }
+
+ @Test
+ public void testGetPnfPackages(){
+ controller.getPnfPackages();
+
+ verify(service, times(1)).getPnfPackages();
+ }
+
+ @Test
+ public void testCreateNetworkServiceData() throws IOException {
+ HttpServletRequest request = mockRequest();
+ controller.createNetworkServiceData(request);
+
+ verify(service, times(1)).createNetworkServiceData(request);
+ }
+
+ @Test
+ public void testCreateVnfData() throws IOException {
+ HttpServletRequest request = mockRequest();
+ controller.createVnfData(request);
+
+ verify(service, times(1)).createVnfData(request);
+ }
+
+ @Test
+ public void testCreatePnfData() throws IOException {
+ HttpServletRequest request = mockRequest();
+ controller.createPnfData(request);
+
+ verify(service, times(1)).createPnfData(request);
+ }
+
+ @Test
+ public void testGetNsdInfo(){
+ String nsdInfoId ="1";
+
+ controller.getNsdInfo(nsdInfoId);
+
+ verify(service, times(1)).getNsdInfo(nsdInfoId);
+ }
+
+ @Test
+ public void testGetVnfInfo(){
+ String nsdInfoId ="1";
+
+ controller.getVnfInfo(nsdInfoId);
+
+ verify(service, times(1)).getVnfInfo(nsdInfoId);
+ }
+
+ @Test
+ public void testGetPnfInfo(){
+ String nsdInfoId ="1";
+
+ controller.getPnfInfo(nsdInfoId);
+
+ verify(service, times(1)).getPnfInfo(nsdInfoId);
+ }
+
+ @Test
+ public void testDownLoadNsPackage(){
+ String nsdInfoId ="1";
+
+ controller.downLoadNsPackage(nsdInfoId);
+
+ verify(service, times(1)).downLoadNsPackage(nsdInfoId);
+ }
+
+ @Test
+ public void testDownLoadPnfPackage(){
+ String nsdInfoId ="1";
+
+ controller.downLoadPnfPackage(nsdInfoId);
+
+ verify(service, times(1)).downLoadPnfPackage(nsdInfoId);
+ }
+
+ @Test
+ public void testDownLoadVnfPackage(){
+ String nsdInfoId ="1";
+
+ controller.downLoadVnfPackage(nsdInfoId);
+
+ verify(service, times(1)).downLoadVnfPackage(nsdInfoId);
+ }
+
+ @Test
+ public void testDeleteNsdPackage(){
+ String nsdInfoId ="1";
+
+ controller.deleteNsdPackage(nsdInfoId);
+
+ verify(service, times(1)).deleteNsdPackage(nsdInfoId);
+ }
+
+ @Test
+ public void testDeleteVnfPackage(){
+ String nsdInfoId ="1";
+
+ controller.deleteVnfPackage(nsdInfoId);
+
+ verify(service, times(1)).deleteVnfPackage(nsdInfoId);
+ }
+
+ @Test
+ public void testDeletePnfPackage(){
+ String nsdInfoId ="1";
+
+ controller.deletePnfPackage(nsdInfoId);
+
+ verify(service, times(1)).deletePnfPackage(nsdInfoId);
+ }
+
+ @Test
+ public void testDeleteNetworkServiceInstance(){
+ String nsdInfoId ="1";
+
+ controller.deleteNetworkServiceInstance(nsdInfoId);
+
+ verify(service, times(1)).deleteNetworkServiceInstance(nsdInfoId);
+ }
+
+ @Test
+ public void testGetNetworkServiceInfo(){
+
+ controller.getNetworkServiceInfo();
+
+ verify(service, times(1)).getNetworkServiceInfo();
+ }
+
+ @Test
+ public void testCreateNetworkServiceInstance() throws IOException {
+ HttpServletRequest request = mockRequest();
+ controller.createNetworkServiceInstance(request);
+
+ verify(service, times(1)).createNetworkServiceInstance(request);
+ }
+
+ @Test
+ public void testInstantiateNetworkServiceInstance() throws IOException {
+ String ns_instance_id="1";
+ HttpServletRequest request = mockRequest();
+ controller.instantiateNetworkServiceInstance(request);
+
+ verify(service, times(1)).instantiateNetworkServiceInstance(request,ns_instance_id);
+ }
+
+ @Test
+ public void testTerminateNetworkServiceInstance() throws IOException {
+ String ns_instance_id="1";
+ HttpServletRequest request = mockRequest();
+ controller.terminateNetworkServiceInstance(request,ns_instance_id);
+
+ verify(service, times(1)).terminateNetworkServiceInstance(request,ns_instance_id);
+ }
+
+ @Test
+ public void testHealNetworkServiceInstance() throws IOException {
+ String ns_instance_id="1";
+ HttpServletRequest request = mockRequest();
+ controller.healNetworkServiceInstance(request,ns_instance_id);
+
+ verify(service, times(1)).healNetworkServiceInstance(request,ns_instance_id);
+ }
+
+ @Test
+ public void testScaleNetworkServiceInstance() throws IOException {
+ String ns_instance_id="1";
+ HttpServletRequest request = mockRequest();
+ controller.scaleNetworkServiceInstance(request,ns_instance_id);
+
+ verify(service, times(1)).scaleNetworkServiceInstance(request,ns_instance_id);
+ }
+
+ @Test
+ public void testGetVnfInfoById() throws IOException {
+ String ns_instance_id="1";
+ controller.getVnfInfoById(ns_instance_id);
+
+ verify(service, times(1)).getVnfInfoById(ns_instance_id);
+ }
} \ No newline at end of file
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java
index 1bfe5e35..8d2d3593 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmServiceTest.java
@@ -15,8 +15,16 @@
*/
package org.onap.usecaseui.server.service.lcm.impl;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
+import org.onap.usecaseui.server.bean.AlarmsHeader;
+import org.onap.usecaseui.server.bean.ServiceBean;
+import org.onap.usecaseui.server.service.impl.AlarmsHeaderServiceImpl;
import org.onap.usecaseui.server.service.lcm.ServiceLcmService;
import org.onap.usecaseui.server.service.lcm.domain.so.SOService;
import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp;
@@ -26,10 +34,17 @@ import org.onap.usecaseui.server.service.lcm.domain.so.bean.SaveOrUpdateOperatio
import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation;
import org.onap.usecaseui.server.service.lcm.domain.so.exceptions.SOException;
+import mockit.Mock;
+import mockit.MockUp;
+
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.eq;
@@ -40,7 +55,100 @@ import static org.onap.usecaseui.server.util.CallStub.failedCall;
import static org.onap.usecaseui.server.util.CallStub.successfulCall;
public class DefaultServiceLcmServiceTest {
-
+
+ private static final long serialVersionUID = 1L;
+
+ ServiceLcmService service = null;
+
+ @Before
+ public void before() throws Exception {
+ SOService soService = mock(SOService.class);
+ service = new DefaultServiceLcmService(soService);
+
+ MockUp<Transaction> mockUpTransaction = new MockUp<Transaction>() {
+ @Mock
+ public void commit() {
+ }
+ };
+ MockUp<Query> mockUpQuery = new MockUp<Query>() {
+ };
+ new MockUp<Query>() {
+ @Mock
+ public Query setString(String name, String value) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public Query setDate(String name, Date value) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public Query setInteger(String name, int value) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public int executeUpdate() {
+ return 0;
+ }
+ @Mock
+ public Query setMaxResults(int value) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public Query setFirstResult(int firstResult) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public Query setParameterList(String name, Object[] values) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public List<AlarmsHeader> list() {
+ AlarmsHeader ah = new AlarmsHeader();
+ return Arrays.asList(ah);
+ }
+ @Mock
+ public Object uniqueResult() {
+ return "0";
+ }
+ };
+ MockUp<Session> mockedSession = new MockUp<Session>() {
+ @Mock
+ public Query createQuery(String sql) {
+ return mockUpQuery.getMockInstance();
+ }
+ @Mock
+ public Transaction beginTransaction() {
+ return mockUpTransaction.getMockInstance();
+ }
+ @Mock
+ public Transaction getTransaction() {
+ return mockUpTransaction.getMockInstance();
+ }
+ @Mock
+ public Serializable save(Object object) {
+ return (Serializable) serialVersionUID;
+ }
+ @Mock
+ public void flush() {
+ }
+ @Mock
+ public void update(Object object) {
+ }
+ };
+ new MockUp<SessionFactory>() {
+ @Mock
+ public Session openSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ new MockUp<AlarmsHeaderServiceImpl>() {
+ @Mock
+ private Session getSession() {
+ return mockedSession.getMockInstance();
+ }
+ };
+ }
+
@Test
public void itCanInstantiateService() throws IOException {
SOService soService = mock(SOService.class);
@@ -258,4 +366,46 @@ public class DefaultServiceLcmServiceTest {
Assert.assertSame(rsp, service.updateService(serviceId, request));
}
+
+ @Test
+ public void itCanGetServiceInstanceIdByParentId() throws IOException {
+
+ String parentServiceInstanceId = "1";
+
+ service.getServiceInstanceIdByParentId(parentServiceInstanceId);
+
+ service.getServiceInstanceIdByParentId(null);
+ }
+
+ @Test
+ public void itCanGetServiceBeanByServiceInStanceId() throws IOException {
+
+ String serviceInstanceId = "1";
+
+ service.getServiceBeanByServiceInStanceId(serviceInstanceId);
+
+ service.getServiceBeanByServiceInStanceId(null);
+ }
+
+ @Test
+ public void itCanUpdateServiceInstanceStatusById() throws IOException {
+
+ String serviceInstanceId = "1";
+
+ String status="active";
+
+ service.updateServiceInstanceStatusById(status,serviceInstanceId);
+
+ service.updateServiceInstanceStatusById(null,null);
+ }
+
+ @Test
+ public void itCanSaveOrUpdateServiceBean() throws IOException {
+
+ ServiceBean serviceBean = new ServiceBean();
+
+ service.saveOrUpdateServiceBean(serviceBean);
+
+ service.saveOrUpdateServiceBean(null);
+ }
} \ No newline at end of file
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java
index 0534838a..2a4bf50d 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java
@@ -52,11 +52,6 @@ import static org.onap.usecaseui.server.util.CallStub.successfulCall;
public class DefaultServiceTemplateServiceTest {
- DefaultServiceTemplateService dsts = null;
- @Before
- public void before() throws Exception {
- dsts = new DefaultServiceTemplateService();
- }
@Test
public void itCanListDistributedServiceTemplate() {
List<SDCServiceTemplate> templates = Collections.singletonList(new SDCServiceTemplate("uuid", "uuid", "name", "V1","url", "category"));
@@ -296,6 +291,8 @@ public class DefaultServiceTemplateServiceTest {
@Test(expected = AAIException.class)
public void testDownloadFile() throws IOException {
+ SDCCatalogService sdcService = mock(SDCCatalogService.class);
+ DefaultServiceTemplateService dsts = new DefaultServiceTemplateService(sdcService,null);
dsts.downloadFile("toscaModelPath", "toPath");
}
} \ No newline at end of file
diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/SOTNServiceImplTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/SOTNServiceImplTest.java
index f6d6defa..e22864b6 100644
--- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/SOTNServiceImplTest.java
+++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/SOTNServiceImplTest.java
@@ -48,9 +48,11 @@ import okhttp3.ResponseBody;
public class SOTNServiceImplTest {
SOTNServiceImpl dsts = null;
+ AAIService aaiService = null;
@Before
public void before() throws Exception {
- dsts = new SOTNServiceImpl();
+ aaiService= mock(AAIService.class);
+ dsts = new SOTNServiceImpl(aaiService);
}
private HttpServletRequest mockRequest() throws IOException {
@@ -84,14 +86,12 @@ public class SOTNServiceImplTest {
@Test
public void itCanGetNetWorkResources(){
ResponseBody result=null;
- AAIService aaiService = mock(AAIService.class);
when(aaiService.listNetWorkResources()).thenReturn(successfulCall(result));
dsts.getNetWorkResources();
}
@Test
public void getNetWorkResourcesWithThrowsEexception(){
- AAIService aaiService = mock(AAIService.class);
when(aaiService.listNetWorkResources()).thenReturn(failedCall("aai is not exist!"));
dsts.getNetWorkResources();
}
@@ -105,14 +105,12 @@ public class SOTNServiceImplTest {
Pinterface pinterface = new Pinterface("interfaceName");
pinterfaces.add(pinterface);
rsp.setPinterfaces(pinterfaces);
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getPinterfaceByPnfName(pnfName)).thenReturn(successfulCall(rsp));
dsts.getPinterfaceByPnfName(pnfName);
}
@Test
public void getPinterfaceByPnfNameWithThrowsEexception(){
- AAIService aaiService = mock(AAIService.class);
String pnfName="test";
when(aaiService.getPinterfaceByPnfName(pnfName)).thenReturn(failedCall("aai is not exist!"));
dsts.getPinterfaceByPnfName(pnfName);
@@ -121,14 +119,12 @@ public class SOTNServiceImplTest {
@Test
public void itCanGetLogicalLinks(){
ResponseBody result=null;
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getLogicalLinks()).thenReturn(successfulCall(result));
dsts.getLogicalLinks();
}
@Test
public void getLogicalLinksWithThrowsEexception(){
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getLogicalLinks()).thenReturn(failedCall("aai is not exist!"));
dsts.getLogicalLinks();
}
@@ -137,14 +133,12 @@ public class SOTNServiceImplTest {
public void itCanGetSpecificLogicalLink(){
ResponseBody result=null;
String linkName="linkName";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getSpecificLogicalLink(linkName)).thenReturn(successfulCall(result));
dsts.getSpecificLogicalLink(linkName);
}
@Test
public void getSpecificLogicalLinkWithThrowsEexception(){
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
when(aaiService.getSpecificLogicalLink(linkName)).thenReturn(failedCall("aai is not exist!"));
dsts.getSpecificLogicalLink(linkName);
@@ -154,14 +148,12 @@ public class SOTNServiceImplTest {
public void itCanGetHostUrl(){
ResponseBody result=null;
String linkName="linkName";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getHostUrl(linkName)).thenReturn(successfulCall(result));
dsts.getHostUrl(linkName);
}
@Test
public void getHostUrlWithThrowsEexception(){
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
when(aaiService.getHostUrl(linkName)).thenReturn(failedCall("aai is not exist!"));
dsts.getHostUrl(linkName);
@@ -171,14 +163,12 @@ public class SOTNServiceImplTest {
public void itCanGetExtAaiId(){
ResponseBody result=null;
String linkName="linkName";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getExtAaiId(linkName)).thenReturn(successfulCall(result));
dsts.getExtAaiId(linkName);
}
@Test
public void getExtAaiIdWithThrowsEexception(){
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
when(aaiService.getExtAaiId(linkName)).thenReturn(failedCall("aai is not exist!"));
dsts.getExtAaiId(linkName);
@@ -189,14 +179,12 @@ public class SOTNServiceImplTest {
ResponseBody result=null;
String linkName="linkName";
HttpServletRequest request = mockRequest();
- AAIService aaiService = mock(AAIService.class);
when(aaiService.createHostUrl(anyObject(),eq(linkName))).thenReturn(successfulCall(result));
Assert.assertSame(result,dsts.createHostUrl(request,linkName));
}
@Test
public void createHostUrlWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
HttpServletRequest request = mockRequest();
when(aaiService.createHostUrl(anyObject(),eq(linkName))).thenReturn(failedCall("aai is not exist!"));
@@ -208,14 +196,12 @@ public class SOTNServiceImplTest {
ResponseBody result=null;
String linkName="linkName";
HttpServletRequest request = mockRequest();
- AAIService aaiService = mock(AAIService.class);
when(aaiService.createTopoNetwork(anyObject(),eq(linkName))).thenReturn(successfulCall(result));
Assert.assertSame(result,dsts.createTopoNetwork(request,linkName));
}
@Test
public void createTopoNetworkWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
HttpServletRequest request = mockRequest();
when(aaiService.createTopoNetwork(anyObject(),eq(linkName))).thenReturn(failedCall("aai is not exist!"));
@@ -228,14 +214,12 @@ public class SOTNServiceImplTest {
String linkName="linkName";
String tpid="tpId";
HttpServletRequest request = mockRequest();
- AAIService aaiService = mock(AAIService.class);
when(aaiService.createTerminationPoint(anyObject(),eq(linkName),eq(linkName))).thenReturn(successfulCall(result));
Assert.assertSame(result,dsts.createTerminationPoint(request,linkName,tpid));
}
@Test
public void createTerminationPointWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
String tpid="tpId";
HttpServletRequest request = mockRequest();
@@ -248,14 +232,12 @@ public class SOTNServiceImplTest {
ResponseBody result=null;
String linkName="linkName";
HttpServletRequest request = mockRequest();
- AAIService aaiService = mock(AAIService.class);
when(aaiService.createLink(anyObject(),eq(linkName))).thenReturn(successfulCall(result));
dsts.createLink(request,linkName);
}
@Test
public void createLinkWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
HttpServletRequest request = mockRequest();
when(aaiService.createLink(anyObject(),eq(linkName))).thenReturn(failedCall("aai is not exist!"));
@@ -267,14 +249,12 @@ public class SOTNServiceImplTest {
ResponseBody result=null;
String linkName="linkName";
HttpServletRequest request = mockRequest();
- AAIService aaiService = mock(AAIService.class);
when(aaiService.createPnf(anyObject(),eq(linkName))).thenReturn(successfulCall(result));
dsts.createPnf(request,linkName);
}
@Test
public void createPnfWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
HttpServletRequest request = mockRequest();
when(aaiService.createPnf(anyObject(),eq(linkName))).thenReturn(failedCall("aai is not exist!"));
@@ -286,14 +266,12 @@ public class SOTNServiceImplTest {
ResponseBody result=null;
String linkName="linkName";
String resourceVersion="resourceVersion";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.deleteLink(linkName,resourceVersion)).thenReturn(successfulCall(result));
dsts.deleteLink(linkName,resourceVersion);
}
@Test
public void deleteLinkWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
String resourceVersion="resourceVersion";
when(aaiService.deleteLink(linkName,resourceVersion)).thenReturn(failedCall("aai is not exist!"));
@@ -305,14 +283,12 @@ public class SOTNServiceImplTest {
ResponseBody result=null;
String linkName="linkName";
String resourceVersion="resourceVersion";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getServiceInstances(linkName,resourceVersion)).thenReturn(successfulCall(result));
dsts.getServiceInstances(linkName,resourceVersion);
}
@Test
public void getServiceInstancesWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
String resourceVersion="resourceVersion";
when(aaiService.getServiceInstances(linkName,resourceVersion)).thenReturn(failedCall("aai is not exist!"));
@@ -325,14 +301,12 @@ public class SOTNServiceImplTest {
String linkName="linkName";
String resourceVersion="resourceVersion";
String serviceId="serviceId";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.serviceInstaneInfo(linkName,resourceVersion,serviceId)).thenReturn(successfulCall(result));
dsts.serviceInstanceInfo(linkName,resourceVersion,serviceId);
}
@Test
public void serviceInstanceInfoWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
String resourceVersion="resourceVersion";
String serviceId="serviceId";
@@ -344,14 +318,12 @@ public class SOTNServiceImplTest {
public void itCanGetPnfInfo() throws IOException{
ResponseBody result=null;
String linkName="linkName";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getPnfInfo(linkName)).thenReturn(successfulCall(result));
dsts.getPnfInfo(linkName);
}
@Test
public void getPnfInfoWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
when(aaiService.getPnfInfo(linkName)).thenReturn(failedCall("aai is not exist!"));
dsts.getPnfInfo(linkName);
@@ -363,14 +335,12 @@ public class SOTNServiceImplTest {
String linkName="linkName";
String resourceVersion="resourceVersion";
String serviceId="serviceId";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getAllottedResources(linkName,resourceVersion,serviceId)).thenReturn(successfulCall(result));
dsts.getAllottedResources(linkName,resourceVersion,serviceId);
}
@Test
public void getAllottedResourcesWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
String resourceVersion="resourceVersion";
String serviceId="serviceId";
@@ -382,14 +352,12 @@ public class SOTNServiceImplTest {
public void itCangetConnectivityInfo() throws IOException{
ResponseBody result=null;
String linkName="linkName";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getConnectivityInfo(linkName)).thenReturn(successfulCall(result));
dsts.getConnectivityInfo(linkName);
}
@Test
public void getConnectivityInfoWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
when(aaiService.getConnectivityInfo(linkName)).thenReturn(failedCall("aai is not exist!"));
dsts.getConnectivityInfo(linkName);
@@ -399,14 +367,12 @@ public class SOTNServiceImplTest {
public void itCangetPinterfaceByVpnId() throws IOException{
ResponseBody result=null;
String linkName="linkName";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.getPinterfaceByVpnId(linkName)).thenReturn(successfulCall(result));
dsts.getPinterfaceByVpnId(linkName);
}
@Test
public void getPinterfaceByVpnIdWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
when(aaiService.getPinterfaceByVpnId(linkName)).thenReturn(failedCall("aai is not exist!"));
dsts.getPinterfaceByVpnId(linkName);
@@ -417,14 +383,12 @@ public class SOTNServiceImplTest {
ResponseBody result=null;
String linkName="linkName";
String resourceVersion="resourceVersion";
- AAIService aaiService = mock(AAIService.class);
when(aaiService.deleteExtNetwork(linkName,resourceVersion)).thenReturn(successfulCall(result));
dsts.deleteExtNetwork(linkName,resourceVersion);
}
@Test
public void deleteExtNetworkWithThrowsEexception() throws IOException{
- AAIService aaiService = mock(AAIService.class);
String linkName="linkName";
String resourceVersion="resourceVersion";
when(aaiService.deleteExtNetwork(linkName,resourceVersion)).thenReturn(failedCall("aai is not exist!"));