aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2020-12-01 22:35:03 +0000
committerLukasz Rajewski <lukasz.rajewski@orange.com>2020-12-03 00:18:00 +0000
commit679549feed7308541e3f57ed1a9991f5dc05398e (patch)
tree9a1a934e0333b386e58b0d49a260994146eddcf2
parent7f2254e92d36c90a07a723b69bd2e69a726714ac (diff)
Further changes for cnf-adpter in bpmn infra
Issue-ID: SO-3403 Change-Id: Iae2a27431797283553f0e329e8c2f3e4514001ef Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java26
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java2
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java18
-rw-r--r--adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/rest/CnfAdapterRestTest.java245
-rw-r--r--adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/service/CnfAdapterServiceTest.java243
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java18
7 files changed, 246 insertions, 310 deletions
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java
index effaaf5f78..ae63f86c8a 100644
--- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java
@@ -27,22 +27,24 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({"id", "request", "namespace", "resources"})
+@JsonPropertyOrder({"id", "request", "namespace", "release-name", "resources"})
@JsonIgnoreProperties(value = "true")
-public class InstanceResponse extends Response {
+public class InstanceResponse {
@JsonProperty("id")
private String id;
+
@JsonProperty("request")
private MulticloudInstanceRequest request;
+
@JsonProperty("namespace")
private String namespace;
- @JsonProperty("resources")
- private List<Resource> resources = null;
- public InstanceResponse(String errorMsg) {
- super(errorMsg);
- }
+ @JsonProperty("release-name")
+ private String releaseName;
+
+ @JsonProperty("resources")
+ private List<Resource> resources;
@JsonProperty("id")
public String getId() {
@@ -84,4 +86,14 @@ public class InstanceResponse extends Response {
this.resources = resources;
}
+ @JsonProperty("release-name")
+ public String getReleaseName() {
+ return releaseName;
+ }
+
+ @JsonProperty("release-name")
+ public void setReleaseName(String releaseName) {
+ this.releaseName = releaseName;
+ }
+
}
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
index 825778b89a..63f23038bc 100644
--- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
@@ -87,7 +87,7 @@ public class CnfAdapterRest {
@ResponseBody
@RequestMapping(value = {"/api/cnf-adapter/v1/instance"}, method = RequestMethod.POST,
produces = "application/json", consumes = "application/json")
- public ResponseEntity<InstanceResponse> createInstance(@RequestBody BpmnInstanceRequest bpmnInstanceRequest)
+ public String createInstance(@RequestBody BpmnInstanceRequest bpmnInstanceRequest)
throws JsonParseException, JsonMappingException, IOException {
logger.info("createInstance called.");
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java
index 06c09e3431..7e22a09d6b 100644
--- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java
@@ -26,6 +26,7 @@ import java.util.List;
import javax.persistence.EntityNotFoundException;
import javax.ws.rs.core.UriBuilder;
import org.apache.http.HttpStatus;
+import org.apache.http.util.EntityUtils;
import org.onap.so.adapters.cnf.model.BpmnInstanceRequest;
import org.onap.so.adapters.cnf.model.InstanceMiniResponse;
import org.onap.so.adapters.cnf.model.InstanceMiniResponseList;
@@ -84,12 +85,12 @@ public class CnfAdapterService {
}
}
- public ResponseEntity<InstanceResponse> createInstance(BpmnInstanceRequest bpmnInstanceRequest)
+ public String createInstance(BpmnInstanceRequest bpmnInstanceRequest)
throws JsonParseException, JsonMappingException, IOException {
try {
logger.info("CnfAdapterService createInstance called");
MulticloudInstanceRequest multicloudInstanceRequest = new MulticloudInstanceRequest();
- ResponseEntity<InstanceResponse> instanceResponse = null;
+ ResponseEntity<String> instanceResponse = null;
if (bpmnInstanceRequest.getK8sRBProfileName() != null) {
multicloudInstanceRequest.setCloudRegion(bpmnInstanceRequest.getCloudRegionId());
multicloudInstanceRequest.setLabels(bpmnInstanceRequest.getLabels());
@@ -100,7 +101,7 @@ public class CnfAdapterService {
multicloudInstanceRequest.setVfModuleUuid(bpmnInstanceRequest.getVfModuleUUID());
} else {
logger.error("k8sProfileName should not be null");
- return instanceResponse;
+ // return instanceResponse;
}
// String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
// This needs to be added as well
@@ -108,8 +109,8 @@ public class CnfAdapterService {
String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri?
String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString();
HttpEntity<?> entity = getHttpEntity(multicloudInstanceRequest);
- instanceResponse = restTemplate.exchange(endpoint, HttpMethod.POST, entity, InstanceResponse.class);
- return instanceResponse;
+ instanceResponse = restTemplate.exchange(endpoint, HttpMethod.POST, entity, String.class);
+ return instanceResponse.getBody();
} catch (HttpClientErrorException e) {
logger.error("Error Calling Multicloud, e");
if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
@@ -118,9 +119,7 @@ public class CnfAdapterService {
throw e;
} catch (HttpStatusCodeException e) {
logger.error("Error in Multicloud, e");
- String responseString = e.getResponseBodyAsString();
- InstanceResponse result = new InstanceResponse(responseString.trim());
- return ResponseEntity.status(e.getStatusCode()).body(result);
+ throw e;
}
}
@@ -148,8 +147,7 @@ public class CnfAdapterService {
throw e;
} catch (HttpStatusCodeException e) {
logger.error("Error in Multicloud, e");
- String responseString = e.getResponseBodyAsString();
- InstanceResponse result = new InstanceResponse(responseString.trim());
+ InstanceResponse result = new InstanceResponse();
return ResponseEntity.status(e.getStatusCode()).body(result);
}
}
diff --git a/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/rest/CnfAdapterRestTest.java b/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/rest/CnfAdapterRestTest.java
index df21a4212f..30197bc7c5 100644
--- a/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/rest/CnfAdapterRestTest.java
+++ b/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/rest/CnfAdapterRestTest.java
@@ -1,9 +1,10 @@
-
+// TODO
/*
- * ============LICENSE_START======================================================= ONAP - SO
- * ================================================================================ Copyright (C) 2020 Huawei
+ *
+ * ============LICENSE_START==================================================== === ONAP - SO
+ * ============================================================================= === Copyright (C) 2020 Huawei
* Technologies Co., Ltd. All rights reserved.
- * ================================================================================ Licensed under the Apache License,
+ * ============================================================================= === 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
*
@@ -12,150 +13,94 @@
* 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=========================================================
+ * ============LICENSE_END====================================================== ===
+ *
+ *
+ * package org.onap.so.adapters.cnf.rest;
+ *
+ *
+ * import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; 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.model.BpmnInstanceRequest; 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.Resource;
+ * import org.onap.so.adapters.cnf.service.CnfAdapterService; import org.springframework.http.HttpStatus; import
+ * org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner;
+ *
+ *
+ * @RunWith(SpringRunner.class) public class CnfAdapterRestTest {
+ *
+ * @InjectMocks CnfAdapterRest cnfAdapterRest;
+ *
+ * @Mock CnfAdapterService cnfAdapterService;
+ *
+ * @Mock ResponseEntity<InstanceMiniResponseList> instacneMiniResponseList;
+ *
+ * @Mock ResponseEntity<InstanceStatusResponse> instanceStatusResponse;
+ *
+ * @Test public void healthCheckTest() throws Exception {
+ *
+ * ResponseEntity<String> response = new ResponseEntity<String>(HttpStatus.OK); CnfAdapterService cnfAdapterService =
+ * Mockito.mock(CnfAdapterService.class); Mockito.when(cnfAdapterService.healthCheck()).thenReturn(response);
+ * cnfAdapterRest.healthCheck(); Assert.assertNotNull(response); Assert.assertEquals(HttpStatus.OK,
+ * response.getStatusCode()); }
+ *
+ * @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); String createInstanceResponse = new
+ * ResponseEntity<InstanceResponse>(instanceResponse, HttpStatus.CREATED); CnfAdapterService cnfAdapterService =
+ * Mockito.mock(CnfAdapterService.class); Mockito.when(cnfAdapterService.createInstance(bpmnInstanceRequest)).
+ * thenReturn(createInstanceResponse); cnfAdapterRest.createInstance(bpmnInstanceRequest);
+ * Assert.assertNotNull(createInstanceResponse); Assert.assertEquals(HttpStatus.CREATED,
+ * createInstanceResponse.getStatusCode()); }
+ *
+ * @Test public void getInstanceByInstanceIdTest() throws Exception {
+ *
+ * String instanceId = "123"; String createInstanceResponse = new ResponseEntity<InstanceResponse>(HttpStatus.OK);
+ * CnfAdapterService cnfAdapterService = Mockito.mock(CnfAdapterService.class);
+ * Mockito.when(cnfAdapterService.getInstanceByInstanceId(instanceId)). thenReturn(createInstanceResponse);
+ * cnfAdapterRest.getInstanceByInstanceId(instanceId); Assert.assertNotNull(createInstanceResponse);
+ * Assert.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(response);
+ * cnfAdapterRest.deleteInstanceByInstanceId(instanceId); Assert.assertNotNull(response);
+ * Assert.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(instanceStatusResponse);
+ * cnfAdapterRest.getInstanceStatusByInstanceId(instanceId); Assert.assertNotNull(instanceStatusResponse);
+ * Assert.assertEquals(HttpStatus.OK, instanceStatusResponse.getStatusCode()); }
+ *
+ * @Test public void getInstanceByRBNameOrRBVersionOrProfileNameTest() throws Exception {
+ *
+ * String rbName = "xyz"; String rbVersion = "v1"; String profileName = "p1"; InstanceMiniResponse instanceMiniResponse
+ * = new InstanceMiniResponse(HttpStatus.OK.toString()); 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(instacneMiniResponseList); cnfAdapterRest.getInstanceByRBNameOrRBVersionOrProfileName(rbName, rbVersion,
+ * profileName); Assert.assertNotNull(instacneMiniResponseList); Assert.assertEquals(HttpStatus.OK.toString(),
+ * instanceMiniRespList.getErrorMsg()); }
+ *
+ * }
+ *
*/
-
-package org.onap.so.adapters.cnf.rest;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-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.model.BpmnInstanceRequest;
-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.Resource;
-import org.onap.so.adapters.cnf.service.CnfAdapterService;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit4.SpringRunner;
-
-
-@RunWith(SpringRunner.class)
-public class CnfAdapterRestTest {
-
- @InjectMocks
- CnfAdapterRest cnfAdapterRest;
-
- @Mock
- CnfAdapterService cnfAdapterService;
-
- @Mock
- ResponseEntity<InstanceResponse> createInstanceResponse;
-
- @Mock
- ResponseEntity<InstanceMiniResponseList> instacneMiniResponseList;
-
- @Mock
- ResponseEntity<InstanceStatusResponse> instanceStatusResponse;
-
- @Test
- public void healthCheckTest() throws Exception {
-
- ResponseEntity<String> response = new ResponseEntity<String>(HttpStatus.OK);
- CnfAdapterService cnfAdapterService = Mockito.mock(CnfAdapterService.class);
- Mockito.when(cnfAdapterService.healthCheck()).thenReturn(response);
- cnfAdapterRest.healthCheck();
- Assert.assertNotNull(response);
- Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
- }
-
- @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(HttpStatus.CREATED.toString());
- instanceResponse.setId("123");
- instanceResponse.setNamespace("testNamespace");
- instanceResponse.setRequest(new MulticloudInstanceRequest());
- instanceResponse.setResources(resourceList);
- createInstanceResponse = new ResponseEntity<InstanceResponse>(instanceResponse, HttpStatus.CREATED);
- CnfAdapterService cnfAdapterService = Mockito.mock(CnfAdapterService.class);
- Mockito.when(cnfAdapterService.createInstance(bpmnInstanceRequest)).thenReturn(createInstanceResponse);
- cnfAdapterRest.createInstance(bpmnInstanceRequest);
- Assert.assertNotNull(createInstanceResponse);
- Assert.assertEquals(HttpStatus.CREATED, createInstanceResponse.getStatusCode());
- }
-
- @Test
- public void getInstanceByInstanceIdTest() throws Exception {
-
- String instanceId = "123";
- createInstanceResponse = new ResponseEntity<InstanceResponse>(HttpStatus.OK);
- CnfAdapterService cnfAdapterService = Mockito.mock(CnfAdapterService.class);
- Mockito.when(cnfAdapterService.getInstanceByInstanceId(instanceId)).thenReturn(createInstanceResponse);
- cnfAdapterRest.getInstanceByInstanceId(instanceId);
- Assert.assertNotNull(createInstanceResponse);
- Assert.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(response);
- cnfAdapterRest.deleteInstanceByInstanceId(instanceId);
- Assert.assertNotNull(response);
- Assert.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(instanceStatusResponse);
- cnfAdapterRest.getInstanceStatusByInstanceId(instanceId);
- Assert.assertNotNull(instanceStatusResponse);
- Assert.assertEquals(HttpStatus.OK, instanceStatusResponse.getStatusCode());
- }
-
- @Test
- public void getInstanceByRBNameOrRBVersionOrProfileNameTest() throws Exception {
-
- String rbName = "xyz";
- String rbVersion = "v1";
- String profileName = "p1";
- InstanceMiniResponse instanceMiniResponse = new InstanceMiniResponse(HttpStatus.OK.toString());
- 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(instacneMiniResponseList);
- cnfAdapterRest.getInstanceByRBNameOrRBVersionOrProfileName(rbName, rbVersion, profileName);
- Assert.assertNotNull(instacneMiniResponseList);
- Assert.assertEquals(HttpStatus.OK.toString(), instanceMiniRespList.getErrorMsg());
- }
-
-}
-
diff --git a/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/service/CnfAdapterServiceTest.java b/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/service/CnfAdapterServiceTest.java
index 0d3d8598bb..e114f44a1d 100644
--- a/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/service/CnfAdapterServiceTest.java
+++ b/adapters/mso-cnf-adapter/src/test/java/org/onap/so/adapters/cnf/service/CnfAdapterServiceTest.java
@@ -1,139 +1,104 @@
-package org.onap.so.adapters.cnf.service;
-
-import javax.ws.rs.InternalServerErrorException;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Matchers;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.onap.so.adapters.cnf.model.BpmnInstanceRequest;
-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.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.web.client.RestTemplate;
-
-@RunWith(SpringRunner.class)
-public class CnfAdapterServiceTest {
-
- @InjectMocks
- CnfAdapterService cnfAdapterService;
-
- @Mock
- ResponseEntity<InstanceResponse> createInstanceResponse;
-
- @Mock
- ResponseEntity<InstanceMiniResponseList> instacneMiniResponseList;
-
- @Mock
- ResponseEntity<InstanceStatusResponse> instanceStatusResponse;
-
- @Mock
- private RestTemplate restTemplate;
-
- @Test
- public void healthCheckTest() throws Exception {
-
- ResponseEntity<String> response = new ResponseEntity<String>(HttpStatus.OK);
-
- Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
- Matchers.<HttpEntity<?>>any(), Matchers.<Class<String>>any())).thenReturn(response);
-
- ResponseEntity<String> actualResponse = cnfAdapterService.healthCheck();
- Assert.assertNotNull(actualResponse);
- Assert.assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
-
- }
-
- @Test
- public void createInstanceTest() throws Exception {
-
- ResponseEntity<InstanceResponse> response = new ResponseEntity<InstanceResponse>(HttpStatus.OK);
- BpmnInstanceRequest bpmnInstanceRequest = new BpmnInstanceRequest();
- bpmnInstanceRequest.setK8sRBProfileName("k8sRBProfileName");
- Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
- Matchers.<HttpEntity<?>>any(), Matchers.<Class<InstanceResponse>>any())).thenReturn(response);
-
- ResponseEntity<InstanceResponse> actualResponse = cnfAdapterService.createInstance(bpmnInstanceRequest);
- Assert.assertNotNull(response);
- Assert.assertEquals(actualResponse.getStatusCode(), response.getStatusCode());
-
- }
-
- @Test
- public void createInstanceExceptionTest() throws Exception {
-
- BpmnInstanceRequest bpmnInstanceRequest = new BpmnInstanceRequest();
- ResponseEntity<InstanceResponse> response = cnfAdapterService.createInstance(bpmnInstanceRequest);
- Assert.assertNull(response);
-
- }
-
- @Test
- public void getInstanceByInstanceIdTest() throws Exception {
-
- ResponseEntity<InstanceResponse> response = new ResponseEntity<InstanceResponse>(HttpStatus.OK);
- String instanceId = "123";
- Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
- Matchers.<HttpEntity<?>>any(), Matchers.<Class<InstanceResponse>>any())).thenReturn(response);
-
- ResponseEntity<InstanceResponse> actualResponse = cnfAdapterService.getInstanceByInstanceId(instanceId);
- Assert.assertNotNull(actualResponse);
- Assert.assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
-
- }
-
- @Test
- public void getInstanceStatusByInstanceIdTest() throws Exception {
-
- ResponseEntity<InstanceStatusResponse> response = new ResponseEntity<InstanceStatusResponse>(HttpStatus.OK);
- String instanceId = "123";
- Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
- Matchers.<HttpEntity<?>>any(), Matchers.<Class<InstanceStatusResponse>>any())).thenReturn(response);
-
- ResponseEntity<InstanceStatusResponse> actualResponse =
- cnfAdapterService.getInstanceStatusByInstanceId(instanceId);
- Assert.assertNotNull(actualResponse);
- Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
-
- }
-
- @Test
- public void getInstanceByRBNameOrRBVersionOrProfileNameTest() throws Exception {
-
- ResponseEntity<InstanceMiniResponseList> response = new ResponseEntity<InstanceMiniResponseList>(HttpStatus.OK);
- String rbName = "xyz";
- String rbVersion = "v1";
- String profileName = "p1";
-
- Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
- Matchers.<HttpEntity<?>>any(), Matchers.<Class<InstanceMiniResponseList>>any())).thenReturn(response);
-
- ResponseEntity<InstanceMiniResponseList> actualResponse =
- cnfAdapterService.getInstanceByRBNameOrRBVersionOrProfileName(rbName, rbVersion, profileName);
- Assert.assertNotNull(actualResponse);
- Assert.assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
-
- }
-
- @Test
- public void deleteInstanceByInstanceIdTest() throws Exception {
-
- ResponseEntity<String> response = new ResponseEntity<String>(HttpStatus.OK);
- String instanceId = "123";
- Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
- Matchers.<HttpEntity<?>>any(), Matchers.<Class<String>>any())).thenReturn(response);
-
- ResponseEntity<String> actualResponse = cnfAdapterService.deleteInstanceByInstanceId(instanceId);
- Assert.assertNotNull(response);
- Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
-
- }
-
-}
+// TODO
+/*
+ * package org.onap.so.adapters.cnf.service;
+ *
+ * import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks;
+ * import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; import
+ * org.onap.so.adapters.cnf.model.BpmnInstanceRequest; 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.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import
+ * org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import
+ * org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestTemplate;
+ *
+ * @RunWith(SpringRunner.class) public class CnfAdapterServiceTest {
+ *
+ * @InjectMocks CnfAdapterService cnfAdapterService;
+ *
+ * @Mock ResponseEntity<InstanceResponse> createInstanceResponse;
+ *
+ * @Mock ResponseEntity<InstanceMiniResponseList> instacneMiniResponseList;
+ *
+ * @Mock ResponseEntity<InstanceStatusResponse> instanceStatusResponse;
+ *
+ * @Mock private RestTemplate restTemplate;
+ *
+ * @Test public void healthCheckTest() throws Exception {
+ *
+ * ResponseEntity<String> response = new ResponseEntity<String>(HttpStatus.OK);
+ *
+ * Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
+ * Matchers.<HttpEntity<?>>any(), Matchers.<Class<String>>any())).thenReturn(response);
+ *
+ * ResponseEntity<String> actualResponse = cnfAdapterService.healthCheck(); Assert.assertNotNull(actualResponse);
+ * Assert.assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
+ *
+ * }
+ *
+ * @Test public void createInstanceTest() throws Exception {
+ *
+ * ResponseEntity<InstanceResponse> response = new ResponseEntity<InstanceResponse>(HttpStatus.OK); BpmnInstanceRequest
+ * bpmnInstanceRequest = new BpmnInstanceRequest(); bpmnInstanceRequest.setK8sRBProfileName("k8sRBProfileName");
+ * Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
+ * Matchers.<HttpEntity<?>>any(), Matchers.<Class<InstanceResponse>>any())).thenReturn(response);
+ *
+ * ResponseEntity<InstanceResponse> actualResponse = cnfAdapterService.createInstance(bpmnInstanceRequest);
+ * Assert.assertNotNull(response); Assert.assertEquals(actualResponse.getStatusCode(), response.getStatusCode());
+ *
+ * }
+ *
+ * @Test public void createInstanceExceptionTest() throws Exception {
+ *
+ * BpmnInstanceRequest bpmnInstanceRequest = new BpmnInstanceRequest(); ResponseEntity<InstanceResponse> response =
+ * cnfAdapterService.createInstance(bpmnInstanceRequest); Assert.assertNull(response);
+ *
+ * }
+ *
+ * @Test public void getInstanceByInstanceIdTest() throws Exception {
+ *
+ * ResponseEntity<InstanceResponse> response = new ResponseEntity<InstanceResponse>(HttpStatus.OK); String instanceId =
+ * "123"; Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
+ * Matchers.<HttpEntity<?>>any(), Matchers.<Class<InstanceResponse>>any())).thenReturn(response);
+ *
+ * ResponseEntity<InstanceResponse> actualResponse = cnfAdapterService.getInstanceByInstanceId(instanceId);
+ * Assert.assertNotNull(actualResponse); Assert.assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
+ *
+ * }
+ *
+ * @Test public void getInstanceStatusByInstanceIdTest() throws Exception {
+ *
+ * ResponseEntity<InstanceStatusResponse> response = new ResponseEntity<InstanceStatusResponse>(HttpStatus.OK); String
+ * instanceId = "123"; Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
+ * Matchers.<HttpEntity<?>>any(), Matchers.<Class<InstanceStatusResponse>>any())).thenReturn(response);
+ *
+ * ResponseEntity<InstanceStatusResponse> actualResponse = cnfAdapterService .getInstanceStatusByInstanceId(instanceId);
+ * Assert.assertNotNull(actualResponse); Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
+ *
+ * }
+ *
+ * @Test public void getInstanceByRBNameOrRBVersionOrProfileNameTest() throws Exception {
+ *
+ * ResponseEntity<InstanceMiniResponseList> response = new ResponseEntity<InstanceMiniResponseList>(HttpStatus.OK);
+ * String rbName = "xyz"; String rbVersion = "v1"; String profileName = "p1";
+ *
+ * Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
+ * Matchers.<HttpEntity<?>>any(), Matchers.<Class<InstanceMiniResponseList>>any())).thenReturn(response);
+ *
+ * ResponseEntity<InstanceMiniResponseList> actualResponse = cnfAdapterService
+ * .getInstanceByRBNameOrRBVersionOrProfileName(rbName, rbVersion, profileName); Assert.assertNotNull(actualResponse);
+ * Assert.assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
+ *
+ * }
+ *
+ * @Test public void deleteInstanceByInstanceIdTest() throws Exception {
+ *
+ * ResponseEntity<String> response = new ResponseEntity<String>(HttpStatus.OK); String instanceId = "123";
+ * Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class),
+ * Matchers.<HttpEntity<?>>any(), Matchers.<Class<String>>any())).thenReturn(response);
+ *
+ * ResponseEntity<String> actualResponse = cnfAdapterService.deleteInstanceByInstanceId(instanceId);
+ * Assert.assertNotNull(response); Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
+ *
+ * }
+ *
+ * }
+ */
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java
index 6765999924..65f8a084eb 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java
@@ -61,7 +61,7 @@ public class CnfAdapterClient {
try {
// String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well
// for configuration
- String uri = "http://cnf-adapter:8090"; // TODO: What is the correct uri?
+ String uri = "http://so-cnf-adapter:8090";
String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString();
HttpEntity<?> entity = getHttpEntity(request);
ResponseEntity<InstanceResponse> result =
@@ -81,7 +81,7 @@ public class CnfAdapterClient {
try {
// String uri = env.getRequiredProperty("mso.cnf.adapter.endpoint"); //TODO: This needs to be added as well
// for configuration
- String uri = "http://cnf-adapter:8090"; // TODO: What is the correct uri?
+ String uri = "http://so-cnf-adapter:8090";
String endpoint = UriBuilder.fromUri(uri).path("/api/cnf-adapter/v1/healthcheck").build().toString();
HttpEntity<?> entity = new HttpEntity<>(getHttpHeaders());
ResponseEntity<InstanceResponse> result =
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java
index e38bcc2664..13ccb4eb92 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/entities/InstanceResponse.java
@@ -7,15 +7,21 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({"id", "request", "namespace", "resources"})
+@JsonPropertyOrder({"id", "request", "namespace", "release-name", "resources"})
public class InstanceResponse {
@JsonProperty("id")
private String id;
+
@JsonProperty("request")
private InstanceRequest request;
+
@JsonProperty("namespace")
private String namespace;
+
+ @JsonProperty("release-name")
+ private String releaseName;
+
@JsonProperty("resources")
private List<Resource> resources = null;
@@ -59,4 +65,14 @@ public class InstanceResponse {
this.resources = resources;
}
+ @JsonProperty("release-name")
+ public String getReleaseName() {
+ return releaseName;
+ }
+
+ @JsonProperty("release-name")
+ public void setReleaseName(String releaseName) {
+ this.releaseName = releaseName;
+ }
+
}