Addressed an adaptability issue 86/138286/2
authorsourabh_sourabh <sourabh.sourabh@est.tech>
Wed, 19 Jun 2024 13:35:30 +0000 (14:35 +0100)
committersourabh_sourabh <sourabh.sourabh@est.tech>
Wed, 19 Jun 2024 14:16:41 +0000 (15:16 +0100)
- Defined a constant instead of duplicating literal "No data nodes 4 times.

Issue-ID: CPS-478
Change-Id: I2b980a228217e85424342d4c2b9e97c5cfa618d1
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java

index 6386d38..5a48428 100644 (file)
@@ -65,6 +65,7 @@ public class CpsDataServiceImpl implements CpsDataService {
 
     private static final String ROOT_NODE_XPATH = "/";
     private static final long DEFAULT_LOCK_TIMEOUT_IN_MILLISECONDS = 300L;
+    private static final String NO_DATA_NODES = "No data nodes.";
 
     private final CpsDataPersistenceService cpsDataPersistenceService;
     private final CpsDataUpdateEventsService cpsDataUpdateEventsService;
@@ -425,7 +426,7 @@ public class CpsDataServiceImpl implements CpsDataService {
                     .withContainerNode(containerNode)
                     .buildCollection();
             if (dataNodes.isEmpty()) {
-                throw new DataValidationException("No data nodes.", "No data nodes provided");
+                throw new DataValidationException(NO_DATA_NODES, "No data nodes provided");
             }
             return dataNodes;
         }
@@ -437,7 +438,7 @@ public class CpsDataServiceImpl implements CpsDataService {
             .withContainerNode(containerNode)
             .buildCollection();
         if (dataNodes.isEmpty()) {
-            throw new DataValidationException("No data nodes.", "No data nodes provided");
+            throw new DataValidationException(NO_DATA_NODES, "No data nodes provided");
         }
         return dataNodes;
     }
@@ -453,8 +454,7 @@ public class CpsDataServiceImpl implements CpsDataService {
                     .withContainerNode(containerNode)
                     .buildCollection();
             if (dataNodes.isEmpty()) {
-                throw new DataValidationException("No data nodes.",
-                        "Data nodes were not found under the xpath " + xpath);
+                throw new DataValidationException(NO_DATA_NODES, "Data nodes were not found under the xpath " + xpath);
             }
             return dataNodes;
         }
@@ -466,7 +466,7 @@ public class CpsDataServiceImpl implements CpsDataService {
                 .withContainerNode(containerNode)
                 .buildCollection();
         if (dataNodes.isEmpty()) {
-            throw new DataValidationException("No data nodes.", "Data nodes were not found under the xpath " + xpath);
+            throw new DataValidationException(NO_DATA_NODES, "Data nodes were not found under the xpath " + xpath);
         }
         return dataNodes;
     }