From fee6611fa805b6bb5f06f07b45396a71ad72c564 Mon Sep 17 00:00:00 2001 From: Joanna Jeremicz Date: Mon, 25 Feb 2019 09:11:16 +0100 Subject: CorrelationId cleanup Remove old correlationId field and references from ServiceInstancesRequest and rename correlationId to pnfCorrelationId Change-Id: I5d8861aebe14c68574b6c54bc8d4eadf2967478b Issue-ID: SO-1274 Signed-off-by: Michal Kabaj --- .../delegate/CreateAndActivatePnfResourceTest.java | 10 +- .../pnf/delegate/DmaapClientTestImpl.java | 18 ++-- .../pnf/delegate/PnfManagementTestImpl.java | 8 +- .../pnf/delegate/CancelDmaapSubscription.java | 4 +- .../delegate/CheckAaiForCorrelationIdDelegate.java | 70 ------------ .../CheckAaiForPnfCorrelationIdDelegate.java | 70 ++++++++++++ .../pnf/delegate/CreatePnfEntryInAaiDelegate.java | 12 +-- .../pnf/delegate/CreateRelation.java | 2 +- .../pnf/delegate/ExecutionVariableNames.java | 2 +- .../pnf/delegate/InformDmaapClient.java | 4 +- .../pnf/delegate/PnfCheckInputs.java | 12 +-- .../bpmn/infrastructure/pnf/dmaap/DmaapClient.java | 4 +- .../pnf/dmaap/JsonUtilForCorrelationId.java | 64 ----------- .../pnf/dmaap/JsonUtilForPnfCorrelationId.java | 64 +++++++++++ .../pnf/dmaap/PnfEventReadyDmaapClient.java | 24 ++--- .../pnf/management/PnfManagement.java | 4 +- .../pnf/management/PnfManagementImpl.java | 8 +- .../pnf/delegate/CancelDmaapSubscriptionTest.java | 4 +- .../CheckAaiForCorrelationIdDelegateTest.java | 119 --------------------- .../CheckAaiForPnfCorrelationIdDelegateTest.java | 119 +++++++++++++++++++++ .../delegate/CreatePnfEntryInAaiDelegateTest.java | 8 +- .../pnf/delegate/CreateRelationTest.java | 2 +- .../pnf/delegate/DmaapClientTestImpl.java | 18 ++-- .../pnf/delegate/InformDmaapClientTest.java | 6 +- .../pnf/delegate/PnfCheckInputsTest.java | 16 +-- .../pnf/delegate/PnfManagementTestImpl.java | 8 +- .../delegate/PnfManagementThrowingException.java | 4 +- .../pnf/dmaap/JsonUtilForCorrelationIdTest.java | 67 ------------ .../pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java | 67 ++++++++++++ .../pnf/dmaap/PnfEventReadyDmaapClientTest.java | 28 ++--- .../process/CreateAndActivatePnfResource.bpmn | 14 +-- .../process/CreateVcpeResCustServiceV2.bpmn | 2 +- .../CreateVcpeResCustService_simplified.bpmn | 2 +- .../ServiceInstancesRequest.java | 11 -- .../apihandler/camundabeans/CamundaVIDRequest.java | 18 ++-- .../onap/so/apihandler/common/CamundaClient.java | 10 +- .../onap/so/apihandler/common/CommonConstants.java | 2 +- .../apihandler/common/RequestClientParameter.java | 14 +-- .../so/apihandler/common/CamundaClientTest.java | 4 +- .../CamundaClientTest/WrappedVIDRequest.json | 2 +- .../onap/so/apihandlerinfra/ServiceInstances.java | 14 +-- .../camundaResponses/processInstanceVariables.json | 6 +- 42 files changed, 467 insertions(+), 478 deletions(-) delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegate.java delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegateTest.java delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java index 13fe61f704..5cc0281407 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java @@ -23,7 +23,7 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; import java.util.HashMap; @@ -62,7 +62,7 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { @Test public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() { // given - variables.put(CORRELATION_ID, PnfManagementTestImpl.ID_WITH_ENTRY); + variables.put(PNF_CORRELATION_ID, PnfManagementTestImpl.ID_WITH_ENTRY); // when ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); @@ -73,7 +73,7 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { assertThat(instance).isEnded().hasPassedInOrder( "CreateAndActivatePnf_StartEvent", "CheckInputs", - "CheckAiiForCorrelationId", + "CheckAiiForPnfCorrelationId", "DoesAaiContainInfoAboutPnf", "AaiEntryExists", "InformDmaapClient", @@ -88,7 +88,7 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { @Test public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() { // given - variables.put(CORRELATION_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY); + variables.put(PNF_CORRELATION_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY); // when ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); @@ -99,7 +99,7 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { assertThat(instance).isEnded().hasPassedInOrder( "CreateAndActivatePnf_StartEvent", "CheckInputs", - "CheckAiiForCorrelationId", + "CheckAiiForPnfCorrelationId", "DoesAaiContainInfoAboutPnf", "CreatePnfEntryInAai", "AaiEntryExists", diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java index 146e07b820..6a5f9fac74 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java @@ -30,19 +30,19 @@ import org.springframework.stereotype.Component; @Primary public class DmaapClientTestImpl implements DmaapClient { - private String correlationId; + private String pnfCorrelationId; private Runnable informConsumer; @Override - public void registerForUpdate(String correlationId, Runnable informConsumer) { - this.correlationId = correlationId; + public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) { + this.pnfCorrelationId = pnfCorrelationId; this.informConsumer = informConsumer; } @Override - public Runnable unregister(String correlationId) { - if (Objects.equals(this.correlationId, correlationId)) { - this.correlationId = null; + public Runnable unregister(String pnfCorrelationId) { + if (Objects.equals(this.pnfCorrelationId, pnfCorrelationId)) { + this.pnfCorrelationId = null; Runnable informConsumer = this.informConsumer; this.informConsumer = null; return informConsumer; @@ -50,8 +50,8 @@ public class DmaapClientTestImpl implements DmaapClient { return null; } - public String getCorrelationId() { - return correlationId; + public String getPnfCorrelationId() { + return pnfCorrelationId; } public Runnable getInformConsumer() { @@ -63,6 +63,6 @@ public class DmaapClientTestImpl implements DmaapClient { } public boolean haveRegisteredConsumer() { - return correlationId != null; + return pnfCorrelationId != null; } } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java index 84c983619b..f9db93e3f7 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -40,8 +40,8 @@ public class PnfManagementTestImpl implements PnfManagement { private Map serviceAndPnfRelationMap = new HashMap<>(); @Override - public Optional getEntryFor(String correlationId) { - if (Objects.equals(correlationId, ID_WITH_ENTRY)) { + public Optional getEntryFor(String pnfCorrelationId) { + if (Objects.equals(pnfCorrelationId, ID_WITH_ENTRY)) { return Optional.of(new Pnf()); } else { return Optional.empty(); @@ -49,8 +49,8 @@ public class PnfManagementTestImpl implements PnfManagement { } @Override - public void createEntry(String correlationId, Pnf entry) { - created.put(correlationId, entry); + public void createEntry(String pnfCorrelationId, Pnf entry) { + created.put(pnfCorrelationId, entry); } @Override diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscription.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscription.java index 05109abc84..439591a295 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscription.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscription.java @@ -33,8 +33,8 @@ public class CancelDmaapSubscription implements JavaDelegate { @Override public void execute(DelegateExecution execution) { - String correlationId = (String) execution.getVariable(ExecutionVariableNames.CORRELATION_ID); - dmaapClient.unregister(correlationId); + String pnfCorrelationId = (String) execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID); + dmaapClient.unregister(pnfCorrelationId); } @Autowired diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java deleted file mode 100644 index a8fb21540a..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.infrastructure.pnf.delegate; - -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; - -import java.io.IOException; - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.so.bpmn.common.scripts.ExceptionUtil; -import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * Implementation of "Check AAI for correlation_id" task in CreateAndActivatePnfResource.bpmn - * - * Inputs: - correlationId - String - * - * Outputs: - aaiContainsInfoAboutPnf - local Boolean - */ -@Component -public class CheckAaiForCorrelationIdDelegate implements JavaDelegate { - - private static final Logger logger = LoggerFactory.getLogger(CheckAaiForCorrelationIdDelegate.class); - - private PnfManagement pnfManagement; - - @Autowired - public void setPnfManagement(PnfManagement pnfManagement) { - this.pnfManagement = pnfManagement; - } - - @Override - public void execute(DelegateExecution execution) { - String correlationId = (String) execution.getVariable(CORRELATION_ID); - if (correlationId == null) { - new ExceptionUtil().buildAndThrowWorkflowException(execution, 500, CORRELATION_ID + " is not set"); - } - try { - boolean isEntry = pnfManagement.getEntryFor(correlationId).isPresent(); - logger.debug("AAI entry is found for pnf correlation id {}: {}", CORRELATION_ID, isEntry); - execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, isEntry); - } catch (IOException e) { - new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, e.getMessage()); - } - } -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegate.java new file mode 100644 index 0000000000..e0fa41b7a1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegate.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.infrastructure.pnf.delegate; + +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; + +import java.io.IOException; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.so.bpmn.common.scripts.ExceptionUtil; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Implementation of "Check AAI for pnf_correlation_id" task in CreateAndActivatePnfResource.bpmn + * + * Inputs: - pnfCorrelationId - String + * + * Outputs: - aaiContainsInfoAboutPnf - local Boolean + */ +@Component +public class CheckAaiForPnfCorrelationIdDelegate implements JavaDelegate { + + private static final Logger logger = LoggerFactory.getLogger(CheckAaiForPnfCorrelationIdDelegate.class); + + private PnfManagement pnfManagement; + + @Autowired + public void setPnfManagement(PnfManagement pnfManagement) { + this.pnfManagement = pnfManagement; + } + + @Override + public void execute(DelegateExecution execution) { + String pnfCorrelationId = (String) execution.getVariable(PNF_CORRELATION_ID); + if (pnfCorrelationId == null) { + new ExceptionUtil().buildAndThrowWorkflowException(execution, 500, PNF_CORRELATION_ID + " is not set"); + } + try { + boolean isEntry = pnfManagement.getEntryFor(pnfCorrelationId).isPresent(); + logger.debug("AAI entry is found for pnf correlation id {}: {}", PNF_CORRELATION_ID, isEntry); + execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, isEntry); + } catch (IOException e) { + new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, e.getMessage()); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java index c31041fbf7..e56cb83119 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java @@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; import org.camunda.bpm.engine.delegate.DelegateExecution; @@ -38,7 +38,7 @@ import org.springframework.stereotype.Component; * Implementation of "Create Pnf entry in AAI" task in CreateAndActivatePnfResource.bpmn * * Inputs: - * - correlationId - String + * - pnfCorrelationId - String * - pnfUuid - String */ @Component @@ -54,12 +54,12 @@ public class CreatePnfEntryInAaiDelegate implements JavaDelegate { @Override public void execute(DelegateExecution execution) throws Exception { - String correlationId = (String) execution.getVariable(CORRELATION_ID); + String pnfCorrelationId = (String) execution.getVariable(PNF_CORRELATION_ID); String pnfUuid = (String) execution.getVariable(PNF_UUID); Pnf pnf = new Pnf(); pnf.setPnfId(pnfUuid); - pnf.setPnfName(correlationId); - pnfManagement.createEntry(correlationId, pnf); - logger.debug("AAI entry is created for pnf correlation id: {}, pnf uuid: {}", correlationId, pnfUuid); + pnf.setPnfName(pnfCorrelationId); + pnfManagement.createEntry(pnfCorrelationId, pnf); + logger.debug("AAI entry is created for pnf correlation id: {}, pnf uuid: {}", pnfCorrelationId, pnfUuid); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java index 7b6706f820..a367bada02 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java @@ -44,7 +44,7 @@ public class CreateRelation implements JavaDelegate { @Override public void execute(DelegateExecution delegateExecution) { String serviceInstanceId = (String) delegateExecution.getVariable("serviceInstanceId"); - String pnfName = (String) delegateExecution.getVariable("correlationId"); + String pnfName = (String) delegateExecution.getVariable("pnfCorrelationId"); try { pnfManagementImpl.createRelation(serviceInstanceId, pnfName); } catch (Exception e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java index c5caea5f2f..7d449e72a8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java @@ -27,7 +27,7 @@ public class ExecutionVariableNames { private ExecutionVariableNames() {} - public final static String CORRELATION_ID = "correlationId"; + public final static String PNF_CORRELATION_ID = "pnfCorrelationId"; public final static String AAI_CONTAINS_INFO_ABOUT_PNF = "aaiContainsInfoAboutPnf"; public final static String AAI_CONTAINS_INFO_ABOUT_IP = "aaiContainsInfoAboutIp"; public final static String DMAAP_MESSAGE = "dmaapMessage"; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java index 1a75b0998c..96455acb84 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java @@ -34,9 +34,9 @@ public class InformDmaapClient implements JavaDelegate { @Override public void execute(DelegateExecution execution) { - String correlationId = (String) execution.getVariable(ExecutionVariableNames.CORRELATION_ID); + String pnfCorrelationId = (String) execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID); RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); - dmaapClient.registerForUpdate(correlationId, () -> + dmaapClient.registerForUpdate(pnfCorrelationId, () -> runtimeService .createMessageCorrelation("WorkflowMessage") .processInstanceBusinessKey(execution.getProcessBusinessKey()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java index 1b185f7c03..1caadea0de 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java @@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION; @@ -49,16 +49,16 @@ public class PnfCheckInputs implements JavaDelegate { @Override public void execute(DelegateExecution execution) { - validateCorrelationId(execution); + validatePnfCorrelationId(execution); validatePnfUuid(execution); validateTimeout(execution); validateServiceInstanceId(execution); } - private void validateCorrelationId(DelegateExecution execution) { - String correlationId = (String) execution.getVariable(CORRELATION_ID); - if (Strings.isNullOrEmpty(correlationId)) { - new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "correlationId variable not defined"); + private void validatePnfCorrelationId(DelegateExecution execution) { + String pnfCorrelationId = (String) execution.getVariable(PNF_CORRELATION_ID); + if (Strings.isNullOrEmpty(pnfCorrelationId)) { + new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "pnfCorrelationId variable not defined"); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java index c7e7c7848c..fbf86cc411 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java @@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.pnf.dmaap; public interface DmaapClient { - void registerForUpdate(String correlationId, Runnable informConsumer); + void registerForUpdate(String pnfCorrelationId, Runnable informConsumer); - Runnable unregister(String correlationId); + Runnable unregister(String pnfCorrelationId); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java deleted file mode 100644 index 159298b4ad..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2018 Nokia. - * ================================================================================ - * 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.bpmn.infrastructure.pnf.dmaap; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.Spliterator; - -public final class JsonUtilForCorrelationId { - - private static final String JSON_CORRELATION_ID_FIELD_NAME = "correlationId"; - - static List parseJsonToGelAllCorrelationId(String json) { - JsonElement je = new JsonParser().parse(json); - JsonArray array = je.getAsJsonArray(); - List list = new ArrayList<>(); - Spliterator spliterator = array.spliterator(); - spliterator.forEachRemaining(jsonElement -> { - handleEscapedCharacters(jsonElement) - .ifPresent(jsonObject -> getCorrelationId(jsonObject) - .ifPresent(correlationId -> list.add(correlationId))); - }); - return list; - } - - private static Optional handleEscapedCharacters(JsonElement jsonElement) { - if (jsonElement.isJsonObject()) { - return Optional.ofNullable(jsonElement.getAsJsonObject()); - } - return Optional.ofNullable(new JsonParser().parse(jsonElement.getAsString()).getAsJsonObject()); - } - - private static Optional getCorrelationId(JsonObject jsonObject) { - if (jsonObject.has(JSON_CORRELATION_ID_FIELD_NAME)) { - return Optional.ofNullable(jsonObject.get(JSON_CORRELATION_ID_FIELD_NAME).getAsString()); - } - return Optional.empty(); - } -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java new file mode 100644 index 0000000000..53f6b78d69 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2018 Nokia. + * ================================================================================ + * 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.bpmn.infrastructure.pnf.dmaap; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Spliterator; + +public final class JsonUtilForPnfCorrelationId { + + private static final String JSON_PNF_CORRELATION_ID_FIELD_NAME = "pnfCorrelationId"; + + static List parseJsonToGelAllPnfCorrelationId(String json) { + JsonElement je = new JsonParser().parse(json); + JsonArray array = je.getAsJsonArray(); + List list = new ArrayList<>(); + Spliterator spliterator = array.spliterator(); + spliterator.forEachRemaining(jsonElement -> { + handleEscapedCharacters(jsonElement) + .ifPresent(jsonObject -> getPnfCorrelationId(jsonObject) + .ifPresent(pnfCorrelationId -> list.add(pnfCorrelationId))); + }); + return list; + } + + private static Optional handleEscapedCharacters(JsonElement jsonElement) { + if (jsonElement.isJsonObject()) { + return Optional.ofNullable(jsonElement.getAsJsonObject()); + } + return Optional.ofNullable(new JsonParser().parse(jsonElement.getAsString()).getAsJsonObject()); + } + + private static Optional getPnfCorrelationId(JsonObject jsonObject) { + if (jsonObject.has(JSON_PNF_CORRELATION_ID_FIELD_NAME)) { + return Optional.ofNullable(jsonObject.get(JSON_PNF_CORRELATION_ID_FIELD_NAME).getAsString()); + } + return Optional.empty(); + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java index 52f879b0ad..1b7a69eec8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java @@ -69,18 +69,18 @@ public class PnfEventReadyDmaapClient implements DmaapClient { } @Override - public synchronized void registerForUpdate(String correlationId, Runnable informConsumer) { - logger.debug("registering for pnf ready dmaap event for correlation id: {}", correlationId); - pnfCorrelationIdToThreadMap.put(correlationId, informConsumer); + public synchronized void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) { + logger.debug("registering for pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId); + pnfCorrelationIdToThreadMap.put(pnfCorrelationId, informConsumer); if (!dmaapThreadListenerIsRunning) { startDmaapThreadListener(); } } @Override - public synchronized Runnable unregister(String correlationId) { - logger.debug("unregistering from pnf ready dmaap event for correlation id: {}", correlationId); - Runnable runnable = pnfCorrelationIdToThreadMap.remove(correlationId); + public synchronized Runnable unregister(String pnfCorrelationId) { + logger.debug("unregistering from pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId); + Runnable runnable = pnfCorrelationIdToThreadMap.remove(pnfCorrelationId); if (pnfCorrelationIdToThreadMap.isEmpty()) { stopDmaapThreadListener(); } @@ -113,7 +113,7 @@ public class PnfEventReadyDmaapClient implements DmaapClient { try { logger.debug("dmaap listener starts listening pnf ready dmaap topic"); HttpResponse response = httpClient.execute(getRequest); - getCorrelationIdListFromResponse(response).forEach(this::informAboutPnfReadyIfCorrelationIdFound); + getPnfCorrelationIdListFromResponse(response).forEach(this::informAboutPnfReadyIfPnfCorrelationIdFound); } catch (IOException e) { logger.error("Exception caught during sending rest request to dmaap for listening event topic", e); } @@ -122,20 +122,20 @@ public class PnfEventReadyDmaapClient implements DmaapClient { } } - private List getCorrelationIdListFromResponse(HttpResponse response) throws IOException { + private List getPnfCorrelationIdListFromResponse(HttpResponse response) throws IOException { if (response.getStatusLine().getStatusCode() == 200) { String responseString = EntityUtils.toString(response.getEntity(), "UTF-8"); if (responseString != null) { - return JsonUtilForCorrelationId.parseJsonToGelAllCorrelationId(responseString); + return JsonUtilForPnfCorrelationId.parseJsonToGelAllPnfCorrelationId(responseString); } } return Collections.emptyList(); } - private void informAboutPnfReadyIfCorrelationIdFound(String correlationId) { - Runnable runnable = unregister(correlationId); + private void informAboutPnfReadyIfPnfCorrelationIdFound(String pnfCorrelationId) { + Runnable runnable = unregister(pnfCorrelationId); if (runnable != null) { - logger.debug("dmaap listener gets pnf ready event for correlationId: {}", correlationId); + logger.debug("dmaap listener gets pnf ready event for pnfCorrelationId: {}", pnfCorrelationId); runnable.run(); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java index b66bb5f61b..9e720fe0a4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java @@ -26,9 +26,9 @@ import org.onap.aai.domain.yang.Pnf; public interface PnfManagement { - Optional getEntryFor(String correlationId) throws IOException; + Optional getEntryFor(String pnfCorrelationId) throws IOException; - void createEntry(String correlationId, Pnf entry) throws IOException; + void createEntry(String pnfCorrelationId, Pnf entry) throws IOException; void createRelation(String serviceInstanceId, String pnfName) throws IOException; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java index 3d8da2a106..32ea357817 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java @@ -33,15 +33,15 @@ import org.springframework.stereotype.Component; public class PnfManagementImpl implements PnfManagement { @Override - public Optional getEntryFor(String correlationId) { + public Optional getEntryFor(String pnfCorrelationId) { AAIRestClientImpl restClient = new AAIRestClientImpl(); - return restClient.getPnfByName(correlationId); + return restClient.getPnfByName(pnfCorrelationId); } @Override - public void createEntry(String correlationId, Pnf entry) { + public void createEntry(String pnfCorrelationId, Pnf entry) { AAIRestClientImpl restClient = new AAIRestClientImpl(); - restClient.createPnf(correlationId, entry); + restClient.createPnf(pnfCorrelationId, entry); } @Override diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java index 8507d9c092..b0ff82e3aa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java @@ -37,9 +37,9 @@ public class CancelDmaapSubscriptionTest { DmaapClientTestImpl dmaapClientTest = new DmaapClientTestImpl(); delegate.setDmaapClient(dmaapClientTest); DelegateExecution delegateExecution = mock(DelegateExecution.class); - when(delegateExecution.getVariable(eq(ExecutionVariableNames.CORRELATION_ID))).thenReturn("testCorrelationId"); + when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID))).thenReturn("testPnfCorrelationId"); when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey"); - dmaapClientTest.registerForUpdate("testCorrelationId", () -> { + dmaapClientTest.registerForUpdate("testPnfCorrelationId", () -> { }); // when delegate.execute(delegateExecution); diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java deleted file mode 100644 index 4b47ed6407..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.infrastructure.pnf.delegate; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITHOUT_ENTRY; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITH_ENTRY; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; - -import org.camunda.bpm.engine.delegate.BpmnError; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.onap.so.bpmn.core.WorkflowException; - -@RunWith(Enclosed.class) -public class CheckAaiForCorrelationIdDelegateTest { - - public static class ConnectionOkTests { - - private CheckAaiForCorrelationIdDelegate delegate; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void setUp() { - delegate = new CheckAaiForCorrelationIdDelegate(); - delegate.setPnfManagement(new PnfManagementTestImpl()); - } - - @Test - public void shouldThrowExceptionWhenCorrelationIdIsNotSet() throws Exception { - // given - DelegateExecution execution = mock(DelegateExecution.class); - when(execution.getVariable(CORRELATION_ID)).thenReturn(null); - when(execution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue"); - // when, then - expectedException.expect(BpmnError.class); - delegate.execute(execution); - verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class)); - } - - @Test - public void shouldSetCorrectVariablesWhenAaiDoesNotContainInfoAboutPnf() throws Exception { - // given - DelegateExecution execution = mock(DelegateExecution.class); - when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITHOUT_ENTRY); - // when - delegate.execute(execution); - // then - verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, false); - } - - @Test - public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnfWithoutIp() throws Exception { - // given - DelegateExecution execution = mock(DelegateExecution.class); - when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY); - // when - delegate.execute(execution); - // then - verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, true); - } - } - - public static class NoConnectionTests { - - private CheckAaiForCorrelationIdDelegate delegate; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void setUp() { - delegate = new CheckAaiForCorrelationIdDelegate(); - delegate.setPnfManagement(new PnfManagementThrowingException()); - } - - @Test - public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() throws Exception { - // given - DelegateExecution execution = mock(DelegateExecution.class); - when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY); - when(execution.getVariable("testProcessKey")).thenReturn("testProcessKey"); - // when, then - expectedException.expect(BpmnError.class); - delegate.execute(execution); - verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class)); - } - } -} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegateTest.java new file mode 100644 index 0000000000..6a0aaf776e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegateTest.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.infrastructure.pnf.delegate; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITHOUT_ENTRY; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITH_ENTRY; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.runners.Enclosed; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.onap.so.bpmn.core.WorkflowException; + +@RunWith(Enclosed.class) +public class CheckAaiForPnfCorrelationIdDelegateTest { + + public static class ConnectionOkTests { + + private CheckAaiForPnfCorrelationIdDelegate delegate; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setUp() { + delegate = new CheckAaiForPnfCorrelationIdDelegate(); + delegate.setPnfManagement(new PnfManagementTestImpl()); + } + + @Test + public void shouldThrowExceptionWhenPnfCorrelationIdIsNotSet() throws Exception { + // given + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable(PNF_CORRELATION_ID)).thenReturn(null); + when(execution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue"); + // when, then + expectedException.expect(BpmnError.class); + delegate.execute(execution); + verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class)); + } + + @Test + public void shouldSetCorrectVariablesWhenAaiDoesNotContainInfoAboutPnf() throws Exception { + // given + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable(PNF_CORRELATION_ID)).thenReturn(ID_WITHOUT_ENTRY); + // when + delegate.execute(execution); + // then + verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, false); + } + + @Test + public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnfWithoutIp() throws Exception { + // given + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable(PNF_CORRELATION_ID)).thenReturn(ID_WITH_ENTRY); + // when + delegate.execute(execution); + // then + verify(execution).setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, true); + } + } + + public static class NoConnectionTests { + + private CheckAaiForPnfCorrelationIdDelegate delegate; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setUp() { + delegate = new CheckAaiForPnfCorrelationIdDelegate(); + delegate.setPnfManagement(new PnfManagementThrowingException()); + } + + @Test + public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() throws Exception { + // given + DelegateExecution execution = mock(DelegateExecution.class); + when(execution.getVariable(PNF_CORRELATION_ID)).thenReturn(ID_WITH_ENTRY); + when(execution.getVariable("testProcessKey")).thenReturn("testProcessKey"); + // when, then + expectedException.expect(BpmnError.class); + delegate.execute(execution); + verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class)); + } + } +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java index 9c5f8f3fc4..986edfeecf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java @@ -25,7 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; import java.util.UUID; @@ -43,14 +43,14 @@ public class CreatePnfEntryInAaiDelegateTest { PnfManagementTestImpl pnfManagementTest = new PnfManagementTestImpl(); delegate.setPnfManagement(pnfManagementTest); DelegateExecution execution = mock(DelegateExecution.class); - given(execution.getVariable(eq(CORRELATION_ID))).willReturn("testCorrelationId"); + given(execution.getVariable(eq(PNF_CORRELATION_ID))).willReturn("testPnfCorrelationId"); given(execution.getVariable(eq(PNF_UUID))).willReturn(pnfUuid); // when delegate.execute(execution); // then - Pnf createdEntry = pnfManagementTest.getCreated().get("testCorrelationId"); + Pnf createdEntry = pnfManagementTest.getCreated().get("testPnfCorrelationId"); assertThat(createdEntry.getPnfId()).isEqualTo(pnfUuid); - assertThat(createdEntry.getPnfName()).isEqualTo("testCorrelationId"); + assertThat(createdEntry.getPnfName()).isEqualTo("testPnfCorrelationId"); assertThat(createdEntry.isInMaint()).isNull(); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java index 2a78337e34..c743ee7018 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java @@ -42,7 +42,7 @@ public class CreateRelationTest { public void setUp() { executionFake = new DelegateExecutionFake(); executionFake.setVariable("serviceInstanceId", SERVICE_INSTANCE_ID); - executionFake.setVariable("correlationId", PNF_NAME); + executionFake.setVariable("pnfCorrelationId", PNF_NAME); } @Test diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java index f2a4205ebd..19ba18f6de 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java @@ -25,19 +25,19 @@ import java.util.Objects; public class DmaapClientTestImpl implements DmaapClient { - private String correlationId; + private String pnfCorrelationId; private Runnable informConsumer; @Override - public void registerForUpdate(String correlationId, Runnable informConsumer) { - this.correlationId = correlationId; + public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) { + this.pnfCorrelationId = pnfCorrelationId; this.informConsumer = informConsumer; } @Override - public Runnable unregister(String correlationId) { - if (Objects.equals(this.correlationId, correlationId)) { - this.correlationId = null; + public Runnable unregister(String pnfCorrelationId) { + if (Objects.equals(this.pnfCorrelationId, pnfCorrelationId)) { + this.pnfCorrelationId = null; Runnable informConsumer = this.informConsumer; this.informConsumer = null; return informConsumer; @@ -45,8 +45,8 @@ public class DmaapClientTestImpl implements DmaapClient { return null; } - public String getCorrelationId() { - return correlationId; + public String getPnfCorrelationId() { + return pnfCorrelationId; } public Runnable getInformConsumer() { @@ -58,6 +58,6 @@ public class DmaapClientTestImpl implements DmaapClient { } public boolean haveRegisteredConsumer() { - return correlationId != null; + return pnfCorrelationId != null; } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java index 23c82229fe..eb9f657d4f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java @@ -55,7 +55,7 @@ public class InformDmaapClientTest { // when informDmaapClient.execute(delegateExecution); // then - assertThat(dmaapClientTest.getCorrelationId()).isEqualTo("testCorrelationId"); + assertThat(dmaapClientTest.getPnfCorrelationId()).isEqualTo("testPnfCorrelationId"); assertThat(dmaapClientTest.getInformConsumer()).isNotNull(); verifyZeroInteractions(messageCorrelationBuilder); } @@ -66,7 +66,7 @@ public class InformDmaapClientTest { informDmaapClient.execute(delegateExecution); dmaapClientTest.getInformConsumer().run(); // then - assertThat(dmaapClientTest.getCorrelationId()).isEqualTo("testCorrelationId"); + assertThat(dmaapClientTest.getPnfCorrelationId()).isEqualTo("testPnfCorrelationId"); InOrder inOrder = inOrder(messageCorrelationBuilder); inOrder.verify(messageCorrelationBuilder).processInstanceBusinessKey("testBusinessKey"); inOrder.verify(messageCorrelationBuilder).correlateWithResult(); @@ -74,7 +74,7 @@ public class InformDmaapClientTest { private DelegateExecution mockDelegateExecution() { DelegateExecution delegateExecution = mock(DelegateExecution.class); - when(delegateExecution.getVariable(eq(ExecutionVariableNames.CORRELATION_ID))).thenReturn("testCorrelationId"); + when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID))).thenReturn("testPnfCorrelationId"); when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey"); ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class); when(delegateExecution.getProcessEngineServices()).thenReturn(processEngineServices); diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java index 80693d7ce6..001815b206 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java @@ -21,7 +21,7 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID; @@ -39,7 +39,7 @@ public class PnfCheckInputsTest { private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString(); private static final String RESERVED_UUID = new UUID(0, 0).toString(); private static final String DEFAULT_SERVICE_INSTANCE_ID = "da7d07d9-b71c-4128-809d-2ec01c807169"; - private static final String DEFAULT_CORRELATION_ID = "testCorrelationId"; + private static final String DEFAULT_PNF_CORRELATION_ID = "testPnfCorrelationId"; private DelegateExecutionBuilder delegateExecutionBuilder; @@ -49,9 +49,9 @@ public class PnfCheckInputsTest { } @Test - public void shouldThrowException_whenCorrelationIdNotSet() { + public void shouldThrowException_whenPnfCorrelationIdNotSet() { PnfCheckInputs testedObject = new PnfCheckInputs(PNF_ENTRY_NOTIFICATION_TIMEOUT); - DelegateExecution execution = delegateExecutionBuilder.setCorrelationId(null).setPnfUuid(VALID_UUID).build(); + DelegateExecution execution = delegateExecutionBuilder.setPnfCorrelationId(null).setPnfUuid(VALID_UUID).build(); assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(BpmnError.class); } @@ -98,12 +98,12 @@ public class PnfCheckInputsTest { } private static class DelegateExecutionBuilder { - private String correlationId = DEFAULT_CORRELATION_ID; + private String pnfCorrelationId = DEFAULT_PNF_CORRELATION_ID; private String pnfUuid = VALID_UUID; private String serviceInstanceId = DEFAULT_SERVICE_INSTANCE_ID; - public DelegateExecutionBuilder setCorrelationId(String correlationId) { - this.correlationId = correlationId; + public DelegateExecutionBuilder setPnfCorrelationId(String pnfCorrelationId) { + this.pnfCorrelationId = pnfCorrelationId; return this; } @@ -120,7 +120,7 @@ public class PnfCheckInputsTest { public DelegateExecution build() { DelegateExecution execution = new DelegateExecutionFake(); execution.setVariable("testProcessKey", "testProcessKeyValue"); - execution.setVariable(CORRELATION_ID, this.correlationId); + execution.setVariable(PNF_CORRELATION_ID, this.pnfCorrelationId); execution.setVariable(PNF_UUID, this.pnfUuid); execution.setVariable(SERVICE_INSTANCE_ID, this.serviceInstanceId); return execution; diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java index 1377c8295f..3a9d6d0055 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -37,8 +37,8 @@ public class PnfManagementTestImpl implements PnfManagement { private Map created = new HashMap<>(); @Override - public Optional getEntryFor(String correlationId) { - if (Objects.equals(correlationId, ID_WITH_ENTRY)) { + public Optional getEntryFor(String pnfCorrelationId) { + if (Objects.equals(pnfCorrelationId, ID_WITH_ENTRY)) { return Optional.of(new Pnf()); } else { return Optional.empty(); @@ -46,8 +46,8 @@ public class PnfManagementTestImpl implements PnfManagement { } @Override - public void createEntry(String correlationId, Pnf entry) throws IOException { - created.put(correlationId, entry); + public void createEntry(String pnfCorrelationId, Pnf entry) throws IOException { + created.put(pnfCorrelationId, entry); } @Override diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java index 43315d3803..f9b467c650 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java @@ -28,12 +28,12 @@ import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; public class PnfManagementThrowingException implements PnfManagement { @Override - public Optional getEntryFor(String correlationId) throws IOException { + public Optional getEntryFor(String pnfCorrelationId) throws IOException { throw new IOException(); } @Override - public void createEntry(String correlationId, Pnf entry) throws IOException { + public void createEntry(String pnfCorrelationId, Pnf entry) throws IOException { throw new IOException(); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java deleted file mode 100644 index fde112b009..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2018 Nokia. - * ================================================================================ - * 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.bpmn.infrastructure.pnf.dmaap; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; -import org.junit.Test; - -public class JsonUtilForCorrelationIdTest { - - private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[{\"correlationId\": \"corrTest1\"," - + "\"key1\":\"value1\"},{\"correlationId\": \"corrTest2\",\"key2\":\"value2\"}]"; - - private static final String JSON_WITH_ONE_CORRELATION_ID = "[{\"correlationId\":\"corrTest3\"}]"; - - private static final String JSON_WITH_TWO_CORRELATION_ID_AND_ESCAPED_CHARACTERS = - "[\"{\\\"correlationId\\\":\\\"corrTest4\\\"}\", \"{\\\"correlationId\\\":\\\"corrTest5\\\"}\"]"; - - private static final String JSON_WITH_NO_CORRELATION_ID = "[{\"key1\":\"value1\"}]"; - - @Test - public void parseJsonSuccessful() { - List expectedResult = JsonUtilForCorrelationId - .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID); - assertThat(expectedResult).containsExactly("corrTest1", "corrTest2"); - - List expectedResult2 = JsonUtilForCorrelationId - .parseJsonToGelAllCorrelationId(JSON_WITH_ONE_CORRELATION_ID); - assertThat(expectedResult2).containsExactly("corrTest3"); - } - - @Test - public void parseJsonWithEscapeCharacters_Successful() { - List expectedResult = JsonUtilForCorrelationId - .parseJsonToGelAllCorrelationId(JSON_WITH_TWO_CORRELATION_ID_AND_ESCAPED_CHARACTERS); - assertThat(expectedResult).containsExactly("corrTest4", "corrTest5"); - } - - @Test - public void parseJson_emptyListReturnedWhenNothingFound() { - List expectedResult = JsonUtilForCorrelationId - .parseJsonToGelAllCorrelationId(JSON_WITH_NO_CORRELATION_ID); - assertThat(expectedResult).isEmpty(); - } - -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java new file mode 100644 index 0000000000..02a6f20992 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2018 Nokia. + * ================================================================================ + * 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.bpmn.infrastructure.pnf.dmaap; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import org.junit.Test; + +public class JsonUtilForPnfCorrelationIdTest { + + private static final String JSON_EXAMPLE_WITH_PNF_CORRELATION_ID = "[{\"pnfCorrelationId\": \"corrTest1\"," + + "\"key1\":\"value1\"},{\"pnfCorrelationId\": \"corrTest2\",\"key2\":\"value2\"}]"; + + private static final String JSON_WITH_ONE_PNF_CORRELATION_ID = "[{\"pnfCorrelationId\":\"corrTest3\"}]"; + + private static final String JSON_WITH_TWO_PNF_CORRELATION_ID_AND_ESCAPED_CHARACTERS = + "[\"{\\\"pnfCorrelationId\\\":\\\"corrTest4\\\"}\", \"{\\\"pnfCorrelationId\\\":\\\"corrTest5\\\"}\"]"; + + private static final String JSON_WITH_NO_PNF_CORRELATION_ID = "[{\"key1\":\"value1\"}]"; + + @Test + public void parseJsonSuccessful() { + List expectedResult = JsonUtilForPnfCorrelationId + .parseJsonToGelAllPnfCorrelationId(JSON_EXAMPLE_WITH_PNF_CORRELATION_ID); + assertThat(expectedResult).containsExactly("corrTest1", "corrTest2"); + + List expectedResult2 = JsonUtilForPnfCorrelationId + .parseJsonToGelAllPnfCorrelationId(JSON_WITH_ONE_PNF_CORRELATION_ID); + assertThat(expectedResult2).containsExactly("corrTest3"); + } + + @Test + public void parseJsonWithEscapeCharacters_Successful() { + List expectedResult = JsonUtilForPnfCorrelationId + .parseJsonToGelAllPnfCorrelationId(JSON_WITH_TWO_PNF_CORRELATION_ID_AND_ESCAPED_CHARACTERS); + assertThat(expectedResult).containsExactly("corrTest4", "corrTest5"); + } + + @Test + public void parseJson_emptyListReturnedWhenNothingFound() { + List expectedResult = JsonUtilForPnfCorrelationId + .parseJsonToGelAllPnfCorrelationId(JSON_WITH_NO_PNF_CORRELATION_ID); + assertThat(expectedResult).isEmpty(); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java index b30239d9c0..078c2f7784 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java @@ -56,12 +56,12 @@ import org.springframework.core.env.Environment; @RunWith(MockitoJUnitRunner.class) public class PnfEventReadyDmaapClientTest { - private static final String CORRELATION_ID = "corrTestId"; - private static final String CORRELATION_ID_NOT_FOUND_IN_MAP = "otherCorrId"; - private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[{\"correlationId\": \"%s\"," - + "\"value\":\"value1\"},{\"correlationId\": \"corr\",\"value\":\"value2\"}]"; + private static final String PNF_CORRELATION_ID = "corrTestId"; + private static final String PNF_CORRELATION_ID_NOT_FOUND_IN_MAP = "otherCorrId"; + private static final String JSON_EXAMPLE_WITH_PNF_CORRELATION_ID = "[{\"pnfCorrelationId\": \"%s\"," + + "\"value\":\"value1\"},{\"pnfCorrelationId\": \"corr\",\"value\":\"value2\"}]"; - private static final String JSON_EXAMPLE_WITH_NO_CORRELATION_ID = "[{\"key1\":\"value1\"}]"; + private static final String JSON_EXAMPLE_WITH_NO_PNF_CORRELATION_ID = "[{\"key1\":\"value1\"}]"; private static final String HOST = "hostTest"; private static final int PORT = 1234; @@ -108,10 +108,10 @@ public class PnfEventReadyDmaapClientTest { * empty) and shutdown the executor because of empty map */ @Test - public void correlationIdIsFoundInHttpResponse_notifyAboutPnfReady() + public void pnfCorrelationIdIsFoundInHttpResponse_notifyAboutPnfReady() throws IOException { when(httpClientMock.execute(any(HttpGet.class))). - thenReturn(createResponse(String.format(JSON_EXAMPLE_WITH_CORRELATION_ID, CORRELATION_ID))); + thenReturn(createResponse(String.format(JSON_EXAMPLE_WITH_PNF_CORRELATION_ID, PNF_CORRELATION_ID))); testedObjectInnerClassThread.run(); ArgumentCaptor captor1 = ArgumentCaptor.forClass(HttpGet.class); verify(httpClientMock).execute(captor1.capture()); @@ -128,16 +128,16 @@ public class PnfEventReadyDmaapClientTest { /** * Test run method, where the are following conditions: *

- DmaapThreadListener is running, flag is set to true - *

- map is filled with one entry with the correlationId that does not match to correlationId + *

- map is filled with one entry with the pnfCorrelationId that does not match to pnfCorrelationId * taken from http response. run method should not do anything with the map not run any thread to notify camunda * process */ @Test - public void correlationIdIsFoundInHttpResponse_NotFoundInMap() + public void pnfCorrelationIdIsFoundInHttpResponse_NotFoundInMap() throws IOException { when(httpClientMock.execute(any(HttpGet.class))). thenReturn(createResponse( - String.format(JSON_EXAMPLE_WITH_CORRELATION_ID, CORRELATION_ID_NOT_FOUND_IN_MAP))); + String.format(JSON_EXAMPLE_WITH_PNF_CORRELATION_ID, PNF_CORRELATION_ID_NOT_FOUND_IN_MAP))); testedObjectInnerClassThread.run(); verifyZeroInteractions(threadMockToNotifyCamundaFlow, executorMock); } @@ -145,13 +145,13 @@ public class PnfEventReadyDmaapClientTest { /** * Test run method, where the are following conditions: *

- DmaapThreadListener is running, flag is set to true - *

- map is filled with one entry with the correlationId but no correlation id is taken from HttpResponse + *

- map is filled with one entry with the pnfCorrelationId but no correlation id is taken from HttpResponse * run method should not do anything with the map and not run any thread to notify camunda process */ @Test - public void correlationIdIsNotFoundInHttpResponse() throws IOException { + public void pnfCorrelationIdIsNotFoundInHttpResponse() throws IOException { when(httpClientMock.execute(any(HttpGet.class))). - thenReturn(createResponse(JSON_EXAMPLE_WITH_NO_CORRELATION_ID)); + thenReturn(createResponse(JSON_EXAMPLE_WITH_NO_PNF_CORRELATION_ID)); testedObjectInnerClassThread.run(); verifyZeroInteractions(threadMockToNotifyCamundaFlow, executorMock); } @@ -171,7 +171,7 @@ public class PnfEventReadyDmaapClientTest { .getDeclaredField("pnfCorrelationIdToThreadMap"); pnfCorrelationToThreadMapField.setAccessible(true); Map pnfCorrelationToThreadMap = new ConcurrentHashMap<>(); - pnfCorrelationToThreadMap.put(CORRELATION_ID, threadMockToNotifyCamundaFlow); + pnfCorrelationToThreadMap.put(PNF_CORRELATION_ID, threadMockToNotifyCamundaFlow); pnfCorrelationToThreadMapField.set(testedObject, pnfCorrelationToThreadMap); Field threadRunFlag = testedObject.getClass().getDeclaredField("dmaapThreadListenerIsRunning"); diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn index 5defe2121b..8ffa32e10d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateAndActivatePnfResource.bpmn @@ -5,8 +5,8 @@ - - + + @@ -20,13 +20,13 @@ - + #{aaiContainsInfoAboutPnf} - + SequenceFlow_0j5ksz1 SequenceFlow_0967g8p @@ -48,7 +48,7 @@ SequenceFlow_1l1t6ak SequenceFlow_0v5ffpe - + SequenceFlow_0967g8p SequenceFlow_1j4r3zt @@ -86,7 +86,7 @@ @@ -115,7 +115,7 @@ - + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn index 2dbf12717c..22b09966a4 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustServiceV2.bpmn @@ -586,7 +586,7 @@ CreateVcpeResCustService.validateVnfCreate(execution)]]> - + SequenceFlow_0gj4vud diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn index c8a5cf03cd..9579f770fc 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn @@ -359,7 +359,7 @@ CreateVcpeResCustService.processDecomposition(execution) - + diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java index b6bfda159d..ea241aa074 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/ServiceInstancesRequest.java @@ -41,8 +41,6 @@ public class ServiceInstancesRequest implements Serializable { private String vfModuleInstanceId; @JsonProperty("configurationId") private String configurationId; - @JsonProperty("correlationId") - private String correlationId; @JsonProperty("instanceGroupId") private String instanceGroupId; @@ -102,14 +100,6 @@ public class ServiceInstancesRequest implements Serializable { this.configurationId = configurationId; } - public String getCorrelationId() { - return correlationId; - } - - public void setCorrelationId(String correlationId) { - this.correlationId = correlationId; - } - public String getInstanceGroupId() { return instanceGroupId; } @@ -128,7 +118,6 @@ public class ServiceInstancesRequest implements Serializable { sb.append(", volumeGroupInstanceId='").append(volumeGroupInstanceId).append('\''); sb.append(", vfModuleInstanceId='").append(vfModuleInstanceId).append('\''); sb.append(", configurationId='").append(configurationId).append('\''); - sb.append(", correlationId='").append(correlationId).append('\''); sb.append('}'); return sb.toString(); } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java index 829f8ce30c..7e9eed32b1 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java @@ -35,7 +35,7 @@ import com.fasterxml.jackson.annotation.JsonRootName; CommonConstants.REQUEST_ID_HEADER, CommonConstants.IS_BASE_VF_MODULE_VARIABLE, CommonConstants.RECIPE_TIMEOUT_VARIABLE, CommonConstants.REQUEST_ACTION_VARIABLE, CommonConstants.SERVICE_INSTANCE_ID_VARIABLE, - CommonConstants.CORRELATION_ID, CommonConstants.VNF_ID_VARIABLE, CommonConstants.VF_MODULE_ID_VARIABLE, + CommonConstants.PNF_CORRELATION_ID, CommonConstants.VNF_ID_VARIABLE, CommonConstants.VF_MODULE_ID_VARIABLE, CommonConstants.VOLUME_GROUP_ID_VARIABLE, CommonConstants.NETWORK_ID_VARIABLE, CommonConstants.CONFIGURATION_ID_VARIABLE, CommonConstants.SERVICE_TYPE_VARIABLE, CommonConstants.VNF_TYPE_VARIABLE, CommonConstants.VF_MODULE_TYPE_VARIABLE, @@ -68,8 +68,8 @@ public class CamundaVIDRequest { @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) private CamundaInput serviceInstanceId; - @JsonProperty(CommonConstants.CORRELATION_ID) - private CamundaInput correlationId; + @JsonProperty(CommonConstants.PNF_CORRELATION_ID) + private CamundaInput pnfCorrelationId; @JsonProperty(CommonConstants.VNF_ID_VARIABLE) private CamundaInput vnfId; @@ -192,14 +192,14 @@ public class CamundaVIDRequest { this.serviceInstanceId = serviceInstanceId; } - @JsonProperty(CommonConstants.CORRELATION_ID) - public CamundaInput getCorrelationId() { - return correlationId; + @JsonProperty(CommonConstants.PNF_CORRELATION_ID) + public CamundaInput getPnfCorrelationId() { + return pnfCorrelationId; } - @JsonProperty(CommonConstants.CORRELATION_ID) - public void setCorrelationId(CamundaInput correlationId) { - this.correlationId = correlationId; + @JsonProperty(CommonConstants.PNF_CORRELATION_ID) + public void setPnfCorrelationId(CamundaInput pnfCorrelationId) { + this.pnfCorrelationId = pnfCorrelationId; } @JsonProperty(CommonConstants.VNF_ID_VARIABLE) diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java index 34cfe18508..0ca85f0a06 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java @@ -128,7 +128,7 @@ public class CamundaClient extends RequestClient{ HttpPost post = new HttpPost(url); msoLogger.debug(CAMUNDA_URL_MESAGE+ url); String jsonReq = wrapVIDRequest(parameterObject.getRequestId(), parameterObject.isBaseVfModule(), parameterObject.getRecipeTimeout(), parameterObject.getRequestAction(), - parameterObject.getServiceInstanceId(), parameterObject.getCorrelationId(), parameterObject.getVnfId(), parameterObject.getVfModuleId(), parameterObject.getVolumeGroupId(), parameterObject.getNetworkId(), parameterObject.getConfigurationId(), + parameterObject.getServiceInstanceId(), parameterObject.getPnfCorrelationId(), parameterObject.getVnfId(), parameterObject.getVfModuleId(), parameterObject.getVolumeGroupId(), parameterObject.getNetworkId(), parameterObject.getConfigurationId(), parameterObject.getServiceType(), parameterObject.getVnfType(), parameterObject.getVfModuleType(), parameterObject.getNetworkType(), parameterObject.getRequestDetails(), parameterObject.getApiVersion(), parameterObject.isaLaCarte(), parameterObject.getRequestUri(), parameterObject.getRecipeParamXsd(), parameterObject.getInstanceGroupId()); @@ -198,7 +198,7 @@ public class CamundaClient extends RequestClient{ protected String wrapVIDRequest(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, String serviceInstanceId, String correlationId, + int recipeTimeout, String requestAction, String serviceInstanceId, String pnfCorrelationId, String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId, String serviceType, String vnfType, String vfModuleType, String networkType, String requestDetails, String apiVersion, boolean aLaCarte, String requestUri, String paramXsd, @@ -214,7 +214,7 @@ public class CamundaClient extends RequestClient{ CamundaIntegerInput recipeTimeoutInput = new CamundaIntegerInput(); CamundaInput requestActionInput = new CamundaInput(); CamundaInput serviceInstanceIdInput = new CamundaInput(); - CamundaInput correlationIdInput = new CamundaInput(); + CamundaInput pnfCorrelationIdInput = new CamundaInput(); CamundaInput vnfIdInput = new CamundaInput(); CamundaInput vfModuleIdInput = new CamundaInput(); CamundaInput volumeGroupIdInput = new CamundaInput(); @@ -236,7 +236,7 @@ public class CamundaClient extends RequestClient{ recipeTimeoutInput.setValue(recipeTimeout); requestActionInput.setValue(StringUtils.defaultString(requestAction)); serviceInstanceIdInput.setValue(StringUtils.defaultString(serviceInstanceId)); - correlationIdInput.setValue(StringUtils.defaultString(correlationId)); + pnfCorrelationIdInput.setValue(StringUtils.defaultString(pnfCorrelationId)); vnfIdInput.setValue(StringUtils.defaultString(vnfId)); vfModuleIdInput.setValue(StringUtils.defaultString(vfModuleId)); volumeGroupIdInput.setValue(StringUtils.defaultString(volumeGroupId)); @@ -261,7 +261,7 @@ public class CamundaClient extends RequestClient{ camundaRequest.setRecipeTimeout(recipeTimeoutInput); camundaRequest.setRequestAction(requestActionInput); camundaRequest.setServiceInstanceId(serviceInstanceIdInput); - camundaRequest.setCorrelationId(correlationIdInput); + camundaRequest.setPnfCorrelationId(pnfCorrelationIdInput); camundaRequest.setVnfId(vnfIdInput); camundaRequest.setVfModuleId(vfModuleIdInput); camundaRequest.setVolumeGroupId(volumeGroupIdInput); diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java index b75ad9e415..24fb0e0d20 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java @@ -54,7 +54,7 @@ public final class CommonConstants { public static final String RECIPE_TIMEOUT_VARIABLE = "recipeTimeout"; public static final String REQUEST_ACTION_VARIABLE = "requestAction"; public static final String SERVICE_INSTANCE_ID_VARIABLE = "serviceInstanceId"; - public static final String CORRELATION_ID = "correlationId"; + public static final String PNF_CORRELATION_ID = "pnfCorrelationId"; public static final String VNF_ID_VARIABLE = "vnfId"; public static final String VF_MODULE_ID_VARIABLE = "vfModuleId"; public static final String VOLUME_GROUP_ID_VARIABLE = "volumeGroupId"; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java index 1d18e2b02c..209f337a1e 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java @@ -28,7 +28,7 @@ public class RequestClientParameter { private int recipeTimeout; private String requestAction; private String serviceInstanceId; - private String correlationId; + private String pnfCorrelationId; private String vnfId; private String vfModuleId; private String volumeGroupId; @@ -51,7 +51,7 @@ public class RequestClientParameter { recipeTimeout = builder.recipeTimeout; requestAction = builder.requestAction; serviceInstanceId = builder.serviceInstanceId; - correlationId = builder.correlationId; + pnfCorrelationId = builder.pnfCorrelationId; vnfId = builder.vnfId; vfModuleId = builder.vfModuleId; volumeGroupId = builder.volumeGroupId; @@ -90,8 +90,8 @@ public class RequestClientParameter { return serviceInstanceId; } - public String getCorrelationId() { - return correlationId; + public String getPnfCorrelationId() { + return pnfCorrelationId; } public String getVnfId() { @@ -160,7 +160,7 @@ public class RequestClientParameter { private int recipeTimeout; private String requestAction; private String serviceInstanceId; - private String correlationId; + private String pnfCorrelationId; private String vnfId; private String vfModuleId; private String volumeGroupId; @@ -202,8 +202,8 @@ public class RequestClientParameter { return this; } - public Builder setCorrelationId(String correlationId) { - this.correlationId = correlationId; + public Builder setPnfCorrelationId(String pnfCorrelationId) { + this.pnfCorrelationId = pnfCorrelationId; return this; } diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java index 7a03ce0542..0958905720 100644 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java @@ -148,7 +148,7 @@ public class CamundaClientTest{ int recipeTimeout = 10000; String requestAction = "createInstance"; String serviceInstanceId = "12345679"; - String correlationId = "12345679"; + String pnfCorrelationId = "12345679"; String vnfId = "234567891"; String vfModuleId = "345678912"; String volumeGroupId = "456789123"; @@ -164,7 +164,7 @@ public class CamundaClientTest{ String requestUri = "v7/serviceInstances/assign"; String instanceGroupId = "ff305d54-75b4-431b-adb2-eb6b9e5ff000"; - String testResult = testClient.wrapVIDRequest(requestId, isBaseVfModule, recipeTimeout, requestAction, serviceInstanceId, correlationId, + String testResult = testClient.wrapVIDRequest(requestId, isBaseVfModule, recipeTimeout, requestAction, serviceInstanceId, pnfCorrelationId, vnfId, vfModuleId, volumeGroupId, networkId, configurationId, serviceType, vnfType, vfModuleType, networkType, requestDetails, apiVersion, aLaCarte, requestUri, "", instanceGroupId); String expected = inputStream("/WrappedVIDRequest.json"); diff --git a/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json b/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json index 4c716c2ae3..b9d0a8c3c6 100644 --- a/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json +++ b/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json @@ -1 +1 @@ -{"variables":{"bpmnRequest":{"value":"{requestDetails: }","type":"String"},"requestId":{"value":"f7ce78bb-423b-11e7-93f8-0050569a796","type":"String"},"mso-request-id":{"value":"f7ce78bb-423b-11e7-93f8-0050569a796","type":"String"},"isBaseVfModule":{"value":true,"type":"Boolean"},"recipeTimeout":{"value":10000,"type":"Integer"},"requestAction":{"value":"createInstance","type":"String"},"serviceInstanceId":{"value":"12345679","type":"String"},"correlationId":{"value":"12345679","type":"String"},"vnfId":{"value":"234567891","type":"String"},"vfModuleId":{"value":"345678912","type":"String"},"volumeGroupId":{"value":"456789123","type":"String"},"networkId":{"value":"567891234","type":"String"},"configurationId":{"value":"678912345","type":"String"},"serviceType":{"value":"testService","type":"String"},"vnfType":{"value":"testVnf","type":"String"},"vfModuleType":{"value":"vfModuleType","type":"String"},"networkType":{"value":"networkType","type":"String"},"recipeParams":{"value":"","type":"String"},"host":{"value":null,"type":"String"},"apiVersion":{"value":"6","type":"String"},"aLaCarte":{"value":true,"type":"Boolean"},"requestUri":{"value":"v7/serviceInstances/assign","type":"String"},"instanceGroupId":{"value":"ff305d54-75b4-431b-adb2-eb6b9e5ff000","type":"String"}}} \ No newline at end of file +{"variables":{"bpmnRequest":{"value":"{requestDetails: }","type":"String"},"requestId":{"value":"f7ce78bb-423b-11e7-93f8-0050569a796","type":"String"},"mso-request-id":{"value":"f7ce78bb-423b-11e7-93f8-0050569a796","type":"String"},"isBaseVfModule":{"value":true,"type":"Boolean"},"recipeTimeout":{"value":10000,"type":"Integer"},"requestAction":{"value":"createInstance","type":"String"},"serviceInstanceId":{"value":"12345679","type":"String"},"pnfCorrelationId":{"value":"12345679","type":"String"},"vnfId":{"value":"234567891","type":"String"},"vfModuleId":{"value":"345678912","type":"String"},"volumeGroupId":{"value":"456789123","type":"String"},"networkId":{"value":"567891234","type":"String"},"configurationId":{"value":"678912345","type":"String"},"serviceType":{"value":"testService","type":"String"},"vnfType":{"value":"testVnf","type":"String"},"vfModuleType":{"value":"vfModuleType","type":"String"},"networkType":{"value":"networkType","type":"String"},"recipeParams":{"value":"","type":"String"},"host":{"value":null,"type":"String"},"apiVersion":{"value":"6","type":"String"},"aLaCarte":{"value":true,"type":"Boolean"},"requestUri":{"value":"v7/serviceInstances/assign","type":"String"},"instanceGroupId":{"value":"ff305d54-75b4-431b-adb2-eb6b9e5ff000","type":"String"}}} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index e3b218b90a..a473b0939e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -809,7 +809,7 @@ public class ServiceInstances { String vfModuleId = ""; String volumeGroupId = ""; String networkId = ""; - String correlationId = ""; + String pnfCorrelationId = ""; String instanceGroupId = null; if(sir.getServiceInstanceId () != null){ serviceInstanceId = sir.getServiceInstanceId (); @@ -834,7 +834,7 @@ public class ServiceInstances { instanceGroupId = sir.getInstanceGroupId(); } - correlationId = getCorrelationId(sir); + pnfCorrelationId = getPnfCorrelationId(sir); try{ infraActiveRequestsClient.save(currentActiveReq); @@ -858,7 +858,7 @@ public class ServiceInstances { .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) .setRequestAction(action.toString()) .setServiceInstanceId(serviceInstanceId) - .setCorrelationId(correlationId) + .setPnfCorrelationId(pnfCorrelationId) .setVnfId(vnfId) .setVfModuleId(vfModuleId) .setVolumeGroupId(volumeGroupId) @@ -944,7 +944,7 @@ public class ServiceInstances { return postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope); } - private String getCorrelationId(ServiceInstancesRequest sir) { + private String getPnfCorrelationId(ServiceInstancesRequest sir) { return Optional.of(sir) .map(ServiceInstancesRequest::getRequestDetails) .map(RequestDetails::getRequestParameters) @@ -1860,7 +1860,7 @@ public class ServiceInstances { serviceInstanceId = ""; String configurationId = ""; - String correlationId = ""; + String pnfCorrelationId = ""; if(sir.getServiceInstanceId () != null){ serviceInstanceId = sir.getServiceInstanceId (); @@ -1870,7 +1870,7 @@ public class ServiceInstances { configurationId = sir.getConfigurationId(); } - correlationId = getCorrelationId(sir); + pnfCorrelationId = getPnfCorrelationId(sir); try{ infraActiveRequestsClient.save(currentActiveReq); @@ -1893,7 +1893,7 @@ public class ServiceInstances { .setRecipeTimeout(Integer.parseInt(timeOut)) .setRequestAction(action.toString()) .setServiceInstanceId(serviceInstanceId) - .setCorrelationId(correlationId) + .setPnfCorrelationId(pnfCorrelationId) .setConfigurationId(configurationId) .setRequestDetails(mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action)) .setApiVersion(apiVersion) diff --git a/so-monitoring/so-monitoring-service/src/test/resources/camundaResponses/processInstanceVariables.json b/so-monitoring/so-monitoring-service/src/test/resources/camundaResponses/processInstanceVariables.json index 15c87ea1e9..7762da7c2d 100644 --- a/so-monitoring/so-monitoring-service/src/test/resources/camundaResponses/processInstanceVariables.json +++ b/so-monitoring/so-monitoring-service/src/test/resources/camundaResponses/processInstanceVariables.json @@ -287,7 +287,7 @@ }, { "type": "String", - "value": "{\"requestDetails\":{\"modelInfo\":{\"modelInvariantUuid\":\"8e2be9fa-fffb-4e23-89a5-65497709f507\",\"modelType\":\"service\",\"modelName\":\"PNFSERVICE\",\"modelVersion\":\"1.0\",\"modelUuid\":\"4f7afc34-e475-41ca-be73-40f9a0f7ffa4\"},\"requestInfo\":{\"productFamilyId\":\"c8d92bf2-2c2e-4802-94e0-3f9e0825cc08\",\"source\":\"UUI\",\"instanceName\":\"AFRPOSTMAN51\",\"suppressRollback\":false,\"requestorId\":\"demo\"},\"subscriberInfo\":{\"globalSubscriberId\":\"Demonstration\"},\"cloudConfiguration\":{\"tenantId\":\"3e001881bcb342418ab5f2788a73255d\",\"lcpCloudRegionId\":\"regionOne_aaa_bbb\"},\"requestParameters\":{\"alaCarte\":false,\"subscriptionServiceType\":\"vCPE\",\"userParams\":[{\"name\":\"Homing_Solution\",\"value\":\"dummy\"}],\"aLaCarte\":false},\"project\":{\"projectName\":\"Project-Demonstration\"},\"owningEntity\":{\"owningEntityId\":\"c77274d4-4881-493a-ad46-368ea0996eb3\",\"owningEntityName\":\"OE-Demonstration\"}},\"correlationId\":\"afr\"}", + "value": "{\"requestDetails\":{\"modelInfo\":{\"modelInvariantUuid\":\"8e2be9fa-fffb-4e23-89a5-65497709f507\",\"modelType\":\"service\",\"modelName\":\"PNFSERVICE\",\"modelVersion\":\"1.0\",\"modelUuid\":\"4f7afc34-e475-41ca-be73-40f9a0f7ffa4\"},\"requestInfo\":{\"productFamilyId\":\"c8d92bf2-2c2e-4802-94e0-3f9e0825cc08\",\"source\":\"UUI\",\"instanceName\":\"AFRPOSTMAN51\",\"suppressRollback\":false,\"requestorId\":\"demo\"},\"subscriberInfo\":{\"globalSubscriberId\":\"Demonstration\"},\"cloudConfiguration\":{\"tenantId\":\"3e001881bcb342418ab5f2788a73255d\",\"lcpCloudRegionId\":\"regionOne_aaa_bbb\"},\"requestParameters\":{\"alaCarte\":false,\"subscriptionServiceType\":\"vCPE\",\"userParams\":[{\"name\":\"Homing_Solution\",\"value\":\"dummy\"}],\"aLaCarte\":false},\"project\":{\"projectName\":\"Project-Demonstration\"},\"owningEntity\":{\"owningEntityId\":\"c77274d4-4881-493a-ad46-368ea0996eb3\",\"owningEntityName\":\"OE-Demonstration\"}},\"pnfCorrelationId\":\"afr\"}", "valueInfo": { }, @@ -314,7 +314,7 @@ }, "id": "595745ec-9736-11e8-8caf-022ac9304eeb", - "name": "correlationId", + "name": "pnfCorrelationId", "processDefinitionKey": "AFRFLOW", "processDefinitionId": "AFRFLOW:1:c6eea1b7-9722-11e8-8caf-022ac9304eeb", "processInstanceId": "5956a99d-9736-11e8-8caf-022ac9304eeb", @@ -4203,7 +4203,7 @@ }, { "type": "String", - "value": "{\"requestDetails\":{\"modelInfo\":{\"modelInvariantUuid\":\"8e2be9fa-fffb-4e23-89a5-65497709f507\",\"modelType\":\"service\",\"modelName\":\"PNFSERVICE\",\"modelVersion\":\"1.0\",\"modelUuid\":\"4f7afc34-e475-41ca-be73-40f9a0f7ffa4\"},\"requestInfo\":{\"productFamilyId\":\"c8d92bf2-2c2e-4802-94e0-3f9e0825cc08\",\"source\":\"UUI\",\"instanceName\":\"AFRPOSTMAN51\",\"suppressRollback\":false,\"requestorId\":\"demo\"},\"subscriberInfo\":{\"globalSubscriberId\":\"Demonstration\"},\"cloudConfiguration\":{\"tenantId\":\"3e001881bcb342418ab5f2788a73255d\",\"lcpCloudRegionId\":\"regionOne_aaa_bbb\"},\"requestParameters\":{\"alaCarte\":false,\"subscriptionServiceType\":\"vCPE\",\"userParams\":[{\"name\":\"Homing_Solution\",\"value\":\"dummy\"}],\"aLaCarte\":false},\"project\":{\"projectName\":\"Project-Demonstration\"},\"owningEntity\":{\"owningEntityId\":\"c77274d4-4881-493a-ad46-368ea0996eb3\",\"owningEntityName\":\"OE-Demonstration\"}},\"correlationId\":\"afr\"}", + "value": "{\"requestDetails\":{\"modelInfo\":{\"modelInvariantUuid\":\"8e2be9fa-fffb-4e23-89a5-65497709f507\",\"modelType\":\"service\",\"modelName\":\"PNFSERVICE\",\"modelVersion\":\"1.0\",\"modelUuid\":\"4f7afc34-e475-41ca-be73-40f9a0f7ffa4\"},\"requestInfo\":{\"productFamilyId\":\"c8d92bf2-2c2e-4802-94e0-3f9e0825cc08\",\"source\":\"UUI\",\"instanceName\":\"AFRPOSTMAN51\",\"suppressRollback\":false,\"requestorId\":\"demo\"},\"subscriberInfo\":{\"globalSubscriberId\":\"Demonstration\"},\"cloudConfiguration\":{\"tenantId\":\"3e001881bcb342418ab5f2788a73255d\",\"lcpCloudRegionId\":\"regionOne_aaa_bbb\"},\"requestParameters\":{\"alaCarte\":false,\"subscriptionServiceType\":\"vCPE\",\"userParams\":[{\"name\":\"Homing_Solution\",\"value\":\"dummy\"}],\"aLaCarte\":false},\"project\":{\"projectName\":\"Project-Demonstration\"},\"owningEntity\":{\"owningEntityId\":\"c77274d4-4881-493a-ad46-368ea0996eb3\",\"owningEntityName\":\"OE-Demonstration\"}},\"pnfCorrelationId\":\"afr\"}", "valueInfo": { }, -- cgit 1.2.3-korg