diff options
author | 2023-07-17 09:22:05 +0100 | |
---|---|---|
committer | 2023-07-17 11:22:06 +0100 | |
commit | dcf84ad73f0301ef41049e692b9963f6dcac3661 (patch) | |
tree | c7384f6abcc35da86475c222e7f6c16186d374fb /cps-service/src/main | |
parent | efd255d61b0414d9cd44267779d144b78d1eb294 (diff) |
Improved code coverage for CpsDataServiceImpl
- Added (extended) test to cover missed scenarios
- Removed unnecesarry null check from Production code
- Improved error messages in production code
- Removed duplicate test
- Cleaned up existign test somewhat (labels and aligment)
Issue-ID: CPS-475
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Change-Id: I9761ad6d4777a6bcfee4cbe1b876dd39fa218fc8
Diffstat (limited to 'cps-service/src/main')
-rwxr-xr-x | cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java index 0a7afc8f6..6e7c1649d 100755 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java @@ -351,7 +351,7 @@ public class CpsDataServiceImpl implements CpsDataService { .withContainerNode(containerNode) .buildCollection(); if (dataNodes.isEmpty()) { - throw new DataValidationException("Invalid data.", "No data nodes provided"); + throw new DataValidationException("No data nodes.", "No data nodes provided"); } return dataNodes; } @@ -363,7 +363,7 @@ public class CpsDataServiceImpl implements CpsDataService { .withContainerNode(containerNode) .buildCollection(); if (dataNodes.isEmpty()) { - throw new DataValidationException("Invalid data.", "No data nodes provided"); + throw new DataValidationException("No data nodes.", "No data nodes provided"); } return dataNodes; } @@ -381,7 +381,7 @@ public class CpsDataServiceImpl implements CpsDataService { try { notificationService.processDataUpdatedEvent(anchor, xpath, operation, observedTimestamp); } catch (final Exception exception) { - //If async message can't be queued for notification service, the initial request should not failed. + //If async message can't be queued for notification service, the initial request should not fail. log.error("Failed to send message to notification service", exception); } } @@ -392,9 +392,6 @@ public class CpsDataServiceImpl implements CpsDataService { } private void processDataNodeUpdate(final Anchor anchor, final DataNode dataNodeUpdate) { - if (dataNodeUpdate == null) { - return; - } cpsDataPersistenceService.batchUpdateDataLeaves(anchor.getDataspaceName(), anchor.getName(), Collections.singletonMap(dataNodeUpdate.getXpath(), dataNodeUpdate.getLeaves())); final Collection<DataNode> childDataNodeUpdates = dataNodeUpdate.getChildDataNodes(); |