summaryrefslogtreecommitdiffstats
path: root/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/rest/CnfAdapterRestTest.java
blob: 1b16580da642d1a83870931fd9d79e809e916426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
/*-
 * ============LICENSE_START=======================================================
 * ONAP - SO
 * ================================================================================
 * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.so.adapters.cnf.rest;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.onap.so.adapters.cnf.MulticloudConfiguration;
import org.onap.so.adapters.cnf.client.SoCallbackClient;
import org.onap.so.adapters.cnf.model.BpmnInstanceRequest;
import org.onap.so.adapters.cnf.model.CheckInstanceRequest;
import org.onap.so.adapters.cnf.model.ConfigTemplateEntity;
import org.onap.so.adapters.cnf.model.ConfigurationEntity;
import org.onap.so.adapters.cnf.model.ConfigurationRollbackEntity;
import org.onap.so.adapters.cnf.model.ConnectivityInfo;
import org.onap.so.adapters.cnf.model.InstanceMiniResponse;
import org.onap.so.adapters.cnf.model.InstanceMiniResponseList;
import org.onap.so.adapters.cnf.model.InstanceResponse;
import org.onap.so.adapters.cnf.model.InstanceStatusResponse;
import org.onap.so.adapters.cnf.model.MulticloudInstanceRequest;
import org.onap.so.adapters.cnf.model.ProfileEntity;
import org.onap.so.adapters.cnf.model.Resource;
import org.onap.so.adapters.cnf.model.ResourceBundleEntity;
import org.onap.so.adapters.cnf.model.Tag;
import org.onap.so.adapters.cnf.model.aai.AaiCallbackResponse;
import org.onap.so.adapters.cnf.model.aai.AaiRequest;
import org.onap.so.adapters.cnf.model.healthcheck.HealthCheckResponse;
import org.onap.so.adapters.cnf.model.statuscheck.StatusCheckResponse;
import org.onap.so.adapters.cnf.model.upgrade.InstanceUpgradeRequest;
import org.onap.so.adapters.cnf.service.CnfAdapterService;
import org.onap.so.adapters.cnf.service.aai.AaiService;
import org.onap.so.adapters.cnf.service.healthcheck.HealthCheckService;
import org.onap.so.adapters.cnf.service.statuscheck.SimpleStatusCheckService;
import org.onap.so.adapters.cnf.service.upgrade.InstanceUpgradeService;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.junit.Assert.assertEquals;


@SpringBootTest
@RunWith(SpringRunner.class)
public class CnfAdapterRestTest {

    @InjectMocks
    org.onap.so.adapters.cnf.rest.CnfAdapterRest cnfAdapterRest;

    @Mock
    CnfAdapterService cnfAdapterService;

    @Mock
    InstanceUpgradeService instanceUpgradeService;

    @Mock
    HealthCheckService healthCheckService;

    @Mock
    private SoCallbackClient callbackClient;

    @Mock
    SimpleStatusCheckService simpleStatusCheckService;

    @Mock
    private MulticloudConfiguration multicloudConfiguration;

    @Mock
    ResponseEntity<InstanceMiniResponseList> instacneMiniResponseList;

    @Mock
    ResponseEntity<InstanceStatusResponse> instanceStatusResponse;

    @Test
    public void createInstanceTest() throws Exception {

        Map<String, String> labels = new HashMap<String, String>();
        labels.put("custom-label-1", "label1");
        Map<String, String> overrideValues = new HashMap<String, String>();
        labels.put("image.tag", "latest");
        labels.put("dcae_collector_ip", "1.2.3.4");
        BpmnInstanceRequest bpmnInstanceRequest = new BpmnInstanceRequest();
        bpmnInstanceRequest.setCloudRegionId("v1");
        bpmnInstanceRequest.setLabels(labels);
        bpmnInstanceRequest.setModelInvariantId("krd");
        bpmnInstanceRequest.setModelVersionId("p1");
        bpmnInstanceRequest.setOverrideValues(overrideValues);
        bpmnInstanceRequest.setVfModuleUUID("20200824");
        List<Resource> resourceList = new ArrayList<Resource>();
        InstanceResponse instanceResponse = new InstanceResponse();
        instanceResponse.setId("123");
        instanceResponse.setNamespace("testNamespace");
        instanceResponse.setRequest(new MulticloudInstanceRequest());
        instanceResponse.setResources(resourceList);
        ResponseEntity<String> createInstanceResponse = new ResponseEntity<String>(HttpStatus.CREATED);
        CnfAdapterService cnfAdapterService = Mockito.mock(CnfAdapterService.class);
        Mockito.when(cnfAdapterService.createInstance(bpmnInstanceRequest))
                .thenReturn(String.valueOf(createInstanceResponse));
        cnfAdapterRest.createInstance(bpmnInstanceRequest);
        Assert.assertNotNull(createInstanceResponse);
        assertEquals(HttpStatus.CREATED, createInstanceResponse.getStatusCode());
    }

    @Test
    public void getInstanceByInstanceIdTest() throws Exception {

        String instanceId = "123";
        ResponseEntity<String> createInstanceResponse = new ResponseEntity<String>(HttpStatus.OK);
        CnfAdapterService cnfAdapterService = Mockito.mock(CnfAdapterService.class);
        Mockito.when(cnfAdapterService.getInstanceByInstanceId(instanceId))
                .thenReturn(String.valueOf(createInstanceResponse));
        cnfAdapterRest.getInstanceByInstanceId(instanceId);
        Assert.assertNotNull(createInstanceResponse);
        assertEquals(HttpStatus.OK, createInstanceResponse.getStatusCode());
    }

    @Test
    public void deleteInstanceByInstanceIdTest() throws Exception {

        String instanceId = "123";
        ResponseEntity<String> response = new ResponseEntity<String>(HttpStatus.OK);
        CnfAdapterService cnfAdapterService = Mockito.mock(CnfAdapterService.class);
        Mockito.when(cnfAdapterService.deleteInstanceByInstanceId(instanceId)).thenReturn(String.valueOf(response));
        cnfAdapterRest.deleteInstanceByInstanceId(instanceId);
        Assert.assertNotNull(response);
        assertEquals(HttpStatus.OK, response.getStatusCode());
    }

    @Test
    public void getInstanceStatusByInstanceIdTest() throws Exception {

        String instanceId = "123";
        instanceStatusResponse = new ResponseEntity<InstanceStatusResponse>(HttpStatus.OK);
        CnfAdapterService cnfAdapterService = Mockito.mock(CnfAdapterService.class);
        Mockito.when(cnfAdapterService.getInstanceStatusByInstanceId(instanceId))
                .thenReturn(String.valueOf(instanceStatusResponse));
        cnfAdapterRest.getInstanceStatusByInstanceId(instanceId);
        Assert.assertNotNull(instanceStatusResponse);
        assertEquals(HttpStatus.OK, instanceStatusResponse.getStatusCode());
    }

    @Test
    public void queryInstanceResourcesTest() {
        String instanceId = "123";
        String kind = "Service";
        String apiVersion = "v1";
        String queryResponseMock = "queryResponseMock";

        Mockito.when(cnfAdapterService.queryInstanceResources(instanceId, kind, apiVersion, null, null,
                null)).thenReturn(queryResponseMock);

        String result = cnfAdapterRest.queryInstanceResources(instanceId, kind, apiVersion, null, null,
                null);
        assertThat(result).isEqualTo(queryResponseMock);
    }

    @Test
    public void queryResourcesTest() {
        String kind = "Service";
        String apiVersion = "v1";
        String cloudRegion = "region";
        String queryResponseMock = "queryResponseMock";

        Mockito.when(cnfAdapterService.queryResources(kind, apiVersion, null, null,
                null, cloudRegion)).thenReturn(queryResponseMock);

        String result = cnfAdapterRest.queryResources(kind, apiVersion, null, null,
                null, cloudRegion);
        assertThat(result).isEqualTo(queryResponseMock);
    }

    @Test
    public void getInstanceByRBNameOrRBVersionOrProfileNameTest() throws Exception {

        String rbName = "xyz";
        String rbVersion = "v1";
        String profileName = "p1";
        MulticloudInstanceRequest request = null;
        InstanceMiniResponse instanceMiniResponse = new InstanceMiniResponse(HttpStatus.OK.toString());

        instanceMiniResponse.setId("a");
        instanceMiniResponse.setNameSpace("ab");
        instanceMiniResponse.setErrorMsg("Error");
        instanceMiniResponse.setRequest(request);

        instanceMiniResponse.getId();
        instanceMiniResponse.getNameSpace();
        instanceMiniResponse.getRequest();
        instanceMiniResponse.getErrorMsg();

        List<InstanceMiniResponse> instancList = new ArrayList<InstanceMiniResponse>();
        instancList.add(instanceMiniResponse);
        InstanceMiniResponseList instanceMiniRespList = new InstanceMiniResponseList(HttpStatus.OK.toString());
        instanceMiniRespList.setInstancList(instancList);
        instanceMiniRespList.setErrorMsg(HttpStatus.OK.toString());
        ResponseEntity<InstanceMiniResponseList> respone =
                new ResponseEntity<InstanceMiniResponseList>(instanceMiniRespList, HttpStatus.OK);
        CnfAdapterService cnfAdapterService = Mockito.mock(CnfAdapterService.class);
        Mockito.when(cnfAdapterService.getInstanceByRBNameOrRBVersionOrProfileName(rbName, rbVersion, profileName))
                .thenReturn(String.valueOf(instanceMiniResponse));
        cnfAdapterRest.getInstanceByRBNameOrRBVersionOrProfileName(rbName, rbVersion, profileName);
        Assert.assertNotNull(instacneMiniResponseList);
        assertEquals(HttpStatus.OK.toString(), instanceMiniRespList.getErrorMsg());
    }

    @Test
    public void createRBTest() throws Exception {

        Map<String, String> labels = new HashMap<String, String>();
        labels.put("custom-label-1", "label1");
        labels.put("image.tag", "latest");
        labels.put("dcae_collector_ip", "1.2.3.4");
        ResourceBundleEntity rb = new ResourceBundleEntity();
        rb.setChartName("v1");
        rb.setDescription("rb1");
        rb.setLabels(labels);
        rb.setRbName("rb");
        rb.setRbVersion("p1");

     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try {
            cnfAdapterRest.createRB(rb);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void getRBTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.getRB(RbName, RbVersion);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void deleteRBTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
    //    ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.deleteRB(RbName, RbVersion);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void getListOfRBTest() throws Exception {

        String RbName = "rb";

      //  ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.getListOfRB(RbName);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void getListOfRBWithoutUsingRBNameTest() throws Exception {

      //  ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.getListOfRBWithoutUsingRBName();
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void uploadArtifactForRBTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";

        MultipartFile file = Mockito.mock(MultipartFile.class);
        Mockito.when(file.getOriginalFilename()).thenReturn("first value");

    //    ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try {
            cnfAdapterRest.uploadArtifactForRB(file, RbName, RbVersion);
        } catch (Exception exp) {
            assert(true);
        }
    }

    @Test
    public void createProfileTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        ProfileEntity fE = new ProfileEntity();
      //  ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.createProfile(fE, RbName, RbVersion);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void getProfileTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String prName = "p";
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.getProfile(prName, RbName, RbVersion);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void getListOfProfileTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.getListOfProfile(RbName, RbVersion);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void deleteProfileTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String prName = "p";
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.deleteProfile(prName, RbName, RbVersion);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void uploadArtifactForProfileTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String prName = "p";

        MultipartFile file = Mockito.mock(MultipartFile.class);
        Mockito.when(file.getOriginalFilename()).thenReturn("OK");
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");

        try {
            cnfAdapterRest.uploadArtifactForProfile(file, RbName, RbVersion, prName);
        } catch (Exception exp) {
            assert(true);
        }

    }

    @Test
    public void createConfigurationTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String prName = "p";
        ConfigurationEntity cE = new ConfigurationEntity();
      //  ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.createConfiguration(cE, prName, RbName, RbVersion);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void getConfigurationTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String prName = "p";
        String cfgName = "cfg";
    //    ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.getConfiguration(prName, RbName, RbVersion, cfgName);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void deleteConfigurationTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String prName = "p";
        String cfgName = "cfg";
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.deleteConfiguration(prName, RbName, RbVersion, cfgName);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void updateConfigurationTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String prName = "p";
        String cfgName = "cfg";
        ConfigurationEntity cE = new ConfigurationEntity();
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.updateConfiguration(cE, prName, RbName, RbVersion, cfgName);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void tagConfigurationValueTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String prName = "p";
        Tag tag = new Tag();
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.tagConfigurationValue(tag, RbName, RbVersion, prName);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void createConnectivityInfoTest() throws Exception {

        ConnectivityInfo cIE = new ConnectivityInfo();
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.createConnectivityInfo(cIE);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void getConnectivityInfoTest() throws Exception {

        String connName = "con";
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.getConnectivityInfo(connName);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void deleteConnectivityInfoTest() throws Exception {

        String connName = "con";
    //    ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.deleteConnectivityInfo(connName);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void createConfigTemplateTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        ConfigTemplateEntity tE = new ConfigTemplateEntity();
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.createConfigTemplate(tE, RbName, RbVersion);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void getConfigTemplateTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String tName = "t";
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.getConfigTemplate(RbName, RbVersion, tName);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }


    @Test
    public void deleteTemplateTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String tName = "t";
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.deleteTemplate(RbName, RbVersion, tName);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void uploadTarFileForTemplateTest() throws Exception {

        String RbName = "rb";
        String RbVersion = "p1";
        String tName = "t";
        MultipartFile file = Mockito.mock(MultipartFile.class);
        Mockito.when(file.getOriginalFilename()).thenReturn("First value");
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try {
            cnfAdapterRest.uploadTarFileForTemplate(file, RbName, RbVersion, tName);
        } catch (Exception exp) {
            assert(true);
        }
    }

    @Test
    public void rollbackConfigurationTest() throws Exception {
        ConfigurationRollbackEntity rE = new ConfigurationRollbackEntity();
        String RbName = "rb";
        String RbVersion = "p1";
        String prName = "p";
     //   ReflectionTestUtils.setField(cnfAdapterRest, "uri", "http://localhost");
        try{
        cnfAdapterRest.rollbackConfiguration(rE, RbName, RbVersion, prName);
        }
        catch(Exception e)
        {
            assert(true);
        }
    }

    @Test
    public void upgradeTest() throws Exception {

        Map<String, String> labels = new HashMap<String, String>();
        labels.put("custom-label-1", "label1");
        Map<String, String> overrideValues = new HashMap<String, String>();
        labels.put("image.tag", "latest");
        labels.put("dcae_collector_ip", "1.2.3.4");
        InstanceUpgradeRequest instanceUpgradeRequest = new InstanceUpgradeRequest();
        instanceUpgradeRequest.setCloudRegionId("v1");
        instanceUpgradeRequest.setK8sRBInstanceStatusCheck(true);
        instanceUpgradeRequest.setK8sRBProfileName("test");
        instanceUpgradeRequest.setLabels(labels);
        instanceUpgradeRequest.setModelCustomizationId("12345");
        instanceUpgradeRequest.setModelInvariantId("krd");
        instanceUpgradeRequest.setOverrideValues(overrideValues);
        instanceUpgradeRequest.setVfModuleUUID("20200824");

        ResponseEntity<String> upgradeResponse = new ResponseEntity<String>(HttpStatus.OK);
        InstanceUpgradeService instanceUpgradeService = Mockito.mock(InstanceUpgradeService.class);
        Mockito.when(instanceUpgradeService.upgradeInstance("123", instanceUpgradeRequest))
                .thenReturn(String.valueOf(upgradeResponse));
        cnfAdapterRest.upgrade("123", instanceUpgradeRequest);
        Assert.assertNotNull(upgradeResponse);
        assertEquals(HttpStatus.OK, upgradeResponse.getStatusCode());
    }

    @Test
    public void healthCheckTest() throws Exception {
        HealthCheckResponse response = new HealthCheckResponse();
        DeferredResult<HealthCheckResponse> deferredResponse = new DeferredResult<>();
        deferredResponse.setResult(response);
        HealthCheckService healthCheckService = Mockito.mock(HealthCheckService.class);
        CheckInstanceRequest healthCheckRequest = Mockito.mock(CheckInstanceRequest.class);
        Mockito.when(healthCheckService.healthCheck(healthCheckRequest)).thenReturn(response);

        cnfAdapterRest.healthCheck(healthCheckRequest);

        Assert.assertNotNull(response);
    }

    @Test
    public void aaiUpdateTest() throws Exception {
        AaiCallbackResponse response = new AaiCallbackResponse();
        DeferredResult<AaiCallbackResponse> deferredResponse = new DeferredResult<>();
        deferredResponse.setResult(response);

        AaiRequest aaiRequest = new AaiRequest();
        aaiRequest.setCallbackUrl("asdf");
        aaiRequest.setVfModuleId("20200824");
        AaiService aaiService = Mockito.mock(AaiService.class);
        SoCallbackClient callbackClient = Mockito.mock(SoCallbackClient.class);

        cnfAdapterRest.aaiUpdate(aaiRequest);

        Assert.assertNotNull(response);
    }

    @Test
    public void aaiDeleteTest() throws Exception {
        AaiCallbackResponse response = new AaiCallbackResponse();
        DeferredResult<AaiCallbackResponse> deferredResponse = new DeferredResult<>();
        deferredResponse.setResult(response);

        AaiRequest aaiRequest = new AaiRequest();
        aaiRequest.setCallbackUrl("asdfds");
        aaiRequest.setVfModuleId("20200824");
        AaiService aaiService = Mockito.mock(AaiService.class);
        SoCallbackClient callbackClient = Mockito.mock(SoCallbackClient.class);

        cnfAdapterRest.aaiDelete(aaiRequest);

        Assert.assertNotNull(response);
    }

    @Test
    public void statusCheckTest() throws Exception {
        StatusCheckResponse response = new StatusCheckResponse();
        DeferredResult<StatusCheckResponse> deferredResponse = new DeferredResult<>();
        deferredResponse.setResult(response);

        CheckInstanceRequest statusCheckRequest = Mockito.mock(CheckInstanceRequest.class);
        SimpleStatusCheckService simpleStatusCheckService = Mockito.mock(SimpleStatusCheckService.class);
        SoCallbackClient callbackClient = Mockito.mock(SoCallbackClient.class);
        Mockito.when(simpleStatusCheckService.statusCheck(statusCheckRequest)).thenReturn(response);
        cnfAdapterRest.statusCheck(statusCheckRequest);

        Assert.assertNotNull(response);
    }
}