SonarQube Violation: fields() deprecated 41/141541/2
authoremaclee <lee.anjella.macabuhay@est.tech>
Wed, 16 Jul 2025 13:34:10 +0000 (14:34 +0100)
committerLee Anjella Macabuhay <lee.anjella.macabuhay@est.tech>
Wed, 16 Jul 2025 16:11:11 +0000 (16:11 +0000)
- change use of fields() to properties() as documented https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/latest/com/fasterxml/jackson/databind/JsonNode.html#fields--

Issue-ID: CPS-475
Change-Id: I17c9d08c3b753103cfe0a07addf175df59c9a082
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleOperationsUtils.java

index 80e4165..203198d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2022-2025 Nordix Foundation
+ *  Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
  *  Modifications Copyright (C) 2022 Bell Canada
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,9 +26,9 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.UUID;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -201,8 +201,8 @@ public class ModuleOperationsUtils {
     private String getFirstResource(final Object responseBody) {
         final String jsonObjectAsString = jsonObjectMapper.asJsonString(responseBody);
         final JsonNode overallJsonNode = jsonObjectMapper.convertToJsonNode(jsonObjectAsString);
-        final Iterator<Map.Entry<String, JsonNode>> overallJsonTreeMap = overallJsonNode.fields();
-        final Map.Entry<String, JsonNode> firstElement = overallJsonTreeMap.next();
+        final Set<Map.Entry<String, JsonNode>> overallJsonTreeMap = overallJsonNode.properties();
+        final Map.Entry<String, JsonNode> firstElement = overallJsonTreeMap.iterator().next();
         return jsonObjectMapper.asJsonString(Map.of(firstElement.getKey(), firstElement.getValue()));
     }