import jakarta.servlet.ServletInputStream;
import jakarta.servlet.http.HttpServletRequest;
+import okhttp3.MediaType;
+import okio.Buffer;
+import okio.BufferedSource;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onap.usecaseui.server.bean.sotn.Pinterface;
import org.onap.usecaseui.server.bean.sotn.PinterfaceRsp;
import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
+import org.onap.usecaseui.server.service.lcm.domain.so.exceptions.SOException;
import org.onap.usecaseui.server.service.sotn.impl.SOTNServiceImpl;
import okhttp3.ResponseBody;
SOTNServiceImpl dsts = null;
AAIService aaiService = null;
+
+ ResponseBody result;
@Before
public void before() throws Exception {
aaiService= mock(AAIService.class);
dsts = new SOTNServiceImpl(aaiService);
+ result= new ResponseBody() {
+ @Nullable
+ @Override
+ public MediaType contentType() {
+ return MediaType.parse("application/json; charset=utf-8");
+ }
+
+ @Override
+ public long contentLength() {
+ return 0;
+ }
+
+ @NotNull
+ @Override
+ public BufferedSource source() {
+
+ return new Buffer();
+ }
+ };
}
private HttpServletRequest mockRequest() throws IOException {
@Test
public void itCanGetNetWorkResources(){
- ResponseBody result=null;
when(aaiService.listNetWorkResources()).thenReturn(successfulCall(result));
dsts.getNetWorkResources();
}
dsts.getPinterfaceByPnfName(pnfName);
}
- @Test
+ @Test(expected = AAIException.class)
public void getPinterfaceByPnfNameWithThrowsEexception(){
String pnfName="test";
when(aaiService.getPinterfaceByPnfName(pnfName)).thenReturn(failedCall("aai is not exist!"));
@Test
public void itCanGetLogicalLinks(){
- ResponseBody result=null;
when(aaiService.getLogicalLinks()).thenReturn(successfulCall(result));
dsts.getLogicalLinks();
}
@Test
public void itCanGetSpecificLogicalLink(){
- ResponseBody result=null;
String linkName="linkName";
when(aaiService.getSpecificLogicalLink(linkName)).thenReturn(successfulCall(result));
dsts.getSpecificLogicalLink(linkName);
@Test
public void itCanGetHostUrl(){
- ResponseBody result=null;
String linkName="linkName";
when(aaiService.getHostUrl(linkName)).thenReturn(successfulCall(result));
dsts.getHostUrl(linkName);
@Test
public void itCanGetExtAaiId(){
- ResponseBody result=null;
String linkName="linkName";
when(aaiService.getExtAaiId(linkName)).thenReturn(successfulCall(result));
dsts.getExtAaiId(linkName);
@Test
public void itCanCreateHostUrl() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
HttpServletRequest request = mockRequest();
when(aaiService.createHostUrl(Mockito.any(),eq(linkName))).thenReturn(successfulCall(result));
@Test
public void itCanCreateTopoNetwork() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
HttpServletRequest request = mockRequest();
when(aaiService.createTopoNetwork(Mockito.any(),eq(linkName))).thenReturn(successfulCall(result));
@Test
public void itCanCreateTerminationPoint() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
String tpid="tpId";
HttpServletRequest request = mockRequest();
@Test
public void itCanCreateLink() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
HttpServletRequest request = mockRequest();
when(aaiService.createLink(Mockito.any(),eq(linkName))).thenReturn(successfulCall(result));
@Test
public void itCanCreatePnf() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
HttpServletRequest request = mockRequest();
when(aaiService.createPnf(Mockito.any(),eq(linkName))).thenReturn(successfulCall(result));
@Test
public void itCanDeleteLink() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
String resourceVersion="resourceVersion";
when(aaiService.deleteLink(linkName,resourceVersion)).thenReturn(successfulCall(result));
@Test
public void itCanGetServiceInstances() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
String resourceVersion="resourceVersion";
when(aaiService.getServiceInstances(linkName,resourceVersion)).thenReturn(successfulCall(result));
@Test
public void itCanGerviceInstanceInfo() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
String resourceVersion="resourceVersion";
String serviceId="serviceId";
dsts.serviceInstanceInfo(linkName,resourceVersion,serviceId);
}
- @Test
+ @Test(expected = SOException.class)
public void serviceInstanceInfoWithThrowsEexception() throws IOException{
String linkName="linkName";
String resourceVersion="resourceVersion";
@Test
public void itCanGetPnfInfo() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
when(aaiService.getPnfInfo(linkName)).thenReturn(successfulCall(result));
dsts.getPnfInfo(linkName);
@Test
public void itCangetAllottedResources() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
String resourceVersion="resourceVersion";
String serviceId="serviceId";
@Test
public void itCangetConnectivityInfo() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
when(aaiService.getConnectivityInfo(linkName)).thenReturn(successfulCall(result));
dsts.getConnectivityInfo(linkName);
@Test
public void itCangetPinterfaceByVpnId() throws IOException{
- ResponseBody result=null;
String linkName="linkName";
when(aaiService.getPinterfaceByVpnId(linkName)).thenReturn(successfulCall(result));
dsts.getPinterfaceByVpnId(linkName);