summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2023-10-11 08:54:57 +0000
committerGerrit Code Review <gerrit@onap.org>2023-10-11 08:54:57 +0000
commit4bc19fe118ca7d81891c12d40719a569bc528a21 (patch)
treeaafde6495f3e5a5f53ea07f92db6a31f13f2d4ad
parentd27dc5428a8bb256b901736f483c795266a68528 (diff)
parent6c338a5655f569adff88d9317e7482f1482b455d (diff)
Merge "Conflicting Error code"
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java2
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy24
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NcmpResponseStatus.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NcmpEventResponseCode.java)17
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java14
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java8
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java52
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java16
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/DataOperationEventCreator.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtils.java21
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java42
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy32
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy22
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy32
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy25
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponseSpec.groovy41
-rw-r--r--dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java12
16 files changed, 182 insertions, 190 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java
index 87f9d835a1..cd61c5a4a5 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java
@@ -126,7 +126,7 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor
final CmHandleRegistrationResponse registrationResponse) {
return new CmHandlerRegistrationErrorResponse()
.cmHandle(registrationResponse.getCmHandle())
- .errorCode(registrationResponse.getRegistrationError().errorCode)
+ .errorCode(registrationResponse.getNcmpResponseStatus().getCode())
.errorText(registrationResponse.getErrorText());
}
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
index e755094dd2..1d03be107d 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryControllerSpec.groovy
@@ -219,14 +219,14 @@ class NetworkCmProxyInventoryControllerSpec extends Specification {
responseBody.getFailedUpdatedCmHandles() == expectedFailedUpdateCmHandle
responseBody.getFailedRemovedCmHandles() == expectedFailedRemovedCmHandle
where:
- scenario | createCmHandleResponse | updateCmHandleResponse | removeCmHandleResponse || expectedFailedCreatedCmHandle | expectedFailedUpdateCmHandle | expectedFailedRemovedCmHandle
- 'only create failed' | failedResponse('cm-handle-1') | successResponse('cm-handle-2') | successResponse('cm-handle-3') || [failedRestResponse('cm-handle-1')] | [] | []
- 'only update failed' | successResponse('cm-handle-1') | failedResponse('cm-handle-2') | successResponse('cm-handle-3') || [] | [failedRestResponse('cm-handle-2')] | []
- 'only delete failed' | successResponse('cm-handle-1') | successResponse('cm-handle-2') | failedResponse('cm-handle-3') || [] | [] | [failedRestResponse('cm-handle-3')]
- 'all three failed' | failedResponse('cm-handle-1') | failedResponse('cm-handle-2') | failedResponse('cm-handle-3') || [failedRestResponse('cm-handle-1')] | [failedRestResponse('cm-handle-2')] | [failedRestResponse('cm-handle-3')]
- 'create update failed' | failedResponse('cm-handle-1') | failedResponse('cm-handle-2') | successResponse('cm-handle-3') || [failedRestResponse('cm-handle-1')] | [failedRestResponse('cm-handle-2')] | []
- 'create delete failed' | failedResponse('cm-handle-1') | successResponse('cm-handle-2') | failedResponse('cm-handle-3') || [failedRestResponse('cm-handle-1')] | [] | [failedRestResponse('cm-handle-3')]
- 'update delete failed' | successResponse('cm-handle-1') | failedResponse('cm-handle-2') | failedResponse('cm-handle-3') || [] | [failedRestResponse('cm-handle-2')] | [failedRestResponse('cm-handle-3')]
+ scenario | createCmHandleResponse | updateCmHandleResponse | removeCmHandleResponse || expectedFailedCreatedCmHandle | expectedFailedUpdateCmHandle | expectedFailedRemovedCmHandle
+ 'only create failed' | expectedFailedResponse('cm-handle-1') | expectedSuccessResponse('cm-handle-2') | expectedSuccessResponse('cm-handle-3') || [expectedUnknownErrorResponse('cm-handle-1')] | [] | []
+ 'only update failed' | expectedSuccessResponse('cm-handle-1') | expectedFailedResponse('cm-handle-2') | expectedSuccessResponse('cm-handle-3') || [] | [expectedUnknownErrorResponse('cm-handle-2')] | []
+ 'only delete failed' | expectedSuccessResponse('cm-handle-1') | expectedSuccessResponse('cm-handle-2') | expectedFailedResponse('cm-handle-3') || [] | [] | [expectedUnknownErrorResponse('cm-handle-3')]
+ 'all three failed' | expectedFailedResponse('cm-handle-1') | expectedFailedResponse('cm-handle-2') | expectedFailedResponse('cm-handle-3') || [expectedUnknownErrorResponse('cm-handle-1')] | [expectedUnknownErrorResponse('cm-handle-2')] | [expectedUnknownErrorResponse('cm-handle-3')]
+ 'create update failed' | expectedFailedResponse('cm-handle-1') | expectedFailedResponse('cm-handle-2') | expectedSuccessResponse('cm-handle-3') || [expectedUnknownErrorResponse('cm-handle-1')] | [expectedUnknownErrorResponse('cm-handle-2')] | []
+ 'create delete failed' | expectedFailedResponse('cm-handle-1') | expectedSuccessResponse('cm-handle-2') | expectedFailedResponse('cm-handle-3') || [expectedUnknownErrorResponse('cm-handle-1')] | [] | [expectedUnknownErrorResponse('cm-handle-3')]
+ 'update delete failed' | expectedSuccessResponse('cm-handle-1') | expectedFailedResponse('cm-handle-2') | expectedFailedResponse('cm-handle-3') || [] | [expectedUnknownErrorResponse('cm-handle-2')] | [expectedUnknownErrorResponse('cm-handle-3')]
}
def 'Get all cm handle IDs by DMI plugin identifier.'() {
@@ -246,15 +246,15 @@ class NetworkCmProxyInventoryControllerSpec extends Specification {
assert response.contentAsString.contains('cm-handle-id-2')
}
- def failedRestResponse(cmHandle) {
- return new CmHandlerRegistrationErrorResponse('cmHandle': cmHandle, 'errorCode': '00', 'errorText': 'Failed')
+ def expectedUnknownErrorResponse(cmHandle) {
+ return new CmHandlerRegistrationErrorResponse('cmHandle': cmHandle, 'errorCode': '108', 'errorText': 'Failed')
}
- def failedResponse(cmHandle) {
+ def expectedFailedResponse(cmHandle) {
return CmHandleRegistrationResponse.createFailureResponse(cmHandle, new RuntimeException('Failed'))
}
- def successResponse(cmHandle) {
+ def expectedSuccessResponse(cmHandle) {
return CmHandleRegistrationResponse.createSuccessResponse(cmHandle)
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NcmpEventResponseCode.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NcmpResponseStatus.java
index 3b11249838..b9c834c559 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NcmpEventResponseCode.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NcmpResponseStatus.java
@@ -23,7 +23,7 @@ package org.onap.cps.ncmp.api;
import lombok.Getter;
@Getter
-public enum NcmpEventResponseCode {
+public enum NcmpResponseStatus {
SUCCESS("0", "Successfully applied changes"),
SUCCESSFULLY_APPLIED_SUBSCRIPTION("1", "successfully applied subscription"),
@@ -33,13 +33,16 @@ public enum NcmpEventResponseCode {
UNABLE_TO_READ_RESOURCE_DATA("103", "dmi plugin service is not able to read resource data"),
PARTIALLY_APPLIED_SUBSCRIPTION("104", "partially applied subscription"),
SUBSCRIPTION_NOT_APPLICABLE("105", "subscription not applicable for all cm handles"),
- SUBSCRIPTION_PENDING("106", "subscription pending for all cm handles");
+ SUBSCRIPTION_PENDING("106", "subscription pending for all cm handles"),
+ UNKNOWN_ERROR("108", "Unknown error"),
+ CM_HANDLE_ALREADY_EXIST("109", "cm-handle already exists"),
+ CM_HANDLE_INVALID_ID("110", "cm-handle has an invalid character(s) in id");
- private final String statusCode;
- private final String statusMessage;
+ private final String code;
+ private final String message;
- NcmpEventResponseCode(final String statusCode, final String statusMessage) {
- this.statusCode = statusCode;
- this.statusMessage = statusMessage;
+ NcmpResponseStatus(final String code, final String message) {
+ this.code = code;
+ this.message = message;
}
}
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 f8adde85ff..d34e2a3141 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
@@ -24,6 +24,9 @@
package org.onap.cps.ncmp.api.impl;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_FOUND;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_ALREADY_EXIST;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_INVALID_ID;
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DMI_REGISTRY_PARENT;
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME;
import static org.onap.cps.ncmp.api.impl.utils.RestQueryParametersValidator.validateCmHandleQueryParameters;
@@ -61,7 +64,6 @@ import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters;
import org.onap.cps.ncmp.api.models.CmHandleQueryServiceParameters;
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse;
-import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError;
import org.onap.cps.ncmp.api.models.DataOperationRequest;
import org.onap.cps.ncmp.api.models.DmiPluginRegistration;
import org.onap.cps.ncmp.api.models.DmiPluginRegistrationResponse;
@@ -356,13 +358,11 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
} catch (final DataNodeNotFoundException dataNodeNotFoundException) {
log.error("Unable to find dataNode for cmHandleId : {} , caused by : {}",
cmHandleId, dataNodeNotFoundException.getMessage());
- return CmHandleRegistrationResponse.createFailureResponse(cmHandleId,
- RegistrationError.CM_HANDLE_DOES_NOT_EXIST);
+ return CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLES_NOT_FOUND);
} catch (final DataValidationException dataValidationException) {
log.error("Unable to de-register cm-handle id: {}, caused by: {}",
cmHandleId, dataValidationException.getMessage());
- return CmHandleRegistrationResponse.createFailureResponse(cmHandleId,
- RegistrationError.CM_HANDLE_INVALID_ID);
+ return CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLE_INVALID_ID);
} catch (final Exception exception) {
log.error("Unable to de-register cm-handle id : {} , caused by : {}", cmHandleId, exception.getMessage());
return CmHandleRegistrationResponse.createFailureResponse(cmHandleId, exception);
@@ -405,14 +405,14 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
private List<CmHandleRegistrationResponse> registerNewCmHandles(final Map<YangModelCmHandle, CmHandleState>
cmHandleStatePerCmHandle) {
final List<String> cmHandleIds = cmHandleStatePerCmHandle.keySet().stream().map(YangModelCmHandle::getId)
- .collect(Collectors.toList());
+ .toList();
try {
lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
return CmHandleRegistrationResponse.createSuccessResponses(cmHandleIds);
} catch (final AlreadyDefinedException alreadyDefinedException) {
return CmHandleRegistrationResponse.createFailureResponses(
alreadyDefinedException.getAlreadyDefinedObjectNames(),
- RegistrationError.CM_HANDLE_ALREADY_EXIST);
+ CM_HANDLE_ALREADY_EXIST);
} catch (final Exception exception) {
return CmHandleRegistrationResponse.createFailureResponses(cmHandleIds, exception);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java
index 2f61b228b3..401b190360 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandler.java
@@ -22,6 +22,8 @@
package org.onap.cps.ncmp.api.impl;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_FOUND;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_INVALID_ID;
import static org.onap.cps.ncmp.api.impl.NetworkCmProxyDataServicePropertyHandler.PropertyType.DMI_PROPERTY;
import static org.onap.cps.ncmp.api.impl.NetworkCmProxyDataServicePropertyHandler.PropertyType.PUBLIC_PROPERTY;
@@ -38,7 +40,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence;
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse;
-import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
import org.onap.cps.spi.exceptions.DataValidationException;
@@ -75,13 +76,12 @@ public class NetworkCmProxyDataServicePropertyHandler {
log.error("Unable to find dataNode for cmHandleId : {} , caused by : {}",
cmHandleId, e.getMessage());
cmHandleRegistrationResponses.add(CmHandleRegistrationResponse
- .createFailureResponse(cmHandleId, RegistrationError.CM_HANDLE_DOES_NOT_EXIST));
+ .createFailureResponse(cmHandleId, CM_HANDLES_NOT_FOUND));
} catch (final DataValidationException e) {
log.error("Unable to update cm handle : {}, caused by : {}",
cmHandleId, e.getMessage());
cmHandleRegistrationResponses.add(
- CmHandleRegistrationResponse.createFailureResponse(cmHandleId,
- RegistrationError.CM_HANDLE_INVALID_ID));
+ CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLE_INVALID_ID));
} catch (final Exception exception) {
log.error("Unable to update cmHandle : {} , caused by : {}",
cmHandleId, exception.getMessage());
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java
index 473538c93e..a0fd81c12a 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java
@@ -20,13 +20,20 @@
package org.onap.cps.ncmp.api.impl.events.cmsubscription;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.PARTIALLY_APPLIED_SUBSCRIPTION;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUBSCRIPTION_NOT_APPLICABLE;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUBSCRIPTION_PENDING;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUCCESSFULLY_APPLIED_SUBSCRIPTION;
+import static org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus.ACCEPTED;
+import static org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus.PENDING;
+import static org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus.REJECTED;
+
import io.cloudevents.CloudEvent;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.ncmp.api.NcmpEventResponseCode;
+import org.onap.cps.ncmp.api.NcmpResponseStatus;
import org.onap.cps.ncmp.api.impl.events.EventsPublisher;
import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistence;
import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus;
@@ -100,48 +107,39 @@ public class CmSubscriptionNcmpOutEventPublisher {
cmSubscriptionStatus.setStatus(SubscriptionStatus.fromString(status));
cmSubscriptionStatus.setDetails(details);
return cmSubscriptionStatus;
- }).collect(Collectors.toList());
+ }).toList();
}
- private NcmpEventResponseCode decideOnNcmpEventResponseCodeForSubscription(
+ private NcmpResponseStatus decideOnNcmpEventResponseCodeForSubscription(
final Map<String, Map<String, String>> cmHandleIdToStatusAndDetailsAsMap) {
- final boolean isAllTargetsPending = isAllTargetCmHandleStatusMatch(cmHandleIdToStatusAndDetailsAsMap,
- SubscriptionStatus.PENDING);
-
- final boolean isAllTargetsRejected = isAllTargetCmHandleStatusMatch(cmHandleIdToStatusAndDetailsAsMap,
- SubscriptionStatus.REJECTED);
-
- final boolean isAllTargetsAccepted = isAllTargetCmHandleStatusMatch(cmHandleIdToStatusAndDetailsAsMap,
- SubscriptionStatus.ACCEPTED);
-
- if (isAllTargetsAccepted) {
- return NcmpEventResponseCode.SUCCESSFULLY_APPLIED_SUBSCRIPTION;
- } else if (isAllTargetsRejected) {
- return NcmpEventResponseCode.SUBSCRIPTION_NOT_APPLICABLE;
- } else if (isAllTargetsPending) {
- return NcmpEventResponseCode.SUBSCRIPTION_PENDING;
- } else {
- return NcmpEventResponseCode.PARTIALLY_APPLIED_SUBSCRIPTION;
+ if (allTargetsHaveStatus(cmHandleIdToStatusAndDetailsAsMap, ACCEPTED)) {
+ return SUCCESSFULLY_APPLIED_SUBSCRIPTION;
+ }
+ if (allTargetsHaveStatus(cmHandleIdToStatusAndDetailsAsMap, REJECTED)) {
+ return SUBSCRIPTION_NOT_APPLICABLE;
+ }
+ if (allTargetsHaveStatus(cmHandleIdToStatusAndDetailsAsMap, PENDING)) {
+ return SUBSCRIPTION_PENDING;
}
+ return PARTIALLY_APPLIED_SUBSCRIPTION;
}
- private boolean isAllTargetCmHandleStatusMatch(
- final Map<String, Map<String, String>> cmHandleIdToStatusAndDetailsAsMap,
- final SubscriptionStatus subscriptionStatus) {
+ private boolean allTargetsHaveStatus(final Map<String, Map<String, String>> cmHandleIdToStatusAndDetailsAsMap,
+ final SubscriptionStatus subscriptionStatus) {
return cmHandleIdToStatusAndDetailsAsMap.values().stream()
.allMatch(entryset -> entryset.containsValue(subscriptionStatus.toString()));
}
private CmSubscriptionNcmpOutEvent fromCmSubscriptionEvent(
final CmSubscriptionEvent cmSubscriptionEvent,
- final NcmpEventResponseCode ncmpEventResponseCode) {
+ final NcmpResponseStatus ncmpResponseStatus) {
final CmSubscriptionNcmpOutEvent cmSubscriptionNcmpOutEvent =
cmSubscriptionEventToCmSubscriptionNcmpOutEventMapper.toCmSubscriptionNcmpOutEvent(
cmSubscriptionEvent);
- cmSubscriptionNcmpOutEvent.getData().setStatusCode(Integer.parseInt(ncmpEventResponseCode.getStatusCode()));
- cmSubscriptionNcmpOutEvent.getData().setStatusMessage(ncmpEventResponseCode.getStatusMessage());
+ cmSubscriptionNcmpOutEvent.getData().setStatusCode(Integer.parseInt(ncmpResponseStatus.getCode()));
+ cmSubscriptionNcmpOutEvent.getData().setStatusMessage(ncmpResponseStatus.getMessage());
return cmSubscriptionNcmpOutEvent;
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
index 8f76a45e0e..b8edeccf2e 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
@@ -21,6 +21,8 @@
package org.onap.cps.ncmp.api.impl.operations;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.DMI_SERVICE_NOT_RESPONDING;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNABLE_TO_READ_RESOURCE_DATA;
import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING;
import static org.onap.cps.ncmp.api.impl.operations.OperationType.READ;
@@ -30,7 +32,7 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.ncmp.api.NcmpEventResponseCode;
+import org.onap.cps.ncmp.api.NcmpResponseStatus;
import org.onap.cps.ncmp.api.impl.client.DmiRestClient;
import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration;
import org.onap.cps.ncmp.api.impl.exception.HttpClientRequestException;
@@ -230,9 +232,7 @@ public class DmiDataOperations extends DmiOperations {
final Map<String, List<DmiDataOperation>>
groupsOutPerDmiServiceName) {
- groupsOutPerDmiServiceName.entrySet().forEach(groupsOutPerDmiServiceNameEntry -> {
- final String dmiServiceName = groupsOutPerDmiServiceNameEntry.getKey();
- final List<DmiDataOperation> dmiDataOperationRequestBodies = groupsOutPerDmiServiceNameEntry.getValue();
+ groupsOutPerDmiServiceName.forEach((dmiServiceName, dmiDataOperationRequestBodies) -> {
final String dmiDataOperationResourceUrl =
getDmiServiceDataOperationRequestUrl(dmiServiceName, topicParamInQuery, requestId);
sendDataOperationRequestToDmiService(dmiDataOperationResourceUrl, dmiDataOperationRequestBodies);
@@ -261,18 +261,18 @@ public class DmiDataOperations extends DmiOperations {
final String topicName = dataOperationResourceUrlParameters.get("topic").get(0);
final String requestId = dataOperationResourceUrlParameters.get("requestId").get(0);
- final MultiValueMap<DmiDataOperation, Map<NcmpEventResponseCode, List<String>>>
+ final MultiValueMap<DmiDataOperation, Map<NcmpResponseStatus, List<String>>>
cmHandleIdsPerResponseCodesPerOperation = new LinkedMultiValueMap<>();
dmiDataOperationRequestBodies.forEach(dmiDataOperationRequestBody -> {
final List<String> cmHandleIds = dmiDataOperationRequestBody.getCmHandles().stream()
- .map(CmHandle::getId).collect(Collectors.toList());
+ .map(CmHandle::getId).toList();
if (throwable.getCause() instanceof HttpClientRequestException) {
cmHandleIdsPerResponseCodesPerOperation.add(dmiDataOperationRequestBody,
- Map.of(NcmpEventResponseCode.UNABLE_TO_READ_RESOURCE_DATA, cmHandleIds));
+ Map.of(UNABLE_TO_READ_RESOURCE_DATA, cmHandleIds));
} else {
cmHandleIdsPerResponseCodesPerOperation.add(dmiDataOperationRequestBody,
- Map.of(NcmpEventResponseCode.DMI_SERVICE_NOT_RESPONDING, cmHandleIds));
+ Map.of(DMI_SERVICE_NOT_RESPONDING, cmHandleIds));
}
});
ResourceDataOperationRequestUtils.publishErrorMessageToClientTopic(topicName, requestId,
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/DataOperationEventCreator.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/DataOperationEventCreator.java
index 65cda94787..61da706c59 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/DataOperationEventCreator.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/DataOperationEventCreator.java
@@ -28,7 +28,7 @@ import java.util.Map;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.ncmp.api.NcmpEventResponseCode;
+import org.onap.cps.ncmp.api.NcmpResponseStatus;
import org.onap.cps.ncmp.api.impl.events.NcmpCloudEventBuilder;
import org.onap.cps.ncmp.api.impl.operations.DmiDataOperation;
import org.onap.cps.ncmp.events.async1_0_0.Data;
@@ -51,7 +51,7 @@ public class DataOperationEventCreator {
public static CloudEvent createDataOperationEvent(final String clientTopic,
final String requestId,
final MultiValueMap<DmiDataOperation,
- Map<NcmpEventResponseCode, List<String>>>
+ Map<NcmpResponseStatus, List<String>>>
cmHandleIdsPerResponseCodesPerOperation) {
final DataOperationEvent dataOperationEvent = new DataOperationEvent();
final Data data = createPayloadFromDataOperationResponses(cmHandleIdsPerResponseCodesPerOperation);
@@ -62,7 +62,7 @@ public class DataOperationEventCreator {
}
private static Data createPayloadFromDataOperationResponses(final MultiValueMap<DmiDataOperation,
- Map<NcmpEventResponseCode, List<String>>> cmHandleIdsPerResponseCodesPerOperation) {
+ Map<NcmpResponseStatus, List<String>>> cmHandleIdsPerResponseCodesPerOperation) {
final Data data = new Data();
final List<org.onap.cps.ncmp.events.async1_0_0.Response> responses = new ArrayList<>();
cmHandleIdsPerResponseCodesPerOperation.forEach((dmiDataOperation, cmHandleIdsPerResponseCodes) ->
@@ -75,13 +75,13 @@ public class DataOperationEventCreator {
private static List<Response> createResponseFromDataOperationResponses(
final DmiDataOperation dmiDataOperation,
- final Map<NcmpEventResponseCode, List<String>> cmHandleIdsPerResponseCodeEntries) {
+ final Map<NcmpResponseStatus, List<String>> cmHandleIdsPerResponseCodeEntries) {
final List<org.onap.cps.ncmp.events.async1_0_0.Response> responses = new ArrayList<>();
cmHandleIdsPerResponseCodeEntries.forEach((ncmpEventResponseCode, cmHandleIds) -> {
final Response response = new Response();
response.setOperationId(dmiDataOperation.getOperationId());
- response.setStatusCode(ncmpEventResponseCode.getStatusCode());
- response.setStatusMessage(ncmpEventResponseCode.getStatusMessage());
+ response.setStatusCode(ncmpEventResponseCode.getCode());
+ response.setStatusMessage(ncmpEventResponseCode.getMessage());
response.setIds(cmHandleIds);
response.setResourceIdentifier(dmiDataOperation.getResourceIdentifier());
response.setOptions(dmiDataOperation.getOptions());
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtils.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtils.java
index e95d4f4c78..e78f0901fe 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtils.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtils.java
@@ -20,6 +20,9 @@
package org.onap.cps.ncmp.api.impl.utils.data.operation;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_FOUND;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_READY;
+
import io.cloudevents.CloudEvent;
import java.util.ArrayList;
import java.util.Collection;
@@ -32,7 +35,7 @@ import java.util.stream.Collectors;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.ncmp.api.NcmpEventResponseCode;
+import org.onap.cps.ncmp.api.NcmpResponseStatus;
import org.onap.cps.ncmp.api.impl.events.EventsPublisher;
import org.onap.cps.ncmp.api.impl.inventory.CmHandleState;
import org.onap.cps.ncmp.api.impl.operations.CmHandle;
@@ -68,7 +71,7 @@ public class ResourceDataOperationRequestUtils {
final Collection<YangModelCmHandle> yangModelCmHandles) {
final Map<String, List<DmiDataOperation>> dmiDataOperationsOutPerDmiServiceName = new HashMap<>();
- final MultiValueMap<DmiDataOperation, Map<NcmpEventResponseCode,
+ final MultiValueMap<DmiDataOperation, Map<NcmpResponseStatus,
List<String>>> cmHandleIdsPerResponseCodesPerOperation = new LinkedMultiValueMap<>();
final Set<String> nonReadyCmHandleIdsLookup = filterAndGetNonReadyCmHandleIds(yangModelCmHandles);
@@ -102,10 +105,10 @@ public class ResourceDataOperationRequestUtils {
}
populateCmHandleIdsPerOperationIdPerResponseCode(cmHandleIdsPerResponseCodesPerOperation,
DmiDataOperation.buildDmiDataOperationRequestBodyWithoutCmHandles(dataOperationDefinitionIn),
- NcmpEventResponseCode.CM_HANDLES_NOT_FOUND, nonExistingCmHandleIds);
+ CM_HANDLES_NOT_FOUND, nonExistingCmHandleIds);
populateCmHandleIdsPerOperationIdPerResponseCode(cmHandleIdsPerResponseCodesPerOperation,
DmiDataOperation.buildDmiDataOperationRequestBodyWithoutCmHandles(dataOperationDefinitionIn),
- NcmpEventResponseCode.CM_HANDLES_NOT_READY, nonReadyCmHandleIds);
+ CM_HANDLES_NOT_READY, nonReadyCmHandleIds);
}
if (!cmHandleIdsPerResponseCodesPerOperation.isEmpty()) {
publishErrorMessageToClientTopic(topicParamInQuery, requestId, cmHandleIdsPerResponseCodesPerOperation);
@@ -124,7 +127,7 @@ public class ResourceDataOperationRequestUtils {
public static void publishErrorMessageToClientTopic(final String clientTopic,
final String requestId,
final MultiValueMap<DmiDataOperation,
- Map<NcmpEventResponseCode, List<String>>>
+ Map<NcmpResponseStatus, List<String>>>
cmHandleIdsPerResponseCodesPerOperation) {
final CloudEvent dataOperationCloudEvent = DataOperationEventCreator.createDataOperationEvent(clientTopic,
requestId, cmHandleIdsPerResponseCodesPerOperation);
@@ -175,13 +178,13 @@ public class ResourceDataOperationRequestUtils {
}
private static void populateCmHandleIdsPerOperationIdPerResponseCode(final MultiValueMap<DmiDataOperation,
- Map<NcmpEventResponseCode, List<String>>> cmHandleIdsPerResponseCodesPerOperation,
+ Map<NcmpResponseStatus, List<String>>> cmHandleIdsPerResponseCodesPerOperation,
final DmiDataOperation dmiDataOperation,
- final NcmpEventResponseCode
- ncmpEventResponseCode,
+ final NcmpResponseStatus
+ ncmpResponseStatus,
final List<String> cmHandleIds) {
if (!cmHandleIds.isEmpty()) {
- cmHandleIdsPerResponseCodesPerOperation.add(dmiDataOperation, Map.of(ncmpEventResponseCode, cmHandleIds));
+ cmHandleIdsPerResponseCodesPerOperation.add(dmiDataOperation, Map.of(ncmpResponseStatus, cmHandleIds));
}
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java
index d5b27b61f6..5bab51bc27 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Bell Canada
- * Modifications Copyright (C) 2022 Nordix Foundation
+ * Modifications Copyright (C) 2022-2023 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,16 +21,17 @@
package org.onap.cps.ncmp.api.models;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNKNOWN_ERROR;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import lombok.Builder;
import lombok.Data;
-import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.onap.cps.ncmp.api.NcmpResponseStatus;
@Data
@Builder
@@ -39,7 +40,7 @@ public class CmHandleRegistrationResponse {
private final String cmHandle;
private final Status status;
- private RegistrationError registrationError;
+ private NcmpResponseStatus ncmpResponseStatus;
private String errorText;
private static final Pattern cmHandleIdInXpathPattern = Pattern.compile("\\[@id='(.*?)']");
@@ -56,7 +57,7 @@ public class CmHandleRegistrationResponse {
return CmHandleRegistrationResponse.builder()
.cmHandle(cmHandleId)
.status(Status.FAILURE)
- .registrationError(RegistrationError.UNKNOWN_ERROR)
+ .ncmpResponseStatus(UNKNOWN_ERROR)
.errorText(exception.getMessage()).build();
}
@@ -64,15 +65,15 @@ public class CmHandleRegistrationResponse {
* Creates a failure response based on registration error.
*
* @param cmHandleId cmHandleId
- * @param registrationError registrationError
+ * @param ncmpResponseStatus registration error code and status
* @return CmHandleRegistrationResponse
*/
public static CmHandleRegistrationResponse createFailureResponse(final String cmHandleId,
- final RegistrationError registrationError) {
+ final NcmpResponseStatus ncmpResponseStatus) {
return CmHandleRegistrationResponse.builder().cmHandle(cmHandleId)
.status(Status.FAILURE)
- .registrationError(registrationError)
- .errorText(registrationError.errorText)
+ .ncmpResponseStatus(ncmpResponseStatus)
+ .errorText(ncmpResponseStatus.getMessage())
.build();
}
@@ -80,17 +81,17 @@ public class CmHandleRegistrationResponse {
* Creates a failure response based on registration error.
*
* @param failedXpaths list of failed Xpaths
- * @param registrationError enum describing the type of registration error
+ * @param ncmpResponseStatus enum describing the type of registration error
* @return CmHandleRegistrationResponse
*/
public static List<CmHandleRegistrationResponse> createFailureResponses(final Collection<String> failedXpaths,
- final RegistrationError registrationError) {
+ final NcmpResponseStatus ncmpResponseStatus) {
final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses = new ArrayList<>(failedXpaths.size());
for (final String xpath : failedXpaths) {
final Matcher matcher = cmHandleIdInXpathPattern.matcher(xpath);
if (matcher.find()) {
cmHandleRegistrationResponses.add(
- CmHandleRegistrationResponse.createFailureResponse(matcher.group(1), registrationError));
+ CmHandleRegistrationResponse.createFailureResponse(matcher.group(1), ncmpResponseStatus));
} else {
log.warn("Unexpected xpath {}", xpath);
}
@@ -109,7 +110,7 @@ public class CmHandleRegistrationResponse {
final Exception exception) {
return cmHandleIds.stream()
.map(cmHandleId -> CmHandleRegistrationResponse.createFailureResponse(cmHandleId, exception))
- .collect(Collectors.toList());
+ .toList();
}
public static CmHandleRegistrationResponse createSuccessResponse(final String cmHandle) {
@@ -118,23 +119,10 @@ public class CmHandleRegistrationResponse {
}
public static List<CmHandleRegistrationResponse> createSuccessResponses(final List<String> cmHandleIds) {
- return cmHandleIds.stream().map(CmHandleRegistrationResponse::createSuccessResponse)
- .collect(Collectors.toList());
+ return cmHandleIds.stream().map(CmHandleRegistrationResponse::createSuccessResponse).toList();
}
public enum Status {
SUCCESS, FAILURE;
}
-
- @RequiredArgsConstructor
- public enum RegistrationError {
- UNKNOWN_ERROR("00", "Unknown error"),
- CM_HANDLE_ALREADY_EXIST("01", "cm-handle already exists"),
- CM_HANDLE_DOES_NOT_EXIST("02", "cm-handle does not exist"),
- CM_HANDLE_INVALID_ID("03", "cm-handle has an invalid character(s) in id");
-
- public final String errorCode;
- public final String errorText;
-
- }
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
index 46666b941f..941139c0b6 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy
@@ -21,6 +21,12 @@
package org.onap.cps.ncmp.api.impl
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_FOUND
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_ALREADY_EXIST
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_INVALID_ID
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNKNOWN_ERROR
+import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.Status
+
import com.fasterxml.jackson.databind.ObjectMapper
import com.hazelcast.map.IMap
import org.onap.cps.api.CpsDataService
@@ -45,12 +51,6 @@ import org.onap.cps.utils.JsonObjectMapper
import spock.lang.Shared
import spock.lang.Specification
-import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_DOES_NOT_EXIST
-import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_ALREADY_EXIST
-import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_INVALID_ID
-import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.UNKNOWN_ERROR
-import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.Status
-
class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
@Shared
@@ -203,7 +203,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
response.createdCmHandles.each {
assert it.cmHandle == 'cmhandle2'
assert it.status == Status.FAILURE
- assert it.registrationError == CM_HANDLE_ALREADY_EXIST
+ assert it.ncmpResponseStatus == CM_HANDLE_ALREADY_EXIST
assert it.errorText == 'cm-handle already exists'
}
}
@@ -221,7 +221,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
with(response.createdCmHandles[0]) {
assert it.status == Status.FAILURE
assert it.cmHandle == 'cmhandle'
- assert it.registrationError == expectedError
+ assert it.ncmpResponseStatus == expectedError
assert it.errorText == expectedErrorText
}
where:
@@ -236,7 +236,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
and: 'cm-handle updates can be processed successfully'
def updateOperationResponse = [CmHandleRegistrationResponse.createSuccessResponse('cm-handle-1'),
CmHandleRegistrationResponse.createFailureResponse('cm-handle-2', new Exception("Failed")),
- CmHandleRegistrationResponse.createFailureResponse('cm-handle-3', CM_HANDLE_DOES_NOT_EXIST),
+ CmHandleRegistrationResponse.createFailureResponse('cm-handle-3', CM_HANDLES_NOT_FOUND),
CmHandleRegistrationResponse.createFailureResponse('cm handle 4', CM_HANDLE_INVALID_ID)]
mockNetworkCmProxyDataServicePropertyHandler.updateCmHandleProperties(_) >> updateOperationResponse
when: 'registration is updated'
@@ -310,7 +310,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
and: '2nd cm-handle deletion fails'
with(response.removedCmHandles[1]) {
assert it.status == Status.FAILURE
- assert it.registrationError == UNKNOWN_ERROR
+ assert it.ncmpResponseStatus == UNKNOWN_ERROR
assert it.errorText == 'Failed'
assert it.cmHandle == 'cmhandle2'
}
@@ -344,7 +344,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
assert it.status == Status.FAILURE
assert it.cmHandle == 'cmhandle'
assert it.errorText == 'Failed'
- assert it.registrationError == UNKNOWN_ERROR
+ assert it.ncmpResponseStatus == UNKNOWN_ERROR
}
}
@@ -364,16 +364,16 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
with(response.removedCmHandles[0]) {
assert it.status == Status.FAILURE
assert it.cmHandle == 'cmhandle'
- assert it.registrationError == expectedError
+ assert it.ncmpResponseStatus == expectedError
assert it.errorText == expectedErrorText
}
and: 'the cm handle state is not updated to "DELETED"'
0 * mockLcmEventsCmHandleStateHandler.updateCmHandleStateBatch(_, CmHandleState.DELETED)
where:
- scenario | cmHandleId | deleteListElementException || expectedError | expectedErrorText
- 'cm-handle does not exist' | 'cmhandle' | new DataNodeNotFoundException('', '', '') || CM_HANDLE_DOES_NOT_EXIST | 'cm-handle does not exist'
- 'cm-handle has invalid name' | 'cm handle with space' | new DataValidationException('', '') || CM_HANDLE_INVALID_ID | 'cm-handle has an invalid character(s) in id'
- 'an unexpected exception' | 'cmhandle' | new RuntimeException('Failed') || UNKNOWN_ERROR | 'Failed'
+ scenario | cmHandleId | deleteListElementException || expectedError | expectedErrorText
+ 'cm-handle does not exist' | 'cmhandle' | new DataNodeNotFoundException('', '', '') || CM_HANDLES_NOT_FOUND | 'cm handle id(s) not found'
+ 'cm-handle has invalid name' | 'cm handle with space' | new DataValidationException('', '') || CM_HANDLE_INVALID_ID | 'cm-handle has an invalid character(s) in id'
+ 'an unexpected exception' | 'cmhandle' | new RuntimeException('Failed') || UNKNOWN_ERROR | 'Failed'
}
def getObjectUnderTest() {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy
index 610400f75b..6439f0b58a 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServicePropertyHandlerSpec.groovy
@@ -24,13 +24,13 @@ package org.onap.cps.ncmp.api.impl
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DMI_REGISTRY_ANCHOR
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_FOUND
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_INVALID_ID
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNKNOWN_ERROR
+import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.Status
import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence
import org.onap.cps.spi.exceptions.DataValidationException
-import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_DOES_NOT_EXIST
-import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.CM_HANDLE_INVALID_ID
-import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError.UNKNOWN_ERROR
-import static org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.Status
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle
import org.onap.cps.spi.exceptions.DataNodeNotFoundException
import org.onap.cps.spi.model.DataNode
@@ -131,14 +131,14 @@ class NetworkCmProxyDataServicePropertyHandlerSpec extends Specification {
with(response.get(0)) {
assert it.status == Status.FAILURE
assert it.cmHandle == cmHandleId
- assert it.registrationError == expectedError
+ assert it.ncmpResponseStatus == expectedError
assert it.errorText == expectedErrorText
}
where:
- scenario | cmHandleId | exception || expectedError | expectedErrorText
- 'Cm Handle does not exist' | 'cmHandleId' | new DataNodeNotFoundException(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR) || CM_HANDLE_DOES_NOT_EXIST | 'cm-handle does not exist'
- 'Unknown' | 'cmHandleId' | new RuntimeException('Failed') || UNKNOWN_ERROR | 'Failed'
- 'Invalid cm handle id' | 'cmHandleId with spaces' | new DataValidationException('Name Validation Error.', cmHandleId + 'contains an invalid character') || CM_HANDLE_INVALID_ID | 'cm-handle has an invalid character(s) in id'
+ scenario | cmHandleId | exception || expectedError | expectedErrorText
+ 'Cm Handle does not exist' | 'cmHandleId' | new DataNodeNotFoundException(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR) || CM_HANDLES_NOT_FOUND | 'cm handle id(s) not found'
+ 'Unknown' | 'cmHandleId' | new RuntimeException('Failed') || UNKNOWN_ERROR | 'Failed'
+ 'Invalid cm handle id' | 'cmHandleId with spaces' | new DataValidationException('Name Validation Error.', cmHandleId + 'contains an invalid character') || CM_HANDLE_INVALID_ID | 'cm-handle has an invalid character(s) in id'
}
def 'Multiple update operations in a single request'() {
@@ -166,8 +166,8 @@ class NetworkCmProxyDataServicePropertyHandlerSpec extends Specification {
with(cmHandleResponseList.get(1)) {
assert it.status == Status.FAILURE
assert it.cmHandle == cmHandleId
- assert it.registrationError == CM_HANDLE_DOES_NOT_EXIST
- assert it.errorText == "cm-handle does not exist"
+ assert it.ncmpResponseStatus == CM_HANDLES_NOT_FOUND
+ assert it.errorText == 'cm handle id(s) not found'
}
then: 'the replace list method is called twice'
2 * mockInventoryPersistence.replaceListContent(cmHandleXpath,_)
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy
index cc14195191..a0567cb4cb 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy
@@ -20,11 +20,15 @@
package org.onap.cps.ncmp.api.impl.events.cmsubscription
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUCCESSFULLY_APPLIED_SUBSCRIPTION
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUBSCRIPTION_PENDING
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUBSCRIPTION_NOT_APPLICABLE
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.PARTIALLY_APPLIED_SUBSCRIPTION
+
import com.fasterxml.jackson.databind.ObjectMapper
import io.cloudevents.CloudEvent
import io.cloudevents.core.builder.CloudEventBuilder
import org.mapstruct.factory.Mappers
-import org.onap.cps.ncmp.api.NcmpEventResponseCode
import org.onap.cps.ncmp.api.impl.events.EventsPublisher
import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistence
import org.onap.cps.ncmp.api.impl.utils.DataNodeBaseSpec
@@ -98,9 +102,9 @@ class CmSubscriptionNcmpOutEventPublisherSpec extends DataNodeBaseSpec {
then: 'the result will be equal to ncmp out event'
expectedResult == ncmpOutEvent
where: 'the following values are used'
- scenario | ncmpEventResponseCode || statusMessage || statusCode
- 'is full outcome' | NcmpEventResponseCode.SUCCESSFULLY_APPLIED_SUBSCRIPTION || 'successfully applied subscription' || 1
- 'is partial outcome' | NcmpEventResponseCode.PARTIALLY_APPLIED_SUBSCRIPTION || 'partially applied subscription' || 104
+ scenario | ncmpEventResponseCode || statusMessage || statusCode
+ 'is full outcome' | SUCCESSFULLY_APPLIED_SUBSCRIPTION || 'successfully applied subscription' || 1
+ 'is partial outcome' | PARTIALLY_APPLIED_SUBSCRIPTION || 'partially applied subscription' || 104
}
def 'Check cm handle id to status map to see if it is a full outcome response'() {
@@ -109,16 +113,16 @@ class CmSubscriptionNcmpOutEventPublisherSpec extends DataNodeBaseSpec {
then: 'the result will be as expected'
response == expectedOutcomeResponseDecision
where: 'the following values are used'
- scenario | cmHandleIdToStatusAndDetailsAsMap || expectedOutcomeResponseDecision
- 'The map contains PENDING status' | [CMHandle1: [details:'Subscription forwarded to dmi plugin',status:'PENDING'] as Map] as Map || NcmpEventResponseCode.SUBSCRIPTION_PENDING
- 'The map contains ACCEPTED status' | [CMHandle1: [details:'',status:'ACCEPTED'] as Map] as Map || NcmpEventResponseCode.SUCCESSFULLY_APPLIED_SUBSCRIPTION
- 'The map contains REJECTED status' | [CMHandle1: [details:'Cm handle does not exist',status:'REJECTED'] as Map] as Map || NcmpEventResponseCode.SUBSCRIPTION_NOT_APPLICABLE
- 'The map contains PENDING and PENDING statuses' | [CMHandle1: [details:'Some details',status:'PENDING'] as Map, CMHandle2: [details:'Some details',status:'PENDING'] as Map as Map] as Map || NcmpEventResponseCode.SUBSCRIPTION_PENDING
- 'The map contains ACCEPTED and ACCEPTED statuses' | [CMHandle1: [details:'',status:'ACCEPTED'] as Map, CMHandle2: [details:'',status:'ACCEPTED'] as Map as Map] as Map || NcmpEventResponseCode.SUCCESSFULLY_APPLIED_SUBSCRIPTION
- 'The map contains REJECTED and REJECTED statuses' | [CMHandle1: [details:'Reject details',status:'REJECTED'] as Map, CMHandle2: [details:'Reject details',status:'REJECTED'] as Map as Map] as Map || NcmpEventResponseCode.SUBSCRIPTION_NOT_APPLICABLE
- 'The map contains PENDING and ACCEPTED statuses' | [CMHandle1: [details:'Some details',status:'PENDING'] as Map, CMHandle2: [details:'',status:'ACCEPTED'] as Map as Map] as Map || NcmpEventResponseCode.PARTIALLY_APPLIED_SUBSCRIPTION
- 'The map contains REJECTED and ACCEPTED statuses' | [CMHandle1: [details:'Cm handle does not exist',status:'REJECTED'] as Map, CMHandle2: [details:'',status:'ACCEPTED'] as Map as Map] as Map || NcmpEventResponseCode.PARTIALLY_APPLIED_SUBSCRIPTION
- 'The map contains PENDING and REJECTED statuses' | [CMHandle1: [details:'Subscription forwarded to dmi plugin',status:'PENDING'] as Map, CMHandle2: [details:'Cm handle does not exist',status:'REJECTED'] as Map as Map] as Map || NcmpEventResponseCode.PARTIALLY_APPLIED_SUBSCRIPTION
+ scenario | cmHandleIdToStatusAndDetailsAsMap || expectedOutcomeResponseDecision
+ 'The map contains PENDING status' | [CMHandle1: [details: 'Subscription forwarded to dmi plugin', status: 'PENDING'] as Map] as Map || SUBSCRIPTION_PENDING
+ 'The map contains ACCEPTED status' | [CMHandle1: [details: '', status: 'ACCEPTED'] as Map] as Map || SUCCESSFULLY_APPLIED_SUBSCRIPTION
+ 'The map contains REJECTED status' | [CMHandle1: [details: 'Cm handle does not exist', status: 'REJECTED'] as Map] as Map || SUBSCRIPTION_NOT_APPLICABLE
+ 'The map contains PENDING and PENDING statuses' | [CMHandle1: [details: 'Some details', status: 'PENDING'] as Map, CMHandle2: [details: 'Some details', status: 'PENDING'] as Map as Map] as Map || SUBSCRIPTION_PENDING
+ 'The map contains ACCEPTED and ACCEPTED statuses' | [CMHandle1: [details: '', status: 'ACCEPTED'] as Map, CMHandle2: [details: '', status: 'ACCEPTED'] as Map as Map] as Map || SUCCESSFULLY_APPLIED_SUBSCRIPTION
+ 'The map contains REJECTED and REJECTED statuses' | [CMHandle1: [details: 'Reject details', status: 'REJECTED'] as Map, CMHandle2: [details: 'Reject details', status: 'REJECTED'] as Map as Map] as Map || SUBSCRIPTION_NOT_APPLICABLE
+ 'The map contains PENDING and ACCEPTED statuses' | [CMHandle1: [details: 'Some details', status: 'PENDING'] as Map, CMHandle2: [details: '', status: 'ACCEPTED'] as Map as Map] as Map || PARTIALLY_APPLIED_SUBSCRIPTION
+ 'The map contains REJECTED and ACCEPTED statuses' | [CMHandle1: [details: 'Cm handle does not exist', status: 'REJECTED'] as Map, CMHandle2: [details: '', status: 'ACCEPTED'] as Map as Map] as Map || PARTIALLY_APPLIED_SUBSCRIPTION
+ 'The map contains PENDING and REJECTED statuses' | [CMHandle1: [details: 'Subscription forwarded to dmi plugin', status: 'PENDING'] as Map, CMHandle2: [details: 'Cm handle does not exist', status: 'REJECTED'] as Map as Map] as Map || PARTIALLY_APPLIED_SUBSCRIPTION
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
index 76ef23fe55..39c4fe6ee5 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
@@ -21,8 +21,16 @@
package org.onap.cps.ncmp.api.impl.operations
+import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_OPERATIONAL
+import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING
+import static org.onap.cps.ncmp.api.impl.operations.OperationType.CREATE
+import static org.onap.cps.ncmp.api.impl.operations.OperationType.READ
+import static org.onap.cps.ncmp.api.impl.operations.OperationType.UPDATE
+import static org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper.toTargetEvent
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNABLE_TO_READ_RESOURCE_DATA
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.DMI_SERVICE_NOT_RESPONDING
+
import com.fasterxml.jackson.databind.ObjectMapper
-import org.onap.cps.ncmp.api.NcmpEventResponseCode
import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration
import org.onap.cps.ncmp.api.impl.events.EventsPublisher
import org.onap.cps.ncmp.api.impl.exception.HttpClientRequestException
@@ -41,13 +49,6 @@ import org.springframework.http.HttpStatus
import spock.lang.Shared
import java.util.concurrent.TimeoutException
-import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_OPERATIONAL
-import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING
-import static org.onap.cps.ncmp.api.impl.operations.OperationType.CREATE
-import static org.onap.cps.ncmp.api.impl.operations.OperationType.READ
-import static org.onap.cps.ncmp.api.impl.operations.OperationType.UPDATE
-import static org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper.toTargetEvent
-
@SpringBootTest
@ContextConfiguration(classes = [EventsPublisher, CpsApplicationContext, NcmpConfiguration.DmiProperties, DmiDataOperations])
class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
@@ -128,12 +129,12 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
def eventDataValue = extractDataValue(actualDataOperationCloudEvent)
assert eventDataValue.operationId == dmiDataOperation.operationId
assert eventDataValue.ids == dmiDataOperation.cmHandles.id
- assert eventDataValue.statusCode == responseCode.statusCode
- assert eventDataValue.statusMessage == responseCode.statusMessage
+ assert eventDataValue.statusCode == responseCode.code
+ assert eventDataValue.statusMessage == responseCode.message
where: 'the following exceptions are occurred'
scenario | exception || responseCode
- 'http client request exception' | new HttpClientRequestException('error-message', 'error-details', HttpStatus.SERVICE_UNAVAILABLE.value()) || NcmpEventResponseCode.UNABLE_TO_READ_RESOURCE_DATA
- 'timeout exception' | new TimeoutException() || NcmpEventResponseCode.DMI_SERVICE_NOT_RESPONDING
+ 'http client request exception' | new HttpClientRequestException('error-message', 'error-details', HttpStatus.SERVICE_UNAVAILABLE.value()) || UNABLE_TO_READ_RESOURCE_DATA
+ 'timeout exception' | new TimeoutException() || DMI_SERVICE_NOT_RESPONDING
}
def 'call get all resource data.'() {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponseSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponseSpec.groovy
index dba29343e9..d76f912234 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponseSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponseSpec.groovy
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Bell Canada
+ * Modifications Copyright (C) 2023 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +21,11 @@
package org.onap.cps.ncmp.api.models
-import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.RegistrationError
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_ALREADY_EXIST
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNKNOWN_ERROR
+
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse.Status
import spock.lang.Specification
-
import java.util.stream.Collectors
class CmHandleRegistrationResponseSpec extends Specification {
@@ -37,7 +39,7 @@ class CmHandleRegistrationResponseSpec extends Specification {
assert it.status == Status.SUCCESS
}
and: 'error details are null'
- cmHandleRegistrationResponse.registrationError == null
+ cmHandleRegistrationResponse.ncmpResponseStatus == null
cmHandleRegistrationResponse.errorText == null
}
@@ -47,33 +49,29 @@ class CmHandleRegistrationResponseSpec extends Specification {
CmHandleRegistrationResponse.createFailureResponse('cmHandle', new Exception('unexpected error'))
then: 'the response is created with expected value'
with(cmHandleRegistrationResponse) {
- assert it.registrationError == RegistrationError.UNKNOWN_ERROR
+ assert it.ncmpResponseStatus == UNKNOWN_ERROR
assert it.cmHandle == 'cmHandle'
assert errorText == 'unexpected error'
}
}
- def 'Failed cm-handle Registration Response: for #scenario'() {
- when: 'cm-handle failure response is created for #scenario'
- def cmHandleRegistrationResponse =
- CmHandleRegistrationResponse.createFailureResponse(cmHandleId, registrationError)
+ def 'Failed cm-handle Registration Response'() {
+ when: 'cm-handle failure response is created'
+ def cmHandleRegistrationResponse =
+ CmHandleRegistrationResponse.createFailureResponse('cmHandle', CM_HANDLE_ALREADY_EXIST)
then: 'the response is created with expected value'
- with(cmHandleRegistrationResponse) {
- assert it.registrationError == registrationError
- assert it.cmHandle == cmHandleId
- assert it.status == Status.FAILURE
- assert errorText == registrationError.errorText
- }
- where:
- scenario | cmHandleId | registrationError
- 'cm-handle already exists' | 'cmHandle' | RegistrationError.CM_HANDLE_ALREADY_EXIST
- 'cm-handle id is invalid' | 'cm handle' | RegistrationError.CM_HANDLE_INVALID_ID
+ with(cmHandleRegistrationResponse) {
+ assert it.ncmpResponseStatus == CM_HANDLE_ALREADY_EXIST
+ assert it.cmHandle == 'cmHandle'
+ assert it.status == Status.FAILURE
+ assert errorText == CM_HANDLE_ALREADY_EXIST.message
+ }
}
def 'Failed cm-handle Registration with multiple responses.'() {
when: 'cm-handle failure response is created for 2 xpaths'
def cmHandleRegistrationResponses =
- CmHandleRegistrationResponse.createFailureResponses(["somePathWithId[@id='123']","somePathWithId[@id='456']"], RegistrationError.CM_HANDLE_ALREADY_EXIST)
+ CmHandleRegistrationResponse.createFailureResponses(["somePathWithId[@id='123']","somePathWithId[@id='456']"], CM_HANDLE_ALREADY_EXIST)
then: 'the response has the correct cm handle ids'
assert cmHandleRegistrationResponses.size() == 2
assert cmHandleRegistrationResponses.stream().map(it -> it.cmHandle).collect(Collectors.toList())
@@ -83,12 +81,9 @@ class CmHandleRegistrationResponseSpec extends Specification {
def 'Failed cm-handle Registration with multiple responses with an unexpected xpath.'() {
when: 'cm-handle failure response is created for one valid and one unexpected xpath'
def cmHandleRegistrationResponses =
- CmHandleRegistrationResponse.createFailureResponses(["somePathWithId[@id='123']","valid/xpath/without-id[@key='123']"], RegistrationError.CM_HANDLE_ALREADY_EXIST)
+ CmHandleRegistrationResponse.createFailureResponses(["somePathWithId[@id='123']","valid/xpath/without-id[@key='123']"], CM_HANDLE_ALREADY_EXIST)
then: 'the response has only one entry'
assert cmHandleRegistrationResponses.size() == 1
}
-
-
-
}
diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
index 987436febc..3f9731d72d 100644
--- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
+++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
@@ -20,6 +20,8 @@
package org.onap.cps.ncmp.dmi.rest.stub.controller;
+import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUCCESS;
+
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.cloudevents.CloudEvent;
@@ -28,12 +30,10 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
-import org.onap.cps.ncmp.api.NcmpEventResponseCode;
import org.onap.cps.ncmp.api.impl.utils.EventDateTimeFormatter;
import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.CmHandle;
import org.onap.cps.ncmp.dmi.rest.stub.model.data.operational.DataOperationRequest;
@@ -161,9 +161,9 @@ public class DmiRestStubController {
private DataOperationEvent getDataOperationEvent(final DataOperationRequest dataOperationRequest) {
final Response response = new Response();
response.setOperationId(dataOperationRequest.getOperationId());
- response.setStatusCode(NcmpEventResponseCode.SUCCESS.getStatusCode());
- response.setStatusMessage(NcmpEventResponseCode.SUCCESS.getStatusMessage());
- response.setIds(dataOperationRequest.getCmHandles().stream().map(CmHandle::getId).collect(Collectors.toList()));
+ response.setStatusCode(SUCCESS.getCode());
+ response.setStatusMessage(SUCCESS.getMessage());
+ response.setIds(dataOperationRequest.getCmHandles().stream().map(CmHandle::getId).toList());
response.setResourceIdentifier(dataOperationRequest.getResourceIdentifier());
response.setOptions(dataOperationRequest.getOptions());
final String ietfNetworkTopologySample = ResourceFileReaderUtil
@@ -176,7 +176,7 @@ public class DmiRestStubController {
} catch (final ParseException parseException) {
log.error("Unable to parse event result as json object. cause : {}", parseException.getMessage());
}
- final List<Response> responseList = new ArrayList<>();
+ final List<Response> responseList = new ArrayList<>(1);
responseList.add(response);
final Data data = new Data();
data.setResponses(responseList);