2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.cnf.service;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.mockito.InjectMocks;
26 import org.mockito.Mock;
27 import org.onap.so.adapters.cnf.MulticloudConfiguration;
28 import org.onap.so.adapters.cnf.model.BpmnInstanceRequest;
29 import org.springframework.http.ResponseEntity;
30 import org.springframework.test.context.junit4.SpringRunner;
31 import org.springframework.web.client.RestTemplate;
33 import java.util.HashMap;
36 @RunWith(SpringRunner.class)
37 public class CnfAdapterServiceTest {
38 private static final String INSTANCE_CREATE_PATH = "/v1/instance";
40 private RestTemplate restTemplate;
43 CnfAdapterService cnfAdapterService;
46 private MulticloudConfiguration multicloudConfiguration;
49 ResponseEntity<String> instanceResponse;
53 public void createInstanceTest() throws Exception {
54 Map<String, String> labels = new HashMap<String, String>();
55 labels.put("custom-label-1", "label1");
56 Map<String, String> overrideValues = new HashMap<String, String>();
57 overrideValues.put("a", "b");
58 labels.put("image.tag", "latest");
59 labels.put("dcae_collector_ip", "1.2.3.4");
60 BpmnInstanceRequest bpmnInstanceRequest = new BpmnInstanceRequest();
61 bpmnInstanceRequest.setCloudRegionId("v1");
62 bpmnInstanceRequest.setLabels(labels);
63 bpmnInstanceRequest.setModelInvariantId("krd");
64 bpmnInstanceRequest.setModelVersionId("p1");
65 bpmnInstanceRequest.setOverrideValues(overrideValues);
66 bpmnInstanceRequest.setVfModuleUUID("20200824");
67 bpmnInstanceRequest.setK8sRBProfileName("K8sRBProfileName is required");
69 cnfAdapterService.createInstance(bpmnInstanceRequest);
71 catch (Exception exp) {
78 public void getInstanceByInstanceIdTest() throws Exception {
79 String instanceId = "ins";
81 cnfAdapterService.getInstanceByInstanceId(instanceId);
83 catch (Exception exp) {
90 public void getInstanceStatusByInstanceIdTest() throws Exception {
91 String instanceId = "ins";
93 cnfAdapterService.getInstanceStatusByInstanceId(instanceId);
95 catch (Exception exp) {
102 public void getInstanceByRBNameOrRBVersionOrProfileNameTest() throws Exception {
103 String rbName = "rb";
104 String rbVersion = "rv1";
105 String profileName = "p1";
107 cnfAdapterService.getInstanceByRBNameOrRBVersionOrProfileName(rbName, rbVersion, profileName);
109 catch (Exception exp) {
116 public void deleteInstanceByInstanceIdTest() throws Exception {
117 String instanceId = "ins";
119 cnfAdapterService.deleteInstanceByInstanceId(instanceId);
121 catch (Exception exp) {