Merge "Query param to pull back nested stack information"
authorSteve Smokowski <ss835w@att.com>
Mon, 8 Apr 2019 16:44:32 +0000 (16:44 +0000)
committerGerrit Code Review <gerrit@onap.org>
Mon, 8 Apr 2019 16:44:32 +0000 (16:44 +0000)
14 files changed:
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml [new file with mode: 0644]
mso-api-handlers/mso-api-handler-common/pom.xml
mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/RequestIdFilter.java [new file with mode: 0644]
mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.java [new file with mode: 0644]
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java

index 0be7c55..7339b23 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3">
   <bpmn:process id="SDNCHandler" name="SDNC" isExecutable="true">
     <bpmn:startEvent id="SDNC_Start">
       <bpmn:outgoing>SequenceFlow_1n0j3hz</bpmn:outgoing>
@@ -38,7 +38,7 @@
     <bpmn:boundaryEvent id="BoundaryEvent_1quvxva" name="Timeout" attachedToRef="SubProcess_0y8yozw">
       <bpmn:outgoing>SequenceFlow_1yifu46</bpmn:outgoing>
       <bpmn:timerEventDefinition>
-        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("sdncTimeout")}]]></bpmn:timeDuration>
+        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">${execution.getVariable("sdncTimeout")}</bpmn:timeDuration>
       </bpmn:timerEventDefinition>
     </bpmn:boundaryEvent>
     <bpmn:sequenceFlow id="SequenceFlow_1ecej8g" sourceRef="SubProcess_0y8yozw" targetRef="ExclusiveGateway_09ehhaf" />
@@ -48,7 +48,7 @@
       <bpmn:outgoing>SequenceFlow_0i4u8g4</bpmn:outgoing>
     </bpmn:exclusiveGateway>
     <bpmn:sequenceFlow id="SequenceFlow_0rh24pq" name="Final Ack = N" sourceRef="ExclusiveGateway_09ehhaf" targetRef="SubProcess_0y8yozw">
-      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isCallbackCompleted")}]]></bpmn:conditionExpression>
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isCallbackCompleted") == false}</bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:sequenceFlow id="SequenceFlow_1yifu46" sourceRef="BoundaryEvent_1quvxva" targetRef="Task_1un0flc" />
     <bpmn:sequenceFlow id="SequenceFlow_1n0j3hz" sourceRef="SDNC_Start" targetRef="SNDC_SetupCallback" />
@@ -62,7 +62,7 @@
     <bpmn:sequenceFlow id="SequenceFlow_0flbj8a" sourceRef="SNDC_SetupCallback" targetRef="Call_SDNC" />
     <bpmn:sequenceFlow id="SequenceFlow_0i4u8g4" name="Final Ack = Y" sourceRef="ExclusiveGateway_09ehhaf" targetRef="SDNC_End" />
     <bpmn:sequenceFlow id="SequenceFlow_0puiqga" name="Final Ack = Y" sourceRef="isAsync_Gateway" targetRef="SDNC_End">
-      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isSDNCCompleted")}]]></bpmn:conditionExpression>
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isSDNCCompleted")}</bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:serviceTask id="SNDC_SetupCallback" name="Setup Callback Variables" camunda:expression="${SDNCRequestTasks.createCorrelationVariables(execution)}">
       <bpmn:incoming>SequenceFlow_1n0j3hz</bpmn:incoming>
@@ -72,7 +72,7 @@
       <bpmn:incoming>SequenceFlow_1yifu46</bpmn:incoming>
     </bpmn:serviceTask>
   </bpmn:process>
-  <bpmn:message id="Message_06oc4iz" name="SDNCCallbackMessage" />
+  <bpmn:message id="Message_06oc4iz" name="WorkflowMessage" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="SDNCHandler">
       <bpmndi:BPMNShape id="StartEvent_0kxwniy_di" bpmnElement="SDNC_Start">
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1qxm8ot_di" bpmnElement="SequenceFlow_1qxm8ot">
-        <di:waypoint xsi:type="dc:Point" x="347" y="-72" />
-        <di:waypoint xsi:type="dc:Point" x="376" y="-72" />
+        <di:waypoint x="347" y="-72" />
+        <di:waypoint x="376" y="-72" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="316.5" y="-93.5" width="90" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_05eggbt_di" bpmnElement="SequenceFlow_05eggbt">
-        <di:waypoint xsi:type="dc:Point" x="412" y="-72" />
-        <di:waypoint xsi:type="dc:Point" x="438" y="-72" />
+        <di:waypoint x="412" y="-72" />
+        <di:waypoint x="438" y="-72" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="380" y="-93.5" width="90" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1ecej8g_di" bpmnElement="SequenceFlow_1ecej8g">
-        <di:waypoint xsi:type="dc:Point" x="618" y="-67" />
-        <di:waypoint xsi:type="dc:Point" x="798" y="-67" />
-        <di:waypoint xsi:type="dc:Point" x="798" y="28" />
+        <di:waypoint x="618" y="-67" />
+        <di:waypoint x="798" y="-67" />
+        <di:waypoint x="798" y="28" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="663" y="-88.5" width="90" height="13" />
         </bpmndi:BPMNLabel>
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0rh24pq_di" bpmnElement="SequenceFlow_0rh24pq">
-        <di:waypoint xsi:type="dc:Point" x="773" y="53" />
-        <di:waypoint xsi:type="dc:Point" x="449" y="53" />
-        <di:waypoint xsi:type="dc:Point" x="449" y="9" />
+        <di:waypoint x="773" y="53" />
+        <di:waypoint x="449" y="53" />
+        <di:waypoint x="449" y="9" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="579.9877300613497" y="32" width="66" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1yifu46_di" bpmnElement="SequenceFlow_1yifu46">
-        <di:waypoint xsi:type="dc:Point" x="636" y="-144" />
-        <di:waypoint xsi:type="dc:Point" x="748" y="-145" />
+        <di:waypoint x="636" y="-144" />
+        <di:waypoint x="748" y="-145" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="647" y="-166" width="90" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_1n0j3hz_di" bpmnElement="SequenceFlow_1n0j3hz">
-        <di:waypoint xsi:type="dc:Point" x="-231" y="152" />
-        <di:waypoint xsi:type="dc:Point" x="-171" y="152" />
+        <di:waypoint x="-231" y="152" />
+        <di:waypoint x="-171" y="152" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="-201" y="130.5" width="0" height="13" />
         </bpmndi:BPMNLabel>
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0yve6l6_di" bpmnElement="SequenceFlow_0yve6l6">
-        <di:waypoint xsi:type="dc:Point" x="253" y="127" />
-        <di:waypoint xsi:type="dc:Point" x="253" y="92" />
-        <di:waypoint xsi:type="dc:Point" x="253" y="92" />
-        <di:waypoint xsi:type="dc:Point" x="253" y="-67" />
-        <di:waypoint xsi:type="dc:Point" x="278" y="-67" />
+        <di:waypoint x="253" y="127" />
+        <di:waypoint x="253" y="92" />
+        <di:waypoint x="253" y="92" />
+        <di:waypoint x="253" y="-67" />
+        <di:waypoint x="278" y="-67" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="263" y="57" width="65" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_07vnhri_di" bpmnElement="SequenceFlow_07vnhri">
-        <di:waypoint xsi:type="dc:Point" x="115" y="152" />
-        <di:waypoint xsi:type="dc:Point" x="228" y="152" />
+        <di:waypoint x="115" y="152" />
+        <di:waypoint x="228" y="152" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="171.5" y="130" width="0" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0flbj8a_di" bpmnElement="SequenceFlow_0flbj8a">
-        <di:waypoint xsi:type="dc:Point" x="-71" y="152" />
-        <di:waypoint xsi:type="dc:Point" x="15" y="152" />
+        <di:waypoint x="-71" y="152" />
+        <di:waypoint x="15" y="152" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="-28" y="130.5" width="0" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0i4u8g4_di" bpmnElement="SequenceFlow_0i4u8g4">
-        <di:waypoint xsi:type="dc:Point" x="798" y="78" />
-        <di:waypoint xsi:type="dc:Point" x="798" y="174" />
+        <di:waypoint x="798" y="78" />
+        <di:waypoint x="798" y="174" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="809" y="119" width="66" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0puiqga_di" bpmnElement="SequenceFlow_0puiqga">
-        <di:waypoint xsi:type="dc:Point" x="253" y="177" />
-        <di:waypoint xsi:type="dc:Point" x="253" y="192" />
-        <di:waypoint xsi:type="dc:Point" x="780" y="192" />
+        <di:waypoint x="253" y="177" />
+        <di:waypoint x="253" y="192" />
+        <di:waypoint x="780" y="192" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="310" y="161" width="66" height="13" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0oh3ye4_di" bpmnElement="SequenceFlow_0oh3ye4">
-        <di:waypoint xsi:type="dc:Point" x="538" y="-72" />
-        <di:waypoint xsi:type="dc:Point" x="562" y="-72" />
+        <di:waypoint x="538" y="-72" />
+        <di:waypoint x="562" y="-72" />
         <bpmndi:BPMNLabel>
           <dc:Bounds x="550" y="-93.5" width="0" height="13" />
         </bpmndi:BPMNLabel>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java
new file mode 100644 (file)
index 0000000..e0f88a2
--- /dev/null
@@ -0,0 +1,13 @@
+package org.onap.so.bpmn.infrastructure.sdnc.exceptions;
+
+public class SDNCErrorResponseException extends Exception {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 7807799223298140702L;
+       
+       public SDNCErrorResponseException(String message) {
+               super(message);
+       }
+}
index a4ef284..24f642a 100644 (file)
 
 package org.onap.so.bpmn.infrastructure.sdnc.tasks;
 
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
 import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.sdnc.exceptions.SDNCErrorResponseException;
 import org.onap.so.client.exception.BadResponseException;
 import org.onap.so.client.exception.ExceptionBuilder;
 import org.onap.so.client.exception.MapperException;
@@ -31,6 +39,8 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.HttpClientErrorException;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
 
 import com.jayway.jsonpath.JsonPath;
 import com.jayway.jsonpath.PathNotFoundException;
@@ -44,6 +54,7 @@ public class SDNCRequestTasks {
        private static final String MESSAGE = "_MESSAGE";
        private static final String CORRELATOR = "_CORRELATOR";
        protected static final String IS_CALLBACK_COMPLETED = "isCallbackCompleted";
+       protected static final String SDNC_SUCCESS = "200";
        
        @Autowired
        private ExceptionBuilder exceptionBuilder;
@@ -82,9 +93,24 @@ public class SDNCRequestTasks {
                try {
                        SDNCRequest request = (SDNCRequest)execution.getVariable(SDNC_REQUEST);
                        String asyncRequest = (String) execution.getVariable(request.getCorrelationName()+MESSAGE);
-                       String finalMessageIndicator = JsonPath.read(asyncRequest, "$.input.ack-final-indicator");              
+                       
+               DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+               DocumentBuilder db = dbf.newDocumentBuilder();
+               Document doc = db.parse(new InputSource(new StringReader(asyncRequest)));
+
+               String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
                        boolean isCallbackCompleted = convertIndicatorToBoolean(finalMessageIndicator);
                        execution.setVariable(IS_CALLBACK_COMPLETED, isCallbackCompleted);
+                       if(isCallbackCompleted) {
+                               String responseCode = getXmlElement(doc, "/input/response-code");
+                               String responseMessage = getXmlElement(doc, "/input/response-message"); 
+                               if(!SDNC_SUCCESS.equalsIgnoreCase(responseCode)) {
+                                       throw new SDNCErrorResponseException(responseMessage);
+                               }
+                       }
+               } catch (SDNCErrorResponseException e) {
+                       logger.error("SDNC error response - " + e.getMessage());
+                       exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage());
                } catch (Exception e) {
                        logger.error("Error procesing SDNC callback", e);
                        exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error procesing SDNC callback");
@@ -99,4 +125,9 @@ public class SDNCRequestTasks {
                return "Y".equals(finalMessageIndicator);
        }
        
+       protected String getXmlElement(Document doc, String exp) throws Exception {
+               XPath xPath = XPathFactory.newInstance().newXPath();
+               return xPath.evaluate(exp, doc);
+       }
+       
 }
index 867be2e..7562bd9 100644 (file)
@@ -372,6 +372,31 @@ public class WorkflowAction {
                return vnfcs;
        }
        
+       protected <T> List<T> getRelatedResourcesInVnfc(Vnfc vnfc, Class<T> resultClass, AAIObjectType type) {
+               
+               List<T> configurations = new ArrayList<>();
+               AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+               AAIResultWrapper vnfcResultsWrapper = bbInputSetupUtils.getAAIResourceDepthOne(uri);
+               Optional<Relationships> relationshipsOp = vnfcResultsWrapper.getRelationships();
+               if (!relationshipsOp.isPresent()) {
+                       logger.debug("No relationships were found for VNFC in AAI");
+               } else {
+                       Relationships relationships = relationshipsOp.get();
+                       List<AAIResultWrapper> configurationResultWrappers = this.getResultWrappersFromRelationships(relationships, type);
+                       for(AAIResultWrapper configurationResultWrapper : configurationResultWrappers) {
+                               Optional<T> configurationOp = configurationResultWrapper.asBean(resultClass);
+                               if(configurationOp.isPresent()) {
+                                       configurations.add(configurationOp.get());
+                               }
+                       }
+               }
+               return configurations;
+       }
+       
+       protected List<AAIResultWrapper> getResultWrappersFromRelationships(Relationships relationships, AAIObjectType type){
+               return relationships.getByType(type);
+       }
+       
        protected boolean isConfiguration(List<OrchestrationFlow> orchFlows) {
                for(OrchestrationFlow flow : orchFlows) {
                        if(flow.getFlowName().contains("Configuration")) {
@@ -384,6 +409,7 @@ public class WorkflowAction {
        protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ServiceInstancesRequest sIRequest, List<OrchestrationFlow> orchFlows, String requestId, Resource resourceKey,
                        String apiVersion, String resourceId, String requestAction, boolean aLaCarte, String vnfType,
                        WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, DelegateExecution execution) {
+               
                List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>();
                List<OrchestrationFlow> result = new ArrayList<>(orchFlows);
                result = orchFlows.stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)).collect(Collectors.toList());
@@ -392,22 +418,29 @@ public class WorkflowAction {
                
                String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId();
                String vfModuleCustomizationUUID = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId();
-               List<org.onap.aai.domain.yang.Configuration> configurations = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
-               
-               for(org.onap.aai.domain.yang.Configuration configuration : configurations) {
-                       workflowResourceIds.setConfigurationId(configuration.getConfigurationId());
-                       for(OrchestrationFlow orchFlow : result) {
-                               resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID);
-                               resourceKey.setCvnfModuleCustomizationId(configuration.getModelCustomizationId());
-                               resourceKey.setVnfCustomizationId(vnfCustomizationUUID);
-                               ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
-                                               requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true);
-                               String vnfcName = getVnfcNameForConfiguration(configuration);
-                               if(vnfcName == null || vnfcName.isEmpty()) {
-                                       buildAndThrowException(execution, "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match"));
+
+               List<org.onap.aai.domain.yang.Vnfc> vnfcs = getRelatedResourcesInVfModule(vnfId, vfModuleId, org.onap.aai.domain.yang.Vnfc.class, AAIObjectType.VNFC);
+               for(org.onap.aai.domain.yang.Vnfc vnfc : vnfcs) {
+                       List<org.onap.aai.domain.yang.Configuration> configurations = getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+                       if (configurations.size() > 1){
+                               String multipleRelationshipsError = "Multiple relationships exist from VNFC "+vnfc.getVnfcName()+" to Configurations";
+                               buildAndThrowException(execution, multipleRelationshipsError, new Exception(multipleRelationshipsError));
+                       }
+                       for(org.onap.aai.domain.yang.Configuration configuration : configurations) {
+                               workflowResourceIds.setConfigurationId(configuration.getConfigurationId());
+                               for(OrchestrationFlow orchFlow : result) {
+                                       resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID);
+                                       resourceKey.setCvnfModuleCustomizationId(vnfc.getModelCustomizationId());
+                                       resourceKey.setVnfCustomizationId(vnfCustomizationUUID);
+                                       ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, resourceId,
+                                                       requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null, true);
+                                       String vnfcName = getVnfcNameForConfiguration(configuration);
+                                       if(vnfcName == null || vnfcName.isEmpty()) {
+                                               buildAndThrowException(execution, "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match"));
+                                       }
+                                       ebb.getConfigurationResourceKeys().setVnfcName(vnfcName);
+                                       flowsToExecuteConfigs.add(ebb);
                                }
-                               ebb.getConfigurationResourceKeys().setVnfcName(vnfcName);
-                               flowsToExecuteConfigs.add(ebb);
                        }
                }
                return flowsToExecuteConfigs;
index f1779cf..043aad4 100644 (file)
@@ -27,9 +27,13 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
 import java.io.IOException;
+import java.io.StringReader;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
 import org.camunda.bpm.engine.delegate.BpmnError;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 
@@ -51,6 +55,8 @@ import org.onap.so.client.exception.MapperException;
 import org.onap.so.client.sdnc.SDNCClient;
 import org.onap.so.client.sdnc.beans.SDNCRequest;
 import org.onap.so.client.sdnc.endpoint.SDNCTopology;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
 
 import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.databind.JsonMappingException;
@@ -131,12 +137,29 @@ public class SDNCRequestTasksTest extends SDNCRequestTasks{
        
        @Test
        public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException{
-               final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_ASYNC_Request.json")));    
+               final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));    
                delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);                 
                sndcRequestTasks.processCallback(delegateExecution);            
                assertEquals(true,delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
        }
        
+       @Test
+       public void getXmlElementTest() throws Exception {
+               final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));    
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+        DocumentBuilder db;
+        db = dbf.newDocumentBuilder ();
+        Document doc = db.parse (new InputSource(new StringReader(sdncResponse)));
+        
+        String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
+        String responseCode = getXmlElement(doc, "/input/response-code");
+               String responseMessage = getXmlElement(doc, "/input/response-message"); 
+               
+               assertEquals("Y", finalMessageIndicator);
+               assertEquals("200", responseCode);
+               assertEquals("Success", responseMessage);
+       }
+       
        public SDNCRequest createSDNCRequest(){
                SDNCRequest request = new SDNCRequest();
                request.setCorrelationName("correlationName");
index 0bc20c1..87e6daa 100644 (file)
@@ -53,6 +53,7 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
+import org.mockito.Spy;
 import org.onap.aai.domain.yang.GenericVnf;
 import org.onap.aai.domain.yang.L3Network;
 import org.onap.aai.domain.yang.Relationship;
@@ -60,6 +61,7 @@ import org.onap.aai.domain.yang.RelationshipList;
 import org.onap.aai.domain.yang.ServiceInstance;
 import org.onap.aai.domain.yang.VfModule;
 import org.onap.aai.domain.yang.VfModules;
+import org.onap.aai.domain.yang.Vnfc;
 import org.onap.aai.domain.yang.VolumeGroup;
 import org.onap.so.bpmn.BaseTaskTest;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
@@ -67,7 +69,11 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
 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.aai.AAIObjectType;
+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.db.catalog.beans.CollectionNetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.CollectionResource;
 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
@@ -100,9 +106,15 @@ public class WorkflowActionTest extends BaseTaskTest {
        private DelegateExecution execution;
 
        
+       @InjectMocks
+       @Spy
+       protected WorkflowAction SPY_workflowAction;
+       
        @Rule
        public ExpectedException thrown = ExpectedException.none();
        
+       private String RESOURCE_PATH = "src/test/resources/__files/";
+       
        @Before
        public void before() throws Exception {
                execution = new DelegateExecutionFake();
@@ -930,6 +942,123 @@ public class WorkflowActionTest extends BaseTaskTest {
                assertEqualsBulkFlowName(ebbs,"AssignVfModuleBB","CreateVfModuleBB","ActivateVfModuleBB","AssignFabricConfigurationBB","ActivateFabricConfigurationBB", "AssignFabricConfigurationBB","ActivateFabricConfigurationBB");
        }
        
+       @Test
+       public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception{
+               String gAction = "deleteInstance";
+               String resource = "VfModule";
+               execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+               execution.setVariable("requestAction", gAction);
+               String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+               execution.setVariable("bpmnRequest", bpmnRequest);              
+               execution.setVariable("aLaCarte", true);
+               execution.setVariable("apiVersion", "7");
+               execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+               
+               NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+               List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
+               northBoundRequest.setOrchestrationFlowList(orchFlows);
+               
+               when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
+               
+               org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+               vnf.setVnfId("vnf0");
+               vnf.setModelCustomizationId("modelCustomizationId");
+               when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+               
+               org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+               vfModule.setModelCustomizationId("modelCustomizationId");
+               when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+               
+               List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+               org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+               vnfc.setModelInvariantId("modelInvariantId");
+               vnfc.setVnfcName("testVnfcName");
+               vnfcs.add(vnfc);
+               doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
+               
+               List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
+               org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+               configuration.setConfigurationId("configurationId");
+               configuration.setModelCustomizationId("modelCustimizationId");
+               configuration.setConfigurationName("testConfigurationName");
+               configurations.add(configuration);
+               doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
+               
+               doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+               
+               SPY_workflowAction.selectExecutionList(execution);
+               List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+               assertEqualsBulkFlowName(ebbs,"DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB","DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
+       }
+       
+       @Test
+       public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception{
+               String gAction = "deleteInstance";
+               String resource = "VfModule";
+               execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
+               execution.setVariable("requestAction", gAction);
+               String bpmnRequest = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
+               execution.setVariable("bpmnRequest", bpmnRequest);              
+               execution.setVariable("aLaCarte", true);
+               execution.setVariable("apiVersion", "7");
+               execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+               
+               NorthBoundRequest northBoundRequest = new NorthBoundRequest();
+               List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB","DeactivateFabricConfigurationBB","UnassignFabricConfigurationBB");
+               northBoundRequest.setOrchestrationFlowList(orchFlows);
+               
+               when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction,resource,true,"my-custom-cloud-owner")).thenReturn(northBoundRequest);
+               
+               org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+               vnf.setVnfId("vnf0");
+               vnf.setModelCustomizationId("modelCustomizationId");
+               when(bbSetupUtils.getAAIGenericVnf(anyObject())).thenReturn(vnf);
+               
+               org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+               vfModule.setModelCustomizationId("modelCustomizationId");
+               when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
+               
+               List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+               org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+               vnfc.setModelInvariantId("modelInvariantId");
+               vnfc.setVnfcName("testVnfcName");
+               vnfcs.add(vnfc);
+               doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(), anyObject());
+               
+               List<org.onap.aai.domain.yang.Configuration> configurations = new ArrayList<org.onap.aai.domain.yang.Configuration>();
+               org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+               doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(), anyObject());
+               
+               doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
+               
+               SPY_workflowAction.selectExecutionList(execution);
+               List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+               assertEqualsBulkFlowName(ebbs,"DeactivateVfModuleBB","DeleteVfModuleBB","UnassignVfModuleBB");
+       }
+       
+       @Test
+       public void getRelatedResourcesInVfModuleTest() throws Exception{
+               org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
+               vnfc.setModelInvariantId("modelInvariantId");
+               vnfc.setVnfcName("testVnfcName");
+               
+               String vfncPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/vnfcResponse.json")));
+               AAIResultWrapper vfncWrapper = new AAIResultWrapper(vfncPayload);
+               
+               String configurationPayload = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "/BuildingBlocks/configurationResponse.json")));
+               AAIResultWrapper configurationWrapper = new AAIResultWrapper(configurationPayload);
+               List<AAIResultWrapper> configurationResultWrappers = new ArrayList<AAIResultWrapper>();
+               configurationResultWrappers.add(configurationWrapper);
+               
+               AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfc.getVnfcName());
+               when(bbSetupUtils.getAAIResourceDepthOne(uri)).thenReturn(vfncWrapper);
+               
+               doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),anyObject());
+               List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+               assertEquals(1,configurationsList.size());
+               assertEquals("testConfigurationId",configurationsList.get(0).getConfigurationId());
+       }
+       
        /**
         * WorkflowActionBB Tests
         */
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/configurationResponse.json
new file mode 100644 (file)
index 0000000..c8420a5
--- /dev/null
@@ -0,0 +1,8 @@
+{
+       "configuration-id": "testConfigurationId",
+       "configuration-type": "...",
+       "orchestration-status": "...",
+       "tunnel-bandwidth": "100",
+       "vendor-allowed-max-bandwidth": "90",
+       "resource-version": "1234"
+}
\ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/vnfcResponse.json
new file mode 100644 (file)
index 0000000..0b2d847
--- /dev/null
@@ -0,0 +1,29 @@
+{
+  "vnfc-name": "vnfcName",
+  "nfc-naming-code": "oamfw",
+  "nfc-function": "FIREWALL",
+  "prov-status": "PREPROV",
+  "orchestration-status": "Active",
+  "in-maint": false,
+  "is-closed-loop-disabled": false,
+  "model-invariant-id": "9dae8bb5-0709-4c0e-8f5b-6448232510ea",
+  "model-version-id": "b4e05ccb-01d0-4176-90ae-380308a35e5f",
+  "model-customization-id": "abf73d38-9da2-47af-bd53-26954318449f",
+  "resource-version": "1552319567126",
+   "relationship-list": {
+      "relationship": [
+        {
+          "related-to": "generic-vnf",
+          "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/testGenericVnfId",
+          "relationship-data": {
+            "relationship-key": "generic-vnf",
+            "relationship-value": "4a9184ac-5fad-44a1-b224-289bb490eaa9"
+          },
+          "related-to-property": {
+            "property-key": "generic-vnf.vnf-name",
+            "property-value": "USBBBBmtwnjVVHP047"
+          }
+        }
+      ]
+    }
+}
\ No newline at end of file
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml
new file mode 100644 (file)
index 0000000..aa69dba
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<input>
+   <service-information>
+      <service-type>MY-SERVICE-TYPE</service-type>
+      <service-instance-id>b8308928-de76-4ce6-9e58-ec6033ff43b3</service-instance-id>
+   </service-information>
+   <svc-request-id>aa243891-4575-4040-bceb-25d5b7bc8c61</svc-request-id>
+   <response-code>200</response-code>
+   <response-message>Success</response-message>
+   <ack-final-indicator>Y</ack-final-indicator>
+</input>
index d35db00..7adb7d1 100644 (file)
                </dependencies>
        </dependencyManagement>
        <dependencies>
+                       <!-- Dependencies on other MSO Projects -->
+               <dependency>
+                       <groupId>org.onap.so</groupId>
+                       <artifactId>mso-requests-db</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-jersey</artifactId>
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/RequestIdFilter.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/RequestIdFilter.java
new file mode 100644 (file)
index 0000000..17dd985
--- /dev/null
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.apihandler.filters;
+
+import java.io.IOException;
+
+import javax.annotation.Priority;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.http.HttpStatus;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.slf4j.MDC;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Priority(2)
+@Provider
+@Component
+public class RequestIdFilter implements ContainerRequestFilter {
+
+       protected static Logger logger = LoggerFactory.getLogger(RequestIdFilter.class);
+       
+       @Autowired
+       private RequestsDbClient infraActiveRequestsClient;
+
+       @Override
+       public void filter(ContainerRequestContext context) throws IOException {
+               String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
+       
+        InfraActiveRequests infraActiveRequests = infraActiveRequestsClient.getInfraActiveRequestbyRequestId(requestId);
+        
+        if (infraActiveRequests != null) {
+               MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(HttpStatus.SC_BAD_REQUEST));
+               logger.error("RequestID exists in RequestDB.InfraActiveRequests : " + requestId);
+        }
+       }
+}
diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/filters/RequestIdFilterTest.java
new file mode 100644 (file)
index 0000000..dae6542
--- /dev/null
@@ -0,0 +1,68 @@
+package org.onap.so.apihandler.filters;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+
+import java.io.IOException;
+
+import javax.ws.rs.container.ContainerRequestContext;
+
+import org.apache.http.HttpStatus;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.MockitoRule;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
+import org.slf4j.MDC;
+
+@RunWith(MockitoJUnitRunner.class)
+public class RequestIdFilterTest {
+
+    @Mock
+    ContainerRequestContext mockContext;
+       
+       @Mock
+       protected RequestsDbClient requestsDbClient;
+       
+    @InjectMocks
+    @Spy
+    RequestIdFilter requestIdFilter;
+       
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+    
+    @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
+    
+       @Test
+       public void filterTest() throws IOException {
+               
+               String requestId = "32807a28-1a14-4b88-b7b3-2950918aa769";              
+               MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
+               
+        //ExpectedRecord InfraActiveRequests
+        InfraActiveRequests infraActiveRequests = new InfraActiveRequests();
+        infraActiveRequests.setRequestStatus("FAILED");
+        infraActiveRequests.setProgress(100L);
+        infraActiveRequests.setLastModifiedBy("APIH");
+        infraActiveRequests.setRequestScope("network");
+        infraActiveRequests.setRequestAction("deleteInstance");
+        infraActiveRequests.setRequestId("32807a28-1a14-4b88-b7b3-2950918aa769");  
+       
+               doReturn(infraActiveRequests).when(requestsDbClient).getInfraActiveRequestbyRequestId(requestId);
+               
+               requestIdFilter.filter(mockContext);
+               
+               Mockito.verify( requestIdFilter, Mockito.times(1)).filter(mockContext);
+               assertEquals(MDC.get(ONAPLogConstants.MDCs.RESPONSE_CODE), String.valueOf(HttpStatus.SC_BAD_REQUEST));
+               
+       }
+}
index 434b9e9..866a4e7 100644 (file)
@@ -26,6 +26,7 @@ import javax.ws.rs.ApplicationPath;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.servlet.ServletProperties;
 import org.onap.so.apihandler.filters.RequestUriFilter;
+import org.onap.so.apihandler.filters.RequestIdFilter;
 import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper;
 import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestration;
 import org.onap.so.apihandlerinfra.tenantisolation.CloudResourcesOrchestration;
@@ -61,6 +62,7 @@ public class JerseyConfiguration extends ResourceConfig {
                register(ApiExceptionMapper.class);
                register(RuntimeExceptionMapper.class);
                register(RequestUriFilter.class);
+               register(RequestIdFilter.class);
                register(E2EServiceInstances.class);
                register(WorkflowSpecificationsHandler.class);
                register(InstanceManagement.class);
index df1c947..d010288 100644 (file)
@@ -787,7 +787,7 @@ public class CatalogDbClient {
             logger.debug("Found CvnfcCustomization: {}", filtered.get(0));
             return filtered.get(0);
         }else
-            throw new EntityNotFoundException("Unable to find VfModuleCustomization ModelCustomizationUUID:" + cvnfcCustomizationUuid);
+            throw new EntityNotFoundException("Unable to find CvnfcCustomization ModelCustomizationUUID:" + cvnfcCustomizationUuid);
     }
     
     public CvnfcConfigurationCustomization getCvnfcCustomization(String serviceModelUUID, String vnfCustomizationUuid,