"description": "alternative id for cmHandle (e.g. 3GPP FDN)",
"type": "string"
},
+ "moduleSetTag": {
+ "description": "module set tag for cmHandle",
+ "type": "string"
+ },
+ "dataProducerIdentifier": {
+ "description": "data producer identifier for cmHandle",
+ "type": "string"
+ },
"oldValues": {
"$ref": "#/definitions/Values"
},
alternateId:
type: string
example: "my-alternate-id"
+ dataProducerIdentifier:
+ type: string
+ example: "my-data-producer-identifier"
RestCmHandleProperties:
type: object
additionalProperties:
$ref: '#/components/schemas/CmHandleCompositeState'
trustLevel:
$ref: '#/components/schemas/CmHandleTrustLevel'
+ moduleSetTag:
+ type: string
+ example: my-module-set-tag
+ alternateId:
+ type: string
+ example: my-alternate-id
+ dataProducerIdentifier:
+ type: string
+ example: my-data-producer-identifier
CmHandlePublicProperties:
type: object
items:
if (cmHandleCurrentTrustLevel != null) {
restOutputCmHandle.setTrustLevel(cmHandleCurrentTrustLevel.toString());
}
+ restOutputCmHandle.setModuleSetTag(ncmpServiceCmHandle.getModuleSetTag());
+ restOutputCmHandle.setAlternateId(ncmpServiceCmHandle.getAlternateId());
+ restOutputCmHandle.setDataProducerIdentifier(ncmpServiceCmHandle.getDataProducerIdentifier());
return restOutputCmHandle;
}
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation
+ * Copyright (C) 2022-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
def 'Convert a created REST CM Handle Input to an NCMP Service CM Handle with #scenario'() {
given: 'a rest cm handle input'
def inputRestCmHandle = new RestInputCmHandle(cmHandle : 'example-id', cmHandleProperties: registrationDmiProperties,
- publicCmHandleProperties: registrationPublicProperties, trustLevel: registrationTrustLevel, alternateId: 'my-alternate-id', moduleSetTag: 'my-module-set-tag')
+ publicCmHandleProperties: registrationPublicProperties, trustLevel: registrationTrustLevel, alternateId: 'my-alternate-id', moduleSetTag: 'my-module-set-tag', dataProducerIdentifier: 'my-data-producer-identifier')
def restDmiPluginRegistration = new RestDmiPluginRegistration(
createdCmHandles: [inputRestCmHandle])
when: 'to plugin dmi registration is called'
and: '(empty) properties are converted correctly'
result.createdCmHandles[0].dmiProperties == mappedDmiProperties
result.createdCmHandles[0].publicProperties == mappedPublicProperties
- result.createdCmHandles[0].registrationTrustLevel == mappedTrustLevel
- and: 'alternate ID and module set tag converted correctly'
+ and: 'other fields are mapped correctly'
result.createdCmHandles[0].alternateId == 'my-alternate-id'
result.createdCmHandles[0].moduleSetTag == 'my-module-set-tag'
+ result.createdCmHandles[0].registrationTrustLevel == mappedTrustLevel
+ result.createdCmHandles[0].dataProducerIdentifier == 'my-data-producer-identifier'
where: 'the following parameters are used'
scenario | registrationDmiProperties | registrationPublicProperties | registrationTrustLevel || mappedDmiProperties | mappedPublicProperties | mappedTrustLevel
'dmi and public properties' | ['Property-Example': 'example property'] | ['Public-Property-Example': 'public example property'] | 'COMPLETE' || ['Property-Example': 'example property'] | ['Public-Property-Example': 'public example property'] | TrustLevel.COMPLETE
def cmHandle2 = new NcmpServiceCmHandle()
cmHandle2.cmHandleId = 'ch-2'
cmHandle2.publicProperties = [color: 'green']
+ cmHandle2.alternateId = 'someAlternateId'
+ cmHandle2.moduleSetTag = 'someModuleSetTag'
+ cmHandle2.dataProducerIdentifier = 'someDataProducerIdentifier'
mockNetworkCmProxyDataService.executeCmHandleSearch(_) >> [cmHandle1, cmHandle2]
and: 'map for trust level per cmHandle has value for only one cm handle'
-// trustLevelPerCmHandle.get('') >> { TrustLevel.NONE }
trustLevelPerCmHandle.put('ch-1', TrustLevel.NONE)
when: 'the searches api is invoked'
def response = mvc.perform(post(searchesEndpoint)
then: 'response status returns OK'
response.status == HttpStatus.OK.value()
and: 'the expected response content is returned'
- response.contentAsString == '[{"cmHandle":"ch-1","publicCmHandleProperties":[{"color":"yellow"}],"state":null,"trustLevel":"NONE"},{"cmHandle":"ch-2","publicCmHandleProperties":[{"color":"green"}],"state":null,"trustLevel":null}]'
+ response.contentAsString == '[{"cmHandle":"ch-1","publicCmHandleProperties":[{"color":"yellow"}],"state":null,"trustLevel":"NONE","moduleSetTag":null,"alternateId":null,"dataProducerIdentifier":null},{"cmHandle":"ch-2","publicCmHandleProperties":[{"color":"green"}],"state":null,"trustLevel":null,"moduleSetTag":"someModuleSetTag","alternateId":"someAlternateId","dataProducerIdentifier":"someDataProducerIdentifier"}]'
}
def 'Get complete Cm Handle details by Cm Handle id.'() {
.contentType(MediaType.APPLICATION_JSON)
.content(jsonString)).andReturn().response
then: 'an empty cm handle identifier is returned'
- response.contentAsString == '[{"cmHandle":"ch-1","publicCmHandleProperties":[{"color":"yellow"}],"state":null,"trustLevel":"COMPLETE"},{"cmHandle":"ch-2","publicCmHandleProperties":[{"color":"green"}],"state":null,"trustLevel":"NONE"}]'
+ response.contentAsString == '[{"cmHandle":"ch-1","publicCmHandleProperties":[{"color":"yellow"}],"state":null,"trustLevel":"COMPLETE","moduleSetTag":null,"alternateId":null,"dataProducerIdentifier":null},{"cmHandle":"ch-2","publicCmHandleProperties":[{"color":"green"}],"state":null,"trustLevel":"NONE","moduleSetTag":null,"alternateId":null,"dataProducerIdentifier":null}]'
}
def 'Query for cm handles matching query parameters'() {
dmiPluginRegistration.getDmiModelPlugin(),
ncmpServiceCmHandle,
ncmpServiceCmHandle.getModuleSetTag(),
- ncmpServiceCmHandle.getAlternateId());
+ ncmpServiceCmHandle.getAlternateId(),
+ ncmpServiceCmHandle.getDataProducerIdentifier());
}
private void processTrustLevels(final Collection<NcmpServiceCmHandle> cmHandlesToBeCreated,
import org.onap.cps.api.CpsDataService;
import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence;
import org.onap.cps.ncmp.api.impl.utils.AlternateIdChecker;
+import org.onap.cps.ncmp.api.impl.utils.YangDataConverter;
+import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse;
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
import org.onap.cps.spi.model.DataNodeBuilder;
import org.onap.cps.utils.JsonObjectMapper;
import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
@Slf4j
@Service
private void processUpdates(final DataNode existingCmHandleDataNode,
final NcmpServiceCmHandle updatedNcmpServiceCmHandle) {
- updateAlternateId(updatedNcmpServiceCmHandle);
+ setAndUpdateCmHandleField(
+ updatedNcmpServiceCmHandle.getCmHandleId(), "alternate-id", updatedNcmpServiceCmHandle.getAlternateId());
+ updateDataProducerIdentifier(existingCmHandleDataNode, updatedNcmpServiceCmHandle);
if (!updatedNcmpServiceCmHandle.getPublicProperties().isEmpty()) {
updateProperties(existingCmHandleDataNode, PUBLIC_PROPERTY,
updatedNcmpServiceCmHandle.getPublicProperties());
}
}
- private void updateAlternateId(final NcmpServiceCmHandle updatedNcmpServiceCmHandle) {
- final String updatedAlternateId = updatedNcmpServiceCmHandle.getAlternateId();
- final String cmHandleId = updatedNcmpServiceCmHandle.getCmHandleId();
- final Map<String, String> cmHandleProperties = new HashMap<>(2);
- cmHandleProperties.put("id", cmHandleId);
- cmHandleProperties.put("alternate-id", updatedAlternateId);
- final Map<String, Map<String, String>> dmiRegistryProperties = new HashMap<>(1);
- dmiRegistryProperties.put("cm-handles", cmHandleProperties);
- cpsDataService.updateNodeLeaves(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, NCMP_DMI_REGISTRY_PARENT,
- jsonObjectMapper.asJsonString(dmiRegistryProperties), OffsetDateTime.now());
- log.debug("Updating alternateId for cmHandle {} with value : {})", cmHandleId, updatedAlternateId);
+ private void updateDataProducerIdentifier(final DataNode cmHandleDataNode,
+ final NcmpServiceCmHandle ncmpServiceCmHandle) {
+ final String newDataProducerIdentifier = ncmpServiceCmHandle.getDataProducerIdentifier();
+ if (StringUtils.hasText(newDataProducerIdentifier)) {
+ final YangModelCmHandle yangModelCmHandle =
+ YangDataConverter.convertCmHandleToYangModel(cmHandleDataNode);
+ final String existingDataProducerIdentifier = yangModelCmHandle.getDataProducerIdentifier();
+ if (StringUtils.hasText(existingDataProducerIdentifier)) {
+ if (!existingDataProducerIdentifier.equals(newDataProducerIdentifier)) {
+ log.warn("Unable to update dataProducerIdentifier for cmHandle {}. "
+ + "Value for dataProducerIdentifier has been set previously.",
+ ncmpServiceCmHandle.getCmHandleId());
+ }
+ } else {
+ setAndUpdateCmHandleField(
+ yangModelCmHandle.getId(), "data-producer-identifier", newDataProducerIdentifier);
+ }
+ }
}
private void updateProperties(final DataNode existingCmHandleDataNode, final PropertyType propertyType,
return new DataNodeBuilder().withXpath(xpath).withLeaves(ImmutableMap.copyOf(updatedLeaves)).build();
}
+ private void setAndUpdateCmHandleField(final String cmHandleIdToUpdate, final String fieldName,
+ final String newFieldValue) {
+ final Map<String, Map<String, String>> dmiRegistryData = new HashMap<>(1);
+ final Map<String, String> cmHandleData = new HashMap<>(2);
+ cmHandleData.put("id", cmHandleIdToUpdate);
+ cmHandleData.put(fieldName, newFieldValue);
+ dmiRegistryData.put("cm-handles", cmHandleData);
+ cpsDataService.updateNodeLeaves(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, NCMP_DMI_REGISTRY_PARENT,
+ jsonObjectMapper.asJsonString(dmiRegistryData), OffsetDateTime.now());
+ log.debug("Updating {} for cmHandle {} with value : {})", fieldName, cmHandleIdToUpdate, newFieldValue);
+ }
+
enum PropertyType {
DMI_PROPERTY("additional-properties"), PUBLIC_PROPERTY("public-properties");
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.api.impl.events.cmsubscription.mapper;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import lombok.RequiredArgsConstructor;
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.CmNotificationSubscriptionStatus;
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionDetails;
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionPredicate;
+import org.onap.cps.ncmp.events.cmsubscription_merge1_0_0.ncmp_to_client.CmNotificationSubscriptionNcmpOutEvent;
+import org.onap.cps.ncmp.events.cmsubscription_merge1_0_0.ncmp_to_client.Data;
+import org.springframework.stereotype.Component;
+
+@Component
+@RequiredArgsConstructor
+public class CmNotificationSubscriptionNcmpOutEventMapper {
+
+ /**
+ * Mapper to form a response for the client for the Cm Notification Subscription.
+ *
+ * @param subscriptionId Cm Notification Subscription Id
+ * @param dmiCmNotificationSubscriptionDetailsMap contains CmNotificationSubscriptionDetails per dmi plugin
+ * @return CmNotificationSubscriptionNcmpOutEvent to sent back to the client
+ */
+ public CmNotificationSubscriptionNcmpOutEvent toCmNotificationSubscriptionNcmpOutEvent(final String subscriptionId,
+ final Map<String, DmiCmNotificationSubscriptionDetails> dmiCmNotificationSubscriptionDetailsMap) {
+
+ final CmNotificationSubscriptionNcmpOutEvent cmNotificationSubscriptionNcmpOutEvent =
+ new CmNotificationSubscriptionNcmpOutEvent();
+ final Data cmSubscriptionData = new Data();
+ cmSubscriptionData.setSubscriptionId(subscriptionId);
+ populateCmNotificationSubscriptionNcmpOutEventWithCmHandleIds(dmiCmNotificationSubscriptionDetailsMap,
+ cmSubscriptionData);
+ cmNotificationSubscriptionNcmpOutEvent.setData(cmSubscriptionData);
+
+ return cmNotificationSubscriptionNcmpOutEvent;
+ }
+
+ private void populateCmNotificationSubscriptionNcmpOutEventWithCmHandleIds(
+ final Map<String, DmiCmNotificationSubscriptionDetails> dmiCmNotificationSubscriptionDetailsMap,
+ final Data cmSubscriptionData) {
+
+ final List<String> acceptedCmHandleIds = new ArrayList<>();
+ final List<String> pendingCmHandleIds = new ArrayList<>();
+ final List<String> rejectedCmHandleIds = new ArrayList<>();
+
+ dmiCmNotificationSubscriptionDetailsMap.forEach((dmiPluginName, dmiCmNotificationSubscriptionDetails) -> {
+ final CmNotificationSubscriptionStatus cmNotificationSubscriptionStatus =
+ dmiCmNotificationSubscriptionDetails.getCmNotificationSubscriptionStatus();
+ final List<DmiCmNotificationSubscriptionPredicate> dmiCmNotificationSubscriptionPredicates =
+ dmiCmNotificationSubscriptionDetails.getDmiCmNotificationSubscriptionPredicates();
+
+ switch (cmNotificationSubscriptionStatus) {
+ case ACCEPTED -> acceptedCmHandleIds.addAll(
+ extractCmHandleIds(dmiCmNotificationSubscriptionPredicates));
+ case PENDING -> pendingCmHandleIds.addAll(extractCmHandleIds(dmiCmNotificationSubscriptionPredicates));
+ default -> rejectedCmHandleIds.addAll(extractCmHandleIds(dmiCmNotificationSubscriptionPredicates));
+ }
+ });
+
+ cmSubscriptionData.setAcceptedTargets(acceptedCmHandleIds);
+ cmSubscriptionData.setPendingTargets(pendingCmHandleIds);
+ cmSubscriptionData.setRejectedTargets(rejectedCmHandleIds);
+
+ }
+
+ private List<String> extractCmHandleIds(
+ final List<DmiCmNotificationSubscriptionPredicate> dmiCmNotificationSubscriptionPredicates) {
+ final List<String> cmHandleIds = new ArrayList<>();
+ dmiCmNotificationSubscriptionPredicates.forEach(dmiCmNotificationSubscriptionPredicate -> cmHandleIds.addAll(
+ dmiCmNotificationSubscriptionPredicate.getTargetCmHandleIds()));
+
+ return cmHandleIds;
+ }
+
+}
final Event event = new Event();
event.setCmHandleId(eventCorrelationId);
event.setAlternateId(targetNcmpServiceCmHandle.getAlternateId());
+ event.setModuleSetTag(targetNcmpServiceCmHandle.getModuleSetTag());
+ event.setDataProducerIdentifier(targetNcmpServiceCmHandle.getDataProducerIdentifier());
final CmHandleValuesHolder cmHandleValuesHolder =
LcmEventsCreatorHelper.determineEventValues(targetNcmpServiceCmHandle, existingNcmpServiceCmHandle,
lcmEventType);
ncmpServiceCmHandle.setCompositeState(yangModelCmHandle.getCompositeState());
ncmpServiceCmHandle.setModuleSetTag(yangModelCmHandle.getModuleSetTag());
ncmpServiceCmHandle.setAlternateId(yangModelCmHandle.getAlternateId());
+ ncmpServiceCmHandle.setDataProducerIdentifier(yangModelCmHandle.getDataProducerIdentifier());
setDmiProperties(dmiProperties, ncmpServiceCmHandle);
setPublicProperties(publicProperties, ncmpServiceCmHandle);
return ncmpServiceCmHandle;
(String) cmHandleDataNode.getLeaves().get("dmi-model-service-name"),
ncmpServiceCmHandle,
(String) cmHandleDataNode.getLeaves().get("module-set-tag"),
- (String) cmHandleDataNode.getLeaves().get("alternate-id")
+ (String) cmHandleDataNode.getLeaves().get("alternate-id"),
+ (String) cmHandleDataNode.getLeaves().get("data-producer-identifier")
);
}
@JsonProperty("alternate-id")
private String alternateId;
+ @JsonProperty("data-producer-identifier")
+ private String dataProducerIdentifier;
+
@JsonProperty("additional-properties")
private List<Property> dmiProperties;
original.getPublicProperties() == null ? null : new ArrayList<>(original.getPublicProperties());
copy.moduleSetTag = original.getModuleSetTag();
copy.alternateId = original.getAlternateId();
+ copy.dataProducerIdentifier = original.getDataProducerIdentifier();
return copy;
}
* @param dmiDataServiceName dmi data service name
* @param dmiModelServiceName dmi model service name
* @param ncmpServiceCmHandle the cm handle
+ * @param moduleSetTag moduleSetTag
+ * @param alternateId alternateId
+ * @param dataProducerIdentifier dataProducerIdentifier
* @return instance of yangModelCmHandle
*/
public static YangModelCmHandle toYangModelCmHandle(final String dmiServiceName,
final String dmiModelServiceName,
final NcmpServiceCmHandle ncmpServiceCmHandle,
final String moduleSetTag,
- final String alternateId) {
+ final String alternateId,
+ final String dataProducerIdentifier) {
final YangModelCmHandle yangModelCmHandle = new YangModelCmHandle();
yangModelCmHandle.setId(ncmpServiceCmHandle.getCmHandleId());
yangModelCmHandle.setDmiServiceName(dmiServiceName);
yangModelCmHandle.setDmiModelServiceName(dmiModelServiceName);
yangModelCmHandle.setModuleSetTag(moduleSetTag == null ? StringUtils.EMPTY : moduleSetTag);
yangModelCmHandle.setAlternateId(alternateId == null ? StringUtils.EMPTY : alternateId);
+ yangModelCmHandle.setDataProducerIdentifier(
+ dataProducerIdentifier == null ? StringUtils.EMPTY : dataProducerIdentifier);
yangModelCmHandle.setDmiProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getDmiProperties()));
yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties(
ncmpServiceCmHandle.getPublicProperties()));
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation
+ * Copyright (C) 2021-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@JsonSetter(nulls = Nulls.AS_EMPTY)
private String alternateId;
+
+ @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private String dataProducerIdentifier;
}
@Service
public class InventoryModelLoader extends AbstractModelLoader {
- private static final String NEW_MODEL_FILE_NAME = "dmi-registry@2023-11-27.yang";
- private static final String NEW_SCHEMA_SET_NAME = "dmi-registry-2023-11-27";
+ private static final String NEW_MODEL_FILE_NAME = "dmi-registry@2024-02-23.yang";
+ private static final String NEW_SCHEMA_SET_NAME = "dmi-registry-2024-02-23";
public InventoryModelLoader(final CpsDataspaceService cpsDataspaceService,
final CpsModuleService cpsModuleService,
contact "toine.siebelink@est.tech";
+ revision "2024-02-23" {
+ description
+ "Added data-producer-identifier";
+ }
+
revision "2023-11-27" {
description
"Added alternate-id";
leaf alternate-id {
type string;
}
+ leaf data-producer-identifier {
+ type string;
+ }
list additional-properties {
key "name";
package org.onap.cps.ncmp.api.impl
+import ch.qos.logback.classic.Level
+import ch.qos.logback.classic.Logger
+import ch.qos.logback.classic.spi.ILoggingEvent
+import ch.qos.logback.core.read.ListAppender
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.api.CpsDataService
import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence
import org.onap.cps.spi.model.DataNode
import org.onap.cps.spi.model.DataNodeBuilder
import org.onap.cps.utils.JsonObjectMapper
+import org.slf4j.LoggerFactory
import spock.lang.Specification
import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_FOUND
def mockAlternateIdChecker = Mock(AlternateIdChecker)
def objectUnderTest = new NetworkCmProxyDataServicePropertyHandler(mockInventoryPersistence, mockCpsDataService, jsonObjectMapper, mockAlternateIdChecker)
+ def logger = Spy(ListAppender<ILoggingEvent>)
- def setup() {
+ void setup() {
+ def setupLogger = ((Logger) LoggerFactory.getLogger(NetworkCmProxyDataServicePropertyHandler.class))
+ setupLogger.addAppender(logger)
+ setupLogger.setLevel(Level.DEBUG)
+ logger.start()
// Always accept all alternate IDs
mockAlternateIdChecker.getIdsOfCmHandlesWithRejectedAlternateId(*_) >> []
}
+ void cleanup() {
+ ((Logger) LoggerFactory.getLogger(NetworkCmProxyDataServicePropertyHandler.class)).detachAndStopAllAppenders()
+ }
+
def static cmHandleId = 'myHandle1'
def static cmHandleXpath = "/dmi-registry/cm-handles[@id='${cmHandleId}']"
assert response[0].cmHandle == cmHandleId
}
+ def 'Update CM Handle data producer identifier from #scenario'() {
+ given: 'an existing cm handle with no data producer identifier'
+ DataNode existingCmHandleDataNode = new DataNode(xpath: cmHandleXpath, leaves: ['id': 'cmHandleId','data-producer-identifier': oldDataProducerIdentifier])
+ and: 'an update request with a new data producer identifier'
+ def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, dataProducerIdentifier: 'someDataProducerIdentifier')
+ when: 'data producer identifier updated'
+ objectUnderTest.updateDataProducerIdentifier(existingCmHandleDataNode, ncmpServiceCmHandle)
+ then: 'the update node leaves method is invoked once'
+ 1 * mockCpsDataService.updateNodeLeaves('NCMP-Admin', 'ncmp-dmi-registry', '/dmi-registry', _, _) >> { args ->
+ assert args[3].contains('someDataProducerIdentifier')
+ }
+ and: 'correct information is logged'
+ def lastLoggingEvent = logger.list[0]
+ assert lastLoggingEvent.level == Level.DEBUG
+ assert lastLoggingEvent.formattedMessage.contains('Updating data-producer-identifier')
+ where: 'the following scenarios are attempted'
+ scenario | oldDataProducerIdentifier
+ 'null to something' | null
+ 'blank to something' | ''
+ }
+
+ def 'Update CM Handle data producer identifier from some data producer identifier to another data producer identifier'() {
+ given: 'an existing cm handle with a data producer identifier'
+ DataNode existingCmHandleDataNode = new DataNode(xpath: cmHandleXpath, leaves: ['id': 'cmHandleId', 'data-producer-identifier': 'someDataProducerIdentifier'])
+ and: 'an update request with a new data producer identifier'
+ def ncmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, dataProducerIdentifier: 'someNewDataProducerIdentifier')
+ when: 'update data producer identifier is called with the update request'
+ objectUnderTest.updateDataProducerIdentifier(existingCmHandleDataNode, ncmpServiceCmHandle)
+ then: 'the update node leaves method is not invoked'
+ 0 * mockCpsDataService.updateNodeLeaves(*_)
+ and: 'correct information is logged'
+ def lastLoggingEvent = logger.list[0]
+ assert lastLoggingEvent.level == Level.WARN
+ assert lastLoggingEvent.formattedMessage.contains('Unable to update dataProducerIdentifier')
+ }
+
def convertToProperties(expectedPropertiesAfterUpdateAsMap) {
def properties = [].withDefault { [:] }
expectedPropertiesAfterUpdateAsMap.forEach(property ->
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.api.impl.events.cmsubscription.mapper
+
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.CmNotificationSubscriptionStatus
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionDetails
+import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionPredicate
+import org.onap.cps.ncmp.api.impl.operations.DatastoreType
+import spock.lang.Specification
+
+class CmNotificationSubscriptionNcmpOutEventMapperSpec extends Specification {
+
+ static Map<String, DmiCmNotificationSubscriptionDetails> dmiCmNotificationSubscriptionDetailsMap
+
+ def objectUnderTest = new CmNotificationSubscriptionNcmpOutEventMapper()
+
+ def setup() {
+ def dmiCmNotificationSubscriptionPredicateA = new DmiCmNotificationSubscriptionPredicate(['ch-A'] as Set, DatastoreType.PASSTHROUGH_RUNNING, ['/a'] as Set)
+ def dmiCmNotificationSubscriptionPredicateB = new DmiCmNotificationSubscriptionPredicate(['ch-B'] as Set, DatastoreType.PASSTHROUGH_OPERATIONAL, ['/b'] as Set)
+ def dmiCmNotificationSubscriptionPredicateC = new DmiCmNotificationSubscriptionPredicate(['ch-C'] as Set, DatastoreType.PASSTHROUGH_OPERATIONAL, ['/c'] as Set)
+ dmiCmNotificationSubscriptionDetailsMap = ['dmi-1': new DmiCmNotificationSubscriptionDetails([dmiCmNotificationSubscriptionPredicateA], CmNotificationSubscriptionStatus.PENDING),
+ 'dmi-2': new DmiCmNotificationSubscriptionDetails([dmiCmNotificationSubscriptionPredicateB], CmNotificationSubscriptionStatus.ACCEPTED),
+ 'dmi-3': new DmiCmNotificationSubscriptionDetails([dmiCmNotificationSubscriptionPredicateC], CmNotificationSubscriptionStatus.REJECTED)
+ ]
+ }
+
+ def 'Check for Cm Notification Subscription Outgoing event mapping'() {
+ when: 'we try to map the event to send it to client'
+ def result = objectUnderTest.toCmNotificationSubscriptionNcmpOutEvent('test-subscription', dmiCmNotificationSubscriptionDetailsMap)
+ then: 'event is mapped correctly for the subscription'
+ result.data.subscriptionId == 'test-subscription'
+ and: 'the cm handle ids are part of correct list'
+ result.data.pendingTargets == ['ch-A']
+ result.data.acceptedTargets == ['ch-B']
+ result.data.rejectedTargets == ['ch-C']
+ }
+}
assert result.eventId != null
}
- def 'Map the LcmEvent for alternate IDs when #scenario'() {
- given: 'NCMP cm handle details with current and old alternate IDs'
- def existingNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: existingAlternateId, compositeState: new CompositeState(dataSyncEnabled: false))
- def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: targetAlternateId, compositeState: new CompositeState(dataSyncEnabled: false))
+ def 'Map the LcmEvent for alternate ID, data producer identifier, and module set tag when they contain #scenario'() {
+ given: 'NCMP cm handle details with current and old values for alternate ID, module set tag, and data producer identifier'
+ def existingNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: existingAlternateId, moduleSetTag: existingModuleSetTag, dataProducerIdentifier: existingDataProducerIdentifier, compositeState: new CompositeState(dataSyncEnabled: false))
+ def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: targetAlternateId, moduleSetTag: targetModuleSetTag, dataProducerIdentifier: targetDataProducerIdentifier, compositeState: new CompositeState(dataSyncEnabled: false))
when: 'the event is populated'
def result = objectUnderTest.populateLcmEvent(cmHandleId, targetNcmpServiceCmHandle, existingNcmpServiceCmHandle)
- then: 'the alternate ID is present or is an empty string in the payload'
- assert result.event.alternateId == expectedEventAlternateId
- where: 'the following alternate IDs are provided'
- scenario | existingAlternateId | targetAlternateId || expectedEventAlternateId
- 'same new and old alternate ID' | 'someAlternateId' | 'someAlternateId' || 'someAlternateId'
- 'blank new and old alternate ID' | '' | '' || ''
- 'new alternate id and blank old alternate ID' | '' | 'someAlternateId' || 'someAlternateId'
+ then: 'the alternate ID, module set tag, and data producer identifier are present or are an empty string in the payload'
+ assert result.event.alternateId == targetAlternateId
+ assert result.event.moduleSetTag == targetModuleSetTag
+ assert result.event.dataProducerIdentifier == targetDataProducerIdentifier
+ where: 'the following values are provided for the alternate ID, module set tag, and data producer identifier'
+ scenario | existingAlternateId | targetAlternateId | existingModuleSetTag | targetModuleSetTag | existingDataProducerIdentifier | targetDataProducerIdentifier
+ 'same target and existing values' | 'someAlternateId' | 'someAlternateId' | 'someModuleSetTag' | 'someModuleSetTag' | 'someDataProducerIdentifier' | 'someDataProducerIdentifier'
+ 'blank target and existing values' | '' | '' | '' | '' | '' | ''
+ 'new target value and blank existing values' | '' | 'someAlternateId' | '' | 'someAlternateId' | '' | 'someDataProducerIdentifier'
}
}
\ No newline at end of file
def ncmpServiceCmHandle = new NcmpServiceCmHandle()
ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withCmHandleState(CmHandleState.ADVISED).build())
ncmpServiceCmHandle.cmHandleId = 'ch-1'
- def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, moduleSetTag, '')
+ def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, moduleSetTag, '', '')
and: 'DMI operations returns some module references'
def moduleReferences = [ new ModuleReference('module1','1'), new ModuleReference('module2','2') ]
mockDmiModelOperations.getModuleReferences(yangModelCmHandle) >> moduleReferences
ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withLockReason(MODULE_UPGRADE, 'Upgrade to ModuleSetTag: tag-1').build())
def dmiServiceName = 'some service name'
ncmpServiceCmHandle.cmHandleId = 'upgraded-ch'
- def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, '', '', ncmpServiceCmHandle,'tag-1', '')
+ def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, '', '', ncmpServiceCmHandle,'tag-1', '', '')
and: 'some module references'
def moduleReferences = [ new ModuleReference('module1','1') ]
and: 'DMI operations returns some module references for upgraded cm handle'
ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder()
.withLockReason(MODULE_UPGRADE, 'Upgrade to ModuleSetTag: targetModuleSetTag').build())
ncmpServiceCmHandle.setCmHandleId('cmHandleId-1')
- def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, 'targetModuleSetTag', '')
+ def yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('some service name', '', '', ncmpServiceCmHandle, 'targetModuleSetTag', '', '')
mockCmHandleQueries.cmHandleHasState('cmHandleId-1', CmHandleState.READY) >> true
and: 'the module service returns some module references'
def moduleReferences = [new ModuleReference('module1', '1'), new ModuleReference('module2', '2')]
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation
+ * Copyright (C) 2022-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class DmiServiceUrlBuilderSpec extends Specification {
static YangModelCmHandle yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('dmiServiceName',
- 'dmiDataServiceName', 'dmiModuleServiceName', new NcmpServiceCmHandle(cmHandleId: 'some-cm-handle-id'),'my-module-set-tag', 'my-alternate-id')
+ 'dmiDataServiceName', 'dmiModuleServiceName', new NcmpServiceCmHandle(cmHandleId: 'some-cm-handle-id'),'my-module-set-tag', 'my-alternate-id', 'my-data-producer-identifier')
NcmpConfiguration.DmiProperties dmiProperties = new NcmpConfiguration.DmiProperties()
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation
+ * Copyright (C) 2021-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
.withOperationalDataStores(DataStoreSyncState.SYNCHRONIZED, 'some-sync-time').build()
ncmpServiceCmHandle.setCompositeState(compositeState)
when: 'it is converted to a yang model cm handle'
- def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle,'my-module-set-tag', 'my-alternate-id')
+ def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle,'my-module-set-tag', 'my-alternate-id', 'my-data-producer-identifier')
then: 'the result has the right size'
assert objectUnderTest.dmiProperties.size() == 1
- and: 'the result has the correct values for module set tag and alternate ID'
+ and: 'the result has the correct values for module set tag, alternate ID, and data producer identifier'
assert objectUnderTest.moduleSetTag == 'my-module-set-tag'
assert objectUnderTest.alternateId == 'my-alternate-id'
+ assert objectUnderTest.dataProducerIdentifier == 'my-data-producer-identifier'
and: 'the DMI property in the result has the correct name and value'
assert objectUnderTest.dmiProperties[0].name == 'myDmiProperty'
assert objectUnderTest.dmiProperties[0].value == 'value1'
def 'Resolve DMI service name: #scenario and #requiredService service require.'() {
given: 'a yang model cm handle'
def objectUnderTest = YangModelCmHandle.toYangModelCmHandle(dmiServiceName, dmiDataServiceName,
- dmiModelServiceName, new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1'),'', '')
+ dmiModelServiceName, new NcmpServiceCmHandle(cmHandleId: 'cm-handle-id-1'),'', '', '')
expect:
assert objectUnderTest.resolveDmiServiceName(requiredService) == expectedService
where:
def loggingListAppender
void setup() {
- expectedYangResourceToContentMap = objectUnderTest.createYangResourcesToContentMap('dmi-registry@2023-11-27.yang')
+ expectedYangResourceToContentMap = objectUnderTest.createYangResourcesToContentMap('dmi-registry@2024-02-23.yang')
logger.setLevel(Level.DEBUG)
loggingListAppender = new ListAppender()
logger.addAppender(loggingListAppender)
when: 'the application is ready'
objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent))
then: 'the module service is used to create the new schema set from the correct resource'
- 1 * mockCpsModuleService.createSchemaSet(NCMP_DATASPACE_NAME, 'dmi-registry-2023-11-27', expectedYangResourceToContentMap)
+ 1 * mockCpsModuleService.createSchemaSet(NCMP_DATASPACE_NAME, 'dmi-registry-2024-02-23', expectedYangResourceToContentMap)
and: 'the admin service is used to update the anchor'
- 1 * mockCpsAnchorService.updateAnchorSchemaSet(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, 'dmi-registry-2023-11-27')
+ 1 * mockCpsAnchorService.updateAnchorSchemaSet(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, 'dmi-registry-2024-02-23')
and: 'No schema sets are being removed by the module service (yet)'
0 * mockCpsModuleService.deleteSchemaSet(NCMP_DATASPACE_NAME, _, _)
}
updatedCmHandles:
- cmHandle: my-cm-handle
alternateId: my-alternate-id
+ dataProducerIdentifier: my-data-producer-identifier
publicCmHandleProperties:
key: my-property
cmHandleProperties:
trustLevel: COMPLETE
- cmHandle: my-cm-handle
alternateId: my-alternate-id
+ dataProducerIdentifier: my-data-producer-identifier
publicCmHandleProperties:
key: my-property
cmHandleProperties:
createdCmHandles:
- cmHandle: my-cm-handle
alternateId: my-alternate-id
+ dataProducerIdentifier: my-data-producer-identifier
publicCmHandleProperties:
key: my-property
cmHandleProperties:
trustLevel: COMPLETE
- cmHandle: my-cm-handle
alternateId: my-alternate-id
+ dataProducerIdentifier: my-data-producer-identifier
publicCmHandleProperties:
key: my-property
cmHandleProperties:
example:
cmHandle: my-cm-handle
alternateId: my-alternate-id
+ dataProducerIdentifier: my-data-producer-identifier
publicCmHandleProperties:
key: my-property
cmHandleProperties:
alternateId:
example: my-alternate-id
type: string
+ dataProducerIdentifier:
+ example: my-data-producer-identifier
+ type: string
required:
- cmHandle
type: object
RestOutputCmHandle:
example:
cmHandle: my-cm-handle1
+ alternateId: my-alternate-id
+ dataProducerIdentifier: my-data-producer-identifier
publicCmHandleProperties:
- key: Book Type
- key: Book Type
details: locked due to failure in module sync
lastUpdateTime: 2022-12-31T20:30:40.000+0000
trustLevel: COMPLETE
+ moduleSetTag: my-module-set-tag
properties:
cmHandle:
example: my-cm-handle1
description: Current trust level of the relevant CM handle ID.
example: COMPLETE
type: string
+ moduleSetTag:
+ example: my-module-set-tag
+ type: string
+ alternateId:
+ example: my-alternate-id
+ type: string
+ dataProducerIdentifier:
+ example: my-data-producer-identifier
+ type: string
title: CM handle Details
type: object
CmHandlePublicProperties:
}
def createRegistrySchemaSet() {
- def modelAsString = readResourceDataFile('ncmp-registry/dmi-registry@2023-11-27.yang')
+ def modelAsString = readResourceDataFile('ncmp-registry/dmi-registry@2024-02-23.yang')
cpsModuleService.createSchemaSet(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_SCHEMA_SET, [registry: modelAsString])
}
contact "toine.siebelink@est.tech";
+ revision "2024-02-23" {
+ description
+ "Added data-producer-identifier";
+ }
+
revision "2023-11-27" {
description
"Added alternateId";
leaf alternate-id {
type string;
}
+ leaf data-producer-identifier {
+ type string;
+ }
list additional-properties {
key "name";