aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN/src')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtil.groovy382
-rw-r--r--bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml81
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtilTest.groovy201
3 files changed, 0 insertions, 664 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtil.groovy
deleted file mode 100644
index cce05feca8..0000000000
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtil.groovy
+++ /dev/null
@@ -1,382 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.common.scripts
-
-import org.camunda.bpm.engine.runtime.Execution
-import org.apache.commons.lang3.*
-
-class CommonExceptionUtil {
-
-
-
- public static enum Error {
- SVC_GENERAL_SERVICE_ERROR("SVC0001","Internal Error"),
- SVC_BAD_PARAMETER("SVC0002", "Invalid input value for message part %1"),
- SVC_NO_SERVER_RESOURCES("SVC1000", "No server resources available to process the request"),
- SVC_DETAILED_SERVICE_ERROR("SVC2000", "The following service error occurred: %1. Error code is %2."),
- POL_GENERAL_POLICY_ERROR("POL0001", "A policy error occurred."),
- POL_USER_NOT_PROVISIONED("POL1009", "User has not been provisioned for service"),
- POL_USER_SUSPENDED("POL1010", "User has been suspended from service"),
- POL_DETAILED_POLICY_ERROR("POL2000", "The following policy error occurred: %1. Error code is %2."),
- POL_MSG_SIZE_EXCEEDS_LIMIT("POL9003", "Message content size exceeds the allowable limit")
-
-
- private final String msgId
- private final String msgTxt
-
- private Error(String msgId, String msgTxt) {
- this.msgId = msgId
- this.msgTxt = msgTxt
- }
-
- public String getMsgId() {
- return msgId
- }
-
- public String getMsgTxt() {
- return msgTxt
- }
-
- }
-
-
-
-
- String mapAdapterExecptionToCommonException(String response, Execution execution)
- {
- def utils=new MsoUtils()
- def method = getClass().getSimpleName() + '.mapAdapterExecptionToCommonException(' +
- 'execution=' + execution.getId() +
- ')'
-
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- utils.log("DEBUG",'Entered ' + method, isDebugLogEnabled)
-
-
- def errorCode
-
-
- try {
- errorCode = MapCategoryToErrorCode(utils.getNodeText(response, "category"))
- execution.setVariable(prefix+"err",errorCode)
- String message = buildException(response, execution)
- utils.log("DEBUG","=========== End MapAdapterExecptionToWorkflowException ===========",isDebugLogEnabled)
- return message
- }catch (Exception ex) {
- //Ignore the exception - cases include non xml payload
- utils.log("DEBUG","error mapping error, ignoring: " + ex,isDebugLogEnabled)
- utils.log("DEBUG","=========== End MapAdapterExecptionToWorkflowException ===========",isDebugLogEnabled)
- return buildException(response, execution)
- }
- }
-
- /**
- * @param response
- * @param execution
- * @return mapped exception
- */
- String mapAOTSExecptionToCommonException(String response, Execution execution)
- {
- def utils=new MsoUtils()
-
- def prefix=execution.getVariable("prefix")
- def method = getClass().getSimpleName() + '.mapAOTSExecptionToCommonException(' +
- 'execution=' + execution.getId() +
- ')'
-
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- utils.log("DEBUG",'Entered ' + method, isDebugLogEnabled)
-
-
- try {
- def errorCode = utils.getNodeText(response,"code")
- def descr = utils.getNodeText(response, "description")
- def mappedErr = mapErrorCodetoError(errorCode, descr)
- if(mappedErr == Error.SVC_DETAILED_SERVICE_ERROR || mappedError == Error.POL_DETAILED_POLICY_ERROR){
- ArrayList myVars = new ArrayList()
- myVars.add(descr)
- myVars.add(errorCode)
- execution.setVariable(prefix+"errVariables", myVars)
- }
- execution.setVariable(prefix+"err",mappedErr)
- def message = buildException("Received error from AOTS: " + descr, execution)
- utils.log("DEBUG","=========== End MapAOTSExecptionToCommonException ===========",isDebugLogEnabled)
- return message
- }catch (Exception ex) {
- //Ignore the exception - cases include non xml payload
- utils.log("DEBUG","error mapping error, ignoring: " + ex,isDebugLogEnabled)
- utils.log("DEBUG","=========== End MapAOTSExecptionToCommonException ===========",isDebugLogEnabled)
- return buildException(response, execution)
- }
- }
-
- String mapSDNCAdapterExceptionToErrorResponse(String sdncAdapterCallbackRequest, Execution execution) {
- def utils=new MsoUtils()
- def prefix=execution.getVariable("prefix")
- def method = getClass().getSimpleName() + '.mapSDNCAdapterExceptionToErrorResponse(' +
- 'execution=' + execution.getId() +
- ')'
-
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- utils.log("DEBUG",'Entered ' + method, isDebugLogEnabled)
-
- def sdncResponseCode
- String responseCode = execution.getVariable(prefix+"ResponseCode")
- utils.log("DEBUG",'responseCode to map: ' + responseCode, isDebugLogEnabled)
- def errorMessage
-
- try {
-
- if(utils.nodeExists(sdncAdapterCallbackRequest, "RequestData")) {
- def reqDataXml = StringEscapeUtils.unescapeXml(utils.getNodeXml(sdncAdapterCallbackRequest, "RequestData"))
- errorMessage = utils.getNodeText(reqDataXml, "response-message")
- sdncResponseCode = utils.getNodeText(reqDataXml, "response-code")
- }else{
- errorMessage = utils.getNodeText(sdncAdapterCallbackRequest, "ResponseMessage")
- sdncResponseCode = responseCode
- }
- def mappedErr = mapErrorCodetoError(responseCode, errorMessage)
- errorMessage = errorMessage.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
- def modifiedErrorMessage = "Received error from SDN-C: " + errorMessage
- if(mappedErr == Error.SVC_DETAILED_SERVICE_ERROR || mappedErr == Error.POL_DETAILED_POLICY_ERROR){
- ArrayList myVars = new ArrayList()
- myVars.add(errorMessage)
- myVars.add(sdncResponseCode)
- execution.setVariable(prefix+"errVariables", myVars)
- }
- execution.setVariable(prefix+"err",mappedErr)
- def message = buildException(modifiedErrorMessage, execution)
-
-
- utils.log("DEBUG","=========== End MapSDNCAdapterException ===========",isDebugLogEnabled)
- return message
- }catch (Exception ex) {
- //Ignore the exception - cases include non xml payload
- utils.log("DEBUG","error mapping sdnc error, ignoring: " + ex,isDebugLogEnabled)
- utils.log("DEBUG","=========== End MapSDNCAdapterException ===========",isDebugLogEnabled)
- return null
- }
-
- }
-
- /**
- * @param response message from called component (ex: AAI)
- * @param execution
- * @return an error response conforming to the common
- */
- String mapAAIExceptionTCommonException(String response, Execution execution)
- {
- def utils=new MsoUtils()
- def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
- def prefix=execution.getVariable("prefix")
- def method = getClass().getSimpleName() + '.mapAAIExceptionTCommonException(' +
- 'execution=' + execution.getId() +
- ')'
-
- utils.log("DEBUG",'Entered ' + method, isDebugLogEnabled)
- def variables
- def message
- String errorCode = 'SVC0001'
- utils.log("DEBUG","response: " + response, isDebugLogEnabled)
- //they use the same format we do, pass their error along
- //TODO add Received error from A&AI at beg of text
- try {
- message = utils.getNodeXml(response, "requestError")
- message = utils.removeXmlNamespaces(message)
- } catch (Exception ex) {
- //Ignore the exception - cases include non xml payload
- message = buildException("Received error from A&AI, unable to parse",execution)
- utils.log("DEBUG","error mapping error, ignoring: " + ex,isDebugLogEnabled)
- }
-
- if(message != null) {
- execution.setVariable(prefix+"ErrorResponse",message)
- utils.log("ERROR","Fault:"+ execution.getVariable(prefix+"ErrorResponse"))
- return message
- } else {
-
- return null
-
- }
- }
-
- /**
- * @param execution
- * @return an error response conforming to the common API with default text msg
- */
- String buildException(execution){
- return buildException(null, execution)
- }
-
- /**
- * @param response message from called component (ex: AAI)
- * @param execution
- * @return an error response conforming to the common
- */
- String buildException(response, execution){
- def utils=new MsoUtils()
- def method = getClass().getSimpleName() + '.buildException(' +
- 'execution=' + execution.getId() +
- ')'
-
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- utils.log("DEBUG",'Entered ' + method, isDebugLogEnabled)
- def prefix=execution.getVariable("prefix")
- def responseCode = String.valueOf(execution.getVariable(prefix+"ResponseCode"))
- def variables
- utils.log("DEBUG","response: " + response, isDebugLogEnabled)
-
- try {
- utils.log("DEBUG","formatting error message" ,isDebugLogEnabled)
- def msgVars = execution.getVariable(prefix+"errVariables")
- def myErr = execution.getVariable(prefix+"err")
- def messageTxt = execution.getVariable(prefix+"errTxt")
- def messageId = null
-
- if(myErr == null){
- utils.log("DEBUG","mapping response code: " + responseCode, isDebugLogEnabled)
- myErr = mapErrorCodetoError(responseCode, response)
- if(myErr == null){
- //not a service or policy error, just return error code
- return ""
- }
- }
- messageId = myErr.getMsgId()
-
- if(messageTxt == null){
- if(myErr!=null){
- messageTxt = myErr.getMsgTxt()
- }else{
- messageTxt = response
- }
- }
-
- if(msgVars==null && (myErr == Error.SVC_DETAILED_SERVICE_ERROR || myErr == Error.POL_DETAILED_POLICY_ERROR)){
- msgVars = new ArrayList()
- msgVars.add(response)
- msgVars.add(responseCode)
- }
-
- def msgVarsXML=""
- StringBuffer msgVarsBuff = new StringBuffer()
- if(msgVars!=null){
- for(String msgVar : msgVars){
- msgVarsBuff.append(
- """
- <tns:variables>${msgVar}</tns:variables>""")
- }
-
- }
- def message = ""
- if(messageId.startsWith("SVC")){
- message = """<tns:requestError xmlns:tns="http://org.openecomp/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.openecomp/mso/request/types/v1 MsoServiceInstanceTypesV1.xsd">
- <tns:serviceException>
- <tns:messageId>${messageId}</tns:messageId>
- <tns:text>${messageTxt}</tns:text>${msgVarsBuff}
- </tns:serviceException>
-</tns:requestError>"""
- }else{
- message ="""<tns:requestError xmlns:tns="http://org.openecomp/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.openecomp/mso/request/types/v1 MsoServiceInstanceTypesV1.xsd">
- <tns:policyException>
- <tns:messageId>${messageId}</tns:messageId>
- <tns:text>${messageTxt}</tns:text>${msgVarsBuff}
- </tns:policyException>
-</tns:requestError>"""
- }
- utils.log("DEBUG", "message " + message, isDebugLogEnabled)
- execution.setVariable(prefix+"ErrorResponse",message)
- execution.setVariable(prefix+"err", myErr)
- execution.setVariable(prefix+"errTxt", messageTxt)
- execution.setVariable(prefix+"errVariables", msgVars)
- utils.log("ERROR","Fault:"+ execution.getVariable(prefix+"ErrorResponse"))
- return message
- }catch(Exception ex) {
- utils.log("DEBUG","error mapping error, return null: " + ex,isDebugLogEnabled)
- return null
- }
-
- }
-
- String parseError(Execution execution){
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- def utils=new MsoUtils()
- def prefix=execution.getVariable("prefix")
- def text = execution.getVariable(prefix+"errTxt")
- def msgVars = execution.getVariable(prefix+"errVariables")
- utils.log("DEBUG",'parsing message: ' + text, isDebugLogEnabled)
- if(text == null){
- return 'failed'
- }
- if(msgVars!=null && !msgVars.isEmpty()){
- for(int i=0; i<msgVars.size(); i++){
- text = text.replaceFirst("%"+(i+1), msgVars[i])
- }
- }
- utils.log("DEBUG",'parsed message is: ' + text, isDebugLogEnabled)
- return text
- }
-
-
-
- Error mapErrorCodetoError(responseCode, descr)
- {
-
- if(responseCode==null || responseCode=='0' || responseCode=='500' || responseCode =='408'){
- return Error.SVC_NO_SERVER_RESOURCES
- }else if(responseCode == '401' || responseCode == '405' || responseCode == '409' || responseCode == '503'){
- return null
- }else if(responseCode == '400'){
- if(descr==null){
- return Error.SVC_GENERAL_SERVICE_ERROR
- }else{
- return Error.SVC_DETAILED_SERVICE_ERROR
- }
- }else if(responseCode == '401'){
- if(descr==null){
- return Error.POL_GENERAL_POLICY_ERROR
- }else{
- return Error.POL_DETAILED_POLICY_ERROR
- }
- }else{
- return Error.SVC_NO_SERVER_RESOURCES
- }
- }
-
- String mapCategoryToErrorCode(String errorCategory)
- {
- if(errorCategory.equals('OPENSTACK'))
- return Error.SVC_NO_SERVER_RESOURCES
- else if (errorCategory.equals('IO'))
- return Error.SVC_NO_SERVER_RESOURCES
- else if (errorCategory.equals('INTERNAL'))
- return Error.SVC_NO_SERVER_RESOURCES
- else if (errorCategory.equals('USERDATA'))
- return Error.SVC_GENERAL_SERVICE_ERROR
- else
- return Error.SVC_GENERAL_SERVICE_ERROR
- }
-
-
-
-
-
-
-}
diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml
deleted file mode 100644
index 1745af6558..0000000000
--- a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
- -->
-
-
-<process-application
- xmlns="http://www.camunda.org/schema/1.0/ProcessApplication"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <process-engine name="common">
- <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration</configuration>
- <datasource>java:jboss/datasources/ProcessEngine</datasource>
- <properties>
- <property name="history">full</property>
- <property name="databaseSchemaUpdate">true</property>
- <property name="authorizationEnabled">true</property>
- <property name="jobExecutorDeploymentAware">true</property>
- <property name="jobExecutorActivate">true</property>
- </properties>
- <plugins>
-
- <!-- plugin enabling Process Application event listener support -->
- <plugin>
- <class>org.camunda.bpm.application.impl.event.ProcessApplicationEventListenerPlugin</class>
- </plugin>
-
- <!-- plugin enabling integration of camunda Spin -->
- <plugin>
- <class>org.camunda.spin.plugin.impl.SpinProcessEnginePlugin</class>
- </plugin>
-
- <!-- plugin enabling connect support -->
- <plugin>
- <class>org.camunda.connect.plugin.impl.ConnectProcessEnginePlugin</class>
- </plugin>
-
- <plugin>
- <class>org.openecomp.mso.bpmn.core.plugins.LoggingAndURNMappingPlugin</class>
- </plugin>
-
- <!-- Needed until all subflows generate MSOWorkflowException events -->
- <plugin>
- <class>org.openecomp.mso.bpmn.core.plugins.WorkflowExceptionPlugin</class>
- </plugin>
-
- <!-- Optional Plugin for Camunda BPM Workbench -->
- <!-- <plugin>
- <class>org.camunda.bpm.debugger.server.EmbeddableDebugWebsocketBootstrap</class>
- <properties>
- <property name="httpPort">8088</property>
- </properties>
- </plugin> -->
- </plugins>
- </process-engine>
-
-
- <process-archive name="MSOCommonBPMN">
- <process-engine>common</process-engine>
- <properties>
- <property name="isDeleteUponUndeploy">false</property>
- <property name="isScanForProcessDefinitions">true</property>
- </properties>
- </process-archive>
-
-</process-application>
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtilTest.groovy
deleted file mode 100644
index abb369725e..0000000000
--- a/bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/CommonExceptionUtilTest.groovy
+++ /dev/null
@@ -1,201 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.common.scripts
-
-import org.junit.Assert
-import org.junit.Ignore
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-
-
-
-import static org.mockito.Mockito.*
-
-import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
-import org.junit.Before
-import org.junit.runner.RunWith
-import org.mockito.MockitoAnnotations
-import org.mockito.internal.debugging.MockitoDebuggerImpl
-import org.mockito.runners.MockitoJUnitRunner
-import org.openecomp.mso.bpmn.common.scripts.CommonExceptionUtil;
-@RunWith(MockitoJUnitRunner.class)
-import org.junit.Test
-
-class CommonExceptionUtilTest {
-
- def aotsFault ="""<n1:Fault xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n1="http://csi.cingular.com/CSI/Namespaces/ATTOneTicketingSystem/InfrastructureCommon/Types/Public/SoapFault.xsd" xmlns:cer="http://csi.cingular.com/CSI/Namespaces/ATTOneTicketingSystem/InfrastructureCommon/Types/Public/ErrorResponse.xsd" xsi:schemaLocation="http://csi.cingular.com/CSI/Namespaces/ATTOneTicketingSystem/InfrastructureCommon/Types/Public/SoapFault.xsd SoapFault-CDM.xsd">
- <n1:faultcode>xml:space</n1:faultcode>
- <n1:faultstring>String</n1:faultstring>
- <n1:faultactor>http://csi.att.com</n1:faultactor>
- <n1:detail>
- <n1:CSIApplicationException>
- <cer:Response>
- <cer:code>400</cer:code>
- <cer:description>bad stuff</cer:description>
- </cer:Response>
- <cer:ServiceProviderEntity>
- <cer:reportingServiceEntity>String</cer:reportingServiceEntity>
- <cer:faultDate>*** ERROR ***</cer:faultDate>
- <cer:faultSequenceNumber>String</cer:faultSequenceNumber>
- <cer:faultLevel>String</cer:faultLevel>
- <cer:faultCode>String</cer:faultCode>
- <cer:faultDescription>String</cer:faultDescription>
- <cer:ServiceProviderRawError>
- <cer:code>String</cer:code>
- <cer:description>String</cer:description>
- <cer:BISError>
- <cer:code>String</cer:code>
- <cer:description>String</cer:description>
- <cer:origination>String</cer:origination>
- <cer:severity>String</cer:severity>
- </cer:BISError>
- </cer:ServiceProviderRawError>
- </cer:ServiceProviderEntity>
- </n1:CSIApplicationException>
- <n1:CSIInternalException>
- <cer:reportingServiceEntity>String</cer:reportingServiceEntity>
- <cer:faultDate>*** ERROR ***</cer:faultDate>
- <cer:faultSequenceNumber>String</cer:faultSequenceNumber>
- <cer:faultLevel>String</cer:faultLevel>
- <cer:faultCode>String</cer:faultCode>
- <cer:faultDescription>String</cer:faultDescription>
- <cer:cingularErrorCode>String</cer:cingularErrorCode>
- <cer:cingularErrorDescription>String</cer:cingularErrorDescription>
- <cer:cingularErrorCategory>String</cer:cingularErrorCategory>
- </n1:CSIInternalException>
- </n1:detail>
-</n1:Fault>"""
-
-
- @Before
- public void init()
- {
- MockitoAnnotations.initMocks(this)
- }
-
- @Test
- @Ignore
- public void testMapAAIExceptionTCommonException() {
-
-
-
- String restFault = """
- <Fault>
-<requestError>
-<serviceException>
-<messageId>SVC3002</messageId>
-<text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text>
-<variables>
-<variable>PUTcustomer</variable>
-<variable>SubName01</variable>
-<variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable>
-<variable>ERR.5.4.5105</variable>
-</variables>
-</serviceException>
-</requestError>
-</Fault>
- """
- def errorString = """<requestError>
-<serviceException>
-<messageId>SVC3002</messageId>
-<text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text>
-<variables>
-<variable>PUTcustomer</variable>
-<variable>SubName01</variable>
-<variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable>
-<variable>ERR.5.4.5105</variable>
-</variables>
-</serviceException>
-</requestError>""" as String
-
-
-
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
-
- CommonExceptionUtil util = new CommonExceptionUtil()
- Assert.assertEquals(errorString, util.mapAAIExceptionTCommonException(restFault, mockExecution))
- }
-
-
-
-
- @Test
- public void testBuildException() {
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getVariable("prefix")).thenReturn("test_")
- when(mockExecution.getVariable("test_ResponseCode")).thenReturn("400")
- ArrayList msgVars = new ArrayList()
- msgVars.add("var1")
- msgVars.add("var2")
- when(mockExecution.getVariable("test_errVariables")).thenReturn(msgVars)
-
-
- CommonExceptionUtil util = new CommonExceptionUtil()
- String msg = "Bad request"
- String errorString = """<tns:requestError xmlns:tns="http://org.openecomp/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.openecomp/mso/request/types/v1 MsoServiceInstanceTypesV1.xsd">
- <tns:serviceException>
- <tns:messageId>SVC2000</tns:messageId>
- <tns:text>The following service error occurred: %1. Error code is %2.</tns:text>
- <tns:variables>var1</tns:variables>
- <tns:variables>var2</tns:variables>
- </tns:serviceException>
-</tns:requestError>"""
- Assert.assertEquals(errorString, util.buildException(msg, mockExecution))
- }
-
- @Test
- public void testMapAOTSExecptionToCommonException() {
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- when(mockExecution.getVariable("prefix")).thenReturn("test_")
- when(mockExecution.getVariable("test_ResponseCode")).thenReturn("400")
-
- CommonExceptionUtil util = new CommonExceptionUtil()
- String errorString = """<tns:requestError xmlns:tns="http://org.openecomp/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.openecomp/mso/request/types/v1 MsoServiceInstanceTypesV1.xsd">
- <tns:serviceException>
- <tns:messageId>SVC2000</tns:messageId>
- <tns:text>The following service error occurred: %1. Error code is %2.</tns:text>
- <tns:variables>Received error from AOTS: bad stuff</tns:variables>
- <tns:variables>400</tns:variables>
- </tns:serviceException>
-</tns:requestError>"""
- Assert.assertEquals(errorString, util.mapAOTSExecptionToCommonException(aotsFault, mockExecution))
- }
-
-
- @Test
- public void testParseError() {
- ExecutionEntity mockExecution = mock(ExecutionEntity.class)
- String errorString = "The following service error occurred: %1. Error code is %2."
- ArrayList msgVars = new ArrayList()
- msgVars.add("var1")
- msgVars.add("var2")
- when(mockExecution.getVariable("prefix")).thenReturn("test_")
- when(mockExecution.getVariable("test_errTxt")).thenReturn(errorString)
- when(mockExecution.getVariable("test_errVariables")).thenReturn(msgVars)
-
- CommonExceptionUtil util = new CommonExceptionUtil()
-
- Assert.assertEquals("The following service error occurred: var1. Error code is var2.", util.parseError(mockExecution))
-}
-
-
-
-}