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