summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/pom.xml14
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy6
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy14
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy70
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy8
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java1
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java57
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java23
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java60
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java39
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java49
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java110
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java50
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java63
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java88
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java84
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java198
25 files changed, 883 insertions, 76 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml
index ab0ac25a99..ad51b3f69e 100644
--- a/bpmn/so-bpmn-infrastructure-common/pom.xml
+++ b/bpmn/so-bpmn-infrastructure-common/pom.xml
@@ -1,5 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.onap.so</groupId>
<artifactId>bpmn</artifactId>
@@ -107,7 +107,7 @@
</goals>
</pluginExecutionFilter>
<action>
- <ignore></ignore>
+ <ignore/>
</action>
</pluginExecution>
</pluginExecutions>
@@ -199,7 +199,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>22.0</version>
+
</dependency>
<dependency>
<groupId>com.fasterxml.uuid</groupId>
@@ -317,5 +317,11 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.camunda.bpm.springboot</groupId>
+ <artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
+ <version>2.3.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
index f11022dc08..ec8df3daa1 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License")
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy
index 63fd20eb2d..37c7d4d29a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License")
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
index 3702862a04..589bbe9c4f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
@@ -140,9 +140,9 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce
AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
- ServiceInstance si = wrapper.asBean(ServiceInstance.class)
- execution.setVariable("model-invariant-id-original", si.getModelInvariantId())
- execution.setVariable("model-version-id-original", si.getModelVersionId())
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ execution.setVariable("model-invariant-id-original", si.get().getModelInvariantId())
+ execution.setVariable("model-version-id-original", si.get().getModelVersionId())
}catch(BpmnError e) {
throw e;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
index 5922ad10a0..26b0fea6a2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
@@ -321,8 +321,8 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
- ServiceInstance si = wrapper.asBean(ServiceInstance.class)
- execution.setVariable("serviceInstanceName", si.getServiceInstanceName())
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ execution.setVariable("serviceInstanceName", si.get().getServiceInstanceName())
}catch(BpmnError e) {
throw e;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
index a376e581fe..731d9c24de 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
@@ -330,6 +330,10 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
if(!resourceClient.exists(uri)){
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
+ }else{
+ Map<String, String> keys = uri.getURIKeys()
+ execution.setVariable("serviceType", keys.get("service-type"))
+ execution.setVariable("subscriberName", keys.get("global-customer-id"))
}
}catch(BpmnError e) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
index d571c00f47..17dbe50cc5 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License")
+ * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -20,7 +20,6 @@
package org.onap.so.bpmn.infrastructure.scripts
-import org.codehaus.jackson.map.ObjectMapper
import org.onap.so.bpmn.infrastructure.properties.BPMNProperties
import java.util.ArrayList
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
index 7fa8b4409b..1585a7bb74 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
@@ -259,6 +259,9 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
if(resourceClient.exists(uri)){
+ Map<String, String> keys = uri.getURIKeys()
+ execution.setVariable("globalCustomerId", keys.get("global-customer-id"))
+ execution.setVariable("serviceType", keys.get("service-type"))
execution.setVariable("GENGS_siResourceLink", uri.build().toString())
}else{
@@ -307,14 +310,9 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
//Get Service Instance Info
String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId")
- String siRelatedLink = getVariableEnforced(execution, "GENGS_siResourceLink")
- int custStart = siRelatedLink.indexOf("customer/")
- int custEnd = siRelatedLink.indexOf("/service-subscriptions")
- String globalCustId = siRelatedLink.substring(custStart + 9, custEnd)
- int serviceStart = siRelatedLink.indexOf("service-subscription/")
- int serviceEnd = siRelatedLink.indexOf("/service-instances/")
- String serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
+ String globalCustId = execution.getVariable("globalCustomerId")
+ String serviceType = execution.getVariable("serviceType")
Map<String, String> payload = new LinkedHashMap<>();
payload.put("vnf-id", vnfId);
@@ -339,7 +337,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
resourceClient.connect(uri, siUri)
}catch(Exception ex) {
- msoLogger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process " + ex.getMessage())
+ msoLogger.debug("Error Occured in DoCreateVnf CreateGenericVnf Process ", ex)
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf CreateGenericVnf Process")
}
msoLogger.trace("COMPLETED DoCreateVnf CreateGenericVnf Process")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy
index c7e3eb437c..eb736f8ffe 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy
@@ -305,45 +305,47 @@ public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor {
}
AAIResultWrapper wrapper = resourceClient.get(uri)
- List<AAIResourceUri> uriList = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.ALLOTTED_RESOURCE)
- uriList.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF))
- uriList.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.L3_NETWORK))
-
- if(uriList.isEmpty){
- ServiceInstance si = wrapper.asBean(ServiceInstance.class)
- String orchestrationStatus = si.getOrchestrationStatus()
- String serviceType = si.getServiceType()
- execution.setVariable("serviceType", serviceType)
- execution.setVariable("serviceRole", si.getServiceRole())
-
- if("TRANSPORT".equalsIgnoreCase(serviceType)){
- if("PendingDelete".equals(orchestrationStatus)){
- execution.setVariable("skipDeactivate", true)
- }else{
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "ServiceInstance of type TRANSPORT must in PendingDelete status to allow Delete. Orchestration-status: " + orchestrationStatus)
+ if(wrapper.getRelationships().isPresent()){
+ List<AAIResourceUri> uriList = wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.ALLOTTED_RESOURCE)
+ uriList.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF))
+ uriList.addAll(wrapper.getRelationships().get().getRelatedAAIUris(AAIObjectType.L3_NETWORK))
+
+ if(uriList.isEmpty()){
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ String orchestrationStatus = si.get().getOrchestrationStatus()
+ String serviceType = si.get().getServiceType()
+ execution.setVariable("serviceType", serviceType)
+ execution.setVariable("serviceRole", si.get().getServiceRole())
+
+ if("TRANSPORT".equalsIgnoreCase(serviceType)){
+ if("PendingDelete".equals(orchestrationStatus)){
+ execution.setVariable("skipDeactivate", true)
+ }else{
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "ServiceInstance of type TRANSPORT must in PendingDelete status to allow Delete. Orchestration-status: " + orchestrationStatus)
+ }
}
- }
- String svcTypes = UrnPropertiesReader.getVariable("sdnc.si.svc.types",execution) ?: ""
- List<String> svcList = Arrays.asList(svcTypes.split("\\s*,\\s*"));
- boolean isSdncService= false
- for(String listEntry : svcList){
- if(listEntry.equalsIgnoreCase(serviceType)){
- isSdncService = true
- break;
+ String svcTypes = UrnPropertiesReader.getVariable("sdnc.si.svc.types",execution) ?: ""
+ List<String> svcList = Arrays.asList(svcTypes.split("\\s*,\\s*"));
+ boolean isSdncService= false
+ for(String listEntry : svcList){
+ if(listEntry.equalsIgnoreCase(serviceType)){
+ isSdncService = true
+ break;
+ }
}
- }
- execution.setVariable("sendToSDNC", true)
- if(execution.getVariable("sdncVersion").equals("1610")){
- if(!isSdncService){
- execution.setVariable("sendToSDNC", false)
+ execution.setVariable("sendToSDNC", true)
+ if(execution.getVariable("sdncVersion").equals("1610")){
+ if(!isSdncService){
+ execution.setVariable("sendToSDNC", false)
+ }
}
- }
- }else{
- execution.setVariable("siInUse", true)
- msoLogger.debug("Stopped deleting Service Instance, it has dependencies")
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Stopped deleting Service Instance, it has dependencies")
+ }else{
+ execution.setVariable("siInUse", true)
+ msoLogger.debug("Stopped deleting Service Instance, it has dependencies")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Stopped deleting Service Instance, it has dependencies")
+ }
}
}else{
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "ServiceInstance not found in aai")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy
index 4f6fbf9966..d7f2087c05 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy
@@ -328,6 +328,10 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
if(!resourceClient.exists(uri)){
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Service Instance not found in aai")
+ }else{
+ Map<String, String> keys = uri.getURIKeys()
+ execution.setVariable("serviceType", keys.get("service-type"))
+ execution.setVariable("subscriberName", keys.get("global-customer-id"))
}
}catch(BpmnError e) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy
index ac8e506e1f..20ced72002 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy
@@ -177,10 +177,10 @@ public class UpdateCustomE2EServiceInstance extends AbstractServiceTaskProcessor
AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
- ServiceInstance si = wrapper.asBean(ServiceInstance.class)
- execution.setVariable("serviceInstanceName", si.getServiceInstanceName())
- execution.setVariable("model-invariant-id-original", si.getModelInvariantId())
- execution.setVariable("model-version-id-original", si.getModelVersionId())
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ execution.setVariable("serviceInstanceName", si.get().getServiceInstanceName())
+ execution.setVariable("model-invariant-id-original", si.get().getModelInvariantId())
+ execution.setVariable("model-version-id-original", si.get().getModelVersionId())
JSONObject ob = new JSONObject(wrapper.getJson())
JSONArray ar = ob.getJSONObject("relationship-list").getJSONArray("relationship")
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
index 63db293a2e..12ddf8465e 100644
--- 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
@@ -67,7 +67,6 @@ public class CheckAaiForCorrelationIdDelegate implements JavaDelegate {
AaiResponse aaiResponse = implementation.check(correlationId, aaiConnection);
execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, aaiResponse.getContainsInfoAboutPnf());
- execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, aaiResponse.getContainsInfoAboutIp());
} catch (IOException e) {
LOGGER.error("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/PnfCheckInputs.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
new file mode 100644
index 0000000000..e4866f5334
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
@@ -0,0 +1,57 @@
+/*-
+ * ============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.CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
+
+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.logger.MsoLogger;
+
+public class PnfCheckInputs implements JavaDelegate {
+
+ private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, PnfCheckInputs.class);
+
+ private String defaultTimeout;
+
+ @Override
+ public void execute(DelegateExecution execution) throws Exception {
+ String correlationId = (String) execution.getVariable(CORRELATION_ID);
+ if (correlationId == null) {
+ new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "correlationId variable not defined");
+ }
+ String timeout = (String) execution.getVariable(TIMEOUT_FOR_NOTIFICATION);
+ if (timeout == null) {
+ LOGGER.debug("timeoutForPnfEntryNotification variable not found, setting default");
+ if (defaultTimeout == null) {
+ new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999,
+ "default timeoutForPnfEntryNotification value not defined");
+ }
+ execution.setVariable(TIMEOUT_FOR_NOTIFICATION, defaultTimeout);
+ }
+ }
+
+ public void setDefaultTimeout(String defaultTimeout) {
+ this.defaultTimeout = defaultTimeout;
+ }
+}
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 353b4e32c5..70323b726c 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
@@ -26,8 +26,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.ws.rs.core.UriBuilder;
@@ -49,10 +48,7 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, PnfEventReadyDmaapClient.class);
- private static final String JSON_PATH_CORRELATION_ID = "$.pnfRegistrationFields.correlationId";
-
- @Autowired
- private Environment env;
+ private final Environment env;
private HttpClient httpClient;
private String dmaapHost;
private int dmaapPort;
@@ -63,10 +59,15 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
private String consumerGroup;
private Map<String, Runnable> pnfCorrelationIdToThreadMap;
private HttpGet getRequest;
- private ScheduledExecutorService executor;
private int dmaapClientDelayInSeconds;
+ private volatile ScheduledThreadPoolExecutor executor;
private volatile boolean dmaapThreadListenerIsRunning;
+ @Autowired
+ public PnfEventReadyDmaapClient(Environment env) {
+ this.env = env;
+ }
+
public void init() {
httpClient = HttpClientBuilder.create().build();
pnfCorrelationIdToThreadMap = new ConcurrentHashMap<>();
@@ -97,7 +98,9 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
private synchronized void startDmaapThreadListener() {
if (!dmaapThreadListenerIsRunning) {
- executor = Executors.newScheduledThreadPool(1);
+ executor = new ScheduledThreadPoolExecutor(1);
+ executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
+ executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
executor.scheduleWithFixedDelay(new DmaapTopicListenerThread(), 0,
dmaapClientDelayInSeconds, TimeUnit.SECONDS);
dmaapThreadListenerIsRunning = true;
@@ -106,7 +109,7 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
private synchronized void stopDmaapThreadListener() {
if (dmaapThreadListenerIsRunning) {
- executor.shutdownNow();
+ executor.shutdown();
dmaapThreadListenerIsRunning = false;
executor = null;
}
@@ -166,7 +169,7 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
return Collections.emptyList();
}
- private synchronized void informAboutPnfReadyIfCorrelationIdFound(String correlationId) {
+ private void informAboutPnfReadyIfCorrelationIdFound(String correlationId) {
Runnable runnable = unregister(correlationId);
if (runnable != null) {
LOGGER.debug("pnf ready event got from dmaap for correlationId: " + correlationId);
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java
index fd844648fa..b13d7fc419 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnOperationClient.java
@@ -29,13 +29,10 @@ import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.GenericResour
import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.HeaderUtil;
import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.NetworkRpcInputEntityBuilder;
import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcNetworkTopologyOperationInputEntity;
-import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcNetworkTopologyOperationOutputEntity;
import org.onap.so.db.request.beans.ResourceOperationStatus;
import org.onap.so.db.request.beans.ResourceOperationStatusId;
-import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
import org.onap.so.logger.MsoLogger;
import org.onap.so.requestsdb.RequestsDbConstant;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java
index 5bd3297c20..8bc9dce966 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java
@@ -24,9 +24,6 @@ import org.apache.commons.lang3.StringUtils;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.onap.so.bpmn.core.BaseTask;
import org.onap.so.db.request.beans.ResourceOperationStatus;
-import org.onap.so.db.request.beans.ResourceOperationStatusId;
-import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
new file mode 100644
index 0000000000..201e791a24
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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 org.onap.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+public class AaiConnectionTestImpl implements AaiConnection {
+
+ public static final String ID_WITHOUT_ENTRY = "IdWithoutEntry";
+ public static final String ID_WITH_ENTRY = "idWithEntryNoIp";
+
+ private Map<String, Pnf> created = new HashMap<>();
+
+ @Override
+ public Optional<Pnf> getEntryFor(String correlationId) throws IOException {
+ if (Objects.equals(correlationId, ID_WITH_ENTRY)) {
+ return Optional.of(new Pnf());
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ @Override
+ public void createEntry(String correlationId, Pnf entry) throws IOException {
+ created.put(correlationId, entry);
+ }
+
+ public Map<String, Pnf> getCreated() {
+ return created;
+ }
+
+ public void reset() {
+ created.clear();
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java
new file mode 100644
index 0000000000..7df6757817
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java
@@ -0,0 +1,39 @@
+/*-
+ * ============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 java.io.IOException;
+import java.util.Optional;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
+
+public class AaiConnectionThrowingException implements AaiConnection {
+
+ @Override
+ public Optional<Pnf> getEntryFor(String correlationId) throws IOException {
+ throw new IOException();
+ }
+
+ @Override
+ public void createEntry(String correlationId, Pnf entry) throws IOException {
+ throw new IOException();
+ }
+}
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
new file mode 100644
index 0000000000..4282b0f2bb
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java
@@ -0,0 +1,49 @@
+/*-
+ * ============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 org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class CancelDmaapSubscriptionTest {
+
+ @Test
+ public void shouldCancelSubscription() throws Exception {
+ // given
+ CancelDmaapSubscription delegate = new CancelDmaapSubscription();
+ DmaapClientTestImpl dmaapClientTest = new DmaapClientTestImpl();
+ delegate.setDmaapClient(dmaapClientTest);
+ DelegateExecution delegateExecution = mock(DelegateExecution.class);
+ when(delegateExecution.getVariable(eq(ExecutionVariableNames.CORRELATION_ID))).thenReturn("testCorrelationId");
+ when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey");
+ dmaapClientTest.registerForUpdate("testCorrelationId", () -> {
+ });
+ // when
+ delegate.execute(delegateExecution);
+ // then
+ assertThat(dmaapClientTest.haveRegisteredConsumer()).isFalse();
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..3eb3bd8796
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
@@ -0,0 +1,110 @@
+/*-
+ * ============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.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.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.AaiConnectionTestImpl.ID_WITHOUT_ENTRY;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.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.Test;
+import org.junit.experimental.runners.Enclosed;
+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;
+
+ @Before
+ public void setUp() {
+ delegate = new CheckAaiForCorrelationIdDelegate();
+ delegate.setAaiConnection(new AaiConnectionTestImpl());
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenCorrelationIdIsNotSet() {
+ // given
+ DelegateExecution execution = mock(DelegateExecution.class);
+ when(execution.getVariable(CORRELATION_ID)).thenReturn(null);
+ when(execution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
+ // when, then
+ assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class);
+ 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;
+
+ @Before
+ public void setUp() {
+ delegate = new CheckAaiForCorrelationIdDelegate();
+ delegate.setAaiConnection(new AaiConnectionThrowingException());
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() {
+ // given
+ DelegateExecution execution = mock(DelegateExecution.class);
+ when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY);
+ when(execution.getVariable("testProcessKey")).thenReturn("testProcessKey");
+ // when, then
+ assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class);
+ 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/CreateAaiEntryWithPnfIdDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java
new file mode 100644
index 0000000000..465dc085fc
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============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.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Test;
+import org.onap.aai.domain.yang.Pnf;
+
+public class CreateAaiEntryWithPnfIdDelegateTest {
+
+ @Test
+ public void shouldSetPnfIdAndPnfName() throws Exception {
+ // given
+ CreateAaiEntryWithPnfIdDelegate delegate = new CreateAaiEntryWithPnfIdDelegate();
+ AaiConnectionTestImpl aaiConnection = new AaiConnectionTestImpl();
+ delegate.setAaiConnection(aaiConnection);
+ DelegateExecution execution = mock(DelegateExecution.class);
+ when(execution.getVariable(eq(CORRELATION_ID))).thenReturn("testCorrelationId");
+ // when
+ delegate.execute(execution);
+ // then
+ Pnf createdEntry = aaiConnection.getCreated().get("testCorrelationId");
+ assertThat(createdEntry.getPnfId()).isEqualTo("testCorrelationId");
+ assertThat(createdEntry.getPnfName()).isEqualTo("testCorrelationId");
+ assertThat(createdEntry.isInMaint()).isTrue();
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..f2a4205ebd
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
@@ -0,0 +1,63 @@
+/*-
+ * ============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 org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
+import java.util.Objects;
+
+public class DmaapClientTestImpl implements DmaapClient {
+
+ private String correlationId;
+ private Runnable informConsumer;
+
+ @Override
+ public void registerForUpdate(String correlationId, Runnable informConsumer) {
+ this.correlationId = correlationId;
+ this.informConsumer = informConsumer;
+ }
+
+ @Override
+ public Runnable unregister(String correlationId) {
+ if (Objects.equals(this.correlationId, correlationId)) {
+ this.correlationId = null;
+ Runnable informConsumer = this.informConsumer;
+ this.informConsumer = null;
+ return informConsumer;
+ }
+ return null;
+ }
+
+ public String getCorrelationId() {
+ return correlationId;
+ }
+
+ public Runnable getInformConsumer() {
+ return informConsumer;
+ }
+
+ public void sendMessage() {
+ informConsumer.run();
+ }
+
+ public boolean haveRegisteredConsumer() {
+ return correlationId != 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
new file mode 100644
index 0000000000..ddf33a1d77
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java
@@ -0,0 +1,88 @@
+/*-
+ * ============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 org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.RuntimeService;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InOrder;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
+
+public class InformDmaapClientTest {
+ @Before
+ public void setUp() throws Exception {
+ informDmaapClient = new InformDmaapClient();
+ dmaapClientTest = new DmaapClientTestImpl();
+ informDmaapClient.setDmaapClient(dmaapClientTest);
+ delegateExecution = mockDelegateExecution();
+ }
+
+ private InformDmaapClient informDmaapClient;
+
+ private DmaapClientTestImpl dmaapClientTest;
+
+ private DelegateExecution delegateExecution;
+
+ private MessageCorrelationBuilder messageCorrelationBuilder;
+
+ @Test
+ public void shouldSendListenerToDmaapClient() throws Exception {
+ // when
+ informDmaapClient.execute(delegateExecution);
+ // then
+ assertThat(dmaapClientTest.getCorrelationId()).isEqualTo("testCorrelationId");
+ assertThat(dmaapClientTest.getInformConsumer()).isNotNull();
+ verifyZeroInteractions(messageCorrelationBuilder);
+ }
+
+ @Test
+ public void shouldSendListenerToDmaapClientAndSendMessageToCamunda() throws Exception {
+ // when
+ informDmaapClient.execute(delegateExecution);
+ dmaapClientTest.getInformConsumer().run();
+ // then
+ assertThat(dmaapClientTest.getCorrelationId()).isEqualTo("testCorrelationId");
+ InOrder inOrder = inOrder(messageCorrelationBuilder);
+ inOrder.verify(messageCorrelationBuilder).processInstanceBusinessKey("testBusinessKey");
+ inOrder.verify(messageCorrelationBuilder).correlateWithResult();
+ }
+
+ private DelegateExecution mockDelegateExecution() {
+ DelegateExecution delegateExecution = mock(DelegateExecution.class);
+ when(delegateExecution.getVariable(eq(ExecutionVariableNames.CORRELATION_ID))).thenReturn("testCorrelationId");
+ when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey");
+ ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
+ when(delegateExecution.getProcessEngineServices()).thenReturn(processEngineServices);
+ RuntimeService runtimeService = mock(RuntimeService.class);
+ when(processEngineServices.getRuntimeService()).thenReturn(runtimeService);
+ messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
+ when(runtimeService.createMessageCorrelation(any())).thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.processInstanceBusinessKey(any())).thenReturn(messageCorrelationBuilder);
+ return delegateExecution;
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..aab289fd90
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============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.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Matchers.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.ExecutionVariableNames.CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
+
+import org.camunda.bpm.engine.delegate.BpmnError;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Before;
+import org.junit.Test;
+
+public class PnfCheckInputsTest {
+
+ private PnfCheckInputs delegate;
+
+ @Before
+ public void setUp() throws Exception {
+ delegate = new PnfCheckInputs();
+ }
+
+ private DelegateExecution mockDelegateExecution() {
+ DelegateExecution delegateExecution = mock(DelegateExecution.class);
+ when(delegateExecution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
+ return delegateExecution;
+ }
+
+ @Test
+ public void shouldThrowException_whenPnfIdNotSet() throws Exception {
+ // given
+ DelegateExecution delegateExecution = mockDelegateExecution();
+ // when, then
+ assertThatThrownBy(() -> delegate.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ }
+
+ private DelegateExecution mockDelegateExecutionWithCorrelationId() {
+ DelegateExecution delegateExecution = mockDelegateExecution();
+ when(delegateExecution.getVariable(CORRELATION_ID)).thenReturn("testCorrelationId");
+ return delegateExecution;
+ }
+
+ @Test
+ public void shouldThrowException_whenTimeoutIsNotSetAndDefaultIsNotDefined() throws Exception {
+ // given
+ DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
+ // when, then
+ assertThatThrownBy(() -> delegate.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ }
+
+ @Test
+ public void shouldSetDefaultTimeout_whenTimeoutIsNotSet() throws Exception {
+ // given
+ String defaultTimeout = "T1D";
+ delegate.setDefaultTimeout(defaultTimeout);
+ DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
+ // when
+ delegate.execute(delegateExecution);
+ // then
+ verify(delegateExecution).setVariable(eq(TIMEOUT_FOR_NOTIFICATION), eq(defaultTimeout));
+ }
+} \ No newline at end of file
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
new file mode 100644
index 0000000000..9ae7ad9bdc
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
@@ -0,0 +1,198 @@
+/*-
+ * ============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.dmaap;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Field;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.ProtocolVersion;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.message.BasicHttpResponse;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.so.bpmn.infrastructure.pnf.dmaap.PnfEventReadyDmaapClient.DmaapTopicListenerThread;
+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 = "[\n"
+ + " {\n"
+ + " \"pnfRegistrationFields\" : {\n"
+ + " \"correlationId\" : \"%s\",\n"
+ + " \"value\" : \"value1\"\n"
+ + " }\n"
+ + " },\n"
+ + " {\n"
+ + " \"pnfRegistrationFields\" : {\n"
+ + " \"correlationId\" : \"corr\",\n"
+ + " \"value\" : \"value2\"\n"
+ + " }\n"
+ + " }\n"
+ + "]";
+ private static final String JSON_EXAMPLE_WITH_NO_CORRELATION_ID =
+ "{\"pnfRegistrationFields\":{\"field\":\"value\"}}";
+
+ private static final String HOST = "hostTest";
+ private static final int PORT = 1234;
+ private static final String PROTOCOL = "http";
+ private static final String URI_PATH_PREFIX = "eventsForTesting";
+ private static final String EVENT_TOPIC_TEST = "eventTopicTest";
+ private static final String CONSUMER_ID = "consumerTestId";
+ private static final String CONSUMER_GROUP = "consumerGroupTest";
+ @Mock
+ private Environment env;
+ private PnfEventReadyDmaapClient testedObject;
+
+ private DmaapTopicListenerThread testedObjectInnerClassThread;
+ private HttpClient httpClientMock;
+ private Runnable threadMockToNotifyCamundaFlow;
+ private ScheduledThreadPoolExecutor executorMock;
+
+ @Before
+ public void init() throws NoSuchFieldException, IllegalAccessException {
+ testedObject = new PnfEventReadyDmaapClient(env);
+ when(env.getProperty(eq("pnf.dmaap.port"), eq(Integer.class))).thenReturn(PORT);
+ when(env.getProperty(eq("pnf.dmaap.host"))).thenReturn(HOST);
+ testedObject.setDmaapProtocol(PROTOCOL);
+ testedObject.setDmaapUriPathPrefix(URI_PATH_PREFIX);
+ testedObject.setDmaapTopicName(EVENT_TOPIC_TEST);
+ testedObject.setConsumerId(CONSUMER_ID);
+ testedObject.setConsumerGroup(CONSUMER_GROUP);
+ testedObject.setDmaapClientDelayInSeconds(1);
+ testedObject.init();
+ testedObjectInnerClassThread = testedObject.new DmaapTopicListenerThread();
+ httpClientMock = mock(HttpClient.class);
+ threadMockToNotifyCamundaFlow = mock(Runnable.class);
+ executorMock = mock(ScheduledThreadPoolExecutor.class);
+ setPrivateField();
+ }
+
+ /**
+ * Test run method, where the are following conditions:
+ * <p> - DmaapThreadListener is running, flag is set to true
+ * <p> - map is filled with one entry with the key that we get from response
+ * <p> run method should invoke thread from map to notify camunda process, remove element from the map (map is
+ * empty) and shutdown the executor because of empty map
+ */
+ @Test
+ public void correlationIdIsFoundInHttpResponse_notifyAboutPnfReady()
+ throws IOException {
+ when(httpClientMock.execute(any(HttpGet.class))).
+ thenReturn(createResponse(String.format(JSON_EXAMPLE_WITH_CORRELATION_ID, CORRELATION_ID)));
+ testedObjectInnerClassThread.run();
+ ArgumentCaptor<HttpGet> captor1 = ArgumentCaptor.forClass(HttpGet.class);
+ verify(httpClientMock).execute(captor1.capture());
+ assertThat(captor1.getValue().getURI()).hasHost(HOST).hasPort(PORT).hasScheme(PROTOCOL)
+ .hasPath(
+ "/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + "");
+ verify(threadMockToNotifyCamundaFlow).run();
+ verify(executorMock).shutdown();
+ }
+
+ /**
+ * Test run method, where the are following conditions:
+ * <p> - DmaapThreadListener is running, flag is set to true
+ * <p> - map is filled with one entry with the correlationId that does not match to correlationId
+ * 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()
+ throws IOException {
+ when(httpClientMock.execute(any(HttpGet.class))).
+ thenReturn(createResponse(
+ String.format(JSON_EXAMPLE_WITH_CORRELATION_ID, CORRELATION_ID_NOT_FOUND_IN_MAP)));
+ testedObjectInnerClassThread.run();
+ verifyZeroInteractions(threadMockToNotifyCamundaFlow, executorMock);
+ }
+
+ /**
+ * Test run method, where the are following conditions:
+ * <p> - DmaapThreadListener is running, flag is set to true
+ * <p> - map is filled with one entry with the correlationId 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 {
+ when(httpClientMock.execute(any(HttpGet.class))).
+ thenReturn(createResponse(JSON_EXAMPLE_WITH_NO_CORRELATION_ID));
+ testedObjectInnerClassThread.run();
+ verifyZeroInteractions(threadMockToNotifyCamundaFlow, executorMock);
+ }
+
+ private void setPrivateField() throws NoSuchFieldException, IllegalAccessException {
+ Field httpClientField = testedObject.getClass().getDeclaredField("httpClient");
+ httpClientField.setAccessible(true);
+ httpClientField.set(testedObject, httpClientMock);
+ httpClientField.setAccessible(false);
+
+ Field executorField = testedObject.getClass().getDeclaredField("executor");
+ executorField.setAccessible(true);
+ executorField.set(testedObject, executorMock);
+ executorField.setAccessible(false);
+
+ Field pnfCorrelationToThreadMapField = testedObject.getClass()
+ .getDeclaredField("pnfCorrelationIdToThreadMap");
+ pnfCorrelationToThreadMapField.setAccessible(true);
+ Map<String, Runnable> pnfCorrelationToThreadMap = new ConcurrentHashMap<>();
+ pnfCorrelationToThreadMap.put(CORRELATION_ID, threadMockToNotifyCamundaFlow);
+ pnfCorrelationToThreadMapField.set(testedObject, pnfCorrelationToThreadMap);
+
+ Field threadRunFlag = testedObject.getClass().getDeclaredField("dmaapThreadListenerIsRunning");
+ threadRunFlag.setAccessible(true);
+ threadRunFlag.set(testedObject, true);
+ threadRunFlag.setAccessible(false);
+ }
+
+ private HttpResponse createResponse(String json) throws UnsupportedEncodingException {
+ HttpEntity entity = new StringEntity(json);
+ ProtocolVersion protocolVersion = new ProtocolVersion("", 1, 1);
+ HttpResponse response = new BasicHttpResponse(protocolVersion, 1, "");
+ response.setEntity(entity);
+ response.setStatusCode(200);
+ return response;
+ }
+
+}