Merge "Add missing duplication test in integration test suite"
diff --git a/cps-ri/src/main/java/org/onap/cps/ri/CpsDataPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/ri/CpsDataPersistenceServiceImpl.java
index ee555f7..ecbe447 100644
--- a/cps-ri/src/main/java/org/onap/cps/ri/CpsDataPersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/ri/CpsDataPersistenceServiceImpl.java
@@ -228,6 +228,9 @@
final Collection<String> xpaths = xpathToUpdatedDataNode.keySet();
Collection<FragmentEntity> existingFragmentEntities = getFragmentEntities(anchorEntity, xpaths);
+
+ logMissingXPaths(xpaths, existingFragmentEntities);
+
existingFragmentEntities = fragmentRepository.prefetchDescendantsOfFragmentEntities(
FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS, existingFragmentEntities);
@@ -243,6 +246,19 @@
}
}
+ private void logMissingXPaths(final Collection<String> xpaths, final Collection<FragmentEntity>
+ existingFragmentEntities) {
+ final Set<String> existingXPaths = existingFragmentEntities.stream().map(FragmentEntity::getXpath)
+ .collect(Collectors.toSet());
+
+ final Set<String> missingXPaths = xpaths.stream().filter(xpath -> !existingXPaths.contains(xpath))
+ .collect(Collectors.toSet());
+
+ if (!missingXPaths.isEmpty()) {
+ log.warn("Cannot update data nodes: Target XPaths {} not found in DB.", missingXPaths);
+ }
+ }
+
private void retryUpdateDataNodesIndividually(final AnchorEntity anchorEntity,
final Collection<FragmentEntity> fragmentEntities) {
final Collection<String> failedXpaths = new HashSet<>();