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