diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks')
7 files changed, 109 insertions, 17 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java index 32516c1dcb..41649dc838 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java @@ -20,7 +20,9 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; +import com.google.common.base.Optional; import org.onap.so.rest.exceptions.InvalidRestRequestException; +import org.onap.so.rest.exceptions.HttpResouceNotFoundException; import org.onap.so.rest.exceptions.RestProcessingException; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.vnfmadapter.v1.model.CreateVnfRequest; @@ -33,7 +35,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; -import com.google.common.base.Optional; /** * @author waqas.ikram@est.tech @@ -82,7 +83,8 @@ public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvide } return Optional.of(createVnfResponse); - } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) { + } catch (final RestProcessingException | InvalidRestRequestException + | HttpResouceNotFoundException httpInvocationException) { LOGGER.error("Unexpected error while processing create and instantiation request", httpInvocationException); return Optional.absent(); } @@ -144,7 +146,8 @@ public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvide return Optional.absent(); } return Optional.of(response.getBody()); - } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) { + } catch (final RestProcessingException | InvalidRestRequestException + | HttpResouceNotFoundException httpInvocationException) { LOGGER.error("Unexpected error while processing job request", httpInvocationException); throw httpInvocationException; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java index 07f448e5e1..7d2fc10d0b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java @@ -55,7 +55,7 @@ public class SDNCClient { BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>(); STOClient.setTargetUrl(targetUrl); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); + HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), true); STOClient.setHttpHeader(httpHeader); LinkedHashMap<String, Object> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); @@ -67,7 +67,7 @@ public class SDNCClient { String jsonRequest = sdnCommonTasks.buildJsonRequest(request); BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>(); STOClient.setTargetUrl(url); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); + HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), true); STOClient.setHttpHeader(httpHeader); LinkedHashMap<String, Object> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); @@ -87,7 +87,7 @@ public class SDNCClient { String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); BaseClient<String, LinkedHashMap<String, Object>> STOClient = new BaseClient<>(); STOClient.setTargetUrl(targetUrl); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); + HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth(), false); STOClient.setHttpHeader(httpHeader); LinkedHashMap<String, Object> output = STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java index 1144648517..e7e4e25af2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java @@ -82,10 +82,12 @@ public class SdnCommonTasks { * @param auth * @return */ - public HttpHeaders getHttpHeaders(String auth) { + public HttpHeaders getHttpHeaders(String auth, boolean includeContentType) { HttpHeaders httpHeader = new HttpHeaders(); httpHeader.set("Authorization", auth); - httpHeader.setContentType(MediaType.APPLICATION_JSON); + if (includeContentType) { + httpHeader.setContentType(MediaType.APPLICATION_JSON); + } List<MediaType> acceptMediaTypes = new ArrayList<>(); acceptMediaTypes.add(MediaType.APPLICATION_JSON); httpHeader.setAccept(acceptMediaTypes); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index 6ddb292a6c..a41c79b171 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -96,6 +96,10 @@ public class VfModuleTopologyOperationRequestMapper { genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.UNASSIGN; requestAction = GenericResourceApiRequestActionEnumeration.DELETEVFMODULEINSTANCE; includeModelInformation = false; + } else if (svcAction.equals(SDNCSvcAction.CHANGE_ASSIGN)) { + genericResourceApiSvcAction = GenericResourceApiSvcActionEnumeration.CHANGEASSIGN; + requestAction = GenericResourceApiRequestActionEnumeration.CREATEVFMODULEINSTANCE; + includeModelInformation = true; } String sdncReqId = UUID.randomUUID().toString(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java index 8328e0e08b..21b472b0f3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksIT.java @@ -40,6 +40,7 @@ import org.onap.so.BaseIntegrationTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; +import org.onap.so.client.aai.AAIVersion; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.springframework.beans.factory.annotation.Autowired; @@ -68,21 +69,22 @@ public class AppcRunTasksIT extends BaseIntegrationTest { final String aaiVnfJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiGenericVnfWithVservers.json"))); wireMockServer.stubFor( - get(urlEqualTo("/aai/v15/network/generic-vnfs/generic-vnf/testVnfId1?depth=all")).willReturn(aResponse() - .withHeader("Content-Type", "application/json").withBody(aaiVnfJson).withStatus(200))); + get(urlEqualTo("/aai/" + AAIVersion.LATEST + "/network/generic-vnfs/generic-vnf/testVnfId1?depth=all")) + .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(aaiVnfJson) + .withStatus(200))); final String aaiVserverJson = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVserverFullQueryResponse.json"))); - wireMockServer.stubFor(get(urlEqualTo( - "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/mtn23a/tenants/tenant/e6beab145f6b49098277ac163ac1b4f3/vservers/vserver/48bd7f11-408f-417c-b834-b41c1b98f7d7")) + wireMockServer.stubFor(get(urlEqualTo("/aai/" + AAIVersion.LATEST + + "/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/mtn23a/tenants/tenant/e6beab145f6b49098277ac163ac1b4f3/vservers/vserver/48bd7f11-408f-417c-b834-b41c1b98f7d7")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(aaiVserverJson) .withStatus(200))); - wireMockServer.stubFor(get(urlEqualTo( - "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/mtn23a/tenants/tenant/e6beab145f6b49098277ac163ac1b4f3/vservers/vserver/1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5")) + wireMockServer.stubFor(get(urlEqualTo("/aai/" + AAIVersion.LATEST + + "/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/mtn23a/tenants/tenant/e6beab145f6b49098277ac163ac1b4f3/vservers/vserver/1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(aaiVserverJson) .withStatus(200))); - wireMockServer.stubFor(get(urlEqualTo( - "/aai/v15/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/mtn23a/tenants/tenant/e6beab145f6b49098277ac163ac1b4f3/vservers/vserver/14551849-1e70-45cd-bc5d-a256d49548a2")) + wireMockServer.stubFor(get(urlEqualTo("/aai/" + AAIVersion.LATEST + + "/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/mtn23a/tenants/tenant/e6beab145f6b49098277ac163ac1b4f3/vservers/vserver/14551849-1e70-45cd-bc5d-a256d49548a2")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(aaiVserverJson) .withStatus(200))); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java index 9c736b7634..a8816e1b04 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdn/common/SdnCommonTasksTest.java @@ -21,6 +21,7 @@ package org.onap.so.client.sdn.common; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import java.util.LinkedHashMap; import org.junit.Assert; import org.junit.Rule; @@ -29,6 +30,8 @@ import org.junit.rules.ExpectedException; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SdnCommonTasks; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; public class SdnCommonTasksTest { @@ -53,7 +56,20 @@ public class SdnCommonTasksTest { @Test public void getHttpHeadersTest() { - Assert.assertNotNull(sdnCommonTasks.getHttpHeaders("")); + HttpHeaders result = sdnCommonTasks.getHttpHeaders("auth", true); + + assertEquals("auth", result.getFirst("Authorization")); + assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Content-Type")); + assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Accept")); + } + + @Test + public void getHttpHeadersGetRequestTest() { + HttpHeaders result = sdnCommonTasks.getHttpHeaders("auth", false); + + assertEquals("auth", result.getFirst("Authorization")); + assertEquals(MediaType.APPLICATION_JSON.toString(), result.getFirst("Accept")); + assertFalse(result.containsKey("Content-Type")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java index b71ddba63b..2fd684e0f0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java @@ -334,4 +334,69 @@ public class VfModuleTopologyOperationRequestMapperTest { serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); } + @Test + public void reqMapperChangeAssignTest() throws Exception { + + // prepare and set service instance + ServiceInstance serviceInstance = new ServiceInstance(); + serviceInstance.setServiceInstanceId("serviceInstanceId"); + ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance(); + modelInfoServiceInstance.setModelInvariantUuid("serviceModelInvariantUuid"); + modelInfoServiceInstance.setModelName("serviceModelName"); + modelInfoServiceInstance.setModelUuid("serviceModelUuid"); + modelInfoServiceInstance.setModelVersion("serviceModelVersion"); + + serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance); + // prepare Customer object + Customer customer = new Customer(); + customer.setGlobalCustomerId("globalCustomerId"); + customer.setServiceSubscription(new ServiceSubscription()); + // set Customer on service instance + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + // + RequestContext requestContext = new RequestContext(); + RequestParameters requestParameters = new RequestParameters(); + HashMap<String, Object> userParams1 = new HashMap<>(); + userParams1.put("key1", "value1"); + List<Map<String, Object>> userParams = new ArrayList<>(); + userParams.add(userParams1); + + requestParameters.setUserParams(userParams); + requestContext.setRequestParameters(requestParameters); + requestContext.setProductFamilyId("productFamilyId"); + + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("testVnfId"); + vnf.setVnfType("testVnfType"); + ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf(); + modelInfoGenericVnf.setModelInvariantUuid("vnfModelInvariantUuid"); + modelInfoGenericVnf.setModelName("vnfModelName"); + modelInfoGenericVnf.setModelVersion("vnfModelVersion"); + modelInfoGenericVnf.setModelUuid("vnfModelUuid"); + modelInfoGenericVnf.setModelCustomizationUuid("vnfModelCustomizationUuid"); + vnf.setModelInfoGenericVnf(modelInfoGenericVnf); + + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("testVfModuleId"); + vfModule.setVfModuleName("testVfModuleName"); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelInvariantUUID("vfModuleModelInvariantUuid"); + modelInfoVfModule.setModelName("vfModuleModelName"); + modelInfoVfModule.setModelVersion("vfModuleModelVersion"); + modelInfoVfModule.setModelUUID("vfModuleModelUuid"); + modelInfoVfModule.setModelCustomizationUUID("vfModuleModelCustomizationUuid"); + vfModule.setModelInfoVfModule(modelInfoVfModule); + + CloudRegion cloudRegion = new CloudRegion(); + + GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( + SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, + serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); + + assertEquals("vnfModelCustomizationUuid", + vfModuleSDNCrequest.getVnfInformation().getOnapModelInformation().getModelCustomizationUuid()); + assertEquals("vfModuleModelCustomizationUuid", + vfModuleSDNCrequest.getVfModuleInformation().getOnapModelInformation().getModelCustomizationUuid()); + } + } |