Add some test code to improve code coverage
[usecase-ui/server.git] / server / src / test / java / org / onap / usecaseui / server / service / lcm / impl / SotnServiceTemplateServiceImplTest.java
1 /**
2  * Copyright (C) 2020 Huawei, Inc. and others. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.usecaseui.server.service.lcm.impl;
17
18 import okhttp3.MediaType;
19 import okhttp3.Request;
20 import okhttp3.RequestBody;
21 import okhttp3.Response;
22 import okhttp3.ResponseBody;
23 import okio.Buffer;
24 import okio.BufferedSource;
25 import okio.ByteString;
26 import okio.Options;
27 import okio.Sink;
28 import okio.Timeout;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.usecaseui.server.bean.lcm.sotne2eservice.E2EServiceInstanceRequest;
32 import org.onap.usecaseui.server.bean.lcm.sotne2eservice.ModelConfig;
33 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
34 import org.onap.usecaseui.server.service.lcm.domain.so.SOService;
35 import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp;
36 import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation;
37 import retrofit2.Call;
38 import retrofit2.Callback;
39
40 import javax.annotation.Nullable;
41 import java.io.IOException;
42 import java.io.InputStream;
43 import java.nio.ByteBuffer;
44 import java.nio.charset.Charset;
45 import java.util.HashMap;
46
47 import static org.mockito.Mockito.any;
48 import static org.mockito.Mockito.anyString;
49 import static org.mockito.Mockito.mock;
50 import static org.mockito.Mockito.when;
51 import static org.onap.usecaseui.server.util.CallStub.failedCall;
52
53 public class SotnServiceTemplateServiceImplTest {
54
55     AAIService aaiService;
56     SOService soService;
57     ServiceOperation serviceOperation;
58     SotnServiceTemplateServiceImpl sotnServiceTemplateService;
59
60     @Before
61     public void before() throws Exception {
62         aaiService = mock(AAIService.class);
63         soService = mock(SOService.class);
64         sotnServiceTemplateService = new SotnServiceTemplateServiceImpl();
65         sotnServiceTemplateService.setSoService(soService);
66         sotnServiceTemplateService.setAaiService(aaiService);
67     }
68
69     @Test
70     public void instantiate_CCVPN_ServiceTest() {
71
72         HashMap<String, Object> map = new HashMap<>();
73         map.put("name","12");
74         map.put("description","23");
75         map.put("l2vpn","34");
76         map.put("sotnUni","45");
77         Call<ServiceOperation> call = getSosCall();
78         when(soService.instantiateSOTNService(any(E2EServiceInstanceRequest.class))).thenReturn(call);
79         sotnServiceTemplateService.instantiate_CCVPN_Service(map);
80     }
81
82     @Test
83     public void instantiate_CCVPN_ServiceWithThrowException() {
84         HashMap<String, Object> map = new HashMap<>();
85         map.put("name","12");
86         map.put("description","23");
87         map.put("l2vpn","34");
88         map.put("sotnUni","45");
89         Call<ServiceOperation> call = getSosCall();
90         when(soService.instantiateSOTNService(any(E2EServiceInstanceRequest.class))).thenReturn(call);
91         sotnServiceTemplateService.instantiate_CCVPN_Service(map);
92     }
93
94     @Test
95     public void createSotnServiceTest() {
96         Call<ServiceOperation> call = getSosCall();
97         when(soService.instantiateSOTNService(any(E2EServiceInstanceRequest.class))).thenReturn(call);
98         sotnServiceTemplateService.createSotnService(new E2EServiceInstanceRequest());
99     }
100
101     @Test
102     public void createSotnServiceWithThrowException() {
103         Call<ServiceOperation> call = getSosCall();
104         when(soService.instantiateSOTNService(any(E2EServiceInstanceRequest.class))).thenReturn(call);
105         sotnServiceTemplateService.createSotnService(new E2EServiceInstanceRequest());
106     }
107
108     @Test
109     public void getServiceInstancesInfoTest() throws Exception {
110         Call<ResponseBody> call = getAaiCall("ServiceInstance");
111         when(aaiService.getServiceInstancesForEdge("ISAAC","SOTN","ISAAC")).thenReturn(call);
112         sotnServiceTemplateService.getServiceInstancesInfo("ISAAC","SOTN","ISAAC");
113     }
114
115     @Test
116     public void getServiceInstancesInfoWithThrowException() throws Exception {
117         Call<ResponseBody> call = getAaiCall("ServiceInstance");
118         when(aaiService.getServiceInstancesForEdge("ISAAC","SOTN","ISAAC")).thenReturn(call);
119         sotnServiceTemplateService.getServiceInstancesInfo("ISAAC","SOTN","ISAAC");
120     }
121
122     @Test
123     public void getTerminationPointTest() throws Exception {
124         Call<ResponseBody> call = getAaiCall("Pinterface");
125         when(aaiService.getTerminationPoint("SOTN","123")).thenReturn(call);
126         sotnServiceTemplateService.getTerminationPoint("SOTN", "123");
127     }
128
129     @Test
130     public void getTerminationPointWithThrowException() throws Exception {
131         Call<ResponseBody> call = getAaiCall("Pinterface");
132         when(aaiService.getTerminationPoint("SOTN","123")).thenReturn(call);
133         sotnServiceTemplateService.getTerminationPoint("SOTN", "123");
134     }
135
136     @Test
137     public void getSOTNPinterfaceByVpnIdTest() throws Exception {
138         Call<ResponseBody> call = getAaiCall("VpnBinding");
139
140         when(aaiService.getPinterfaceByVpnId("1")).thenReturn(call);
141         sotnServiceTemplateService.getSOTNPinterfaceByVpnId("1");
142     }
143
144     @Test
145     public void getSOTNPinterfaceByVpnIdWithThrowException() throws Exception {
146         Call<ResponseBody> call = getAaiCall("VpnBinding");
147         when(aaiService.getPinterfaceByVpnId("1")).thenReturn(call);
148         sotnServiceTemplateService.getSOTNPinterfaceByVpnId("1");
149     }
150
151     @Test
152     public void getSOTNPnfTest() throws Exception {
153         Call<ResponseBody> call = getAaiCall("Pnf");
154         when(aaiService.getPnfInfo("test")).thenReturn(call);
155         sotnServiceTemplateService.getSOTNPnf("test");
156     }
157
158     @Test
159     public void getSOTNPnfWithThrowException() throws Exception {
160         Call<ResponseBody> call = getAaiCall("Pnf");
161         when(aaiService.getPnfInfo("test")).thenReturn(call);
162         sotnServiceTemplateService.getSOTNPnf("test");
163     }
164
165     @Test
166     public void getSOTNLinkbyNameTest() throws Exception {
167         Call<ResponseBody> call = getAaiCall("LogicalLink");
168         when(aaiService.getSpecificLogicalLink("link")).thenReturn(call);
169         sotnServiceTemplateService.getSOTNLinkbyName("link");
170     }
171
172     @Test
173     public void getSOTNLinkbyNameWithThrowException() throws Exception {
174         Call<ResponseBody> call = getAaiCall("LogicalLink");
175         when(aaiService.getSpecificLogicalLink("link")).thenReturn(call);
176         sotnServiceTemplateService.getSOTNLinkbyName("link");
177     }
178
179
180     @Test
181     public void getUNIInfoTest() throws Exception {
182         Call<ResponseBody> call = getAaiCall("Uni");
183         when(aaiService.getUNIInfo("uni-id")).thenReturn(call);
184         sotnServiceTemplateService.getUNIInfo("uni-id");
185     }
186     @Test
187     public void getUNIInfoWithThrowException() throws Exception {
188         Call<ResponseBody> call = getAaiCall("Uni");
189         when(aaiService.getUNIInfo("uni-id")).thenReturn(call);
190         sotnServiceTemplateService.getUNIInfo("uni-id");
191     }
192     @Test
193     public void getVnfsTest() throws Exception {
194         Call<ResponseBody> call = getAaiCall("Vnfs");
195         when(aaiService.getVNFsDetail("vnf-id")).thenReturn(call);
196         sotnServiceTemplateService.getVnfs("vnf-id");
197     }
198     @Test
199     public void getVnfsWithThrowException() throws Exception {
200         Call<ResponseBody> call = getAaiCall("Vnfs");
201         when(aaiService.getVNFsDetail("vnf-id")).thenReturn(call);
202         sotnServiceTemplateService.getVnfs("vnf-id");
203     }
204     @Test
205     public void getReadFile_unniTest() throws Exception {
206         ModelConfig mdl = new ModelConfig();
207         sotnServiceTemplateService.readFile_unni();
208     }
209     @Test
210     public void getReadFileTest() throws Exception {
211         ModelConfig mdl = new ModelConfig();
212         sotnServiceTemplateService.readFile();
213     }
214
215     // TODO: 2021/1/22  
216     @Test
217     public void getSOTNSiteInformationTopologyTest() throws Exception {
218         Call<ResponseBody> call = getAaiCall("ServiceInstance");
219         Call<ResponseBody> call1 = getAaiCall("AllottedResource");
220         Call<ResponseBody> call2 = getAaiCall("SiteResource");
221         Call<ResponseBody> call3 = getAaiCall("Connectivity");
222         Call<ResponseBody> call4 = getAaiCall("ComplexObj");
223         Call<ResponseBody> call5 = getAaiCall("Pinterface");
224         when(aaiService.getServiceInstancesForEdge(anyString(),anyString(),anyString())).thenReturn(call);
225         when(aaiService.getSiteResourceInfo(anyString())).thenReturn(call2);
226         when(aaiService.getConnectivityInformation(anyString())).thenReturn(call3);
227         when(aaiService.getAllotedResourceFor5G(anyString(),anyString(),anyString(),anyString())).thenReturn(call1);
228         when(aaiService.getComplexObject(anyString())).thenReturn(call4);
229         when(aaiService.getTerminationPoint(anyString(),anyString())).thenReturn(call5);
230         sotnServiceTemplateService.getSOTNSiteInformationTopology("SOTN", "ISAAC");
231     }
232     @Test
233     public void getSOTNSiteInformationTopologyWithThrowException() throws Exception {
234         Call<ResponseBody> call = getAaiCall("ServiceInstance");
235         Call<ResponseBody> call1 = getAaiCall("AllottedResource");
236         Call<ResponseBody> call2 = getAaiCall("SiteResource");
237         Call<ResponseBody> call3 = getAaiCall("Connectivity");
238         Call<ResponseBody> call4 = getAaiCall("ComplexObj");
239         Call<ResponseBody> call5 = getAaiCall("Pinterface");
240         when(aaiService.getServiceInstancesForEdge(anyString(),anyString(),anyString())).thenReturn(call);
241         when(aaiService.getSiteResourceInfo(anyString())).thenReturn(call2);
242         when(aaiService.getConnectivityInformation(anyString())).thenReturn(call3);
243         when(aaiService.getAllotedResourceFor5G(anyString(),anyString(),anyString(),anyString())).thenReturn(call1);
244         when(aaiService.getComplexObject(anyString())).thenReturn(call4);
245         when(aaiService.getTerminationPoint(anyString(),anyString())).thenReturn(call5);
246         sotnServiceTemplateService.getSOTNSiteInformationTopology("SOTN", "ISAAC");
247     }
248     @Test
249     public void getServiceTest() throws Exception {
250         Call<ResponseBody> call = getAaiCall("ServiceInstance");
251         Call<ResponseBody> call1 = getAaiCall("AllottedResource");
252         Call<ResponseBody> call2 = getAaiCall("SiteResource");
253         Call<ResponseBody> call3 = getAaiCall("Connectivity");
254         Call<ResponseBody> call4 = getAaiCall("ComplexObj");
255         when(aaiService.getServiceInstancesForEdge(anyString(),anyString(),anyString())).thenReturn(call);
256         when(aaiService.getSiteResourceInfo(anyString())).thenReturn(call2);
257         when(aaiService.getConnectivityInformation(anyString())).thenReturn(call3);
258         when(aaiService.getAllotedResourceFor5G(anyString(),anyString(),anyString(),anyString())).thenReturn(call1);
259         when(aaiService.getComplexObject(anyString())).thenReturn(call4);
260         sotnServiceTemplateService.getService("SOTN", "ISAAC");
261     }
262     @Test
263     public void getServiceWithThrowException() throws Exception {
264         Call<ResponseBody> call = getAaiCall("ServiceInstance");
265         ResponseBody result = null;
266         when(aaiService.getServiceInstancesForEdge(anyString(),anyString(),anyString())).thenReturn(call);
267         ResponseBody result1 = null;
268         when(aaiService.getConnectivityInformation("1")).thenReturn(failedCall("Failed to get connectivity"));
269         ResponseBody result2 = null;
270         when(aaiService.getAllotedResourceFor5G("1", "SONT", "ISAAC", "2")).thenReturn(failedCall("failed to get allocated resource"));
271         sotnServiceTemplateService.getService("SOTN", "ISAAC");
272     }
273     @Test
274     public void getSOTNServiceInformationTopologyTest() throws Exception {
275         Call<ResponseBody> call = getAaiCall("ServiceInstance");
276         Call<ResponseBody> call1 = getAaiCall("Uni");
277         Call<ResponseBody> call2 = getAaiCall("Vnfs");
278         Call<ResponseBody> call3 = getAaiCall("Connectivity");
279         Call<ResponseBody> call4 = getAaiCall("Pinterface");
280         Call<ResponseBody> call5 = getAaiCall("VpnBinding");
281         when(aaiService.getServiceInstancesForEdge(anyString(),anyString(),anyString())).thenReturn(call);
282         when(aaiService.getUNIInfo(anyString())).thenReturn(call1);
283         when(aaiService.getVNFsDetail(anyString())).thenReturn(call2);
284         when(aaiService.getConnectivityInformation(anyString())).thenReturn(call3);
285         when(aaiService.getTerminationPoint(anyString(),anyString())).thenReturn(call4);
286         when(aaiService.getPinterfaceByVpnId(anyString())).thenReturn(call5);
287         sotnServiceTemplateService.getServiceInformationTopology("example-service-type-val-52265", "NNI-001");
288     }
289     @Test
290     public void getSOTNServiceInformationTopologyWithThrowException() throws Exception {
291         Call<ResponseBody> call = getAaiCall("ServiceInstance");
292         Call<ResponseBody> call1 = getAaiCall("Uni");
293         Call<ResponseBody> call2 = getAaiCall("Vnfs");
294         Call<ResponseBody> call3 = getAaiCall("Connectivity");
295         Call<ResponseBody> call4 = getAaiCall("Pinterface");
296         Call<ResponseBody> call5 = getAaiCall("VpnBinding");
297         when(aaiService.getServiceInstancesForEdge(anyString(),anyString(),anyString())).thenReturn(call);
298         when(aaiService.getUNIInfo(anyString())).thenReturn(call1);
299         when(aaiService.getVNFsDetail(anyString())).thenReturn(call2);
300         when(aaiService.getConnectivityInformation(anyString())).thenReturn(call3);
301         when(aaiService.getTerminationPoint(anyString(),anyString())).thenReturn(call4);
302         when(aaiService.getPinterfaceByVpnId(anyString())).thenReturn(call5);
303         sotnServiceTemplateService.getServiceInformationTopology("SOTN", "ISAAC");
304     }
305
306
307     @Test
308     public void getVPNBindingInformationTopologyTest() throws Exception {
309         Call<ResponseBody> call = getAaiCall("VpnBinding");
310         when(aaiService.getPinterfaceByVpnId(anyString())).thenReturn(call);
311         Call<ResponseBody> call1 = getAaiCall("Pinterface");
312         when(aaiService.getTerminationPoint(anyString(),anyString())).thenReturn(call1);
313         sotnServiceTemplateService.getVPNBindingInformationTopology("example-service-type-val-52265", "NNI-001", "vpn-bind-1");
314     }
315     @Test
316     public void getVPNBindingInformationTopologyWithThrowException() throws Exception {
317         Call<ResponseBody> call = getAaiCall("VpnBinding");
318         when(aaiService.getPinterfaceByVpnId(anyString())).thenReturn(call);
319         Call<ResponseBody> call1 = getAaiCall("Pinterface");
320         when(aaiService.getTerminationPoint(anyString(),anyString())).thenReturn(call1);
321         sotnServiceTemplateService.getVPNBindingInformationTopology("example-service-type-val-52265", "NNI-001", "vpn-bind-1");
322     }
323
324     @Test
325     public void deleteServiceTest() throws Exception {
326         Call<ResponseBody> aaiCall = getAaiCall("ServiceInstance");
327         Call<DeleteOperationRsp> sosCall = getDeleteSosCall();
328         Response result = null;
329         RequestBody requestBody = null;
330         when(aaiService.getServiceInstancesForEdge(anyString(),anyString(),anyString())).thenReturn(aaiCall);
331         when(soService.terminateService(anyString(),any(RequestBody.class))).thenReturn(sosCall);
332         sotnServiceTemplateService.deleteService("NNI-001", "vpn-bind-1");
333     }
334     @Test
335     public void deleteServiceWithThrowException() throws Exception {
336         Call<ResponseBody> aaiCall = getAaiCall("ServiceInstance");
337         Call<ServiceOperation> sosCall = getSosCall();
338         Response result = null;
339         RequestBody requestBody = null;
340         when(aaiService.getServiceInstancesForEdge("ISAAC", "example-service-type-val-52265", "NNI-001")).thenReturn(aaiCall);
341         when(soService.terminateService("serviceId",requestBody)).thenReturn(failedCall("failed to delete the server."));
342         sotnServiceTemplateService.deleteService("NNI-001", "vpn-bind-1");
343     }
344     @Test
345     public void getNodeTest() throws Exception {
346         sotnServiceTemplateService.getNode("001", "vpn-bind-1","image.png");
347     }
348     @Test
349     public void getEdgeTest() throws Exception {
350         sotnServiceTemplateService.getEdge("fromid", "toId");
351     }
352
353     @Test
354     public void getSOTNResourceInformationTopologyTest() throws Exception {
355         Call<ResponseBody> aaiCall = getAaiCall("ServiceInstance");
356         Call<ResponseBody> aaiCall1 = getAaiCall("Connectivity");
357         Call<ResponseBody> aaiCall2 = getAaiCall("Pnf");
358         Call<ResponseBody> aaiCall3 = getAaiCall("Pinterface");
359         Call<ResponseBody> aaiCall4 = getAaiCall("VpnBinding");
360         Call<ResponseBody> aaiCall5 = getAaiCall("LogicalLink");
361         when(aaiService.getServiceInstancesForEdge(anyString(),anyString(),anyString())).thenReturn(aaiCall);
362         when(aaiService.getConnectivityInformation( anyString())).thenReturn(aaiCall1);
363         when(aaiService.getPnfInfo(anyString())).thenReturn(aaiCall2);
364         when(aaiService.getTerminationPoint(anyString(),anyString())).thenReturn(aaiCall3);
365         when(aaiService.getPinterfaceByVpnId(anyString())).thenReturn(aaiCall4);
366         when(aaiService.getSpecificLogicalLink(anyString())).thenReturn(aaiCall5);
367         sotnServiceTemplateService.getSOTNResourceInformationTopology("example-service-type-val-52265", "NNI-001");
368     }
369     @Test
370     public void getSOTNResourceInformationTopologyWithThrowException() throws Exception {
371         ResponseBody result = null;
372         when(aaiService.getServiceInstancesForEdge("ISAAC", "example-service-type-val-52265", "NNI-001")).thenReturn(failedCall("failed to get sotn resource topology."));
373         sotnServiceTemplateService.getSOTNResourceInformationTopology("example-service-type-val-52265", "NNI-001");
374     }
375
376
377     private Call<ServiceOperation> getSosCall(){
378         Call<ServiceOperation> call = new Call<ServiceOperation>() {
379
380             @Override
381             public retrofit2.Response<ServiceOperation> execute() throws IOException {
382                 ServiceOperation serviceOperation=new ServiceOperation();
383                 return retrofit2.Response.success(serviceOperation);
384             }
385
386             @Override
387             public void enqueue(Callback<ServiceOperation> callback) {
388
389             }
390
391             @Override
392             public boolean isExecuted() {
393                 return false;
394             }
395
396             @Override
397             public void cancel() {
398
399             }
400
401             @Override
402             public boolean isCanceled() {
403                 return false;
404             }
405
406             @Override
407             public Call<ServiceOperation> clone() {
408                 return null;
409             }
410
411             @Override
412             public Request request() {
413                 return null;
414             }
415         };
416         return call;
417     }
418     private Call<DeleteOperationRsp> getDeleteSosCall(){
419         Call<DeleteOperationRsp> call = new Call<DeleteOperationRsp>() {
420             @Override
421             public retrofit2.Response<DeleteOperationRsp> execute() throws IOException {
422                 DeleteOperationRsp deleteOperationRsp = new DeleteOperationRsp();
423                 return retrofit2.Response.success(deleteOperationRsp);
424             }
425
426             @Override
427             public void enqueue(Callback<DeleteOperationRsp> callback) {
428
429             }
430
431             @Override
432             public boolean isExecuted() {
433                 return false;
434             }
435
436             @Override
437             public void cancel() {
438
439             }
440
441             @Override
442             public boolean isCanceled() {
443                 return false;
444             }
445
446             @Override
447             public Call<DeleteOperationRsp> clone() {
448                 return null;
449             }
450
451             @Override
452             public Request request() {
453                 return null;
454             }
455         };
456         return call;
457     }
458     private Call<ResponseBody> getAaiCall(String t){
459         Call<ResponseBody> call = new Call<ResponseBody>() {
460             @Override
461             public retrofit2.Response<ResponseBody> execute() throws IOException {
462                 ResponseBody responseBody= new ResponseBody() {
463                     @Nullable
464                     @Override
465                     public MediaType contentType() {
466                         return null;
467                     }
468
469                     @Override
470                     public long contentLength() {
471                         long lenth = 0;
472                         // TODO: 2021/1/21 é•¿åº¦
473                         if(t.equals("ServiceInstance")){
474                             lenth = 417;
475                         }else if(t.equals("Connectivity")){
476                             lenth = 163;
477                         }else if(t.equals("Pinterface")){
478                             lenth = 326;
479                         }else if(t.equals("AllottedResource")){
480                             lenth = 48;
481                         }else if(t.equals("SiteResource")){
482                             lenth = 154;
483                         }else if(t.equals("ComplexObj")){
484                             lenth = 111;
485                         }else if(t.equals("VpnBinding")){
486                             lenth = 254;
487                         }else if(t.equals("Pnf")){
488                             lenth = 46;
489                         }else if(t.equals("LogicalLink")){
490                             lenth = 281;
491                         }else if(t.equals("Uni")){
492                             lenth = 221;
493                         }else if(t.equals("Vnfs")){
494                             lenth = 190;
495                         }
496                         return lenth;
497                     }
498
499                     @Override
500                     public BufferedSource source() {
501                         BufferedSource bufferedSource = new BufferedSource() {
502                             @Override
503                             public long read(Buffer buffer, long l) throws IOException {
504                                 return 0;
505                             }
506
507                             @Override
508                             public Timeout timeout() {
509                                 return null;
510                             }
511
512                             @Override
513                             public void close() throws IOException {
514
515                             }
516
517                             @Override
518                             public boolean isOpen() {
519                                 return false;
520                             }
521
522                             @Override
523                             public int read(ByteBuffer dst) throws IOException {
524                                 return 0;
525                             }
526
527                             @Override
528                             public Buffer buffer() {
529                                 return null;
530                             }
531
532                             @Override
533                             public boolean exhausted() throws IOException {
534                                 return false;
535                             }
536
537                             @Override
538                             public void require(long l) throws IOException {
539
540                             }
541
542                             @Override
543                             public boolean request(long l) throws IOException {
544                                 return false;
545                             }
546
547                             @Override
548                             public byte readByte() throws IOException {
549                                 return 0;
550                             }
551
552                             @Override
553                             public short readShort() throws IOException {
554                                 return 0;
555                             }
556
557                             @Override
558                             public short readShortLe() throws IOException {
559                                 return 0;
560                             }
561
562                             @Override
563                             public int readInt() throws IOException {
564                                 return 0;
565                             }
566
567                             @Override
568                             public int readIntLe() throws IOException {
569                                 return 0;
570                             }
571
572                             @Override
573                             public long readLong() throws IOException {
574                                 return 0;
575                             }
576
577                             @Override
578                             public long readLongLe() throws IOException {
579                                 return 0;
580                             }
581
582                             @Override
583                             public long readDecimalLong() throws IOException {
584                                 return 0;
585                             }
586
587                             @Override
588                             public long readHexadecimalUnsignedLong() throws IOException {
589                                 return 0;
590                             }
591
592                             @Override
593                             public void skip(long l) throws IOException {
594
595                             }
596
597                             @Override
598                             public ByteString readByteString() throws IOException {
599                                 return null;
600                             }
601
602                             @Override
603                             public ByteString readByteString(long l) throws IOException {
604                                 return null;
605                             }
606
607                             @Override
608                             public int select(Options options) throws IOException {
609                                 return 0;
610                             }
611
612                             @Override
613                             public byte[] readByteArray() throws IOException {
614                                 // TODO: 2021/1/21 å­—符串
615                                 String s = new String();
616                                 if(t.equals("ServiceInstance")){
617                                     s = "{\"service-instance-id\":\"234\",\"service-instance-name\":18,\"input-parameters\":\"as\",\"service-type\":1591851786568,\"relationship-list\":{\"relationship\":[{\"related-to\":\"service-instance\",\"related-link\":\"12/0\"},{\"related-to\":\"generic-vnf\",\"related-link\":\"12/0\"},{\"related-to\":\"allotted-resource\",\"related-link\":\"12/0\"},{\"related-to\":\"connectivity\",\"related-link\":\"12/0\"},{\"related-to\":\"site-resource\",\"related-link\":\"12/0\"}]}}";
618                                 }else if(t.equals("Connectivity")){
619                                     s = "{\"connectivity-id\":\"234\",\"bandwidth-profile-name\":18,\"cir\":1591851786568,\"relationship-list\":{\"relationship\":[{\"related-to\":\"vpn-binding\",\"related-link\":\"12/0\"}]}}";
620                                 }else if(t.equals("Pinterface")){
621                                     s = "{\"interface-name\":\"234\",\"speed-units\":18,\"port-description\":1591851786568," +
622                                             "\"speed-value\":\"234\",\"equipment-identifier\":18,\"resource-version\":1591851786568," +
623                                             "\"in-maint\":\"true\",\"network-ref\":\"23\",\"transparent\":\"34\",\"operational-status\":\"34\",\"relationship-list\":{\"relationship\":[{\"related-to\":\"logical-link\",\"related-link\":\"12/0\"}]}}";
624                                 }else if(t.equals("AllottedResource")){
625                                     s = "{\"id\":234,\"selflink\":18,\"model-invariant-id\":12}";
626                                 }else if(t.equals("SiteResource")){
627                                     s = "{\"site-resource-id\":\"234\",\"site-resource-name\":18,\"description\":12,\"relationship-list\":{\"relationship\":[{\"related-to\":\"complex\",\"related-link\":\"123/0\"}]}}";
628                                 }else if(t.equals("ComplexObj")){
629                                     s = "{\"physical-location-id\":\"234\",\"resource-version\":18,\"physical-location-type\":12,\"city\":\"sd\",\"postal-code\":\"ds\"}";
630                                 }else if(t.equals("VpnBinding")){
631                                     s = "{\"vpn-binding\":[{\"vpn-id\":23,\"src-access-node-id\":18,\"dst-access-node-id\":18,\"relationship-list\":{\"relationship\":[{\"related-to\":\"p-interface\",\"relationship-data\":[{\"relationship-key\":\"pnf.pnf-name\",\"relationship-value\":\"23\"}],\"related-link\":\"123/2\"}]}}]}";
632                                 }else if(t.equals("Pnf")){
633                                     s = "{\"pnf-name\":\"234\",\"pnf-id\":18,\"in-maint\":true}";
634                                 }else if(t.equals("LogicalLink")){
635                                     s = "{\"link-name\":\"234\",\"in-maint\":18,\"link-type\":true,\"relationship-list\":{\"relationship\":[{\"related-to\":\"p-interface\",\"relationship-data\":[{\"relationship-key\":\"pnf.pnf-name\",\"relationship-value\":\"26\"}],\"related-link\":\"123/0\"},{\"related-to\":\"ext-aai-network\",\"related-link\":\"123/0\"}]}}";;
636                                 }else if(t.equals("Uni")){
637                                     s = "{\"id\":\"234\",\"tpId\":18,\"resource-version\":true,\"relationship-list\":{\"relationship\":[{\"related-to\":\"p-interface\",\"relationship-data\":[{\"relationship-key\":\"pnf.pnf-name\",\"relationship-value\":\"26\"}],\"related-link\":\"123/0\"}]}}";
638                                 }else if(t.equals("Vnfs")){
639                                     s = "{\"vnf-id\":\"234\",\"in-maint\":18,\"resource-version\":true,\"relationship-list\":{\"relationship\":[{\"related-to\":\"connectivity\",\"related-link\":\"123/0\"},{\"related-to\":\"uni\",\"related-link\":\"123/0\"}]}}";
640                                 }
641                                 byte[] bytes = s.getBytes();
642                                 return bytes;
643                             }
644
645                             @Override
646                             public byte[] readByteArray(long l) throws IOException {
647                                 return new byte[0];
648                             }
649
650                             @Override
651                             public int read(byte[] bytes) throws IOException {
652                                 return 0;
653                             }
654
655                             @Override
656                             public void readFully(byte[] bytes) throws IOException {
657
658                             }
659
660                             @Override
661                             public int read(byte[] bytes, int i, int i1) throws IOException {
662                                 return 0;
663                             }
664
665                             @Override
666                             public void readFully(Buffer buffer, long l) throws IOException {
667
668                             }
669
670                             @Override
671                             public long readAll(Sink sink) throws IOException {
672                                 return 0;
673                             }
674
675                             @Override
676                             public String readUtf8() throws IOException {
677                                 return null;
678                             }
679
680                             @Override
681                             public String readUtf8(long l) throws IOException {
682                                 return null;
683                             }
684
685                             @Nullable
686                             @Override
687                             public String readUtf8Line() throws IOException {
688                                 return null;
689                             }
690
691                             @Override
692                             public String readUtf8LineStrict() throws IOException {
693                                 return null;
694                             }
695
696                             @Override
697                             public String readUtf8LineStrict(long l) throws IOException {
698                                 return null;
699                             }
700
701                             @Override
702                             public int readUtf8CodePoint() throws IOException {
703                                 return 0;
704                             }
705
706                             @Override
707                             public String readString(Charset charset) throws IOException {
708                                 return null;
709                             }
710
711                             @Override
712                             public String readString(long l, Charset charset) throws IOException {
713                                 return null;
714                             }
715
716                             @Override
717                             public long indexOf(byte b) throws IOException {
718                                 return 0;
719                             }
720
721                             @Override
722                             public long indexOf(byte b, long l) throws IOException {
723                                 return 0;
724                             }
725
726                             @Override
727                             public long indexOf(byte b, long l, long l1) throws IOException {
728                                 return 0;
729                             }
730
731                             @Override
732                             public long indexOf(ByteString byteString) throws IOException {
733                                 return 0;
734                             }
735
736                             @Override
737                             public long indexOf(ByteString byteString, long l) throws IOException {
738                                 return 0;
739                             }
740
741                             @Override
742                             public long indexOfElement(ByteString byteString) throws IOException {
743                                 return 0;
744                             }
745
746                             @Override
747                             public long indexOfElement(ByteString byteString, long l) throws IOException {
748                                 return 0;
749                             }
750
751                             @Override
752                             public boolean rangeEquals(long l, ByteString byteString) throws IOException {
753                                 return false;
754                             }
755
756                             @Override
757                             public boolean rangeEquals(long l, ByteString byteString, int i, int i1) throws IOException {
758                                 return false;
759                             }
760
761                             @Override
762                             public InputStream inputStream() {
763                                 return null;
764                             }
765                         };
766                         return bufferedSource;
767                     }
768                 };
769                 return retrofit2.Response.success(200,responseBody);
770             }
771
772             @Override
773             public void enqueue(Callback<ResponseBody> callback) {
774
775             }
776
777             @Override
778             public boolean isExecuted() {
779                 return false;
780             }
781
782             @Override
783             public void cancel() {
784
785             }
786
787             @Override
788             public boolean isCanceled() {
789                 return false;
790             }
791
792             @Override
793             public Call<ResponseBody> clone() {
794                 return null;
795             }
796
797             @Override
798             public Request request() {
799                 return null;
800             }
801         };
802         return call;
803     }
804 }
805