summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main/java/org
diff options
context:
space:
mode:
authorToineSiebelink <toine.siebelink@est.tech>2022-02-02 12:17:15 +0000
committerToineSiebelink <toine.siebelink@est.tech>2022-02-02 12:17:15 +0000
commitd924ab57a11af19f92037d150e5e5e8ea52f04a8 (patch)
treeab3c0891df254ed7e3bd9692dc92bc7b6c25b5db /cps-ri/src/main/java/org
parente40ad3de6b58e3f421f29e4550e35adebd38abe6 (diff)
Test Scenario for replaceListContent
-Improved a test scenarios for replaceListContent in CpsDataPersistenceServiceSpec -Removed redundant SQL Data -Used groovy shortcuts where posisble (no need for get...() methods when using Groovy :-) Issue-ID: CPS-868 Change-Id: I3d29bbb0c5d035c6f266cf31bf2886f1bcf5d48a Signed-off-by: mpriyank <priyank.maheshwari@est.tech> Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Diffstat (limited to 'cps-ri/src/main/java/org')
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
index c6e28aba91..2d67d7c953 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
@@ -48,6 +48,7 @@ import org.onap.cps.spi.entities.DataspaceEntity;
import org.onap.cps.spi.entities.FragmentEntity;
import org.onap.cps.spi.exceptions.AlreadyDefinedException;
import org.onap.cps.spi.exceptions.ConcurrencyException;
+import org.onap.cps.spi.exceptions.CpsAdminException;
import org.onap.cps.spi.exceptions.CpsPathException;
import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
import org.onap.cps.spi.model.DataNode;
@@ -384,6 +385,10 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
}
private static String getListElementXpathPrefix(final Collection<DataNode> newListElements) {
+ if (newListElements.isEmpty()) {
+ throw new CpsAdminException("Invalid list replacement",
+ "Cannot replace list elements with empty collection");
+ }
final String firstChildNodeXpath = newListElements.iterator().next().getXpath();
return firstChildNodeXpath.substring(0, firstChildNodeXpath.lastIndexOf("[") + 1);
}