diff options
author | danielhanrahan <daniel.hanrahan@est.tech> | 2023-02-03 18:35:16 +0000 |
---|---|---|
committer | danielhanrahan <daniel.hanrahan@est.tech> | 2023-02-07 12:31:31 +0000 |
commit | 95ccdb630575a34c0229c08b6fdabd3a2e57f5fc (patch) | |
tree | 4b578c14ed0000547b814674e1a555d0c1de4412 /cps-ncmp-service/src/main | |
parent | f965c8eefcf21ceaeff1be461bc51269e1d36715 (diff) |
Update CmHandleState on deregistration response
Current implementation incorrectly sets CmHandleState to DELETED for
CM handles that were not deleted.
- Update CmHandleState to DELETED only for deleted CM handles
- Minor test refactoring
Issue-ID: CPS-1471
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: Ibf8b6d2b87d46a7633f0497b065e3d4099851fd6
Diffstat (limited to 'cps-ncmp-service/src/main')
-rwxr-xr-x | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index a5bd60605a..59b960af65 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -327,9 +327,10 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService final List<String> tobeRemovedCmHandles) { final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses = new ArrayList<>(tobeRemovedCmHandles.size()); - final List<YangModelCmHandle> yangModelCmHandles = - tobeRemovedCmHandles.stream().map(inventoryPersistence::getYangModelCmHandle) - .collect(Collectors.toList()); + final Map<String, YangModelCmHandle> cmHandleIdToYangModelCmHandleMap = tobeRemovedCmHandles.stream() + .collect(Collectors.toMap(cmHandleId -> cmHandleId, inventoryPersistence::getYangModelCmHandle)); + + final Collection<YangModelCmHandle> yangModelCmHandles = cmHandleIdToYangModelCmHandleMap.values(); updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETING); for (final List<String> tobeRemovedCmHandleBatch : Lists.partition(tobeRemovedCmHandles, DELETE_BATCH_SIZE)) { @@ -348,7 +349,15 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService } } - updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETED); + final Collection<YangModelCmHandle> deletedYangModelCmHandles = + cmHandleRegistrationResponses.stream() + .filter(cmHandleRegistrationResponse -> + cmHandleRegistrationResponse.getStatus().equals(CmHandleRegistrationResponse.Status.SUCCESS)) + .map(CmHandleRegistrationResponse::getCmHandle) + .map(cmHandleIdToYangModelCmHandleMap::get) + .collect(Collectors.toList()); + updateCmHandleStateBatch(deletedYangModelCmHandles, CmHandleState.DELETED); + return cmHandleRegistrationResponses; } @@ -372,11 +381,10 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService } } - private void updateCmHandleStateBatch(final List<YangModelCmHandle> yangModelCmHandles, + private void updateCmHandleStateBatch(final Collection<YangModelCmHandle> yangModelCmHandles, final CmHandleState cmHandleState) { final Map<YangModelCmHandle, CmHandleState> cmHandleIdsToBeRemoved = new HashMap<>(); - yangModelCmHandles.stream().forEach(yangModelCmHandle -> - cmHandleIdsToBeRemoved.put(yangModelCmHandle, cmHandleState)); + yangModelCmHandles.forEach(yangModelCmHandle -> cmHandleIdsToBeRemoved.put(yangModelCmHandle, cmHandleState)); lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleIdsToBeRemoved); } |