Changed the object mapper to ignore unknown fields 77/113077/2
authorParthasarathy, Ramesh <ramesh.parthasarathy@att.com>
Wed, 23 Sep 2020 18:43:29 +0000 (14:43 -0400)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Wed, 23 Sep 2020 18:45:05 +0000 (14:45 -0400)
Changed the object mapper to ignore unknown fields
Changed to use instance object mapper

switched to use method level object mapper

Issue-ID: SO-3263
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: Iae713978393a04313abec215e8ea330a93db9c24

bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/FlowsToExecute.json

index 4e0b563..477d3c6 100644 (file)
@@ -86,7 +86,6 @@ import com.fasterxml.jackson.databind.type.TypeFactory;
 public class BBInputSetupUtils {
 
     private static final Logger logger = LoggerFactory.getLogger(BBInputSetupUtils.class);
-    private ObjectMapper objectMapper = new ObjectMapper();
     private static final String REQUEST_ERROR = "Could not find request.";
     private static final String DATA_LOAD_ERROR = "Could not process loading data from database";
     private static final String DATA_PARSE_ERROR = "Could not parse data";
@@ -189,7 +188,8 @@ public class BBInputSetupUtils {
                                 request.getOriginalRequestId(), PROCESSING_DATA_NAME_EXECUTION_FLOWS);
                 try {
                     ObjectMapper om = new ObjectMapper();
-                    TypeFactory typeFactory = objectMapper.getTypeFactory();
+                    TypeFactory typeFactory = om.getTypeFactory();
+                    om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
                     return om.readValue(requestProcessingData.getValue(),
                             typeFactory.constructCollectionType(List.class, ExecuteBuildingBlock.class));
                 } catch (Exception e) {
@@ -245,6 +245,8 @@ public class BBInputSetupUtils {
         if (requestId != null && !requestId.isEmpty()) {
             InfraActiveRequests activeRequest = this.getInfraActiveRequest(requestId);
             String requestBody = activeRequest.getRequestBody().replaceAll("\\\\", "");
+            ObjectMapper objectMapper = new ObjectMapper();
+            objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
             objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
             objectMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
             return objectMapper.readValue(requestBody, RequestDetails.class);
index f6615e5..5e8d484 100644 (file)
@@ -42,6 +42,7 @@ import java.nio.file.Paths;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
+import com.fasterxml.jackson.databind.DeserializationFeature;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -115,6 +116,7 @@ public class BBInputSetupUtilsTest {
 
     @Before
     public void setup() {
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
     }
 
index fa271b9..7bbc287 100644 (file)
@@ -58,7 +58,8 @@
       "vnfResourceCustomizationUUID": "a80f05b8-d651-44af-b999-8ed78fb4582f",
       "cvnfcCustomizationUUID": "69cce457-9ffd-4359-962b-0596a1e83ad1",
       "vnfcName": "zauk51bmcmr01mcm001"
-    }
+    },
+    "resume": null
   },
   {
     "buildingBlock": {