diff options
Diffstat (limited to 'bpmn')
134 files changed, 3022 insertions, 212 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy index ee70dcc89c..ecd90165c2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.util.regex.Matcher import java.util.regex.Pattern diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index 976ad1466d..e83e7e2ea2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -32,6 +32,7 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.HttpClientFactory import org.onap.so.client.aai.AAIResourcesClient import org.springframework.web.util.UriUtils import org.slf4j.Logger @@ -677,4 +678,8 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess public AAIResourcesClient getAAIClient(){ return new AAIResourcesClient(); } + + HttpClientFactory getHttpClientFactory(){ + return new HttpClientFactory() + } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy index 4df38edcc3..e5fff9c100 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.client.aai.entities.AAIResultWrapper -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.isBlank; diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy index c843cc35fe..6b021834b3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy @@ -28,7 +28,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.json.JsonUtils import org.onap.appc.client.lcm.model.Action import org.onap.so.client.appc.ApplicationControllerAction -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy index 83784e1960..7b49fa06b3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy @@ -32,7 +32,7 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy index 841fe9f50e..48a8e60095 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy @@ -27,7 +27,7 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.db.request.beans.InfraActiveRequests import org.onap.so.db.request.client.RequestsDbClient -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy index b666c8d19d..9c8d8bfa12 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy @@ -30,7 +30,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy index 569d4b75b9..24375e59cc 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -32,7 +32,7 @@ import org.onap.so.client.aai.entities.Relationships import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy index 163e914238..b43a153acb 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -33,7 +33,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.db.catalog.beans.OrchestrationStatus -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy index 4d57b1b26f..4b33676955 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy @@ -29,7 +29,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy index 195b1fc0d6..38f7bf445f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy index 8306f33592..c294f1b8c3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy @@ -26,7 +26,7 @@ import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.db.request.beans.InfraActiveRequests import org.onap.so.db.request.client.RequestsDbClient -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.core.UrnPropertiesReader; import java.text.SimpleDateFormat diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy index 6d4b50f690..203ccb97f6 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -25,7 +25,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.io.Serializable; diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy index 615964b2a9..a1e3576d86 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import static org.apache.commons.lang3.StringUtils.*; diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy index a2f5dfbffe..eea476a278 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.text.SimpleDateFormat diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy index 39e6db4d3f..f012eabe5e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy @@ -30,7 +30,7 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy index ce474fa713..b35042e3c0 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtil.groovy @@ -49,8 +49,8 @@ class RequestDBUtil { String operationType = operationStatus.getOperation() String result = operationStatus.getResult() String progress = operationStatus.getProgress() - String operationContent = operationStatus.getOperationContent() - String reason = operationStatus.getReason() + String operationContent = operationStatus.getOperationContent()?: "" + String reason = operationStatus.getReason()?: "" String payload = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy index db39358ccd..f9119dcb1d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.text.SimpleDateFormat diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy index 52d6758b2b..ebaf65ff81 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.text.SimpleDateFormat import javax.ws.rs.core.Response diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy index ba5145d19b..753d4403f3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import java.text.SimpleDateFormat import java.net.URLEncoder diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy index f24eda813d..2455305b4e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy @@ -28,7 +28,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.L3Network import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.springframework.web.util.UriUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.logger.MessageEnum diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy index 30964aa4ec..8075944c8c 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy @@ -25,7 +25,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.DelegateExecution import org.apache.commons.lang3.* -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index 8f409fa13e..f19933fa8b 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -31,7 +31,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy index 20aeb11c5f..cfa384dc50 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy index 803a3f71de..a6aacc7ea5 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.ws.rs.core.Response import org.apache.commons.lang3.* diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy index 6cfa2a1a64..91b29d3867 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy @@ -26,7 +26,7 @@ import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java index d9356306b7..bd31c552d3 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java @@ -34,7 +34,7 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; import org.onap.so.bpmn.core.UrnPropertiesReader; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java index 047b1f3930..204611cb8f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java @@ -26,7 +26,7 @@ package org.onap.so.bpmn.common.workflow.context; import java.util.concurrent.DelayQueue; import java.util.concurrent.TimeUnit; import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index e7e51bba77..f0954c3695 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -662,6 +662,7 @@ public class BBInputSetup implements JavaDelegate { } protected void populateVolumeGroup(BBInputSetupParameter parameter) throws Exception { + String replaceVnfModelCustomizationUUID = null; VolumeGroup volumeGroup = null; GenericVnf vnf = null; String vnfModelCustomizationUUID = null; @@ -674,7 +675,11 @@ public class BBInputSetup implements JavaDelegate { for (RelatedInstanceList relatedInstList : parameter.getRelatedInstanceList()) { RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { - vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationUuid(); + if (parameter.getIsReplace()) { + replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } else { + vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } break; } } @@ -685,8 +690,13 @@ public class BBInputSetup implements JavaDelegate { vnfModelCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId(); ModelInfo vnfModelInfo = new ModelInfo(); - vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); - mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getService()); + if (parameter.getIsReplace()) { + vnfModelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID); + mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getServiceModel().getNewService()); + } else { + vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); + mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getServiceModel().getCurrentService()); + } break; } } @@ -696,6 +706,22 @@ public class BBInputSetup implements JavaDelegate { && volumeGroupTemp.getVolumeGroupId() .equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.VOLUME_GROUP_ID))) { volumeGroup = volumeGroupTemp; + if (volumeGroup.getModelInfoVfModule() == null) { + throw new Exception( + "ModelInfoVfModule is null for VolumeGroup: " + volumeGroup.getVolumeGroupId()); + } + String volumeGroupCustId = volumeGroup.getModelInfoVfModule().getModelCustomizationUUID(); + ModelInfo modelInfoVolumeGroup = new ModelInfo(); + modelInfoVolumeGroup.setModelCustomizationId(volumeGroupCustId); + if (parameter.getIsReplace() && parameter.getLookupKeyMap().get(ResourceKey.VOLUME_GROUP_ID) != null + && volumeGroupTemp.getVolumeGroupId() + .equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.VOLUME_GROUP_ID))) { + mapCatalogVolumeGroup(volumeGroupTemp, modelInfoVolumeGroup, + parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID); + } else { + mapCatalogVolumeGroup(volumeGroupTemp, modelInfoVolumeGroup, + parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID); + } break; } } @@ -703,10 +729,13 @@ public class BBInputSetup implements JavaDelegate { volumeGroup = createVolumeGroup(parameter.getLookupKeyMap(), parameter.getResourceId(), parameter.getInstanceName(), generatedVnfType, parameter.getInstanceParams()); vnf.getVolumeGroups().add(volumeGroup); - } - if (volumeGroup != null) { - mapCatalogVolumeGroup(volumeGroup, parameter.getModelInfo(), parameter.getService(), - vnfModelCustomizationUUID); + if (parameter.getIsReplace()) { + mapCatalogVolumeGroup(volumeGroup, parameter.getModelInfo(), + parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID); + } else { + mapCatalogVolumeGroup(volumeGroup, parameter.getModelInfo(), + parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID); + } } } else { logger.debug("Related VNF instance Id not found: {}", @@ -1514,6 +1543,9 @@ public class BBInputSetup implements JavaDelegate { parameter.setInstanceName(vfModules.getVolumeGroupInstanceName()); parameter.setVnfType(vnfType); parameter.setInstanceParams(vfModules.getInstanceParams()); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); + parameter.setServiceModel(serviceModel); this.populateVolumeGroup(parameter); } else { parameter.setResourceId(lookupKeyMap.get(ResourceKey.VF_MODULE_ID)); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 28ec71b13f..67d073d7b6 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -186,6 +186,9 @@ public class BBInputSetupMapperLayer { protected VolumeGroup mapAAIVolumeGroup(org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup) { VolumeGroup volumeGroup = modelMapper.map(aaiVolumeGroup, VolumeGroup.class); + ModelInfoVfModule modelInfo = new ModelInfoVfModule(); + modelInfo.setModelCustomizationUUID(aaiVolumeGroup.getModelCustomizationId()); + volumeGroup.setModelInfoVfModule(modelInfo); volumeGroup.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiVolumeGroup.getOrchestrationStatus())); return volumeGroup; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index 0a6ce05a06..2e9d4b0117 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -40,7 +40,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.objects.audit.AAIObjectAudit; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java index eb2567d47c..9b46611468 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/SDNCLcmPropertiesImpl.java @@ -31,12 +31,14 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { public static final String SDNC_HOST = "sdnc.host"; public static final String SDNC_AUTH = "sdnc.auth"; public static final String LCM_PATH = "sdnc.lcm.path"; + public static final String LCM_ACTION_TIMEOUT = "sdnc.lcm.actionTimeout"; public static final String DMAAP_HOST = "sdnc.dmaap.host"; public static final String DMAAP_AUTH = "sdnc.dmaap.auth"; - public static final String DMAAP_PARTITION = "sdnc.dmaap.partition"; public static final String DMAAP_TIMEOUT = "sdnc.dmaap.timeout"; public static final String DMAAP_ENVIRONMENT = "sdnc.dmaap.environment"; + + public static final String LCM_DMAAP_PARTITION = "sdnc.lcm.dmaap.partition"; public static final String LCM_DMAAP_READ_TOPIC = "sdnc.lcm.dmapp.readTopic"; public static final String LCM_DMAAP_WRITE_TOPIC = "sdnc.lcm.dmaap.writeTopic"; @@ -56,6 +58,12 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { } @Override + public long getActionTimeout() { + String actionTimeout = UrnPropertiesReader.getVariable(LCM_ACTION_TIMEOUT); + return (actionTimeout != null) ? Long.parseLong(actionTimeout) : SDNCConstants.LCM_ACTION_TIMEOUT; + } + + @Override public String getBasicAuth() { return UrnPropertiesReader.getVariable(SDNC_AUTH); } @@ -72,7 +80,7 @@ public class SDNCLcmPropertiesImpl implements SDNCLcmProperties { @Override public String getDmaapPartition() { - String partition = UrnPropertiesReader.getVariable(DMAAP_PARTITION); + String partition = UrnPropertiesReader.getVariable(LCM_DMAAP_PARTITION); return (partition != null) ? partition : SDNCConstants.LCM_DMAAP_PARTITION; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java index fd9412e70e..dcbb120c69 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/common/SDNCConstants.java @@ -45,5 +45,6 @@ public interface SDNCConstants { String LCM_DMAAP_READ_TOPIC = "SDNC-LCM-WRITE"; String LCM_DMAAP_WRITE_TOPIC = "SDNC-LCM-READ"; - int LCM_TIMEOUT = 300; + long LCM_ACTION_TIMEOUT = 300000; // Millisecond + int LCM_OUTPUT_SUCCESS_CODE = 400; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java new file mode 100644 index 0000000000..8ab40cb08d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmActionConstants.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm; + +public interface SDNCLcmActionConstants { + String ACTIVATE_N_E_SW = "ActivateNESw"; + String DOWNLOAD_N_E_SW = "DownloadNESw"; + String UPGRADE_POST_CHECK = "UpgradePostCheck"; + String UPGRADE_PRE_CHECK = "UpgradePreCheck"; +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java index 5616db3577..0f17c547b5 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmClientBuilder.java @@ -39,6 +39,10 @@ public class SDNCLcmClientBuilder { sdncLcmProperties = pros; } + public SDNCLcmProperties getSDNCLcmProperties() { + return sdncLcmProperties; + } + public SDNCLcmRestClient newSDNCLcmRestClient(String operation) throws SDNCLcmClientBuilderException { URI pathUri; try { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java index df5fb3be0b..a21196e08f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmProperties.java @@ -27,6 +27,8 @@ public interface SDNCLcmProperties extends RestProperties { String getPath(); + long getActionTimeout(); + String getBasicAuth(); String getDmaapHost(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java new file mode 100644 index 0000000000..d86d114a9f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayload.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "swVersionToBeActivated"}) +public class ActivateNESwPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "swVersionToBeActivated", required = true) + private String swVersionToBeActivated; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getSwVersionToBeActivated() { + return swVersionToBeActivated; + } + + public void setSwVersionToBeActivated(String value) { + this.swVersionToBeActivated = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java new file mode 100644 index 0000000000..5dc5cf503d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayload.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm.beans.payload; + +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "swToBeDownloaded"}) +public class DownloadNESwPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "swToBeDownloaded", required = true) + private List<SwToBeDownloadedElement> swToBeDownloaded = new ArrayList<>(); + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public List<SwToBeDownloadedElement> getSwToBeDownloaded() { + return swToBeDownloaded; + } + + public void setSwToBeDownloaded(List<SwToBeDownloadedElement> value) { + this.swToBeDownloaded = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java new file mode 100644 index 0000000000..1a3529d7c4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/SwToBeDownloadedElement.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"swLocation", "swFileSize", "swFileCompression", "swFileFormat"}) +public class SwToBeDownloadedElement { + + @JsonProperty(value = "swLocation", required = true) + private String swLocation; + + @JsonProperty(value = "swFileSize") + private long swFileSize; + + @JsonProperty(value = "swFileCompression") + private String swFileCompression; + + @JsonProperty(value = "swFileFormat") + private String swFileFormat; + + public String getSwLocation() { + return swLocation; + } + + public void setSwLocation(String value) { + this.swLocation = value; + } + + public long getSwFileSize() { + return swFileSize; + } + + public void setSwFileSize(long value) { + this.swFileSize = value; + } + + public String getSwFileCompression() { + return swFileCompression; + } + + public void setSwFileCompression(String value) { + this.swFileCompression = value; + } + + public String getSwFileFormat() { + return swFileFormat; + } + + public void setSwFileFormat(String value) { + this.swFileFormat = value; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java new file mode 100644 index 0000000000..76937d262c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayload.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "oldSwVersion", "targetSwVersion", "ruleName", "additionalData"}) +public class UpgradePostCheckPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "oldSwVersion", required = true) + private String oldSwVersion; + + @JsonProperty(value = "targetSwVersion", required = true) + private String targetSwVersion; + + @JsonProperty(value = "ruleName", required = true) + private String ruleName; + + @JsonProperty(value = "additionalData") + private String additionalData; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getOldSwVersion() { + return oldSwVersion; + } + + public void setOldSwVersion(String value) { + this.oldSwVersion = value; + } + + public String getTargetSwVersion() { + return targetSwVersion; + } + + public void setTargetSwVersion(String value) { + this.targetSwVersion = value; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String value) { + this.ruleName = value; + } + + public String getAdditionalData() { + return additionalData; + } + + public void setAdditionalData(String value) { + this.additionalData = value; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java new file mode 100644 index 0000000000..d1a95b8418 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayload.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"ipaddressV4Oam", "playbookName", "oldSwVersion", "targetSwVersion", "ruleName", "additionalData"}) +public class UpgradePreCheckPayload { + + @JsonProperty(value = "ipaddress-v4-oam", required = true) + private String ipaddressV4Oam; + + @JsonProperty(value = "playbook-name") + private String playbookName; + + @JsonProperty(value = "oldSwVersion", required = true) + private String oldSwVersion; + + @JsonProperty(value = "targetSwVersion", required = true) + private String targetSwVersion; + + @JsonProperty(value = "ruleName", required = true) + private String ruleName; + + @JsonProperty(value = "additionalData") + private String additionalData; + + public String getIpaddressV4Oam() { + return ipaddressV4Oam; + } + + public void setIpaddressV4Oam(String value) { + this.ipaddressV4Oam = value; + } + + public String getPlaybookName() { + return playbookName; + } + + public void setPlaybookName(String value) { + this.playbookName = value; + } + + public String getOldSwVersion() { + return oldSwVersion; + } + + public void setOldSwVersion(String value) { + this.oldSwVersion = value; + } + + public String getTargetSwVersion() { + return targetSwVersion; + } + + public void setTargetSwVersion(String value) { + this.targetSwVersion = value; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String value) { + this.ruleName = value; + } + + public String getAdditionalData() { + return additionalData; + } + + public void setAdditionalData(String value) { + this.additionalData = value; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy new file mode 100644 index 0000000000..6b63bbe56c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/RequestDBUtilTest.groovy @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.common.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.db.request.beans.OperationStatus + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class RequestDBUtilTest extends MsoGroovyTest { + + @Before + void init() throws IOException { + super.init("DoDeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void prepareUpdateOperationStatus(){ + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://sdc-wfd-be:8080") + OperationStatus operationStatus = new OperationStatus() + operationStatus.setServiceId("testServiceId") + operationStatus.setOperationId("testOperationId") + operationStatus.setUserId("testUserId") + operationStatus.setOperation("testOpertation") + operationStatus.setResult("testResult") + operationStatus.setProgress("testProgress") + operationStatus.setOperationContent("testOperationContent") + operationStatus.setReason("testReason") + + RequestDBUtil requestDBUtil = new RequestDBUtil() + requestDBUtil.prepareUpdateOperationStatus(mockExecution, operationStatus) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus = captor.getAllValues() + assertNotNull(updateOperationStatus) + } + + @Test + void testGetOperationStatus(){ + when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://sdc-wfd-be:8080") + + RequestDBUtil requestDBUtil = new RequestDBUtil() + requestDBUtil.getOperationStatus(mockExecution, "testServiceId","testOperationId") + + Mockito.verify(mockExecution,times(1)).setVariable(eq("getOperationStatus"), captor.capture()) + String getOperationStatus = captor.getAllValues() + assertNotNull(getOperationStatus) + + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index 1acf4edb4a..df7337c0d9 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -888,7 +888,6 @@ public class BBInputSetupTest { verify(SPY_bbInputSetup, times(1)).populateGenericVnf(parameter); assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId)); - doReturn(ModelType.volumeGroup).when(modelInfo).getModelType(); resourceId = "volumeGroupId"; parameter.setResourceId(resourceId); @@ -1159,12 +1158,13 @@ public class BBInputSetupTest { ModelInfo mi = new ModelInfo(); mi.setModelType(ModelType.vnf); mi.setModelCustomizationUuid("vnfModelCustomizationUUID"); + mi.setModelCustomizationId("vnfModelCustomizationUUID"); ri.setModelInfo(mi); ril.setRelatedInstance(ri); requestDetails.setRelatedInstanceList(new RelatedInstanceList[] {ril}); ModelInfo modelInfo = new ModelInfo(); - modelInfo.setModelType(ModelType.volumeGroup); + modelInfo.setModelCustomizationId("volumeGroupCustId"); RequestInfo reqInfo = new RequestInfo(); reqInfo.setInstanceName("volumeGroupName"); @@ -1178,6 +1178,8 @@ public class BBInputSetupTest { VolumeGroup vg = new VolumeGroup(); vg.setVolumeGroupName("volumeGroupName"); vg.setVolumeGroupId("volumeGroupId"); + vg.setModelInfoVfModule(new ModelInfoVfModule()); + vg.getModelInfoVfModule().setModelCustomizationUUID("volumeGroupCustId"); vnf.getVolumeGroups().add(vg); serviceInstance.getVnfs().add(vnf); @@ -1186,6 +1188,8 @@ public class BBInputSetupTest { Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId"); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); String bbName = AssignFlows.VOLUME_GROUP.toString(); String resourceId = "123"; doNothing().when(SPY_bbInputSetup).mapCatalogVolumeGroup(isA(VolumeGroup.class), eq(modelInfo), eq(service), @@ -1198,9 +1202,10 @@ public class BBInputSetupTest { BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID) .setModelInfo(modelInfo).setService(service).setBbName(bbName).setServiceInstance(serviceInstance) .setLookupKeyMap(lookupKeyMap).setResourceId(resourceId).setRequestDetails(requestDetails) - .setInstanceName(reqInfo.getInstanceName()).build(); + .setInstanceName(reqInfo.getInstanceName()).setServiceModel(serviceModel).build(); SPY_bbInputSetup.populateVolumeGroup(parameter); - verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vg, modelInfo, service, "vnfModelCustomizationUUID"); + verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(eq(vg), isA(ModelInfo.class), eq(service), + eq("vnfModelCustomizationUUID")); vnf.getVolumeGroups().clear(); SPY_bbInputSetup.populateVolumeGroup(parameter); verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vnf.getVolumeGroups().get(0), modelInfo, service, diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java index 5483792a84..3757769769 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/SDNCLcmDmaapClientTest.java @@ -42,7 +42,7 @@ public class SDNCLcmDmaapClientTest extends BaseTest { protected static final String DMAAP_HOST_PROP = SDNCLcmPropertiesImpl.DMAAP_HOST; protected static final String DMAAP_WRITE_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_WRITE_TOPIC; protected static final String DMAAP_READ_TOPIC_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_READ_TOPIC; - protected static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.DMAAP_PARTITION; + protected static final String DMAAP_PARTITION_PROP = SDNCLcmPropertiesImpl.LCM_DMAAP_PARTITION; protected String testWriteTopic = "TEST-WRITE-TOPIC"; protected String testReadTopic = "TEST-READ-TOPIC"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java new file mode 100644 index 0000000000..bee07f2022 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/ActivateNESwPayloadTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm.beans.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class ActivateNESwPayloadTest extends LcmBasePayloadTest { + private static String expectedActivateNESwPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"swVersionToBeActivated\":\"v2\"" + "}"; + + public ActivateNESwPayload buildActivateNESwPayload() { + ActivateNESwPayload activateNESwPayload = new ActivateNESwPayload(); + + activateNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + activateNESwPayload.setPlaybookName(playbookName); + activateNESwPayload.setSwVersionToBeActivated("v2"); + + return activateNESwPayload; + } + + @Test + public final void testActivateNESwPayload() { + ActivateNESwPayload activateNESwPayload = buildActivateNESwPayload(); + + try { + String activateNESwPayloadString = convertToSting(activateNESwPayload); + assertEquals(expectedActivateNESwPayload, activateNESwPayloadString); + } catch (Exception e) { + fail("Convert ActivateNESwPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java new file mode 100644 index 0000000000..f9fa679790 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/DownloadNESwPayloadTest.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm.beans.payload; + +import java.util.Collections; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class DownloadNESwPayloadTest extends LcmBasePayloadTest { + private static String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\"," + + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}"; + + private static String expectedDownloadNESwPayload = + "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"test_playbook\"," + + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}"; + + public SwToBeDownloadedElement buildSwToBeDownloadedElement() { + SwToBeDownloadedElement swToBeDownloadedElement = new SwToBeDownloadedElement(); + + swToBeDownloadedElement.setSwLocation("http://192.168.1.20/test.zip"); + swToBeDownloadedElement.setSwFileSize(123456); + swToBeDownloadedElement.setSwFileCompression("ZIP"); + swToBeDownloadedElement.setSwFileFormat("binary"); + + return swToBeDownloadedElement; + } + + public DownloadNESwPayload buildDownloadNESwPayload() { + DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload(); + + downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + downloadNESwPayload.setPlaybookName(playbookName); + + SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement(); + downloadNESwPayload.setSwToBeDownloaded(Collections.singletonList(swToBeDownloadedElement)); + + return downloadNESwPayload; + } + + @Test + public final void testSwToBeDownloadedElement() { + SwToBeDownloadedElement swToBeDownloadedElement = buildSwToBeDownloadedElement(); + + try { + String swToBeDownloadedElementString = convertToSting(swToBeDownloadedElement); + assertEquals(expectedSwToBeDownloadedElement, swToBeDownloadedElementString); + } catch (Exception e) { + fail("Convert SwToBeDownloadedElement to String error: " + e.toString()); + } + } + + @Test + public final void testDownloadNESwPayload() { + DownloadNESwPayload downloadNESwPayload = buildDownloadNESwPayload(); + + try { + String downloadNESwPayloadString = convertToSting(downloadNESwPayload); + assertEquals(expectedDownloadNESwPayload, downloadNESwPayloadString); + } catch (Exception e) { + fail("Convert DownloadNESwPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java new file mode 100644 index 0000000000..5452166d03 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/LcmBasePayloadTest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm.beans.payload; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LcmBasePayloadTest { + private static Logger logger = LoggerFactory.getLogger(LcmBasePayloadTest.class); + + protected String ipaddressV4Oam = "192.168.1.10"; + protected String playbookName = "test_playbook"; + + public String convertToSting(Object msgObject) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + + String msgString = mapper.writeValueAsString(msgObject); + logger.debug(msgObject.getClass().getSimpleName() + "\n" + msgString); + + return msgString; + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java new file mode 100644 index 0000000000..acd447e890 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePostCheckPayloadTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm.beans.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class UpgradePostCheckPayloadTest extends LcmBasePayloadTest { + private static String expectedUpgradePostCheckPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"oldSwVersion\":\"v1\"," + "\"targetSwVersion\":\"v2\"," + + "\"ruleName\":\"r102\"," + "\"additionalData\":\"{}\"" + "}"; + + public UpgradePostCheckPayload buildUpgradePostCheckPayload() { + UpgradePostCheckPayload upgradePostCheckPayload = new UpgradePostCheckPayload(); + + upgradePostCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + upgradePostCheckPayload.setPlaybookName(playbookName); + upgradePostCheckPayload.setOldSwVersion("v1"); + upgradePostCheckPayload.setTargetSwVersion("v2"); + upgradePostCheckPayload.setRuleName("r102"); + upgradePostCheckPayload.setAdditionalData("{}"); + + return upgradePostCheckPayload; + } + + @Test + public final void testUpgradePostCheckPayload() { + UpgradePostCheckPayload upgradePostCheckPayload = buildUpgradePostCheckPayload(); + + try { + String upgradePostCheckPayloadString = convertToSting(upgradePostCheckPayload); + assertEquals(expectedUpgradePostCheckPayload, upgradePostCheckPayloadString); + } catch (Exception e) { + fail("Convert UpgradePostCheckPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java new file mode 100644 index 0000000000..8bc0714fff --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/sdnc/lcm/beans/payload/UpgradePreCheckPayloadTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.client.sdnc.lcm.beans.payload; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class UpgradePreCheckPayloadTest extends LcmBasePayloadTest { + private static String expectedUpgradePreCheckPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"test_playbook\"," + "\"oldSwVersion\":\"v1\"," + "\"targetSwVersion\":\"v2\"," + + "\"ruleName\":\"r101\"," + "\"additionalData\":\"{}\"" + "}"; + + public UpgradePreCheckPayload buildUpgradePreCheckPayload() { + UpgradePreCheckPayload upgradePreCheckPayload = new UpgradePreCheckPayload(); + + upgradePreCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + upgradePreCheckPayload.setPlaybookName(playbookName); + upgradePreCheckPayload.setOldSwVersion("v1"); + upgradePreCheckPayload.setTargetSwVersion("v2"); + upgradePreCheckPayload.setRuleName("r101"); + upgradePreCheckPayload.setAdditionalData("{}"); + + return upgradePreCheckPayload; + } + + @Test + public final void testUpgradePreCheckPayload() { + UpgradePreCheckPayload upgradePreCheckPayload = buildUpgradePreCheckPayload(); + + try { + String upgradePreCheckPayloadString = convertToSting(upgradePreCheckPayload); + assertEquals(expectedUpgradePreCheckPayload, upgradePreCheckPayloadString); + } catch (Exception e) { + fail("Convert UpgradePreCheckPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VolumeGroup.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VolumeGroup.json index bcc565dc75..7de6df617b 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VolumeGroup.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/VolumeGroup.json @@ -4,5 +4,8 @@ "vnf-type":"vnfType", "orchestration-status":"PRECREATED", "cloud-params":{}, - "heat-stack-id":"heatStackId" + "heat-stack-id":"heatStackId", + "model-info-vf-module": { + "modelCustomizationUUID": "modelCustomizationId" + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java index 13ba46a852..4e6396c4be 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java @@ -33,7 +33,7 @@ import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.Execution; import org.camunda.bpm.engine.runtime.MessageCorrelationResult; import org.onap.so.bpmn.core.UrnPropertiesReader; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java index f76fde9ef1..2eb9d175f2 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java @@ -35,7 +35,7 @@ import javax.ws.rs.core.Response; import org.onap.so.logger.LoggingAnchor; import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackError; import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java index 6debcfbff6..731e9d8703 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java @@ -49,7 +49,7 @@ import org.camunda.bpm.engine.variable.Variables.SerializationDataFormats; import org.camunda.bpm.engine.variable.impl.VariableMapImpl; import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.bpmn.core.WorkflowException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy index dc33bc930a..4ed0ea6a44 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationService.groovy @@ -102,6 +102,9 @@ class ActivateCommunicationService extends AbstractServiceTaskProcessor { String operationId = jsonUtil.getJsonValue(siRequest, "operationId") execution.setVariable("operationId", operationId) + String operationType = execution.getVariable("operationType") + execution.setVariable("operationType", operationType.toUpperCase()) + } catch (BpmnError e) { throw e } catch (Exception ex) { @@ -139,14 +142,14 @@ class ActivateCommunicationService extends AbstractServiceTaskProcessor { if(si.isPresent()) { if (si.get().getOrchestrationStatus().toLowerCase() == "activated" && - operationType == "deactivation") { + operationType.equalsIgnoreCase("deactivation")) { logger.info("Service is in active state") execution.setVariable("serviceExpectStatus", "deactivated") execution.setVariable("isContinue", "true") execution.setVariable("requestParam", "deactivate") } else if (si.get().getOrchestrationStatus().toLowerCase() == "deactivated" && - operationType == "activation"){ + operationType.equalsIgnoreCase("activation")){ logger.info("Service is in de-activated state") execution.setVariable("serviceExpectStatus", "activated") execution.setVariable("isContinue", "true") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy index 630148e899..a8c3ef189e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceService.groovy @@ -38,7 +38,7 @@ import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.db.request.beans.OperationStatus -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger @@ -95,6 +95,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { if (isBlank(globalSubscriberId)) { msg = "Input globalSubscriberId' is null" logger.info(msg) + execution.setVariable("globalSubscriberId", "5GCustomer") } else { execution.setVariable("globalSubscriberId", globalSubscriberId) } @@ -104,14 +105,16 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { if (isBlank(subscriptionServiceType)) { msg = "Input subscriptionServiceType is null" logger.debug(msg) - //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + execution.setVariable("subscriptionServiceType", "5G") } else { execution.setVariable("subscriptionServiceType", subscriptionServiceType) } String operationId = jsonUtil.getJsonValue(siRequest, "operationId") execution.setVariable("operationId", operationId) - execution.getVariable("operationType") + String operationType = execution.getVariable("operationType") + execution.setVariable("operationType", operationType.toUpperCase()) + logger.info("operationType is " + execution.getVariable("operationType") ) } catch (BpmnError e) { throw e @@ -308,7 +311,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { String nssiid = nssi.getNssiId() updateStratus(execution, globalCustId, serviceType, nssiid, operationType) } - if (operationType == "activation") { + if (operationType.equalsIgnoreCase("activation")) { //update the s-nssai updateStratus(execution, globalCustId, serviceType, e2eserviceInstanceId, operationType) //update the nsi @@ -345,7 +348,7 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) if (si.isPresent()) { - if (operationType == "activation") { + if (operationType.equalsIgnoreCase("activation")) { if (si.get().getOrchestrationStatus() == "deactivated") { si.get().setOrchestrationStatus("activated") client.update(uri, si.get()) @@ -484,15 +487,14 @@ class ActivateSliceService extends AbstractServiceTaskProcessor { Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) if (si.isPresent()) { if (si.get().getOrchestrationStatus().toLowerCase() == "activated" && - operationType == "deactivation") { + operationType.equalsIgnoreCase("deactivation")) { logger.info("Service is in active state") execution.setVariable("e2eservicestatus", "activated") execution.setVariable("isContinue", "true") String snssai = si.get().getEnvironmentContext() execution.setVariable("snssai", snssai) - } else if ((si.get().getOrchestrationStatus().toLowerCase() == "deactivated" || - si.get().getOrchestrationStatus().toLowerCase() == "created") && - operationType == "activation") { + } else if (si.get().getOrchestrationStatus().toLowerCase() == "deactivated" && + operationType.equalsIgnoreCase("activation")) { logger.info("Service is in de-activated state") execution.setVariable("e2eservicestatus", "deactivated") execution.setVariable("isContinue", "true") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy index e3470cd011..71da2abd05 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy @@ -54,7 +54,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank */ class CreateCommunicationService extends AbstractServiceTaskProcessor { - String Prefix="CRESI_" + String Prefix="CCS_" ExceptionUtil exceptionUtil = new ExceptionUtil() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy index cae629fdf0..650f79b633 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy @@ -39,7 +39,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index 3da4161953..8b9726c2b7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -127,7 +127,11 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String key = iterator.next() HashMap<String, String> hashMap = new HashMap() hashMap.put("name", key) - hashMap.put("value", jsonObject.get(key)) + if(jsonObject.get(key)==null){ + hashMap.put("value", "") + }else{ + hashMap.put("value", jsonObject.get(key)) + } paramList.add(hashMap) } Map<String, List<Map<String, Object>>> paramMap = new HashMap() @@ -345,6 +349,32 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { switch (modelType) { case "VNF" : + if(modelName.contains("UNI") && "MDONS_OTN".equals(serviceType)){ + source = "SO" + sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" + xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>optical-service-create</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>opticalservice</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-id>${msoUtils.xmlEscape(hdrRequestId)}</request-id> + <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> + <service-type>${msoUtils.xmlEscape(serviceType)}</service-type> + <notification-url>sdncCallback</notification-url> + <source>${msoUtils.xmlEscape(source)}</source> + <service-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-id> + <payload> + $netowrkInputParameters + </payload> + </sdncadapterworkflow:SDNCRequestData> + </aetgt:SDNCAdapterWorkflowRequest>""".trim() + } else{ sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> @@ -399,6 +429,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { </vnf-request-input> </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() + } break case "GROUP" : String vnfid = resourceInputObj.getVnfId() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index c3f36ef545..1efc1c11aa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -45,7 +45,7 @@ import org.onap.so.bpmn.common.scripts.OofUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index c9dadf57cb..fc97c292fb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -36,7 +36,7 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.infrastructure.aai.AAICreateResources -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy index 1fba23d3c8..33a607268d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy @@ -32,7 +32,7 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy index 3eb15558d2..dc9655e7af 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.*; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy index 00b0b37b18..b121083954 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationService.groovy @@ -141,7 +141,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { * save e2eslice-service instance id and service name * @param execution */ - private void queryCommunicationSeriveFromAAI(DelegateExecution execution) + void queryCommunicationSeriveFromAAI(DelegateExecution execution) { LOGGER.trace(" ***** begin queryCommunicationSeriveFromAAI *****") String serviceInstanceId = execution.getVariable("serviceInstanceId") @@ -186,12 +186,11 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) return wrapper } @@ -215,7 +214,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { requestBody.replaceAll("\\s+", "") String basicAuthValue = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution) - HttpClient httpClient = new HttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) + HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.SO) httpClient.addAdditionalHeader("Authorization", basicAuthValue) httpClient.addAdditionalHeader("Accept", "application/json") Response httpResponse = httpClient.delete(requestBody) @@ -233,6 +232,41 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { } /** + * prepare update operation status + * @param execution + */ + private void handleNSSMFWFResponse(Response httpResponse, DelegateExecution execution){ + LOGGER.debug(" ======== STARTED prepareUpdateOperationStatus Process ======== ") + + int nsmfResponseCode = httpResponse.getStatus() + LOGGER.debug("nsmfResponseCode${nsmfResponseCode}") + + if (nsmfResponseCode >= 200 && nsmfResponseCode < 204 && httpResponse.hasEntity()) { + String nsmfResponse = httpResponse.readEntity(String.class) + def e2eOperationId = jsonUtil.getJsonValue(nsmfResponse, "operationId") + execution.setVariable("e2eOperationId", e2eOperationId) + execution.setVariable("progress","20") + execution.setVariable("operationContent","waiting nsmf service delete finished") + + execution.setVariable("currentCycle",0) + execution.setVariable("isNSMFTimeOut", "no") + execution.setVariable("isNSMFWFRspSucceed","yes") + } + else + { + String serviceName = execution.getVariable("serviceInstanceName") + execution.setVariable("progress", "100") + execution.setVariable("result", "error") + execution.setVariable("operationContent", "terminate service failure.") + execution.setVariable("reason","NSMF WF asynchronous response failed, status Code:${nsmfResponseCode}") + execution.setVariable("isNSMFWFRspSucceed","no") + LOGGER.error("nsmf async response error,nsmfResponseCode:${nsmfResponseCode},serivceName:${serviceName}") + } + setOperationStatus(execution) + LOGGER.debug("======== COMPLETED prepareUpdateOperationStatus Process ======== ") + } + + /** * prepare to call sub process * @param execution */ @@ -272,22 +306,20 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { String profileId try { - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, globalSubscriberId, serviceType, serviceInstanceId) - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) Optional<CommunicationServiceProfiles> csProfilesOpt = wrapper.asBean(CommunicationServiceProfiles.class) if(csProfilesOpt.isPresent()){ - CommunicationServiceProfiles csProf - iles = csProfilesOpt.get() + CommunicationServiceProfiles csProfiles = csProfilesOpt.get() CommunicationServiceProfile csProfile = csProfiles.getCommunicationServiceProfile().get(0) profileId = csProfile ? csProfile.getProfileId() : "" } resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, globalSubscriberId, serviceType, serviceInstanceId, profileId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "communication service profile was not found in aai") } - - resourceClient.delete(resourceUri) + + getAAIClient().delete(resourceUri) LOGGER.debug("end delete communication service profile from AAI") } catch (any) @@ -308,9 +340,8 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { try { LOGGER.debug("start delete communication service from AAI") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), execution.getVariable("serviceInstanceId")) - resourceClient.delete(serviceInstanceUri) + getAAIClient().delete(serviceInstanceUri) execution.setVariable("progress", "100") execution.setVariable("result", "finished") @@ -330,12 +361,10 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { LOGGER.debug("Starting sendSyncError") try { - String errorMessage + String errorMessage = "Sending Sync Error." if (execution.getVariable("WorkflowException") instanceof WorkflowException) { WorkflowException wfe = execution.getVariable("WorkflowException") errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." } String buildworkflowException = @@ -397,6 +426,7 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { void prepareFailureStatus(DelegateExecution execution) { + execution.setVariable("result", "finished") execution.setVariable("progress", "100") execution.setVariable("operationContent", "terminate service failure.") setOperationStatus(execution) @@ -426,4 +456,5 @@ class DeleteCommunicationService extends AbstractServiceTaskProcessor { execution.setVariable(paraName, paramValue) } } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy index 5c7127f36e..41a4ab85ec 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy @@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.NetworkUtils import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy index f0d43cf8d7..d8160a97bc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceService.groovy @@ -45,19 +45,19 @@ import static org.apache.commons.lang3.StringUtils.isBlank class DeleteSliceService extends AbstractServiceTaskProcessor { - String Prefix="DELSS_" + private final String PREFIX ="DeleteSliceService" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() private RequestDBUtil requestDBUtil = new RequestDBUtil() - private static final Logger logger = LoggerFactory.getLogger( DeleteSliceService.class) + private static final Logger LOGGER = LoggerFactory.getLogger( DeleteSliceService.class) @Override void preProcessRequest(DelegateExecution execution) { - execution.setVariable("prefix", Prefix) + execution.setVariable("prefix", PREFIX) String msg = "" - logger.trace("Starting preProcessRequest") + LOGGER.debug("*****${PREFIX} preProcessRequest *****") try { // check for incoming json message/input @@ -71,7 +71,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { msg = "e2eslice-service id is null" exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } - logger.info("Input Request: ${siRequest}, reqId: ${requestId}, e2eslice-service: ${serviceInstanceId}") + LOGGER.info("Input Request: ${siRequest}, reqId: ${requestId}, e2eslice-service: ${serviceInstanceId}") //subscriberInfo checkAndSetRequestParam(siRequest,"globalSubscriberId",false, execution) @@ -82,17 +82,17 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { execution.setVariable("progress", "0") execution.setVariable("result", "processing") execution.setVariable("operationType", "DELETE") - execution.setVariable("operationContent", "Prepare init service") + execution.setVariable("operationContent", "Delete Slice service operation start") updateServiceOperationStatus(execution) } catch (BpmnError e) { throw e } catch (Exception ex) { msg = "Exception in preProcessRequest " + ex.getMessage() - logger.debug(msg) + LOGGER.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.trace("Exit preProcessRequest") + LOGGER.debug("*****${PREFIX} Exit preProcessRequest *****") } /** @@ -100,40 +100,39 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { * @param execution */ void sendAsyncResponse(DelegateExecution execution) { - logger.trace("Staring sendSyncResponse") + LOGGER.trace("${PREFIX} Start sendSyncResponse ") try { String operationId = execution.getVariable("operationId") String syncResponse = """{"operationId":"${operationId}"}""".trim() - logger.info("sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) + LOGGER.info("sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse) sendWorkflowResponse(execution, 202, syncResponse) } catch (Exception ex) { String msg = "Exception in sendSyncResponse: " + ex.getMessage() exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } - logger.trace("Exit sendSyncResponse") + LOGGER.trace("${PREFIX} Exit sendSyncResponse") } /** * Deletes the slice service instance in aai */ void deleteSliceServiceInstance(DelegateExecution execution) { - logger.trace("Entered deleteSliceServiceInstance") + LOGGER.trace("${PREFIX} Start deleteSliceServiceInstance") try { - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), execution.getVariable("serviceInstanceId")) - resourceClient.delete(serviceInstanceUri) + getAAIClient().delete(serviceInstanceUri) execution.setVariable("progress", "100") execution.setVariable("result", "finished") execution.setVariable("operationContent", "NSMF completes slicing service termination.") updateServiceOperationStatus(execution) - logger.trace("Exited deleteSliceServiceInstance") + LOGGER.trace("${PREFIX} Exited deleteSliceServiceInstance") }catch(Exception e){ - logger.debug("Error occured within deleteSliceServiceInstance method: " + e) + LOGGER.debug("Error occured within deleteSliceServiceInstance method: " + e) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Error occured during deleteSliceServiceInstance from aai") } } @@ -161,7 +160,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { * delete service profile from aai * @param execution */ - private void delServiceProfileFromAAI(DelegateExecution execution) + void delServiceProfileFromAAI(DelegateExecution execution) { String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") @@ -170,9 +169,8 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { try { - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, globalSubscriberId, serviceType, serviceInstanceId) - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) Optional<ServiceProfiles> serviceProfilesOpt =wrapper.asBean(ServiceProfiles.class) if(serviceProfilesOpt.isPresent()){ ServiceProfiles serviceProfiles = serviceProfilesOpt.get() @@ -180,29 +178,27 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { profileId = serviceProfile ? serviceProfile.getProfileId() : "" } resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, globalSubscriberId, serviceType, serviceInstanceId, profileId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } - resourceClient.delete(resourceUri) + getAAIClient().delete(resourceUri) } catch (any) { String msg = "delete service profile from aai failed! cause-"+any.getCause() - logger.error(any.printStackTrace()) + LOGGER.error(any.printStackTrace()) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } } void sendSyncError(DelegateExecution execution) { - logger.info("Starting sendSyncError") + LOGGER.debug("${PREFIX} Start sendSyncError") try { - String errorMessage + String errorMessage = "Sending Sync Error." if (execution.getVariable("WorkflowException") instanceof WorkflowException) { WorkflowException wfe = execution.getVariable("WorkflowException") errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." } String buildworkflowException = @@ -211,17 +207,17 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { <aetgt:ErrorCode>7000</aetgt:ErrorCode> </aetgt:WorkflowException>""" - logger.debug(buildworkflowException) + LOGGER.debug(buildworkflowException) sendWorkflowResponse(execution, 500, buildworkflowException) } catch (Exception ex) { - logger.error("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) + LOGGER.error("Sending Sync Error Activity Failed. " + "\n" + ex.getMessage()) } } void prepareEndOperationStatus(DelegateExecution execution){ - logger.debug(" ======== STARTED prepareEndOperationStatus Process ======== ") + LOGGER.debug(" ======== ${PREFIX} STARTED prepareEndOperationStatus Process ======== ") execution.setVariable("progress", "100") execution.setVariable("result", "error") @@ -233,7 +229,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { execution.setVariable("reason",errorMessage) updateServiceOperationStatus(execution) - logger.debug("======== COMPLETED prepareEndOperationStatus Process ======== ") + LOGGER.debug("======== ${PREFIX} COMPLETED prepareEndOperationStatus Process ======== ") } /** @@ -250,7 +246,7 @@ class DeleteSliceService extends AbstractServiceTaskProcessor { String paramValue = jsonUtil.getJsonValue(siRequest, paraName) if (isBlank(paramValue)) { msg = "Input ${paraName} is null" - logger.error(msg) + LOGGER.error(msg) if(isErrorException) { exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy index 79aa745792..fd30722369 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy @@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.VidUtils; import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy index 9fa488f8a7..eb2ec2bc9d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -38,7 +38,7 @@ import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory 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 15b91e5221..6af7cc069e 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 @@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializationFeature import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy index 2def9e2d06..4835c9b84b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy @@ -33,7 +33,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index dafc4b5470..c12d3553d5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -25,7 +25,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy index 4bab2b390d..573282dafd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -38,7 +38,7 @@ import org.onap.so.client.aai.AAIObjectPlurals import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory 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 e9b748b14b..823217c4f7 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 @@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.db.catalog.beans.HomingInstance -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy index 180032c8f0..e60fab5766 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy @@ -41,7 +41,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.logger.MessageEnum diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy index a6cb5cf4cc..150f55316c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy index a88becad1a..72f71686d9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy index 48e4fdf2ff..bc535a348f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.aai.domain.yang.AllottedResource -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.ws.rs.core.UriBuilder diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy index d8897a2468..8d8e97328d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSI.groovy @@ -76,7 +76,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * * @param execution */ - private void prepareDecomposeService(DelegateExecution execution) + void prepareDecomposeService(DelegateExecution execution) { LOGGER.trace(" *****${PREFIX} Start prepareDecomposeService *****") try @@ -103,7 +103,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * get vendor Info * @param execution */ - private void processDecomposition(DelegateExecution execution) { + void processDecomposition(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start processDecomposition *****") try { @@ -130,7 +130,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * send deallocate request to nssmf * @param execution */ - private void sendRequestToNSSMF(DelegateExecution execution) + void sendRequestToNSSMF(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start sendRequestToNSSMF *****") def currentNSSI = execution.getVariable("currentNSSI") @@ -160,7 +160,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor URL url = new URL(nssmfRequest) LOGGER.info("deallocate nssmfRequest:${nssmfRequest}, reqBody: ${json}") - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) Response httpResponse = httpClient.post(json) checkNssmfResponse(httpResponse, execution) @@ -176,7 +176,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * send to nssmf query progress * @param execution */ - private void getJobStatus(DelegateExecution execution) + void getJobStatus(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") String jobId = currentNSSI['jobId'] @@ -198,7 +198,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor URL url = new URL(nssmfRequest) LOGGER.info("get deallocate job status, nssmfRequest:${nssmfRequest}, requestBody: ${json}") - HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) + HttpClient httpClient = getHttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL) Response httpResponse = httpClient.post(json) checkNssmfResponse(httpResponse, execution) @@ -248,7 +248,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * prepare update requestdb * @param execution */ - private void handleJobStatus(DelegateExecution execution) + void handleJobStatus(DelegateExecution execution) { def currentNSSI = execution.getVariable("currentNSSI") int currentProgress = currentNSSI["jobProgress"] @@ -267,7 +267,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor LOGGER.debug("update operation, currentProgress=${currentProgress}, proportion=${proportion}, progress = ${progress}" ) } - private void timeDelay(DelegateExecution execution) { + void timeDelay(DelegateExecution execution) { try { Thread.sleep(10000); } catch(InterruptedException e) { @@ -279,7 +279,7 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor * delete slice profile from aai * @param execution */ - private void delSliceProfileFromAAI(DelegateExecution execution) + void delSliceProfileFromAAI(DelegateExecution execution) { LOGGER.debug("*****${PREFIX} start delSliceProfileFromAAI *****") def currentNSSI = execution.getVariable("currentNSSI") @@ -291,12 +291,11 @@ class DoDeallocateNSSI extends AbstractServiceTaskProcessor try { LOGGER.debug("delete nssiServiceInstanceId:${nssiServiceInstanceId}, profileId:${profileId}") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, globalSubscriberId, serviceType, nssiServiceInstanceId, profileId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } - resourceClient.delete(resourceUri) + getAAIClient().delete(resourceUri) } catch (any) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 09eb7994a8..89c5be8d6e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -45,7 +45,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy index 7c2a2be6ac..76086dab49 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceService.groovy @@ -29,7 +29,6 @@ import org.onap.aai.domain.yang.SliceProfiles import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.client.aai.AAIObjectType -import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory @@ -309,12 +308,11 @@ class DoDeleteSliceService extends AbstractServiceTaskProcessor { String globalSubscriberId = execution.getVariable("globalSubscriberId") String serviceType = execution.getVariable("serviceType") - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(aaiObjectType, globalSubscriberId, serviceType, instanceId) - if (!resourceClient.exists(resourceUri)) { + if (!getAAIClient().exists(resourceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMsg) } - AAIResultWrapper wrapper = resourceClient.get(resourceUri, NotFoundException.class) + AAIResultWrapper wrapper = getAAIClient().get(resourceUri, NotFoundException.class) LOGGER.trace(" *****${PREFIX} Exit queryAAI *****") return wrapper } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy index 4c8247a309..511f461844 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy @@ -25,7 +25,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.aai.domain.yang.NetworkPolicies import org.onap.aai.domain.yang.NetworkPolicy -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy index eba43632a7..9c8bd156a9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy @@ -27,7 +27,7 @@ import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.NetworkPolicies import org.onap.aai.domain.yang.NetworkPolicy import org.onap.aai.domain.yang.VfModule -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* import org.camunda.bpm.engine.delegate.BpmnError diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy index 20d250d89f..ff58fd567d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy @@ -45,7 +45,7 @@ import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.aai.AAIObjectType -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy index 231fe6e252..4eba33dc7d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy @@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.*; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy index 367975e003..16e1241750 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy @@ -34,7 +34,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.camunda.bpm.engine.delegate.BpmnError import com.fasterxml.jackson.databind.ObjectMapper import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.ws.rs.core.Response diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy index 63cd3c72f9..5acc016c7b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy @@ -36,7 +36,7 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy index f7852431e5..854584fea9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy @@ -45,7 +45,7 @@ import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy index cfdba89db7..7caa63ec72 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy @@ -24,7 +24,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import javax.ws.rs.core.Response import org.camunda.bpm.engine.delegate.BpmnError diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy index e36f32578d..275cef0b0c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy @@ -35,7 +35,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.aai.* import org.onap.so.client.appc.ApplicationControllerOrchestrator import org.onap.so.client.appc.ApplicationControllerSupport -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy index ed65616d89..d5bdb73b61 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy @@ -22,7 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.ExceptionUtil diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy index b21efdd563..b27ca4a956 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy @@ -23,7 +23,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy index 6946eebc56..6e5ee01c9a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy @@ -29,7 +29,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy index 2404169493..76702eab81 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy @@ -30,7 +30,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy index 3e9b934a2e..f1fbafc7de 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy @@ -37,7 +37,7 @@ import org.onap.so.client.aai.entities.Relationships import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy index 7f2bbebc8d..5449ba6708 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -42,7 +42,7 @@ import org.onap.so.client.aai.entities.Relationships import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy index 26a509022c..053e2b36d1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy @@ -35,7 +35,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.aai.AAIRestClientImpl import org.onap.so.client.aai.AAIUpdatorImpl import org.onap.so.client.aai.AAIValidatorImpl -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy index 09e7516f85..e423ecc83c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy @@ -46,7 +46,7 @@ import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.appc.ApplicationControllerClient import org.onap.so.client.appc.ApplicationControllerSupport -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy index 90523a02be..d11f4c19eb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy @@ -33,7 +33,7 @@ import org.onap.so.client.aai.* import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy index 3cb40115ba..34215a11aa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy @@ -39,7 +39,7 @@ import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.appc.ApplicationControllerClient import org.onap.so.client.appc.ApplicationControllerSupport -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index d57011f61f..6327ea233c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -22,7 +22,7 @@ package org.onap.so.bpmn.vcpe.scripts import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import static org.apache.commons.lang3.StringUtils.* diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy index 553ec2397c..5205fa1874 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.NetworkUtils import org.onap.so.bpmn.common.scripts.VidUtils import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy index 0681e54bba..68abcea07c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy @@ -35,7 +35,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy index f24bb46981..b5ddc57781 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy @@ -31,7 +31,7 @@ import org.onap.so.bpmn.common.scripts.AllottedResourceUtils import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy index 51d04dd092..fc50d3a3b3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy @@ -34,7 +34,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy index 1427730187..80e5831fbe 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy @@ -29,7 +29,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy index 29ee1a648e..117078992f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy @@ -32,7 +32,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy index 404f19eca9..b029a4686b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy @@ -32,7 +32,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.logger.ErrorCode +import org.onap.logging.filter.base.ErrorCode import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory 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 fab3496559..3ea8b190ad 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 @@ -35,8 +35,10 @@ public class ExecutionVariableNames { public final static String TIMEOUT_FOR_NOTIFICATION = "timeoutForPnfEntryNotification"; public final static String PNF_UUID = "pnfUuid"; public final static String SERVICE_INSTANCE_ID = "serviceInstanceId"; + public final static String REQUEST_ID = "requestId"; public final static String MSO_REQUEST_ID = "msoRequestId"; public final static String MODEL_UUID = "modelUuid"; + public final static String REQUEST_PAYLOAD = "requestPayload"; public final static String SERVICE_MODEL_INFO = "serviceModelInfo"; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java index 4482d2a327..6c140061c0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/NfSoftwareUpgradeDispatcher.java @@ -69,7 +69,7 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { @Override public void execute(DelegateExecution delegateExecution) throws Exception { - logger.debug("Running execute block for activity id:{}, name:{}", delegateExecution.getCurrentActivityId(), + logger.debug("Running execute block for activity id: {}, name: {}", delegateExecution.getCurrentActivityId(), delegateExecution.getCurrentActivityName()); RequestDetails bpmnRequestDetails = requestVerification(delegateExecution); @@ -82,9 +82,10 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { final List<PnfResourceCustomization> pnfCustomizations = getPnfResourceCustomizations(delegateExecution, serviceModelUuid); final PnfResourceCustomization pnfResourceCustomization = pnfCustomizations.get(0); + final String payload = bpmnRequestDetails.getRequestParameters().getPayload(); populateExecution(delegateExecution, bpmnRequestDetails, pnfResourceCustomization, pnf, serviceInstanceName, - pnfName, serviceModelUuid, userParams); + pnfName, serviceModelUuid, userParams, payload); logger.trace("Completed preProcessRequest PnfSoftwareUpgradeServiceRequest Request "); } @@ -104,7 +105,7 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { private void populateExecution(DelegateExecution delegateExecution, RequestDetails bpmnRequestDetails, PnfResourceCustomization pnfResourceCustomization, Pnf pnf, String serviceInstanceName, String pnfName, - String serviceModelUuid, List<Map<String, Object>> userParams) { + String serviceModelUuid, List<Map<String, Object>> userParams, String payload) { delegateExecution.setVariable(SERVICE_MODEL_INFO, bpmnRequestDetails.getModelInfo()); delegateExecution.setVariable(SERVICE_INSTANCE_NAME, serviceInstanceName); @@ -124,6 +125,8 @@ public class NfSoftwareUpgradeDispatcher implements JavaDelegate { delegateExecution.setVariable(param.get("name").toString(), param.get("value").toString()); } } + + delegateExecution.setVariable(REQUEST_PAYLOAD, payload); } private Pnf getPnfByPnfName(DelegateExecution delegateExecution, String pnfName) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 7f2cd5c071..109f45e6eb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -71,7 +71,7 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.Relationships; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java index f933277f3c..de8a35de06 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java @@ -45,7 +45,7 @@ import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi; import org.onap.so.db.request.beans.ResourceOperationStatus; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.requestsdb.RequestsDbConstant; import org.slf4j.Logger; diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy index 7e02779f10..3eefd31e63 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateCommunicationServiceTest.groovy @@ -57,11 +57,11 @@ class ActivateCommunicationServiceTest extends MsoGroovyTest { when(mockExecution.getVariable("bpmnRequest")).thenReturn(req) when(mockExecution.getVariable("mso-request-id")).thenReturn("54321") when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") - + when(mockExecution.getVariable("operationType")).thenReturn("activation") ActivateCommunicationService service = new ActivateCommunicationService() service.preProcessRequest(mockExecution) - Mockito.verify(mockExecution, times(5)).setVariable(captor.capture(), captor.capture()) + Mockito.verify(mockExecution, times(6)).setVariable(captor.capture(), captor.capture()) } @Test diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy new file mode 100644 index 0000000000..f3c61dd628 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceServiceTest.groovy @@ -0,0 +1,118 @@ +package org.onap.so.bpmn.infrastructure.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class ActivateSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("ActivateSliceService") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest() { + + String req = """ + { + "globalSubscriberId": "5GCustomer", + "serviceType": "5G", + "operationId": "test123" + } + """ + when(mockExecution.getVariable("bpmnRequest")).thenReturn(req) + when(mockExecution.getVariable("mso-request-id")).thenReturn("54321") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationType")).thenReturn("activation") + + + ActivateSliceService service = new ActivateSliceService() + service.preProcessRequest(mockExecution) + Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture()) + } + + @Test + void testPrepareInitOperationStatus() { + + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + + ActivateSliceService service = new ActivateSliceService() + + service.prepareInitServiceOperationStatus(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + assertNotNull(res) + } + + @Test + void testSendSyncResponse() { + when(mockExecution.getVariable("operationId")).thenReturn("123456") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + ActivateSliceService service = new ActivateSliceService() + service.sendSyncResponse(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("sentSyncResponse"), captor.capture()) + def updateVolumeGroupRequest = captor.getValue() + assertEquals(updateVolumeGroupRequest, true) + } + + private static getExpectPayload = { String type, String result, String progress, String operationContent -> + String expect = + """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:ns="http://org.onap.so/requestsdb"> + <soapenv:Header/> + <soapenv:Body> + <ns:${type} xmlns:ns="http://org.onap.so/requestsdb"> + <serviceId>12345</serviceId> + <operationId>54321</operationId> + <operationType>activate</operationType> + <userId>11111</userId> + <result>${result}</result> + <operationContent>${operationContent}</operationContent> + <progress>${progress}</progress> + <reason></reason> + </ns:${type}> + </soapenv:Body> + </soapenv:Envelope> + """ + return expect + } + + @Test + void testPrepareCompleteStatus() { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("operationId")).thenReturn("54321") + when(mockExecution.getVariable("operationType")).thenReturn("activate") + when(mockExecution.getVariable("operationContent")) + .thenReturn("slice service activate operation finished") + + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("11111") + when(mockExecution.getVariable("operationStatus")) + .thenReturn("deactivated") + ActivateSliceService service = new ActivateSliceService() + + service.prepareCompletionRequest(mockExecution) + Mockito.verify(mockExecution, times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String res = captor.getValue() + + String expect = getExpectPayload("updateServiceOperationStatus", "finished", "100", + "slice service activate operation finished") + + assertEquals(expect.replaceAll("\\s+", ""), res.replaceAll("\\s+", "")) + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy new file mode 100644 index 0000000000..8c08e51efe --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCommunicationServiceTest.groovy @@ -0,0 +1,308 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.* + +class DeleteCommunicationServiceTest extends MsoGroovyTest { + + private HttpClientFactory httpClientFactoryMock + private HttpClient httpClientMock + + @Before + void init() throws IOException { + super.init("DeleteCommunicationServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "globalSubscriberId ":"5GCustomer", + "serviceType ":"5G" + }""".replaceAll("\\\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + + DeleteCommunicationService delCS = new DeleteCommunicationService() + delCS.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(3)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testPreInitUpdateOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("processing") + when(mockExecution.getVariable("progress")).thenReturn("0") + when(mockExecution.getVariable("operationContent")).thenReturn("delete communication service operation start") + + DeleteCommunicationService delCS = new DeleteCommunicationService() + delCS.preInitUpdateOperationStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testQueryCommunicationSeriveFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.queryCommunicationSeriveFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("e2eSliceServiceInstanceId"), captor.capture()) + String e2eSliceServiceInstanceId = captor.getValue() + assertNotNull(e2eSliceServiceInstanceId) + } + + @Test + void testPrepareCallCheckProcessStatus(){ + DeleteCommunicationService dcs = new DeleteCommunicationService() + dcs.prepareCallCheckProcessStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("endProgress"), captor.capture()) + int endProgress = captor.getValue() + assertEquals(90,endProgress) + } + + @Test + void testDelCSProfileFromAAI() + { + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryCommunicationServiceProfile()) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.COMMUNICATION_SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-111111") + + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + doNothing().when(client).delete(profileUri) + obj.delCSProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testPrepareFailureStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("finished") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure.") + + DeleteCommunicationService dcs = new DeleteCommunicationService() + dcs.prepareFailureStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelCSFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + when(obj.getAAIClient()).thenReturn(client) + doNothing().when(client).delete(serviceInstanceUri) + + obj.delCSFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testPreFailedOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("error") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure") + + DeleteCommunicationService deleteCommunicationService = new DeleteCommunicationService() + WorkflowException exception = new WorkflowException("11113",7000,"terminate service failure") + when(mockExecution.getVariable("WorkflowException")).thenReturn(exception) + deleteCommunicationService.preFailedOperationStatus(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testSendRequest2NSMFWF(){ + httpClientMock = mock(HttpClient.class) + httpClientFactoryMock = mock(HttpClientFactory.class) + String url ="http://so.onap:8080/onap/so/infra/e2eServiceInstances/v3/5G-777" + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("progress")).thenReturn("20") + when(mockExecution.getVariable("operationContent")).thenReturn("waiting nsmf service delete finished") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://so.onap:8080/onap/so/infra") + when(mockExecution.getVariable("e2eSliceServiceInstanceId")).thenReturn("5G-777") + when(mockExecution.getVariable("e2eOperationId")).thenReturn("e151059a-d924-4629-845f-264db19e50b3") + when(httpClientFactoryMock.newJsonClient(new URL(url), ONAPComponents.SO)).thenReturn(httpClientMock) + DeleteCommunicationService obj = spy(DeleteCommunicationService.class) + + Response responseMock = mock(Response.class) + when(responseMock.getStatus()).thenReturn(200) + when(responseMock.hasEntity()).thenReturn(true) + when(responseMock.getEntity()).thenReturn(getNSSMFResponse()) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + when(httpClientMock.delete(anyString())).thenReturn(responseMock) + + obj.sendRequest2NSMFWF(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + private String getNSSMFResponse(){ + String response = """{ + "service":{ + "serviceId":"e151059a-d924-4629-845f-264db19e50b4", + "operationId":"e151059a-d924-4629-845f-264db19e50b3" + } + }""" + return response + } + + + + + private String mockQueryCommunicationServiceReturn() + { + String expect = + """{ + "service-instance-id": "5G-666", + "service-instance-name": "eMBB_Slice_Communication_Service_5GCustomer", + "service-type": "eMBB", + "service-role": "communication-service", + "environment-context": "01-010101", + "workload-context": "12", + "created-at": "2019-12-11 19:56:00", + "description": "", + "model-invariant-id": "e75698d9-925a-4cdd-a6c0-edacbe6a0b51", + "model-version-id": "8ee5926d-720b-4bb2-86f9-d20e921c143b", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1582623470778", + "orchestration-status": "created", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-777", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-777" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + }""" + return expect + } + + private String mockQueryCommunicationServiceProfile() + { + String expect = + """{ + "communication-service-profile": [ + { + "profile-id": "5G-111111", + "max-number-of-UEs": 50, + "coverage-area-list": "longgang,futian", + "latency": 20, + "exp-data-rate-UL": 300, + "exp-data-rate-DL": 500, + "ue-mobility-level": "stationary", + "resource-sharing-level": "Non-Shared", + "resource-version": "1577454950460" + } + ] + }""" + return expect + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy new file mode 100644 index 0000000000..fb50fcc43b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSliceServiceTest.groovy @@ -0,0 +1,171 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.NotFoundException + +import static org.junit.Assert.assertNotNull +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when +import static org.mockito.Mockito.when + +class DeleteSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("eb0863e9-a69b-4b17-8a56-f05ad110bef7") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("result")).thenReturn("processing") + when(mockExecution.getVariable("progress")).thenReturn("0") + when(mockExecution.getVariable("operationContent")).thenReturn("Delete Slice service operation start") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(""" + { + "globalSubscriberId ":"5GCustomer", + "serviceType ":"5G" + }""".replaceAll("\\\\s+", "")) + when(mockExecution.getVariable("mso-request-id")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + + DeleteSliceService delSS = new DeleteSliceService() + delSS.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus = captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDeleteSliceServiceInstance(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + when(mockExecution.getVariable("result")).thenReturn("finished") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("NSMF completes slicing service termination.") + + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DeleteSliceService obj = spy(DeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + doNothing().when(client).delete(serviceInstanceUri) + + obj.deleteSliceServiceInstance(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelServiceProfileFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceProfile()) + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_PROFILE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be", "5G-2222222") + + DeleteSliceService obj = spy(DeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + doNothing().when(client).delete(profileUri) + obj.delServiceProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testPrepareEndOperationStatus(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceName")).thenReturn("5G-test") + when(mockExecution.getVariable("result")).thenReturn("error") + when(mockExecution.getVariable("progress")).thenReturn("100") + when(mockExecution.getVariable("operationContent")).thenReturn("terminate service failure") + + DeleteSliceService deleteSliceService = new DeleteSliceService() + WorkflowException exception = new WorkflowException("11113",7000,"terminate service failure") + when(mockExecution.getVariable("WorkflowException")).thenReturn(exception) + deleteSliceService.prepareEndOperationStatus(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + + } + + private String mockQuerySliceServiceProfile(){ + String expect = + """{ + "service-profile": [ + { + "profile-id": "5G-2222222", + "latency": 50, + "max-number-of-UEs": 500, + "coverage-area-TA-list": "longgang,futian", + "ue-mobility-level": "stationary", + "resource-sharing-level": "Non-Shared", + "exp-data-rate-UL": 10, + "exp-data-rate-DL": 30, + "area-traffic-cap-UL": 100, + "area-traffic-cap-DL": 100, + "activity-factor": 80, + "jitter": 10, + "survival-time": 30, + "cs-availability": 95.5, + "reliability": 99.9, + "exp-data-rate": 80, + "traffic-density": 100, + "conn-density": 80, + "resource-version": "1577454958647" + } + ] + }""" + return expect + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy new file mode 100644 index 0000000000..493e2c9e1e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateNSSITest.groovy @@ -0,0 +1,258 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.JobStatusResponse +import org.onap.so.beans.nsmf.NssiResponse +import org.onap.so.beans.nsmf.ResponseDescriptor +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.bpmn.core.domain.ServiceArtifact +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceInfo +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.core.Response + +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.anyString +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.when + +class DoDeallocateNSSITest extends MsoGroovyTest { + + private HttpClientFactory httpClientFactoryMock + private HttpClient httpClientMock + + @Before + void init() throws IOException { + super.init("DoDeallocateNSSITest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + + @Test + void testPreProcessRequest(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.preProcessRequest(mockExecution) + Mockito.verify(mockExecution,times(1)).getVariable("currentNSSI") + } + + @Test + void testPrepareDecomposeService(){ + def currentNSSI = [:] + currentNSSI.put("modelInvariantId", "21d57d4b-52ad-4d3c-a798-248b5bb9124b") + currentNSSI.put("modelVersionId", "bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.prepareDecomposeService(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("serviceModelInfo"), captor.capture()) + String serviceModelInfo = captor.getValue() + assertNotNull(serviceModelInfo) + } + + @Test + void testProcessDecomposition(){ + def currentNSSI = [:] + ServiceArtifact artifact = new ServiceArtifact() + artifact.setContent(getArtifactContent()) + ServiceInfo serviceInfo = new ServiceInfo() + List<ServiceArtifact> artifactList = new ArrayList<>() + artifactList.add(artifact) + serviceInfo.setServiceArtifact(artifactList) + ServiceDecomposition decomposition = new ServiceDecomposition() + decomposition.setServiceInfo(serviceInfo) + when(mockExecution.getVariable("serviceDecomposition")).thenReturn(decomposition) + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.processDecomposition(mockExecution) + String vendor = currentNSSI.get("vendor") + assertNotNull(vendor) + } + + @Test + void testHandleJobStatus(){ + def currentNSSI = [:] + currentNSSI.put("jobProgress", 10) + currentNSSI.put("proportion", 90) + currentNSSI.put("statusDescription","") + currentNSSI.put("e2eServiceInstanceId","21d57d4b-52ad-4d3c-a798-248b5bb9124b") + currentNSSI.put("operationId","4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + DoDeallocateNSSI ddnssi = new DoDeallocateNSSI() + ddnssi.handleJobStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("updateOperationStatus"), captor.capture()) + String updateOperationStatus= captor.getValue() + assertNotNull(updateOperationStatus) + } + + @Test + void testDelSliceProfileFromAAI(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId", "5G-999") + currentNSSI.put("profileId", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + currentNSSI.put("globalSubscriberId","5GCustomer") + currentNSSI.put("serviceType","5G") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, "5GCustomer", "5G", "5G-999", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(profileUri)).thenReturn(true) + doNothing().when(client).delete(profileUri) + + obj.delSliceProfileFromAAI(mockExecution) + Mockito.verify(client,times(1)).delete(profileUri) + } + + @Test + void testSendRequestToNSSMF(){ + httpClientFactoryMock = mock(HttpClientFactory.class) + httpClientMock = mock(HttpClient.class) + + def currentNSSI = [:] + currentNSSI.put("snssai", "01-010101") + currentNSSI.put("profileId", "ddf57704-fe8d-417b-882d-2f2a12ddb225") + currentNSSI.put("nssiServiceInstanceId","5G-999") + currentNSSI.put("nsiServiceInstanceId","5G-888") + + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("mso.adapters.nssmf.endpoint")).thenReturn("http://so-nssmf-adapter.onap:8088") + String nssmfRequest = "http://so-nssmf-adapter.onap:8088/api/rest/provMns/v1/NSS/SliceProfiles/ddf57704-fe8d-417b-882d-2f2a12ddb225" + + when(httpClientFactoryMock.newJsonClient(new URL(nssmfRequest), ONAPComponents.EXTERNAL)).thenReturn(httpClientMock) + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + Response responseMock = mock(Response.class) + NssiResponse response = new NssiResponse() + response.setNssiId("NSSI-C-004-HDBHZ-NSSMF-01-A-HW") + response.setJobId("a5c5913d-448a-bcb1-9b800a944d84") + when(httpClientMock.post(anyString())).thenReturn(responseMock) + when(responseMock.getStatus()).thenReturn(202) + when(responseMock.readEntity(NssiResponse.class)) thenReturn(response) + when(responseMock.hasEntity()).thenReturn(true) + + obj.sendRequestToNSSMF(mockExecution) + String jobId = currentNSSI['jobId'] + assertNotNull(jobId) + } + + @Test + void testGetJobStatus(){ + httpClientFactoryMock = mock(HttpClientFactory.class) + httpClientMock = mock(HttpClient.class) + + def currentNSSI = [:] + currentNSSI.put("jobId", "a5c5913d-448a-bcb1-9b800a944d84") + currentNSSI.put("nssiServiceInstanceId","5G-999") + currentNSSI.put("nsiServiceInstanceId","5G-888") + currentNSSI.put("jobProgress",60) + + when(mockExecution.getVariable("isNSSIDeAllocated")).thenReturn(false) + when(mockExecution.getVariable("isNSSIDeAllocated")).thenReturn(false) + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("mso.adapters.nssmf.endpoint")).thenReturn("http://so-nssmf-adapter.onap:8088") + String nssmfRequest = "http://so-nssmf-adapter.onap:8088/api/rest/provMns/v1/NSS/jobs/a5c5913d-448a-bcb1-9b800a944d84" + + when(httpClientFactoryMock.newJsonClient(new URL(nssmfRequest), ONAPComponents.EXTERNAL)).thenReturn(httpClientMock) + DoDeallocateNSSI obj = spy(DoDeallocateNSSI.class) + when(obj.getHttpClientFactory()).thenReturn(httpClientFactoryMock) + Response responseMock = mock(Response.class) + ResponseDescriptor descriptor = new ResponseDescriptor() + descriptor.setProgress(100) + descriptor.setStatusDescription("finished deallocate nssi") + JobStatusResponse jobStatusResponse = new JobStatusResponse() + jobStatusResponse.setResponseDescriptor(descriptor) + when(httpClientMock.post(anyString())).thenReturn(responseMock) + when(responseMock.getStatus()).thenReturn(202) + when(responseMock.readEntity(JobStatusResponse.class)) thenReturn(jobStatusResponse) + when(responseMock.hasEntity()).thenReturn(true) + + obj.getJobStatus(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("isNSSIDeAllocated"), captor.capture()) + boolean value = captor.getValue() + assertTrue(value) + } + + + private String getArtifactContent(){ + String content = + """ + { + "metadata":{ + "id":"NSST-C-001-HDBNJ-NSSMF-01-A-HW", + "vendor":"HW", + "version":"1.0", + "name":"eMBB_demo", + "description":"eMBB for demo", + "type":"embb", + "domainType":"cn" + }, + "capabilities":{ + "latency":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"20" + }, + "areaTrafficCapDL":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + }, + "areaTrafficCapUL":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + }, + "maxNumberofUEs":{ + "type":"integer", + "constrainstsl":"less_or_equal", + "value":"300" + } + } + } + """ + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy new file mode 100644 index 0000000000..8a18376819 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteSliceServiceTest.groovy @@ -0,0 +1,460 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # 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.scripts + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mockito +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.so.bpmn.common.scripts.MsoGroovyTest +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory + +import javax.ws.rs.NotFoundException + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.Mockito.doNothing +import static org.mockito.Mockito.spy +import static org.mockito.Mockito.times +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when + +class DoDeleteSliceServiceTest extends MsoGroovyTest { + @Before + void init() throws IOException { + super.init("DoDeleteSliceServiceTest") + } + + @Captor + static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) + + @Test + void testPreProcessRequest(){ + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("e2a747a0-2ca6-476d-ac28-de999cf3fbfe") + + DoDeleteSliceService doDeleteSliceService = new DoDeleteSliceService() + doDeleteSliceService.preProcessRequest(mockExecution) + + Mockito.verify(mockExecution,times(1)).setVariable(captor.capture() as String, captor.capture()) + List<ExecutionEntity> values = captor.getAllValues() + assertNotNull(values) + } + + @Test + void testQueryE2ESliceSeriveFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQuerySliceServiceReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.queryE2ESliceSeriveFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("snssai"), captor.capture()) + String snssai = captor.getValue() + assertNotNull(snssai) + } + + @Test + void testGetAllottedResFromAAI(){ + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5ad89cf9-0569-4a93-9306-d8324321e2be") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE_ALL, "5GCustomer", "5G", "5ad89cf9-0569-4a93-9306-d8324321e2be") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockQueryAllottedResource()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getAllottedResFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nsiId"), captor.capture()) + String nsiId = captor.getValue() + assertNotNull(nsiId) + } + + @Test + void testGetNSIFromAAI(){ + when(mockExecution.getVariable("nsiId")).thenReturn("5G-888") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-888") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockNSIReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getNSIFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nssiIdList"), captor.capture()) + List<String> nssiIdList = captor.getValue() + assertNotNull(nssiIdList) + } + + @Test + void testGetNSSIListFromAAI(){ + List<String> nssiIdList = [] + nssiIdList.add("5G-999") + + when(mockExecution.getVariable("nssiIdList")).thenReturn(nssiIdList) + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5GCustomer", "5G", "5G-999") + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + + AAIResultWrapper wrapper = new AAIResultWrapper(mockNSSIReturn()) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(resourceUri)).thenReturn(true) + when(client.get(resourceUri, NotFoundException.class)).thenReturn(wrapper) + obj.getNSSIListFromAAI(mockExecution) + Mockito.verify(mockExecution,times(1)).setVariable(eq("nssiInstanceList"), captor.capture()) + List<ServiceInstance> nssiInstanceList = captor.getValue() + assertNotNull(nssiInstanceList) + } + + @Test + void testGetCurrentNSSI(){ + ServiceInstance nssi = new ServiceInstance() + nssi.setServiceInstanceId("5G-999") + nssi.setModelInvariantId("21d57d4b-52ad-4d3c-a798-248b5bb9124a") + nssi.setModelVersionId("bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + List<ServiceInstance> nssiInstanceList = [] + nssiInstanceList.add(nssi) + when(mockExecution.getVariable("currentNSSIIndex")).thenReturn(0) + when(mockExecution.getVariable("nssiInstanceList")).thenReturn(nssiInstanceList) + when(mockExecution.getVariable("snssai")).thenReturn("01-010101") + when(mockExecution.getVariable("nsiId")).thenReturn("5G-888") + when(mockExecution.getVariable("operationId")).thenReturn("998c2081-5a71-4a39-9ae6-d6b7c5bb50c0") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("5G-777") + when(mockExecution.getVariable("msoRequestId")).thenReturn("4c614769-f58a-4556-8ad9-dcd903077c82") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + when(mockExecution.getVariable("proportion")).thenReturn("90") + + DoDeleteSliceService ddss = new DoDeleteSliceService() + ddss.getCurrentNSSI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("currentNSSI"), captor.capture()) + Map currentNSSI = captor.getValue() + assertTrue(currentNSSI.size()>0) + } + + @Test + void testQuerySliceProfileFromAAI(){ + def currentNSSI = [:] + currentNSSI.put("nssiServiceInstanceId","5G-999") + when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI) + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("5GCustomer") + when(mockExecution.getVariable("serviceType")).thenReturn("5G") + + AAIResultWrapper wrapper = new AAIResultWrapper(mockSliceProfile()) + AAIResourceUri profileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE_ALL, "5GCustomer", "5G", "5G-999") + + DoDeleteSliceService obj = spy(DoDeleteSliceService.class) + when(obj.getAAIClient()).thenReturn(client) + when(client.exists(profileUri)).thenReturn(true) + when(client.get(profileUri, NotFoundException.class)).thenReturn(wrapper) + obj.querySliceProfileFromAAI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("currentNSSI"), captor.capture()) + Map value = captor.getValue() + assertNotNull(currentNSSI.get('profileId')) + } + + @Test + void parseNextNSSI(){ + ServiceInstance nssi = new ServiceInstance() + nssi.setServiceInstanceId("5G-999") + nssi.setModelInvariantId("21d57d4b-52ad-4d3c-a798-248b5bb9124b") + nssi.setModelVersionId("bfba363e-e39c-4bd9-a9d5-1371c28f4d22") + List<ServiceInstance> nssiInstanceList = [] + nssiInstanceList.add(nssi) + when(mockExecution.getVariable("currentNSSIIndex")).thenReturn(0) + when(mockExecution.getVariable("nssiInstanceList")).thenReturn(nssiInstanceList) + + DoDeleteSliceService ddss = new DoDeleteSliceService() + ddss.parseNextNSSI(mockExecution) + verify(mockExecution,times(1)).setVariable(eq("isAllNSSIFinished"), captor.capture()) + boolean isAllNSSIFinished = captor.getValue() + assertTrue(isAllNSSIFinished) + } + + private String mockSliceProfile(){ + String expect = + """{ + "slice-profile": [ + { + "profile-id": "ddf57704-fe8d-417b-882d-2f2a12ddb225", + "latency": 20, + "max-number-of-UEs": 0, + "coverage-area-TA-list": "[{\\"province\\":\\"??\\",\\"city\\":\\"???\\",\\"county\\":\\"???\\",\\"street\\":\\"?????\\"}]", + "ue-mobility-level": "stationary", + "resource-sharing-level": "0", + "exp-data-rate-UL": 100, + "exp-data-rate-DL": 100, + "activity-factor": 0, + "e2e-latency": 0, + "jitter": 0, + "survival-time": 0, + "exp-data-rate": 0, + "payload-size": 0, + "traffic-density": 0, + "conn-density": 0, + "s-nssai": "01003", + "resource-version": "1580800791373" + } + ] + } + """ + return expect + } + + private String mockNSSIReturn(){ + String expect = + """ + { + "service-instance-id": "5G-999", + "service-instance-name": "eMBB_Slice_NSSI_5GCustomer", + "service-type": "eMBB", + "service-role": "nssi", + "environment-context": "cn", + "model-invariant-id": "21d57d4b-52ad-4d3c-a798-248b5bb9124a", + "model-version-id": "bfba363e-e39c-4bd9-a9d5-1371c28f4d22", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1578449638032", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-888", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-888" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + } + """ + return expect + } + + private String mockNSIReturn(){ + String expect = + """ + { + "service-instance-id": "5G-888", + "service-instance-name": "eMBB_e2e_Slice_Service_5GCustomer", + "service-type": "embb", + "service-role": "nsi", + "model-invariant-id": "0e9bcb9a-c832-433b-a0c1-74866768f608", + "model-version-id": "2c5fd79d-0f84-4057-9222-952cb6f27036", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1579691104911", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-999", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-999" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_Slice_NSSI_5GCustomer" + } + ] + }, + { + "related-to": "allotted-resource", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-777/allotted-resources/allotted-resource/5G-1234", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-777" + }, + { + "relationship-key": "allotted-resource.id", + "relationship-value": "5G-1234" + } + ], + "related-to-property": [ + { + "property-key": "allotted-resource.description" + }, + { + "property-key": "allotted-resource.allotted-resource-name" + } + ] + } + ] + } + } + """ + return expect + } + + private String mockQueryAllottedResource(){ + String expect = + """{ + "allotted-resource": [ + { + "id": "5G-1234", + "resource-version": "1577454983471", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-888", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-888" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_e2e_Slice_Service_5GCustomer" + } + ] + } + ] + } + } + ] + } + """ + return expect + } + + String mockQuerySliceServiceReturn(){ + String expect = + """{ + "service-instance-id": "5G-777", + "service-instance-name": "eMBB_e2e_Slice_Service_5GCustomer", + "service-type": "embb", + "service-role": "e2eslice-service", + "environment-context": "01-010101", + "model-invariant-id": "e65d737a-41e0-4ad1-958f-56defdf2e907", + "model-version-id": "f2f5967e-72d3-4c5c-b880-e214e71dba4e", + "service-instance-location-id": "300-01|300-02", + "resource-version": "1578449638436", + "orchestration-status": "activated", + "relationship-list": { + "relationship": [ + { + "related-to": "service-instance", + "relationship-label": "org.onap.relationships.inventory.ComposedOf", + "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/5G-666", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "5GCustomer" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "5G" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "5G-666" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "eMBB_Slice_Communication_Service_5GCustomer" + } + ] + } + ] + } + } + """ + return expect + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index dab5102efd..bbdcbf7ae3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -66,7 +66,7 @@ import org.onap.so.client.orchestration.AAIVfModuleResources; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.client.orchestration.AAIVolumeGroupResources; import org.onap.so.client.orchestration.AAIVpnBindingResources; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index 4522f7f2e7..415d4614da 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -42,7 +42,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java index e5f28aa4c3..8b78560521 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java @@ -38,7 +38,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.exceptions.MarshallerException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index 00d0fdc01d..332c390c7d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -50,7 +50,7 @@ import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java index 95e270a071..40034aa26c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/LcmControllerDE.java @@ -24,7 +24,6 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable; -import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,9 +43,6 @@ public abstract class LcmControllerDE implements ControllerRunnable<DelegateExec @Autowired protected List<ControllerPreparable<DelegateExecution>> prepareList; - @Autowired - protected ApplicationControllerAction client; - @Override public void prepare(ControllerContext<DelegateExecution> context) { prepareList.stream().filter(prepare -> prepare.understand(context)) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java new file mode 100644 index 0000000000..badce18a51 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/common/SoPropertyConstants.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.decisionpoint.impl.camunda.controller.common; + +public interface SoPropertyConstants { + String TARGET_SOFTWARE_VERSION = "targetSoftwareVersion"; + + String SO_ACTION = "action"; + String SO_ACTION_MODE = "mode"; + + String ACTION_ACTIVATE_N_E_SW = "activateNESw"; + String ACTION_DOWNLOAD_N_E_SW = "downloadNESw"; + String ACTION_POST_CHECK = "postCheck"; + String ACTION_PRE_CHECK = "preCheck"; + + String CONTROLLER_STATUS = "ControllerStatus"; +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java new file mode 100644 index 0000000000..b29009ff1d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilder.java @@ -0,0 +1,153 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.decisionpoint.impl.camunda.controller.sdnc; + +import java.util.Arrays; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.sdnc.lcm.beans.payload.*; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD; +import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants; + +public class SDNCLcmPayloadBuilder { + + private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilder.class); + + public static ActivateNESwPayload buildActivateNESwPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + ActivateNESwPayload activateNESwPayload = new ActivateNESwPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + activateNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)); + if (targetSwVersion == null) { + targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion"); + } + activateNESwPayload.setSwVersionToBeActivated(targetSwVersion); + + String playbookName = JsonUtils.getJsonValue(requestPayload, "activateNESwPlaybook"); + if (playbookName != null) { + activateNESwPayload.setPlaybookName(playbookName); + } + + return activateNESwPayload; + } + + public static DownloadNESwPayload buildDownloadNESwPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + DownloadNESwPayload downloadNESwPayload = new DownloadNESwPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + downloadNESwPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String swToBeDownloadedString = JsonUtils.getJsonValue(requestPayload, "swToBeDownloaded"); + SwToBeDownloadedElement[] swToBeDownloadedArray; + + ObjectMapper mapper = new ObjectMapper(); + try { + swToBeDownloadedArray = mapper.readValue(swToBeDownloadedString, SwToBeDownloadedElement[].class); + downloadNESwPayload.setSwToBeDownloaded(Arrays.asList(swToBeDownloadedArray)); + } catch (Exception e) { + logger.error("Parse SwToBeDownloaded error: ", e); + } + + String playbookName = JsonUtils.getJsonValue(requestPayload, "downloadNESwPlaybook"); + if (playbookName != null) { + downloadNESwPayload.setPlaybookName(playbookName); + } + + return downloadNESwPayload; + } + + public static UpgradePostCheckPayload buildUpgradePostCheckPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + UpgradePostCheckPayload upgradePostCheckPayload = new UpgradePostCheckPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + upgradePostCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String oldSwVersion = JsonUtils.getJsonValue(requestPayload, "oldSwVersion"); + upgradePostCheckPayload.setOldSwVersion(oldSwVersion); + + String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)); + if (targetSwVersion == null) { + targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion"); + } + upgradePostCheckPayload.setTargetSwVersion(targetSwVersion); + + String ruleName = JsonUtils.getJsonValue(requestPayload, "postCheckRuleName"); + upgradePostCheckPayload.setRuleName(ruleName); + + String additionalData = JsonUtils.getJsonValue(requestPayload, "postCheckAdditionalData"); + upgradePostCheckPayload.setAdditionalData(additionalData); + + String playbookName = JsonUtils.getJsonValue(requestPayload, "postCheckPlaybook"); + if (playbookName != null) { + upgradePostCheckPayload.setPlaybookName(playbookName); + } + + return upgradePostCheckPayload; + } + + public static UpgradePreCheckPayload buildUpgradePreCheckPayload(DelegateExecution execution) { + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + + UpgradePreCheckPayload upgradePreCheckPayload = new UpgradePreCheckPayload(); + + String ipaddressV4Oam = JsonUtils.getJsonValue(requestPayload, "ipaddressV4Oam"); + upgradePreCheckPayload.setIpaddressV4Oam(ipaddressV4Oam); + + String oldSwVersion = JsonUtils.getJsonValue(requestPayload, "oldSwVersion"); + upgradePreCheckPayload.setOldSwVersion(oldSwVersion); + + String targetSwVersion = String.valueOf(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)); + if (targetSwVersion == null) { + targetSwVersion = JsonUtils.getJsonValue(requestPayload, "targetSwVersion"); + } + upgradePreCheckPayload.setTargetSwVersion(targetSwVersion); + + String ruleName = JsonUtils.getJsonValue(requestPayload, "preCheckRuleName"); + upgradePreCheckPayload.setRuleName(ruleName); + + String additionalData = JsonUtils.getJsonValue(requestPayload, "preCheckAdditionalData"); + upgradePreCheckPayload.setAdditionalData(additionalData); + + String playbookName = JsonUtils.getJsonValue(requestPayload, "preCheckPlaybook"); + if (playbookName != null) { + upgradePreCheckPayload.setPlaybookName(playbookName); + } + + return upgradePreCheckPayload; + } + + public static String convertToSting(Object msgObject) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(msgObject); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java index db0d402f6e..ed865e058f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDE.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix + * Modifications Copyright (C) 2020 Huawei * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,16 +20,24 @@ package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.sdnc; +import java.util.List; +import java.util.UUID; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.stereotype.Component; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; +import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants; import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.LcmControllerDE; -import org.springframework.stereotype.Component; +import org.onap.so.client.sdnc.common.SDNCConstants; +import org.onap.so.client.sdnc.lcm.*; +import org.onap.so.client.sdnc.lcm.beans.*; +import org.onap.so.client.sdnc.lcm.beans.payload.*; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD; -/** - * This class is created to demonstrate how to support {@link DelegateExecution} API based SDNC controller. - * - * Function wise, it's similar to the Appc Controller, like in the AppcClient groovy code. - */ @Component public class SdncControllerDE extends LcmControllerDE { @@ -44,14 +53,33 @@ public class SdncControllerDE extends LcmControllerDE { return true; } - /** - * This method is left empty intentionally. If you are planning to use the SDNC Controller, please implement here. - * - * You can use the {@ref ApplicationControllerAction}, {@ref ApplicationControllerOrchestrator}, - * {@ref ApplicationControllerClient} or create your own SDNC Client proxy. - */ @Override protected int callLcmClient(ControllerContext<DelegateExecution> context) { + DelegateExecution execution = context.getExecution(); + + logger.debug("Running activity for id: {}, name: {}", execution.getCurrentActivityId(), + execution.getCurrentActivityName()); + + boolean result; + try { + LcmInput lcmInput = buildLcmInput(execution); + if (lcmInput != null) { + result = sendLcmRequest(execution, lcmInput); + } else { + logger.error("Build LCM Input error"); + result = false; + } + } catch (Exception e) { + logger.error("Call SDNC LCM Client failure: ", e); + result = false; + } + + if (result) { + execution.setVariable(SoPropertyConstants.CONTROLLER_STATUS, "Success"); + } else { + execution.setVariable(SoPropertyConstants.CONTROLLER_STATUS, "Failure"); + } + return 0; } @@ -59,4 +87,177 @@ public class SdncControllerDE extends LcmControllerDE { protected int getErrorCode() { return SDNC_DELEGATE_EXECUTION_ERROR_CODE; } + + private LcmOutput sendSyncRequest(String operation, LcmInput lcmInput) { + SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder(); + SDNCLcmRestClient sdncLcmRestClient; + try { + sdncLcmRestClient = sdncLcmClientBuilder.newSDNCLcmRestClient(operation); + } catch (SDNCLcmClientBuilderException e) { + logger.error("Create SDNCLcmRestClient error: ", e); + return null; + } + + return sdncLcmRestClient.sendRequest(lcmInput); + } + + private LcmOutput selectLcmOutputFromDmaapResponses(List<LcmDmaapResponse> lcmDmaapResponses, LcmInput lcmInput) { + String expectedCorrelationId = + lcmInput.getCommonHeader().getRequestId() + "-" + lcmInput.getCommonHeader().getSubRequestId(); + + for (LcmDmaapResponse lcmDmaapResponse : lcmDmaapResponses) { + String correlationId = lcmDmaapResponse.getCorrelationId(); + if (expectedCorrelationId.equals(correlationId)) { + return lcmDmaapResponse.getBody().getOutput(); + } + } + + return null; + } + + private LcmOutput sendAsyncRequest(String operation, LcmInput lcmInput) { + SDNCLcmClientBuilder sdncLcmClientBuilder = new SDNCLcmClientBuilder(); + SDNCLcmDmaapClient sdncLcmDmaapClient; + try { + sdncLcmDmaapClient = sdncLcmClientBuilder.newSDNCLcmDmaapClient(); + } catch (SDNCLcmClientBuilderException e) { + logger.error("Create SDNCLcmDmaapClient error: ", e); + return null; + } + + LcmDmaapRequest lcmDmaapRequest = SDNCLcmMessageBuilder.buildLcmDmaapRequest(operation, lcmInput); + try { + sdncLcmDmaapClient.sendRequest(lcmDmaapRequest); + } catch (Exception e) { + logger.error("SDNCLcmDmaapClient sends request error: ", e); + return null; + } + + long timeout = sdncLcmClientBuilder.getSDNCLcmProperties().getActionTimeout(); + long startTime = System.currentTimeMillis(); + while (true) { + List<LcmDmaapResponse> lcmDmaapResponses = sdncLcmDmaapClient.getResponse(); + if (lcmDmaapResponses.size() > 0) { + LcmOutput lcmOutput = selectLcmOutputFromDmaapResponses(lcmDmaapResponses, lcmInput); + if (lcmOutput != null) { + return lcmOutput; + } + } + + long stopTime = System.currentTimeMillis(); + if ((stopTime - startTime) > timeout) { + logger.error("Timeout for SDNC LCM action {}", lcmInput.getAction()); + return null; + } + } + } + + public static String toLowerHyphen(String lcmAction) { + String regex = "([a-z0-9A-Z])(?=[A-Z])"; + String replacement = "$1-"; + return lcmAction.replaceAll(regex, replacement).toLowerCase(); + } + + private LcmInput buildLcmInput(DelegateExecution execution) throws JsonProcessingException { + String requestId = String.valueOf(execution.getVariable(REQUEST_ID)); + String requestAction = String.valueOf(execution.getVariable(SoPropertyConstants.SO_ACTION)); + String pnfName = String.valueOf(execution.getVariable(PNF_CORRELATION_ID)); + logger.debug(String.format("requestId: %s, action: %s, pnfName: %s", requestId, requestAction, pnfName)); + + String requestPayload = String.valueOf(execution.getVariable(REQUEST_PAYLOAD)); + logger.debug("SO request payload: " + requestPayload); + + String lcmAction; + String lcmPayload; + + switch (requestAction) { + case SoPropertyConstants.ACTION_PRE_CHECK: + lcmAction = SDNCLcmActionConstants.UPGRADE_PRE_CHECK; + + UpgradePreCheckPayload upgradePreCheckPayload; + upgradePreCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePreCheckPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(upgradePreCheckPayload); + break; + case SoPropertyConstants.ACTION_DOWNLOAD_N_E_SW: + lcmAction = SDNCLcmActionConstants.DOWNLOAD_N_E_SW; + + DownloadNESwPayload downloadNESwPayload; + downloadNESwPayload = SDNCLcmPayloadBuilder.buildDownloadNESwPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(downloadNESwPayload); + break; + case SoPropertyConstants.ACTION_ACTIVATE_N_E_SW: + lcmAction = SDNCLcmActionConstants.ACTIVATE_N_E_SW; + + ActivateNESwPayload activateNESwPayload; + activateNESwPayload = SDNCLcmPayloadBuilder.buildActivateNESwPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(activateNESwPayload); + break; + case SoPropertyConstants.ACTION_POST_CHECK: + lcmAction = SDNCLcmActionConstants.UPGRADE_POST_CHECK; + + UpgradePostCheckPayload upgradePostCheckPayload; + upgradePostCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePostCheckPayload(execution); + lcmPayload = SDNCLcmPayloadBuilder.convertToSting(upgradePostCheckPayload); + break; + default: + logger.error("Unsupported SO Action: " + requestAction); + return null; + } + + logger.debug("SDNC LCM payload for {}: {}", lcmAction, lcmPayload); + + String subRequestId = UUID.randomUUID().toString(); + LcmInput lcmInput = + SDNCLcmMessageBuilder.buildLcmInputForPnf(requestId, subRequestId, pnfName, lcmAction, lcmPayload); + + ObjectMapper mapper = new ObjectMapper(); + String lcmInputMsg = mapper.writeValueAsString(lcmInput); + logger.debug("SDNC input message:\n" + lcmInputMsg); + + return lcmInput; + } + + private boolean parseLcmOutput(LcmOutput lcmOutput, String lcmAction) { + if (lcmOutput == null) { + logger.error("Call SDNC LCM API failure"); + return false; + } + + LcmStatus lcmStatus = lcmOutput.getStatus(); + + if (lcmStatus.getCode() == SDNCConstants.LCM_OUTPUT_SUCCESS_CODE) { + logger.debug("Call SDNC LCM API success: " + lcmStatus.getMessage()); + } else { + logger.error("Call SDNC LCM API failure: " + lcmStatus.getMessage()); + } + + String outputPayload = lcmOutput.getPayload(); + logger.debug("SDNC LCM action: {}, result: {}", lcmAction, outputPayload); + if (outputPayload != null) { + String result = JsonUtils.getJsonValue(outputPayload, "result"); + if ("Success".equals(result)) { + logger.debug("Run SDNC LCM action {} success", lcmAction); + return true; + } else { + String reason = JsonUtils.getJsonValue(outputPayload, "reason"); + logger.error("Run SDNC LCM action {} failure, reason: {}", lcmAction, reason); + } + } + + return false; + } + + private boolean sendLcmRequest(DelegateExecution execution, LcmInput lcmInput) { + String actionMode = String.valueOf(execution.getVariable(SoPropertyConstants.SO_ACTION_MODE)); + String lcmOperation = toLowerHyphen(lcmInput.getAction()); + + LcmOutput lcmOutput; + if ("async".equals(actionMode)) { + lcmOutput = sendAsyncRequest(lcmOperation, lcmInput); + } else { + lcmOutput = sendSyncRequest(lcmOperation, lcmInput); + } + + return parseLcmOutput(lcmOutput, lcmInput.getAction()); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java index ff9d7376de..7930a33a2a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java @@ -39,7 +39,7 @@ import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java index 1a7d22c0dd..2d39cc185e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java @@ -35,7 +35,7 @@ import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.catalog.beans.ControllerSelectionReference; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java index 6bfe618460..7bfcd56c42 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java @@ -24,7 +24,7 @@ import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.client.ticket.ExternalTicket; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index cf56964af3..9de8e184f2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -282,6 +282,7 @@ public class AAIObjectMapper { map().setConfigurationType(source.getModelInfoConfiguration().getConfigurationType()); map().setConfigurationSubType(source.getModelInfoConfiguration().getConfigurationRole()); map().setConfigPolicyName(source.getModelInfoConfiguration().getPolicyName()); + skip().setConfigurationRole(null); } }); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java index 088ce1ac38..dd9ecbead4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java @@ -31,7 +31,7 @@ import org.onap.namingservice.model.NameGenResponse; import org.onap.namingservice.model.NameGenResponseError; import org.onap.namingservice.model.Respelement; import org.onap.so.client.exception.BadResponseException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java index e7e4e25af2..01ac675d83 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java @@ -30,7 +30,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index a41c79b171..f6642ab76a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -48,7 +48,7 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.so.logger.ErrorCode; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java index 5bd4df74bb..9adae88a5a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java @@ -24,10 +24,15 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; import java.util.HashMap; import java.util.Map; +import java.util.Optional; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; import javax.xml.bind.JAXBException; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.glassfish.jersey.message.internal.OutboundJaxrsResponse; +import org.glassfish.jersey.message.internal.OutboundMessageContext; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -39,8 +44,8 @@ import org.onap.so.adapters.nwrest.DeleteNetworkResponse; import org.onap.so.adapters.nwrest.UpdateNetworkError; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; -import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.NetworkAdapterResources; import org.onap.so.utils.Components; import org.onap.logging.filter.base.ONAPComponents; import static org.junit.Assert.assertTrue; @@ -54,13 +59,19 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; -public class NetworkAdapterRestV1Test extends BaseTaskTest { +public class NetworkAdapterRestV1Test { - @InjectMocks - NetworkAdapterRestV1 networkAdapterRestV1Tasks = new NetworkAdapterRestV1(); @Mock - ExceptionBuilder exceptionBuilder = new ExceptionBuilder(); + private ExceptionBuilder exceptionBuilder; + @Mock + private NetworkAdapterResources networkAdapterResources; + @InjectMocks + private NetworkAdapterRestV1 networkAdapterRestV1Tasks; + + private DelegateExecution delegateExecution; private static final String CREATE_NETWORK_RESPONSE = "createNetworkResponse"; private static final String DELETE_NETWORK_RESPONSE = "deleteNetworkResponse"; @@ -73,6 +84,7 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { @Before public void setup() { + initMocks(this); delegateExecution = new DelegateExecutionFake(); } @@ -187,6 +199,53 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { } } + @Test + public void callNetworkAdapter_CreateNetworkRequestSuccess() throws Exception { + // given + String messageId = "createNetReqMessageId"; + CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest(); + createNetworkRequest.setMessageId(messageId); + delegateExecution.setVariable("networkAdapterRequest", createNetworkRequest); + Status status = Status.OK; + String responseEntity = "createNetworkResponse"; + Optional<Response> response = Optional.of(createResponse(status, responseEntity)); + when(networkAdapterResources.createNetworkAsync(createNetworkRequest)).thenReturn(response); + // when + networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); + // then + verifyExecutionContent(status, responseEntity, messageId); + } + + @Test + public void callNetworkAdapter_DeleteNetworkRequestSuccess() throws Exception { + // given + String messageId = "DeleteNetReqMessageId"; + DeleteNetworkRequest deleteNetworkRequest = new DeleteNetworkRequest(); + deleteNetworkRequest.setMessageId(messageId); + delegateExecution.setVariable("networkAdapterRequest", deleteNetworkRequest); + Status status = Status.OK; + String responseEntity = "createNetworkResponse"; + Optional<Response> response = Optional.of(createResponse(status, responseEntity)); + when(networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest)).thenReturn(response); + // when + networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); + // then + verifyExecutionContent(status, responseEntity, messageId); + } + + private void verifyExecutionContent(Status status, String responseEntity, String messageId) { + assertEquals(delegateExecution.getVariable("NETWORKREST_networkAdapterStatusCode"), + Integer.toString(status.getStatusCode())); + assertEquals(delegateExecution.getVariable("NETWORKREST_networkAdapterResponse"), responseEntity); + assertEquals(delegateExecution.getVariable("NetworkAResponse_CORRELATOR"), messageId); + } + + private Response createResponse(Status status, String responseEntity) { + OutboundMessageContext outboundMessageContext = new OutboundMessageContext(); + outboundMessageContext.setEntity(responseEntity); + return new OutboundJaxrsResponse(status, outboundMessageContext); + } + private String createNetworkResponse(String networkResponseType, String networkId) { return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><" + networkResponseType + "><networkId>" diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java new file mode 100644 index 0000000000..61f2ee3432 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SDNCLcmPayloadBuilderTest.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. 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.decisionpoint.impl.camunda.controller.sdnc; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.junit.runner.RunWith; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.REQUEST_PAYLOAD; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.common.SoPropertyConstants; +import org.onap.so.client.sdnc.lcm.beans.payload.*; + +@RunWith(SpringJUnit4ClassRunner.class) +public class SDNCLcmPayloadBuilderTest { + private static Logger logger = LoggerFactory.getLogger(SDNCLcmPayloadBuilderTest.class); + + protected static String payload = "{" + "\"ipaddressV4Oam\": \"192.168.1.10\"," + "\"oldSwVersion\": \"v1\"," + + "\"preCheckRuleName\": \"r101\"," + "\"preCheckAdditionalData\": \"{}\"," + + "\"preCheckPlaybook\": \"precheck_playbook\"," + "\"swToBeDownloaded\": \"[{" + + "\\\"swLocation\\\": \\\"http://192.168.1.20/test.zip\\\"," + "\\\"swFileSize\\\": 123456," + + "\\\"swFileCompression\\\": \\\"ZIP\\\"," + "\\\"swFileFormat\\\": \\\"binary\\\"}]\"," + + "\"downloadNESwPlaybook\": \"downloadnesw_playbook\"," + + "\"activateNESwPlaybook\": \"activatenesw_playbook\"," + "\"postCheckRuleName\": \"r102\"," + + "\"postCheckAdditionalData\": \"{}\"," + "\"postCheckPlaybook\": \"postcheck_playbook\"" + "}"; + protected String targetSoftwareVersion = "v2"; + + @MockBean + private DelegateExecution execution; + + public static String getRequestPayload() { + return payload; + } + + @Before + public void setUp() { + when(execution.getVariable(REQUEST_PAYLOAD)).thenReturn(payload); + when(execution.getVariable(SoPropertyConstants.TARGET_SOFTWARE_VERSION)).thenReturn(targetSoftwareVersion); + } + + + @Test + public final void testBuildActivateNESwPayload() { + String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"activatenesw_playbook\"," + "\"swVersionToBeActivated\":\"v2\"" + "}"; + + ActivateNESwPayload activateNESwPayload = SDNCLcmPayloadBuilder.buildActivateNESwPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(activateNESwPayload); + logger.debug("ActivateNESwPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert ActivateNESwPayload to String error: " + e.toString()); + } + } + + @Test + public final void testBuildDownloadNESwPayload() { + String expectedSwToBeDownloadedElement = "{" + "\"swLocation\":\"http://192.168.1.20/test.zip\"," + + "\"swFileSize\":123456," + "\"swFileCompression\":\"ZIP\"," + "\"swFileFormat\":\"binary\"" + "}"; + String expectedPayload = + "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + "\"playbook-name\":\"downloadnesw_playbook\"," + + "\"swToBeDownloaded\":[" + expectedSwToBeDownloadedElement + "]" + "}"; + + DownloadNESwPayload downloadNESwPayload = SDNCLcmPayloadBuilder.buildDownloadNESwPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(downloadNESwPayload); + logger.debug("DownloadNESwPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert DownloadNESwPayload to String error: " + e.toString()); + } + } + + @Test + public final void testBuildUpgradePostCheckPayload() { + String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"postcheck_playbook\"," + "\"oldSwVersion\":\"v1\"," + + "\"targetSwVersion\":\"v2\"," + "\"ruleName\":\"r102\"," + "\"additionalData\":\"{}\"" + "}"; + + UpgradePostCheckPayload upgradePostCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePostCheckPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(upgradePostCheckPayload); + logger.debug("UpgradePostCheckPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert UpgradePostCheckPayload to String error: " + e.toString()); + } + } + + @Test + public final void testBuildUpgradePreCheckPayload() { + String expectedPayload = "{" + "\"ipaddress-v4-oam\":\"192.168.1.10\"," + + "\"playbook-name\":\"precheck_playbook\"," + "\"oldSwVersion\":\"v1\"," + + "\"targetSwVersion\":\"v2\"," + "\"ruleName\":\"r101\"," + "\"additionalData\":\"{}\"" + "}"; + + UpgradePreCheckPayload upgradePreCheckPayload = SDNCLcmPayloadBuilder.buildUpgradePreCheckPayload(execution); + try { + String payload = SDNCLcmPayloadBuilder.convertToSting(upgradePreCheckPayload); + logger.debug("UpgradePreCheckPayload:\n" + payload); + + assertEquals(expectedPayload, payload); + } catch (JsonProcessingException e) { + fail("Convert UpgradePreCheckPayload to String error: " + e.toString()); + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java index 674167624e..02c7dca9ae 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/sdnc/SdncControllerDETest.java @@ -28,7 +28,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable; -import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; @@ -48,9 +47,6 @@ public class SdncControllerDETest { @MockBean private ControllerPreparable<DelegateExecution> preparable; - @MockBean - protected ApplicationControllerAction client; - @Before public void setUp() { when(controllerContext.getControllerActor()).thenReturn("sdnc"); |