* @return the VNFM to use, or <code>null</code> if no VNFM has been assigned yet
*/
public EsrVnfm getAssignedVnfm(final GenericVnf vnf) {
- final Relationship relationship = getRelationship(vnf, "esr-vnfm");
- final String vnfmId = getRelationshipKey(relationship, "esr-vnfm.vnfm-id");
+ final String vnfmId = getIdOfAssignedVnfm(vnf);
return vnfmId == null ? null : aaiServiceProvider.invokeGetVnfm(vnfmId);
}
+ /**
+ * Get the ID of the VNFM assigned for use for the given generic VNF.
+ *
+ * @param vnf the generic VNF
+ * @return the ID of the VNFM to use, or <code>null</code> if no VNFM has been assigned yet
+ */
+ public String getIdOfAssignedVnfm(final GenericVnf vnf) {
+ final Relationship relationship = getRelationship(vnf, "esr-vnfm");
+ return getRelationshipKey(relationship, "esr-vnfm.vnfm-id");
+ }
+
/**
* Get the tenant assigned for use for the given generic VNF.
*
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest;
/**
* Provides methods for invoking REST calls to a VNFM.
*/
String instantiateVnf(final String vnfSelfLink, final InstantiateVnfRequest instantiateVnfRequest);
+ /**
+ * Invoke a terminate request for a VNF.
+ *
+ * @param vnfSelfLink the link to he VNF on the VNFM
+ * @param terminateVnfRequest the terminate request
+ * @return the operation ID of the termination operation
+ */
+ String terminateVnf(final String vnfSelfLink, final TerminateVnfRequest terminateVnfRequest);
+
/**
* Invoke a get request for a VNFM operation.
*
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmRequestFailureException;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.slf4j.Logger;
@Override
public String instantiateVnf(final String vnfSelfLink, final InstantiateVnfRequest instantiateVnfRequest) {
logger.debug("Sending instantiate request " + instantiateVnfRequest + " to : " + vnfSelfLink);
- final ResponseEntity<Void> response = httpServiceProvider.getHttpResponse(vnfSelfLink, Void.class);
+
+ ResponseEntity<Void> response = null;
+ try {
+ response = httpServiceProvider.postHttpRequest(instantiateVnfRequest, vnfSelfLink + "/instantiate",
+ Void.class);
+ } catch (final Exception exception) {
+ final String errorMessage =
+ "Instantiate request to " + vnfSelfLink + " resulted in exception" + instantiateVnfRequest;
+ logger.error(errorMessage, exception);
+ throw new VnfmRequestFailureException(errorMessage, exception);
+ }
if (response.getStatusCode() != HttpStatus.ACCEPTED) {
- throw new VnfmRequestFailureException("Instantiate request to " + vnfSelfLink + " return status code: "
- + response.getStatusCode() + ", request: " + instantiateVnfRequest);
+ final String errorMessage = "Instantiate request to " + vnfSelfLink + " returned status code: "
+ + response.getStatusCode() + ", request: " + instantiateVnfRequest;
+ logger.error(errorMessage);
+ throw new VnfmRequestFailureException(errorMessage);
}
final String locationHeader = response.getHeaders().get("Location").iterator().next();
return locationHeader.substring(locationHeader.lastIndexOf("/") + 1);
+
+ }
+
+ @Override
+ public String terminateVnf(final String vnfSelfLink, final TerminateVnfRequest terminateVnfRequest) {
+ logger.debug("Sending terminate request " + terminateVnfRequest + " to : " + vnfSelfLink);
+
+ ResponseEntity<Void> response = null;
+ try {
+ response = httpServiceProvider.postHttpRequest(terminateVnfRequest, vnfSelfLink + "/terminate", Void.class);
+ } catch (final Exception exception) {
+ final String errorMessage =
+ "Terminate request to " + vnfSelfLink + " resulted in exception" + terminateVnfRequest;
+ logger.error(errorMessage, exception);
+ throw new VnfmRequestFailureException(errorMessage, exception);
+ }
+ if (response.getStatusCode() != HttpStatus.ACCEPTED) {
+ final String errorMessage = "Terminate request to " + vnfSelfLink + " returned status code: "
+ + response.getStatusCode() + ", request: " + terminateVnfRequest;
+ logger.error(errorMessage);
+ throw new VnfmRequestFailureException(errorMessage);
+ }
+ final String locationHeader = response.getHeaders().get("Location").iterator().next();
+ return locationHeader.substring(locationHeader.lastIndexOf("/") + 1);
+
}
@Override
import java.util.UUID;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.JobNotFoundException;
import org.onap.vnfmadapter.v1.model.OperationEnum;
import org.onap.vnfmadapter.v1.model.OperationStateEnum;
import org.onap.vnfmadapter.v1.model.OperationStatusRetrievalStatusEnum;
final QueryJobResponse response = new QueryJobResponse();
if (vnfmOperation == null) {
- return null;
+ throw new JobNotFoundException("No job found with ID: " + jobId);
}
final Optional<InlineResponse200> operationOptional =
package org.onap.so.adapters.vnfmadapter.lifecycle;
import com.google.common.base.Optional;
-import java.util.UUID;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest.TerminationTypeEnum;
import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfNotFoundException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.CreateVnfResponse;
import org.onap.vnfmadapter.v1.model.DeleteVnfResponse;
return response;
}
- private GenericVnf getGenericVnfFromAai(final String vnfIdInAai) {
- final GenericVnf genericVnf = aaiServiceProvider.invokeGetGenericVnf(vnfIdInAai);
- logger.debug("Retrieved generic VNF from AAI: " + genericVnf);
- return genericVnf;
- }
-
private void checkIfVnfAlreadyExistsInVnfm(final GenericVnf genericVnf) {
if (genericVnf.getSelflink() != null && !genericVnf.getSelflink().isEmpty()) {
Optional<InlineResponse201> response = Optional.absent();
* @return the response to the request
*/
public DeleteVnfResponse deleteVnf(final String vnfIdInAai) {
- // vnfm ID and operation ID set to random value for now, will be set correctly once we implement
- // terminate call towards the VNFM
- final String jobId = jobManager.createJob(UUID.randomUUID().toString(), UUID.randomUUID().toString(), true);
- final DeleteVnfResponse response = new DeleteVnfResponse();
- response.setJobId(jobId);
- return response;
+ final GenericVnf genericVnf = getGenericVnfFromAai(vnfIdInAai);
+ final String vnfmId = getIdOfAssignedVnfm(genericVnf);
+
+ final String operationId = sendTerminateRequestToVnfm(genericVnf);
+ final String jobId = jobManager.createJob(vnfmId, operationId, true);
+
+ return new DeleteVnfResponse().jobId(jobId);
+ }
+
+ private String sendTerminateRequestToVnfm(final GenericVnf genericVnf) {
+ final TerminateVnfRequest terminateVnfRequest = new TerminateVnfRequest();
+ terminateVnfRequest.setTerminationType(TerminationTypeEnum.FORCEFUL);
+ return vnfmServiceProvider.terminateVnf(genericVnf.getSelflink(), terminateVnfRequest);
+ }
+
+ private GenericVnf getGenericVnfFromAai(final String vnfIdInAai) {
+ final GenericVnf genericVnf = aaiServiceProvider.invokeGetGenericVnf(vnfIdInAai);
+ if (genericVnf == null) {
+ throw new VnfNotFoundException("VNF not found in AAI: " + vnfIdInAai);
+ }
+ logger.debug("Retrieved generic VNF from AAI: " + genericVnf);
+ return genericVnf;
+ }
+
+ private String getIdOfAssignedVnfm(final GenericVnf genericVnf) {
+ final String vnfmId = aaiHelper.getIdOfAssignedVnfm(genericVnf);
+ if (vnfmId == null) {
+ throw new VnfmNotFoundException("No VNFM found in AAI for VNF " + genericVnf.getVnfId());
+ }
+ return vnfmId;
}
}
logger.info("REST request vnfCreate with body: {}", createVnfRequest);
- final CreateVnfResponse createVnfResponse = lifecycleManager.createVnf(vnfId, createVnfRequest);
- clearLoggingMDCs();
- return new ResponseEntity<>(createVnfResponse, HttpStatus.ACCEPTED);
+ try {
+ final CreateVnfResponse createVnfResponse = lifecycleManager.createVnf(vnfId, createVnfRequest);
+ return new ResponseEntity<>(createVnfResponse, HttpStatus.ACCEPTED);
+ } finally {
+ clearLoggingMDCs();
+ }
}
@DeleteMapping(value = "/vnfs/{vnfId}")
logger.info("REST request vnfDelete for VNF: {}", vnfId);
- final DeleteVnfResponse response = lifecycleManager.deleteVnf(vnfId);
- clearLoggingMDCs();
- return new ResponseEntity<>(response, HttpStatus.ACCEPTED);
+ try {
+ final DeleteVnfResponse response = lifecycleManager.deleteVnf(vnfId);
+ return new ResponseEntity<>(response, HttpStatus.ACCEPTED);
+ } finally {
+ clearLoggingMDCs();
+ }
}
@GetMapping(value = "/jobs/{jobId}")
setLoggingMDCs(requestId, partnerName, invocationId);
- final QueryJobResponse response = jobManager.getVnfmOperation(jobId);
- if (response == null) {
- return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+ try {
+ final QueryJobResponse response = jobManager.getVnfmOperation(jobId);
+ return new ResponseEntity<>(response, HttpStatus.OK);
+ } finally {
+ clearLoggingMDCs();
}
- return new ResponseEntity<>(response, HttpStatus.OK);
-
}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.rest.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Exception for job not found.
+ */
+@ResponseStatus(HttpStatus.NOT_FOUND)
+public class JobNotFoundException extends RuntimeException {
+
+ private static final long serialVersionUID = 6398018034431666933L;
+
+ public JobNotFoundException(final String message) {
+ super(message);
+ }
+
+}
+
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.rest.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Exception for VNF not found.
+ */
+@ResponseStatus(HttpStatus.NOT_FOUND)
+public class VnfNotFoundException extends RuntimeException {
+
+ private static final long serialVersionUID = 6398018034431666933L;
+
+ public VnfNotFoundException(final String message) {
+ super(message);
+ }
+
+}
+
package org.onap.so.adapters.vnfmadapter.rest.exceptions;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
/**
* Exception for VNFM not found.
*/
+@ResponseStatus(HttpStatus.BAD_REQUEST)
public class VnfmNotFoundException extends RuntimeException {
private static final long serialVersionUID = 6398018034431666933L;
super(message);
}
+ public VnfmRequestFailureException(final String message, final Throwable throwable) {
+ super(message, throwable);
+ }
+
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
import java.util.Optional;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
-import org.hamcrest.core.StringStartsWith;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
setUpVnfmsInMockAai();
setUpVimInMockAai();
- mockRestServer.expect(requestTo("http://dummy.value/until/create/implememted/vnfId"))
+ mockRestServer.expect(requestTo("http://dummy.value/until/create/implememted/vnfId/instantiate"))
.andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON)
.location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/123456")));
final Tenant tenant = new Tenant().cloudOwner(CLOUD_OWNER).regionName(REGION).tenantId(TENANT_ID);
final CreateVnfRequest createVnfRequest = new CreateVnfRequest().name("myTestName").tenant(tenant);
- final GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("myTestVnfId");
- genericVnf.setNfType("vnfmType1");
- genericVnf.setSelflink("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm");
-
- doReturn(Optional.of(genericVnf)).when(aaiResourcesClient).get(eq(GenericVnf.class),
- MockitoHamcrest.argThat(new AaiResourceUriMatcher("/network/generic-vnfs/generic-vnf/myTestVnfId")));
+ final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType1");
+ addSelfLinkToGenericVnf(genericVnf);
final InlineResponse201 reponse = new InlineResponse201();
mockRestServer.expect(requestTo(new URI("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm")))
final Tenant tenant = new Tenant().cloudOwner(CLOUD_OWNER).regionName(REGION).tenantId(TENANT_ID);
final CreateVnfRequest createVnfRequest = new CreateVnfRequest().name("myTestName").tenant(tenant);
- setUpGenericVnfWithVnfmRelationshipInMockAai("vnfmType2", "vnfm1");
+ final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType2");
+ addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm1");
setUpVnfmsInMockAai();
setUpVimInMockAai();
- mockRestServer.expect(requestTo("http://dummy.value/until/create/implememted/vnfId"))
+ mockRestServer.expect(requestTo("http://dummy.value/until/create/implememted/vnfId/instantiate"))
.andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON)
.location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/123456")));
@Test
public void deleteVnf_ValidRequest_Returns202AndJobId() throws Exception {
final TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
+
+ final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType");
+ addSelfLinkToGenericVnf(genericVnf);
+ addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm");
+
+ mockRestServer.expect(requestTo("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm/terminate"))
+ .andRespond(withStatus(HttpStatus.ACCEPTED).contentType(MediaType.APPLICATION_JSON)
+ .location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/1234567")));
+
+ final InlineResponse200 firstOperationQueryResponse = createOperationQueryResponse(
+ org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE,
+ org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.PROCESSING);
+ mockRestServer.expect(requestTo("http://vnfm:8080/vnf_lcm_op_occs/1234567"))
+ .andRespond(withSuccess(gson.toJson(firstOperationQueryResponse), MediaType.APPLICATION_JSON));
+
+
+ final InlineResponse200 secondOperationQueryReponse = createOperationQueryResponse(
+ org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE,
+ org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.COMPLETED);
+ mockRestServer.expect(requestTo("http://vnfm:8080/vnf_lcm_op_occs/1234567"))
+ .andRespond(withSuccess(gson.toJson(secondOperationQueryReponse), MediaType.APPLICATION_JSON));
+
+
final RequestEntity<Void> request = RequestEntity
- .delete(new URI("http://localhost:" + port + "/so/vnfm-adapter/v1/vnfs/myVnfId"))
+ .delete(new URI("http://localhost:" + port + "/so/vnfm-adapter/v1/vnfs/myTestVnfId"))
.accept(MediaType.APPLICATION_JSON).header("X-ONAP-RequestId", "myRequestId")
.header("X-ONAP-InvocationID", "myInvocationId").header("Content-Type", "application/json").build();
final ResponseEntity<DeleteVnfResponse> deleteVnfResponse =
doReturn(Optional.of(esrSystemInfoList)).when(aaiResourcesClient).get(eq(EsrSystemInfoList.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher("/external-system/esr-vnfm-list/esr-vnfm/...")));
- final InlineResponse200 firstOperationQueryResponse = createOperationQueryResponse(
- org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE,
- org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.PROCESSING);
- mockRestServer.expect(requestTo(new StringStartsWith("http://vnfm:8080/vnf_lcm_op_occs")))
- .andRespond(withSuccess(gson.toJson(firstOperationQueryResponse), MediaType.APPLICATION_JSON));
-
-
- final InlineResponse200 secondOperationQueryReponse = createOperationQueryResponse(
- org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE,
- org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.COMPLETED);
- mockRestServer.expect(requestTo(new StringStartsWith("http://vnfm:8080/vnf_lcm_op_occs")))
- .andRespond(withSuccess(gson.toJson(secondOperationQueryReponse), MediaType.APPLICATION_JSON));
-
final ResponseEntity<QueryJobResponse> firstJobQueryResponse =
controller.jobQuery(deleteVnfResponse.getBody().getJobId(), "", "so", "1213");
assertEquals(JAN_1_2019_1_00, secondJobQueryResponse.getBody().getStateEnteredTime());
}
+ @Test
+ public void deleteVnf_GenericVnfNotFound_Returns404() throws Exception {
+ final TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
+
+ final RequestEntity<Void> request = RequestEntity
+ .delete(new URI("http://localhost:" + port + "/so/vnfm-adapter/v1/vnfs/myNonExistingVnfId"))
+ .accept(MediaType.APPLICATION_JSON).header("X-ONAP-RequestId", "myRequestId")
+ .header("X-ONAP-InvocationID", "myInvocationId").header("Content-Type", "application/json").build();
+ final ResponseEntity<DeleteVnfResponse> deleteVnfResponse =
+ restTemplate.exchange(request, DeleteVnfResponse.class);
+ assertEquals(404, deleteVnfResponse.getStatusCode().value());
+ assertNull(deleteVnfResponse.getBody().getJobId());
+ }
+
+ @Test
+ public void deleteVnf_NoAssignedVnfm_Returns400() throws Exception {
+ final TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
+
+ setUpGenericVnfInMockAai("vnfmType");
+
+ final RequestEntity<Void> request = RequestEntity
+ .delete(new URI("http://localhost:" + port + "/so/vnfm-adapter/v1/vnfs/myTestVnfId"))
+ .accept(MediaType.APPLICATION_JSON).header("X-ONAP-RequestId", "myRequestId")
+ .header("X-ONAP-InvocationID", "myInvocationId").header("Content-Type", "application/json").build();
+ final ResponseEntity<DeleteVnfResponse> deleteVnfResponse =
+ restTemplate.exchange(request, DeleteVnfResponse.class);
+ assertEquals(400, deleteVnfResponse.getStatusCode().value());
+ assertNull(deleteVnfResponse.getBody().getJobId());
+ }
+
+ @Test
+ public void deleteVnf_ErrorStatusCodeFromVnfm_Returns500() throws Exception {
+ final TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
+
+ final GenericVnf genericVnf = setUpGenericVnfInMockAai("vnfmType");
+ addSelfLinkToGenericVnf(genericVnf);
+ addRelationshipFromGenericVnfToVnfm(genericVnf, "vnfm");
+
+ mockRestServer.expect(requestTo("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm/terminate"))
+ .andRespond(withStatus(HttpStatus.BAD_REQUEST).contentType(MediaType.APPLICATION_JSON));
+
+
+ final RequestEntity<Void> request = RequestEntity
+ .delete(new URI("http://localhost:" + port + "/so/vnfm-adapter/v1/vnfs/myTestVnfId"))
+ .accept(MediaType.APPLICATION_JSON).header("X-ONAP-RequestId", "myRequestId")
+ .header("X-ONAP-InvocationID", "myInvocationId").header("Content-Type", "application/json").build();
+ final ResponseEntity<DeleteVnfResponse> deleteVnfResponse =
+ restTemplate.exchange(request, DeleteVnfResponse.class);
+ assertEquals(500, deleteVnfResponse.getStatusCode().value());
+ assertNull(deleteVnfResponse.getBody().getJobId());
+
+ }
+
private InlineResponse200 createOperationQueryResponse(
final org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum operation,
final org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum operationState) {
return genericVnf;
}
- private void setUpGenericVnfInMockAai(final String type) {
+ private GenericVnf setUpGenericVnfInMockAai(final String type) {
final GenericVnf genericVnf = createGenericVnf(type);
doReturn(Optional.of(genericVnf)).when(aaiResourcesClient).get(eq(GenericVnf.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher("/network/generic-vnfs/generic-vnf/myTestVnfId")));
+ return genericVnf;
}
- private void setUpGenericVnfWithVnfmRelationshipInMockAai(final String type, final String vnfmId) {
- final GenericVnf genericVnf = createGenericVnf(type);
+ private void addSelfLinkToGenericVnf(final GenericVnf vnf) {
+ vnf.setSelflink("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm");
+ }
+ private void addRelationshipFromGenericVnfToVnfm(final GenericVnf genericVnf, final String vnfmId) {
final Relationship relationshipToVnfm = new Relationship();
relationshipToVnfm.setRelatedLink(
"/aai/v15/external-system/esr-vnfm-li// final InlineResponse201 vnfInstance = new InlineResponse201();\n"
final RelationshipList relationshipList = new RelationshipList();
relationshipList.getRelationship().add(relationshipToVnfm);
genericVnf.setRelationshipList(relationshipList);
-
- doReturn(Optional.of(genericVnf)).when(aaiResourcesClient).get(eq(GenericVnf.class),
- MockitoHamcrest.argThat(new AaiResourceUriMatcher("/network/generic-vnfs/generic-vnf/myTestVnfId")));
}
private void setUpVnfmsInMockAai() {