summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src')
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java5
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/HttpClientConfiguration.java57
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/NcmpConfiguration.java48
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistence.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionPersistence.java)2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistenceImpl.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionPersistenceImpl.java)2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionStatus.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionStatus.java)2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventConsumer.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumer.java)4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper.java)5
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper.java)4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventConsumer.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumer.java)4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventForwarder.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarder.java)6
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventMapper.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapper.java)2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.java)2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java)12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/ResponseTimeoutTask.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/ResponseTimeoutTask.java)2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImpl.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtils.java20
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java113
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncTasks.java16
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java3
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmDataSubscriptionEvent.java76
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java8
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelSubscriptionEvent.java2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionStatus.java2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java17
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/SubscriptionEventResponse.java2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java12
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java10
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java14
-rw-r--r--cps-ncmp-service/src/main/resources/models/dmi-registry@2023-11-27.yang (renamed from cps-ncmp-service/src/main/resources/models/dmi-registry@2023-08-23.yang)17
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy10
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/HttpClientConfigurationSpec.groovy48
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/NcmpConfigurationSpec.groovy18
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistenceSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionPersistenceSpec.groovy)2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy)4
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy)6
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy)6
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec.groovy)8
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy)8
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy)12
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy)6
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy)12
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImplSpec.groovy12
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtilsSpec.groovy21
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy37
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/CmSubscriptionEventCloudMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmSubscriptionEventCloudMapperSpec.groovy)7
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/SubscriptionOutcomeCloudMapperSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapperSpec.groovy)7
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandleSpec.groovy7
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/NcmpServiceCmHandleSpec.groovy50
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy31
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy15
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy15
-rw-r--r--cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionDmiInEvent.json (renamed from cps-ncmp-service/src/test/resources/cmSubscriptionDmiInEvent.json)0
-rw-r--r--cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionDmiOutEvent.json (renamed from cps-ncmp-service/src/test/resources/cmSubscriptionDmiOutEvent.json)0
-rw-r--r--cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionEvent.json (renamed from cps-ncmp-service/src/test/resources/cmSubscriptionEvent.json)0
-rw-r--r--cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json (renamed from cps-ncmp-service/src/test/resources/cmSubscriptionNcmpInEvent.json)0
-rw-r--r--cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json (renamed from cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent.json)0
-rw-r--r--cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionNcmpOutEvent2.json (renamed from cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent2.json)0
59 files changed, 533 insertions, 292 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index 1afe5c7114..469d75ab94 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
@@ -328,7 +328,8 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
dmiPluginRegistration.getDmiDataPlugin(),
dmiPluginRegistration.getDmiModelPlugin(),
cmHandle,
- cmHandle.getModuleSetTag());
+ cmHandle.getModuleSetTag(),
+ cmHandle.getAlternateId());
yangModelCmHandles.add(yangModelCmHandle);
initialTrustLevelPerCmHandleId.put(cmHandle.getCmHandleId(), cmHandle.getRegistrationTrustLevel());
});
@@ -420,7 +421,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
.withLockReason(MODULE_UPGRADE, lockReasonWithModuleSetTag).build());
return YangModelCmHandle.toYangModelCmHandle(dmiPluginRegistration.getDmiPlugin(),
dmiPluginRegistration.getDmiDataPlugin(), dmiPluginRegistration.getDmiModelPlugin(),
- ncmpServiceCmHandle, moduleSetTag);
+ ncmpServiceCmHandle, moduleSetTag, ncmpServiceCmHandle.getAlternateId());
}
private CmHandleRegistrationResponse deleteCmHandleAndGetCmHandleRegistrationResponse(final String cmHandleId) {
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/HttpClientConfiguration.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/HttpClientConfiguration.java
new file mode 100644
index 0000000000..729930e65e
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/HttpClientConfiguration.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * 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.config;
+
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.convert.DurationUnit;
+
+@Getter
+@Setter
+@ConfigurationProperties(prefix = "ncmp.dmi.httpclient", ignoreUnknownFields = true)
+public class HttpClientConfiguration {
+
+ /**
+ * The maximum time to establish a connection.
+ */
+ @DurationUnit(ChronoUnit.SECONDS)
+ private Duration connectionTimeoutInSeconds = Duration.ofSeconds(180);
+
+ /**
+ * The maximum number of open connections per route.
+ */
+ private int maximumConnectionsPerRoute = 50;
+
+ /**
+ * The maximum total number of open connections.
+ */
+ private int maximumConnectionsTotal = maximumConnectionsPerRoute * 2;
+
+ /**
+ * The duration after which idle connections are evicted.
+ */
+ @DurationUnit(ChronoUnit.SECONDS)
+ private Duration idleConnectionEvictionThresholdInSeconds = Duration.ofSeconds(5);
+
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/NcmpConfiguration.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/NcmpConfiguration.java
index ffecf9c7f1..c6ff116a7f 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/NcmpConfiguration.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/NcmpConfiguration.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation
+ * Copyright (C) 2021-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,29 +20,36 @@
package org.onap.cps.ncmp.api.impl.config;
-import java.time.Duration;
import java.util.Arrays;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.apache.hc.client5.http.config.ConnectionConfig;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
+import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
+import org.apache.hc.core5.util.TimeValue;
+import org.apache.hc.core5.util.Timeout;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.http.MediaType;
+import org.springframework.http.client.ClientHttpRequestFactory;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
@Configuration
+@EnableConfigurationProperties(HttpClientConfiguration.class)
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
public class NcmpConfiguration {
- private static final Duration CONNECTION_TIMEOUT_MILLISECONDS = Duration.ofMillis(180000);
- private static final Duration READ_TIMEOUT_MILLISECONDS = Duration.ofMillis(180000);
-
@Getter
@Component
public static class DmiProperties {
@@ -60,13 +67,38 @@ public class NcmpConfiguration {
* Rest template bean.
*
* @param restTemplateBuilder the rest template builder
+ * @param httpClientConfiguration the http client configuration
* @return rest template instance
*/
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
- public static RestTemplate restTemplate(final RestTemplateBuilder restTemplateBuilder) {
- final RestTemplate restTemplate = restTemplateBuilder.setConnectTimeout(CONNECTION_TIMEOUT_MILLISECONDS)
- .setReadTimeout(READ_TIMEOUT_MILLISECONDS).build();
+ public static RestTemplate restTemplate(final RestTemplateBuilder restTemplateBuilder,
+ final HttpClientConfiguration httpClientConfiguration) {
+
+ final ConnectionConfig connectionConfig = ConnectionConfig.copy(ConnectionConfig.DEFAULT)
+ .setConnectTimeout(Timeout.of(httpClientConfiguration.getConnectionTimeoutInSeconds()))
+ .build();
+
+ final PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create()
+ .setDefaultConnectionConfig(connectionConfig)
+ .setMaxConnTotal(httpClientConfiguration.getMaximumConnectionsTotal())
+ .setMaxConnPerRoute(httpClientConfiguration.getMaximumConnectionsPerRoute())
+ .build();
+
+ final CloseableHttpClient httpClient = HttpClients.custom()
+ .setConnectionManager(connectionManager)
+ .evictExpiredConnections()
+ .evictIdleConnections(
+ TimeValue.of(httpClientConfiguration.getIdleConnectionEvictionThresholdInSeconds()))
+ .build();
+
+ final ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
+
+ final RestTemplate restTemplate = restTemplateBuilder
+ .requestFactory(() -> requestFactory)
+ .setConnectTimeout(httpClientConfiguration.getConnectionTimeoutInSeconds())
+ .build();
+
setRestTemplateMessageConverters(restTemplate);
return restTemplate;
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionPersistence.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistence.java
index 8092e39510..7aa073d356 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionPersistence.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistence.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.subscriptions;
+package org.onap.cps.ncmp.api.impl.deprecated.subscriptions;
import java.util.Collection;
import org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionPersistenceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistenceImpl.java
index dd0c20d590..29b7c7d044 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionPersistenceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistenceImpl.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.subscriptions;
+package org.onap.cps.ncmp.api.impl.deprecated.subscriptions;
import java.util.Collection;
import java.util.HashMap;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionStatus.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionStatus.java
index 63ab102d14..023e8de527 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionStatus.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionStatus.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.subscriptions;
+package org.onap.cps.ncmp.api.impl.deprecated.subscriptions;
public enum SubscriptionStatus {
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventConsumer.java
index d2b596ec04..307940c19e 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumer.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventConsumer.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription;
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription;
import static org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper.toTargetEvent;
@@ -30,7 +30,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.onap.cps.ncmp.api.impl.config.embeddedcache.ForwardedSubscriptionEventCacheConfig;
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistence;
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistence;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent;
import org.onap.cps.ncmp.api.models.CmSubscriptionEvent;
import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper.java
index 77eebe36f5..e2999950e5 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription;
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription;
import java.util.List;
import java.util.stream.Collectors;
@@ -49,7 +49,8 @@ public interface CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapper {
default List<YangModelSubscriptionEvent.TargetCmHandle> mapSubscriptionStatusToCmHandleTargets(
List<SubscriptionStatus> subscriptionStatus) {
return subscriptionStatus.stream().map(status -> new YangModelSubscriptionEvent.TargetCmHandle(status.getId(),
- org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus.fromString(status.getStatus().value()),
+ org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus.fromString(
+ status.getStatus().value()),
status.getDetails())).collect(Collectors.toList());
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper.java
index 0fe2c9ae5d..0de04ade7b 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapper.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription;
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription;
import java.util.List;
import java.util.Map;
@@ -26,7 +26,7 @@ import java.util.stream.Collectors;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus;
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus;
import org.onap.cps.ncmp.api.models.CmSubscriptionEvent;
import org.onap.cps.ncmp.api.models.CmSubscriptionStatus;
import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.AdditionalInfo;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventConsumer.java
index f1c64c788a..7227af91a6 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumer.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventConsumer.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription;
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription;
import static org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper.toTargetEvent;
import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_OPERATIONAL;
@@ -28,7 +28,7 @@ import io.cloudevents.CloudEvent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistence;
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistence;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent;
import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent;
import org.springframework.beans.factory.annotation.Value;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarder.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventForwarder.java
index e8086b1171..ae192c439d 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarder.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventForwarder.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription;
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription;
import com.hazelcast.map.IMap;
import io.cloudevents.CloudEvent;
@@ -37,10 +37,10 @@ import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.impl.config.embeddedcache.ForwardedSubscriptionEventCacheConfig;
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistence;
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus;
import org.onap.cps.ncmp.api.impl.events.EventsPublisher;
import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence;
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistence;
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus;
import org.onap.cps.ncmp.api.impl.utils.CmSubscriptionEventCloudMapper;
import org.onap.cps.ncmp.api.impl.utils.DmiServiceNameOrganizer;
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventMapper.java
index ab93f13a2c..852d5510c4 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventMapper.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription;
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription;
import java.util.List;
import java.util.stream.Collectors;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.java
index f1c1664537..a87508ce54 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription;
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
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/deprecated/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java
index a0fd81c12a..8a3c44da4f 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/deprecated/cmsubscription/CmSubscriptionNcmpOutEventPublisher.java
@@ -18,15 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription;
+package org.onap.cps.ncmp.api.impl.events.deprecated.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 static org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus.ACCEPTED;
+import static org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus.PENDING;
+import static org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus.REJECTED;
import io.cloudevents.CloudEvent;
import java.util.List;
@@ -34,9 +34,9 @@ import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.ncmp.api.NcmpResponseStatus;
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistence;
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus;
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;
import org.onap.cps.ncmp.api.impl.utils.DataNodeHelper;
import org.onap.cps.ncmp.api.impl.utils.SubscriptionOutcomeCloudMapper;
import org.onap.cps.ncmp.api.models.CmSubscriptionEvent;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/ResponseTimeoutTask.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/ResponseTimeoutTask.java
index 78b000dae6..8832ca3d04 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/ResponseTimeoutTask.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/ResponseTimeoutTask.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription;
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription;
import com.hazelcast.map.IMap;
import java.util.Set;
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImpl.java
index 159d8f345a..a0aeac3e89 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImpl.java
@@ -29,7 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.api.CpsAdminService;
+import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.ncmp.api.impl.utils.YangDataConverter;
@@ -48,7 +48,7 @@ import org.springframework.stereotype.Component;
public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements InventoryPersistence {
private final CpsModuleService cpsModuleService;
- private final CpsAdminService cpsAdminService;
+ private final CpsAnchorService cpsAnchorService;
private final CpsValidator cpsValidator;
/**
@@ -58,14 +58,14 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
* @param cpsDataService cps data service instance
* @param cpsModuleService cps module service instance
* @param cpsValidator cps validation service instance
- * @param cpsAdminService cps admin service instance
+ * @param cpsAnchorService cps anchor service instance
*/
public InventoryPersistenceImpl(final JsonObjectMapper jsonObjectMapper, final CpsDataService cpsDataService,
final CpsModuleService cpsModuleService, final CpsValidator cpsValidator,
- final CpsAdminService cpsAdminService) {
+ final CpsAnchorService cpsAnchorService) {
super(jsonObjectMapper, cpsDataService, cpsModuleService, cpsValidator);
this.cpsModuleService = cpsModuleService;
- this.cpsAdminService = cpsAdminService;
+ this.cpsAnchorService = cpsAnchorService;
this.cpsValidator = cpsValidator;
}
@@ -160,7 +160,7 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
@Override
public Collection<String> getCmHandleIdsWithGivenModules(final Collection<String> moduleNamesForQuery) {
- return cpsAdminService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNamesForQuery);
+ return cpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNamesForQuery);
}
private static String createCmHandleXPath(final String cmHandleId) {
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtils.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtils.java
index 25ea3bc1e6..750be2dc86 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtils.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtils.java
@@ -38,6 +38,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.onap.cps.ncmp.api.impl.inventory.CmHandleQueries;
import org.onap.cps.ncmp.api.impl.inventory.CmHandleState;
import org.onap.cps.ncmp.api.impl.inventory.CompositeState;
@@ -64,7 +65,7 @@ public class ModuleOperationsUtils {
public static final String MODULE_SET_TAG_KEY = "moduleSetTag";
public static final String MODULE_SET_TAG_MESSAGE_FORMAT = "Upgrade to ModuleSetTag: {0}";
private static final String UPGRADE_FORMAT = "Upgrade to ModuleSetTag: %s";
- private static final String UPGRADE_FAILED_FORMAT = UPGRADE_FORMAT + " Attempt #%d failed: %s";
+ private static final String LOCK_REASON_DETAILS_MSG_FORMAT = UPGRADE_FORMAT + " Attempt #%d failed: %s";
private static final Pattern retryAttemptPattern = Pattern.compile("Attempt #(\\d+) failed:.+");
private static final Pattern moduleSetTagPattern = Pattern.compile("Upgrade to ModuleSetTag: (\\S+)");
@@ -127,13 +128,14 @@ public class ModuleOperationsUtils {
int attempt = 1;
final Map<String, String> compositeStateDetails
= getLockedCompositeStateDetails(compositeState.getLockReason());
- if (!compositeStateDetails.isEmpty()) {
+ if (!compositeStateDetails.isEmpty() && compositeStateDetails.containsKey(RETRY_ATTEMPT_KEY)) {
attempt = 1 + Integer.parseInt(compositeStateDetails.get(RETRY_ATTEMPT_KEY));
}
+ final String moduleSetTag = compositeStateDetails.get(MODULE_SET_TAG_KEY);
compositeState.setLockReason(CompositeState.LockReason.builder()
- .details(String.format(UPGRADE_FAILED_FORMAT,
- compositeStateDetails.get(MODULE_SET_TAG_KEY), attempt, errorMessage))
- .lockReasonCategory(lockReasonCategory).build());
+ .details(String.format(LOCK_REASON_DETAILS_MSG_FORMAT, StringUtils.isNotBlank(moduleSetTag)
+ ? moduleSetTag : "not-specified", attempt, errorMessage)).lockReasonCategory(lockReasonCategory)
+ .build());
}
/**
@@ -174,13 +176,19 @@ public class ModuleOperationsUtils {
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
final CompositeState.LockReason lockReason = compositeState.getLockReason();
+ final boolean moduleUpgrade = LockReasonCategory.MODULE_UPGRADE == lockReason.getLockReasonCategory();
+ if (moduleUpgrade) {
+ log.info("Locked for module upgrade");
+ return true;
+ }
+
final boolean failedDuringModuleSync = LockReasonCategory.MODULE_SYNC_FAILED
== lockReason.getLockReasonCategory();
final boolean failedDuringModuleUpgrade = LockReasonCategory.MODULE_UPGRADE_FAILED
== lockReason.getLockReasonCategory();
if (failedDuringModuleSync || failedDuringModuleUpgrade) {
- log.info("Locked for module {}.", failedDuringModuleSync ? "sync" : "upgrade");
+ log.info("Locked for module {} (last attempt failed).", failedDuringModuleSync ? "sync" : "upgrade");
return isRetryDue(lockReason, time);
}
log.info("Locked for other reason");
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java
index 841368c0db..b21a2f1f85 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java
@@ -35,7 +35,7 @@ import java.util.Optional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.onap.cps.api.CpsAdminService;
+import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.ncmp.api.impl.inventory.CmHandleQueries;
@@ -59,9 +59,9 @@ public class ModuleSyncService {
private final DmiModelOperations dmiModelOperations;
private final CpsModuleService cpsModuleService;
- private final CpsAdminService cpsAdminService;
private final CmHandleQueries cmHandleQueries;
private final CpsDataService cpsDataService;
+ private final CpsAnchorService cpsAnchorService;
private final JsonObjectMapper jsonObjectMapper;
private final Map<String, Collection<ModuleReference>> moduleSetTagCache;
private static final Map<String, String> NO_NEW_MODULES = Collections.emptyMap();
@@ -73,60 +73,43 @@ public class ModuleSyncService {
*/
public void syncAndCreateOrUpgradeSchemaSetAndAnchor(final YangModelCmHandle yangModelCmHandle) {
- final String moduleSetTag;
final String cmHandleId = yangModelCmHandle.getId();
final CompositeState compositeState = yangModelCmHandle.getCompositeState();
final boolean inUpgrade = ModuleOperationsUtils.isInUpgradeOrUpgradeFailed(compositeState);
-
- if (inUpgrade) {
- moduleSetTag = ModuleOperationsUtils.getLockedCompositeStateDetails(compositeState.getLockReason())
- .get(ModuleOperationsUtils.MODULE_SET_TAG_KEY);
- } else {
- moduleSetTag = yangModelCmHandle.getModuleSetTag();
- }
+ final String moduleSetTag = getModuleSetTag(yangModelCmHandle, compositeState, inUpgrade);
final Collection<ModuleReference> moduleReferencesFromCache = moduleSetTagCache.get(moduleSetTag);
if (moduleReferencesFromCache == null) {
- final Optional<DataNode> optionalExistingCmHandleWithSameModuleSetTag
+ final Optional<DataNode> existingCmHandleWithSameModuleSetTag
= getFirstReadyDataNodeWithModuleSetTag(moduleSetTag);
- if (optionalExistingCmHandleWithSameModuleSetTag.isPresent()) {
- final String existingCmHandleAnchorName
- = optionalExistingCmHandleWithSameModuleSetTag.get().getAnchorName();
- createOrUpgradeSchemaSetUsingModuleSetTag(cmHandleId, moduleSetTag, existingCmHandleAnchorName);
+ if (existingCmHandleWithSameModuleSetTag.isPresent()) {
+ final String existingAnchorName = existingCmHandleWithSameModuleSetTag.get().getAnchorName();
+ final Collection<ModuleReference> moduleReferencesFromExistingCmHandle =
+ upgradeOrCreateSchemaSetUsingModuleSetTag(yangModelCmHandle.getId(), moduleSetTag,
+ existingAnchorName, inUpgrade);
+ updateModuleSetTagCache(moduleSetTag, moduleReferencesFromExistingCmHandle);
} else {
- syncAndCreateSchemaSet(yangModelCmHandle, moduleSetTag);
+ final Collection<ModuleReference> allModuleReferencesFromCmHandle
+ = syncAndCreateSchemaSet(yangModelCmHandle);
+ updateModuleSetTagCache(moduleSetTag, allModuleReferencesFromCmHandle);
}
} else {
- cpsModuleService.createOrUpgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,
- cmHandleId, NO_NEW_MODULES, moduleReferencesFromCache);
+ if (inUpgrade) {
+ cpsModuleService.upgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId,
+ NO_NEW_MODULES, moduleReferencesFromCache);
+ } else {
+ cpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,
+ cmHandleId, NO_NEW_MODULES, moduleReferencesFromCache);
+ }
}
if (!inUpgrade) {
- cpsAdminService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, cmHandleId);
+ cpsAnchorService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, cmHandleId);
}
setCmHandleModuleSetTag(yangModelCmHandle, moduleSetTag);
}
- private void syncAndCreateSchemaSet(final YangModelCmHandle yangModelCmHandle, final String moduleSetTag) {
- final Collection<ModuleReference> allModuleReferencesFromCmHandle =
- dmiModelOperations.getModuleReferences(yangModelCmHandle);
- final Collection<ModuleReference> identifiedNewModuleReferencesFromCmHandle = cpsModuleService
- .identifyNewModuleReferences(allModuleReferencesFromCmHandle);
- final Map<String, String> newModuleNameToContentMap;
- if (identifiedNewModuleReferencesFromCmHandle.isEmpty()) {
- newModuleNameToContentMap = NO_NEW_MODULES;
- } else {
- newModuleNameToContentMap = dmiModelOperations.getNewYangResourcesFromDmi(yangModelCmHandle,
- identifiedNewModuleReferencesFromCmHandle);
- }
- cpsModuleService.createOrUpgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,
- yangModelCmHandle.getId(), newModuleNameToContentMap, allModuleReferencesFromCmHandle);
- if (StringUtils.isNotBlank(moduleSetTag)) {
- moduleSetTagCache.put(moduleSetTag, allModuleReferencesFromCmHandle);
- }
- }
-
/**
* Deletes the SchemaSet for schema set id if the SchemaSet Exists.
*
@@ -162,16 +145,56 @@ public class ModuleSyncService {
jsonObjectMapper.asJsonString(dmiRegistryProperties), OffsetDateTime.now());
}
- private void createOrUpgradeSchemaSetUsingModuleSetTag(final String schemaSetName,
- final String moduleSetTag,
- final String existingCmHandleAnchorName) {
+ private Collection<ModuleReference> syncAndCreateSchemaSet(final YangModelCmHandle yangModelCmHandle) {
+ final Collection<ModuleReference> allModuleReferencesFromCmHandle =
+ dmiModelOperations.getModuleReferences(yangModelCmHandle);
+ final Collection<ModuleReference> identifiedNewModuleReferencesFromCmHandle = cpsModuleService
+ .identifyNewModuleReferences(allModuleReferencesFromCmHandle);
+ final Map<String, String> newModuleNameToContentMap;
+ if (identifiedNewModuleReferencesFromCmHandle.isEmpty()) {
+ newModuleNameToContentMap = NO_NEW_MODULES;
+ } else {
+ newModuleNameToContentMap = dmiModelOperations.getNewYangResourcesFromDmi(yangModelCmHandle,
+ identifiedNewModuleReferencesFromCmHandle);
+ }
+ cpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,
+ yangModelCmHandle.getId(), newModuleNameToContentMap, allModuleReferencesFromCmHandle);
+ return allModuleReferencesFromCmHandle;
+ }
+
+ private Collection<ModuleReference> upgradeOrCreateSchemaSetUsingModuleSetTag(final String schemaSetName,
+ final String moduleSetTag,
+ final String existingAnchorName,
+ final boolean inUpgrade) {
log.info("Found cm handle having module set tag: {}", moduleSetTag);
final Collection<ModuleReference> moduleReferencesFromExistingCmHandle =
cpsModuleService.getYangResourcesModuleReferences(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,
- existingCmHandleAnchorName);
- cpsModuleService.createOrUpgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,
- schemaSetName, NO_NEW_MODULES, moduleReferencesFromExistingCmHandle);
- moduleSetTagCache.put(moduleSetTag, moduleReferencesFromExistingCmHandle);
+ existingAnchorName);
+ if (inUpgrade) {
+ cpsModuleService.upgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, schemaSetName,
+ NO_NEW_MODULES, moduleReferencesFromExistingCmHandle);
+ } else {
+ cpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME,
+ schemaSetName, NO_NEW_MODULES, moduleReferencesFromExistingCmHandle);
+ }
+ return moduleReferencesFromExistingCmHandle;
+ }
+
+ private String getModuleSetTag(final YangModelCmHandle yangModelCmHandle,
+ final CompositeState compositeState,
+ final boolean inUpgrade) {
+ if (inUpgrade) {
+ return ModuleOperationsUtils.getLockedCompositeStateDetails(compositeState.getLockReason())
+ .get(ModuleOperationsUtils.MODULE_SET_TAG_KEY);
+ }
+ return yangModelCmHandle.getModuleSetTag();
+ }
+
+ private void updateModuleSetTagCache(final String moduleSetTag,
+ final Collection<ModuleReference> allModuleReferencesFromCmHandle) {
+ if (StringUtils.isNotBlank(moduleSetTag)) {
+ moduleSetTagCache.putIfAbsent(moduleSetTag, allModuleReferencesFromCmHandle);
+ }
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncTasks.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncTasks.java
index 896316a496..e214044189 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncTasks.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncTasks.java
@@ -67,20 +67,20 @@ public class ModuleSyncTasks {
final YangModelCmHandle yangModelCmHandle =
YangDataConverter.convertCmHandleToYangModel(cmHandleAsDataNode, cmHandleId);
final CompositeState compositeState = inventoryPersistence.getCmHandleState(cmHandleId);
+ final boolean inUpgrade = ModuleOperationsUtils.isInUpgradeOrUpgradeFailed(compositeState);
try {
- moduleSyncService.deleteSchemaSetIfExists(cmHandleId);
+ if (!inUpgrade) {
+ moduleSyncService.deleteSchemaSetIfExists(cmHandleId);
+ }
moduleSyncService.syncAndCreateOrUpgradeSchemaSetAndAnchor(yangModelCmHandle);
yangModelCmHandle.getCompositeState().setLockReason(null);
cmHandelStatePerCmHandle.put(yangModelCmHandle, CmHandleState.READY);
} catch (final Exception e) {
log.warn("Processing of {} module failed due to reason {}.", cmHandleId, e.getMessage());
- if (ModuleOperationsUtils.isInUpgradeOrUpgradeFailed(compositeState)) {
- moduleOperationsUtils.updateLockReasonDetailsAndAttempts(compositeState,
- LockReasonCategory.MODULE_UPGRADE_FAILED, e.getMessage());
- } else {
- moduleOperationsUtils.updateLockReasonDetailsAndAttempts(compositeState,
- LockReasonCategory.MODULE_SYNC_FAILED, e.getMessage());
- }
+ final LockReasonCategory lockReasonCategory = inUpgrade ? LockReasonCategory.MODULE_UPGRADE_FAILED
+ : LockReasonCategory.MODULE_SYNC_FAILED;
+ moduleOperationsUtils.updateLockReasonDetailsAndAttempts(compositeState,
+ lockReasonCategory, e.getMessage());
setCmHandleStateLocked(yangModelCmHandle, compositeState.getLockReason());
cmHandelStatePerCmHandle.put(yangModelCmHandle, CmHandleState.LOCKED);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java
index b6a04d3677..b54c154b2a 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java
@@ -87,7 +87,8 @@ public class YangDataConverter {
(String) cmHandleDataNode.getLeaves().get("dmi-data-service-name"),
(String) cmHandleDataNode.getLeaves().get("dmi-model-service-name"),
ncmpServiceCmHandle,
- (String) cmHandleDataNode.getLeaves().get("module-set-tag")
+ (String) cmHandleDataNode.getLeaves().get("module-set-tag"),
+ (String) cmHandleDataNode.getLeaves().get("alternate-id")
);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmDataSubscriptionEvent.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmDataSubscriptionEvent.java
new file mode 100644
index 0000000000..e527d99f2f
--- /dev/null
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmDataSubscriptionEvent.java
@@ -0,0 +1,76 @@
+/*
+ * ============LICENSE_START=======================================================
+ * 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.
+ * 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.yangmodels;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * Subscription event model to persist data into DB.
+ * Yang model subscription event
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+@JsonInclude(Include.NON_NULL)
+@EqualsAndHashCode(onlyExplicitlyIncluded = true)
+public class YangModelCmDataSubscriptionEvent {
+
+ @EqualsAndHashCode.Include
+ @JsonProperty("name")
+ private String name;
+
+ private List<CmHandle> cmHandles;
+
+ @AllArgsConstructor
+ @Data
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static class CmHandle {
+
+ @JsonProperty()
+ private final String id;
+
+ private final List<Filter> filters;
+ }
+
+ @AllArgsConstructor
+ @Data
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public static class Filter {
+
+ @JsonProperty()
+ private final String id;
+
+ @JsonProperty()
+ private final List<String> subscribers;
+ }
+}
+
+
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java
index f930d5b71d..ba36b1a54c 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java
@@ -68,6 +68,9 @@ public class YangModelCmHandle {
@JsonProperty("module-set-tag")
private String moduleSetTag;
+ @JsonProperty("alternate-id")
+ private String alternateId;
+
@JsonProperty("additional-properties")
private List<Property> dmiProperties;
@@ -91,6 +94,7 @@ public class YangModelCmHandle {
copy.dmiProperties = original.getDmiProperties() == null ? null : new ArrayList<>(original.getDmiProperties());
copy.publicProperties =
original.getPublicProperties() == null ? null : new ArrayList<>(original.getPublicProperties());
+ copy.alternateId = original.getAlternateId();
return copy;
}
@@ -107,13 +111,15 @@ public class YangModelCmHandle {
final String dmiDataServiceName,
final String dmiModelServiceName,
final NcmpServiceCmHandle ncmpServiceCmHandle,
- final String moduleSetTag) {
+ final String moduleSetTag,
+ final String alternateId) {
final YangModelCmHandle yangModelCmHandle = new YangModelCmHandle();
yangModelCmHandle.setId(ncmpServiceCmHandle.getCmHandleId());
yangModelCmHandle.setDmiServiceName(dmiServiceName);
yangModelCmHandle.setDmiDataServiceName(dmiDataServiceName);
yangModelCmHandle.setDmiModelServiceName(dmiModelServiceName);
yangModelCmHandle.setModuleSetTag(moduleSetTag == null ? StringUtils.EMPTY : moduleSetTag);
+ yangModelCmHandle.setAlternateId(alternateId);
yangModelCmHandle.setDmiProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getDmiProperties()));
yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties(
ncmpServiceCmHandle.getPublicProperties()));
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelSubscriptionEvent.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelSubscriptionEvent.java
index 866bfd4e7b..a6cfa7bb73 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelSubscriptionEvent.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelSubscriptionEvent.java
@@ -31,7 +31,7 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus;
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus;
/**
* Subscription event model to persist data into DB.
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionStatus.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionStatus.java
index 5541a01bd8..c56912376f 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionStatus.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmSubscriptionStatus.java
@@ -25,7 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus;
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Getter
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java
index f323079e0b..4989878975 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/NcmpServiceCmHandle.java
@@ -23,7 +23,6 @@ package org.onap.cps.ncmp.api.models;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import java.util.Collections;
-import java.util.LinkedHashMap;
import java.util.Map;
import lombok.Getter;
import lombok.NoArgsConstructor;
@@ -59,18 +58,6 @@ public class NcmpServiceCmHandle {
@JsonSetter(nulls = Nulls.AS_EMPTY)
private TrustLevel registrationTrustLevel;
- /**
- * NcmpServiceCmHandle copy constructor.
- *
- * @param ncmpServiceCmHandle Ncmp Service CmHandle
- */
- public NcmpServiceCmHandle(final NcmpServiceCmHandle ncmpServiceCmHandle) {
- this.cmHandleId = ncmpServiceCmHandle.getCmHandleId();
- this.dmiProperties = new LinkedHashMap<>(ncmpServiceCmHandle.getDmiProperties());
- this.publicProperties = new LinkedHashMap<>(ncmpServiceCmHandle.getPublicProperties());
- this.compositeState = ncmpServiceCmHandle.getCompositeState() != null ? new CompositeState(
- ncmpServiceCmHandle.getCompositeState()) : null;
- this.moduleSetTag = ncmpServiceCmHandle.getModuleSetTag();
- this.registrationTrustLevel = ncmpServiceCmHandle.getRegistrationTrustLevel();
- }
+ @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private String alternateId;
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/SubscriptionEventResponse.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/SubscriptionEventResponse.java
index 05663a55d8..cabd8683ff 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/SubscriptionEventResponse.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/SubscriptionEventResponse.java
@@ -25,7 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus;
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus;
@JsonInclude(JsonInclude.Include.NON_NULL)
@Getter
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java
index fd5f2b0ed6..bd8dec4dc8 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/AbstractModelLoader.java
@@ -29,8 +29,9 @@ import java.util.Map;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.api.CpsAdminService;
+import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
+import org.onap.cps.api.CpsDataspaceService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException;
import org.onap.cps.spi.CascadeDeleteAllowed;
@@ -44,9 +45,10 @@ import org.springframework.boot.context.event.ApplicationReadyEvent;
@RequiredArgsConstructor
abstract class AbstractModelLoader implements ModelLoader {
- private final CpsAdminService cpsAdminService;
+ private final CpsDataspaceService cpsDataspaceService;
private final CpsModuleService cpsModuleService;
private final CpsDataService cpsDataService;
+ private final CpsAnchorService cpsAnchorService;
private static final int EXIT_CODE_ON_ERROR = 1;
@@ -71,7 +73,7 @@ abstract class AbstractModelLoader implements ModelLoader {
void waitUntilDataspaceIsAvailable(final String dataspaceName) {
log.info("Model Loader start-up, waiting for database to be ready");
int attemptCount = 0;
- while (cpsAdminService.getDataspace(dataspaceName) == null) {
+ while (cpsDataspaceService.getDataspace(dataspaceName) == null) {
if (attemptCount < maximumAttemptCount) {
try {
Thread.sleep(attemptCount * retryTimeMs);
@@ -111,7 +113,7 @@ abstract class AbstractModelLoader implements ModelLoader {
void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) {
try {
- cpsAdminService.createAnchor(dataspaceName, schemaSetName, anchorName);
+ cpsAnchorService.createAnchor(dataspaceName, schemaSetName, anchorName);
} catch (final AlreadyDefinedException alreadyDefinedException) {
log.warn("Creating new anchor failed as anchor already exists");
} catch (final Exception exception) {
@@ -134,7 +136,7 @@ abstract class AbstractModelLoader implements ModelLoader {
void updateAnchorSchemaSet(final String dataspaceName, final String anchorName, final String schemaSetName) {
try {
- cpsAdminService.updateAnchorSchemaSet(dataspaceName, anchorName, schemaSetName);
+ cpsAnchorService.updateAnchorSchemaSet(dataspaceName, anchorName, schemaSetName);
} catch (final Exception exception) {
log.error("Updating schema set failed: {}", exception.getMessage());
throw new NcmpStartUpException("Updating schema set failed", exception.getMessage());
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java
index ade31e9ce6..c0f0279ad4 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java
@@ -23,8 +23,9 @@ package org.onap.cps.ncmp.init;
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.api.CpsAdminService;
+import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
+import org.onap.cps.api.CpsDataspaceService;
import org.onap.cps.api.CpsModuleService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -45,10 +46,11 @@ public class CmDataSubscriptionModelLoader extends AbstractModelLoader {
- public CmDataSubscriptionModelLoader(final CpsAdminService cpsAdminService,
+ public CmDataSubscriptionModelLoader(final CpsDataspaceService cpsDataspaceService,
final CpsModuleService cpsModuleService,
- final CpsDataService cpsDataService) {
- super(cpsAdminService, cpsModuleService, cpsDataService);
+ final CpsDataService cpsDataService,
+ final CpsAnchorService cpsAnchorService) {
+ super(cpsDataspaceService, cpsModuleService, cpsDataService, cpsAnchorService);
}
@Value("${ncmp.model-loader.subscription:true}")
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java
index b805cdcd84..0e562cdd8b 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/InventoryModelLoader.java
@@ -24,8 +24,9 @@ import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DA
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DMI_REGISTRY_ANCHOR;
import lombok.extern.slf4j.Slf4j;
-import org.onap.cps.api.CpsAdminService;
+import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
+import org.onap.cps.api.CpsDataspaceService;
import org.onap.cps.api.CpsModuleService;
import org.springframework.stereotype.Service;
@@ -33,13 +34,14 @@ import org.springframework.stereotype.Service;
@Service
public class InventoryModelLoader extends AbstractModelLoader {
- private static final String NEW_MODEL_FILE_NAME = "dmi-registry@2023-08-23.yang";
- private static final String NEW_SCHEMA_SET_NAME = "dmi-registry-2023-08-23";
+ 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";
- public InventoryModelLoader(final CpsAdminService cpsAdminService,
+ public InventoryModelLoader(final CpsDataspaceService cpsDataspaceService,
final CpsModuleService cpsModuleService,
- final CpsDataService cpsDataService) {
- super(cpsAdminService, cpsModuleService, cpsDataService);
+ final CpsDataService cpsDataService,
+ final CpsAnchorService cpsAnchorService) {
+ super(cpsDataspaceService, cpsModuleService, cpsDataService, cpsAnchorService);
}
@Override
diff --git a/cps-ncmp-service/src/main/resources/models/dmi-registry@2023-08-23.yang b/cps-ncmp-service/src/main/resources/models/dmi-registry@2023-11-27.yang
index bb7604d91a..808bbdd1bc 100644
--- a/cps-ncmp-service/src/main/resources/models/dmi-registry@2023-08-23.yang
+++ b/cps-ncmp-service/src/main/resources/models/dmi-registry@2023-11-27.yang
@@ -8,24 +8,29 @@ module dmi-registry {
contact "toine.siebelink@est.tech";
+ revision "2023-11-27" {
+ description
+ "Added alternate-id";
+ }
+
revision "2023-08-23" {
description
- "Added ModuleSetTag";
+ "Added module-set-tag";
}
revision "2022-05-10" {
description
- "Added DataSyncEnabled, SyncState with State, LastSyncTime, DataStoreSyncState with Operational and Running syncstate";
+ "Added data-sync-enabled, sync-state with state, last-sync-time, data-store-sync-state with operational and running syncstate";
}
revision "2022-02-10" {
description
- "Added State, LockReason, LockReasonDetails to aid with cmHandle sync and timestamp to aid with retry/timeout scenarios";
+ "Added state, lock-reason, lock-reason-details to aid with cmHandle sync and timestamp to aid with retry/timeout scenarios";
}
revision "2021-12-13" {
description
- "Added new list of public additional properties for a Cm-Handle which are exposed to clients of the NCMP interface";
+ "Added new list of public-properties and additional-properties for a Cm-Handle which are exposed to clients of the NCMP interface";
}
revision "2021-10-20" {
@@ -83,6 +88,9 @@ module dmi-registry {
leaf module-set-tag {
type string;
}
+ leaf alternate-id {
+ type string;
+ }
list additional-properties {
key "name";
@@ -129,3 +137,4 @@ module dmi-registry {
}
}
}
+
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 51b00d1431..f565ede394 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
@@ -210,12 +210,10 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification {
}
and: 'state handler is invoked with the expected parameters'
1 * mockLcmEventsCmHandleStateHandler.initiateStateAdvised(_) >> {
- args ->
- {
- def cmHandleStatePerCmHandle = (args[0] as Map)
- cmHandleStatePerCmHandle.each {
- assert (it.id == 'cmhandle' && it.dmiServiceName == 'my-server')
- }
+ args -> {
+ def yangModelCmHandles = args[0]
+ assert yangModelCmHandles.id == ['cmhandle']
+ assert yangModelCmHandles.dmiServiceName == ['my-server']
}
}
where:
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/HttpClientConfigurationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/HttpClientConfigurationSpec.groovy
new file mode 100644
index 0000000000..2c76b5bb44
--- /dev/null
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/HttpClientConfigurationSpec.groovy
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * 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.config
+
+import java.time.Duration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.support.AnnotationConfigContextLoader
+import spock.lang.Specification
+
+@SpringBootTest
+@ContextConfiguration(classes = [HttpClientConfiguration])
+@EnableConfigurationProperties(HttpClientConfiguration.class)
+@TestPropertySource(properties = ["ncmp.dmi.httpclient.connectionTimeoutInSeconds=1", "ncmp.dmi.httpclient.maximumConnectionsTotal=200"])
+class HttpClientConfigurationSpec extends Specification {
+
+ @Autowired
+ private HttpClientConfiguration httpClientConfiguration
+
+ def 'Test HttpClientConfiguration properties with custom and default values'() {
+ expect: 'custom property values'
+ assert httpClientConfiguration.getConnectionTimeoutInSeconds() == Duration.ofSeconds(1)
+ assert httpClientConfiguration.getMaximumConnectionsTotal() == 200
+ and: 'default property values'
+ assert httpClientConfiguration.getMaximumConnectionsPerRoute() == 50
+ assert httpClientConfiguration.getIdleConnectionEvictionThresholdInSeconds() == Duration.ofSeconds(5)
+ }
+}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/NcmpConfigurationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/NcmpConfigurationSpec.groovy
index e1aba79a50..a4df9b37cf 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/NcmpConfigurationSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/NcmpConfigurationSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation
+ * Copyright (C) 2021-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.
@@ -19,22 +19,27 @@
*/
package org.onap.cps.ncmp.api.impl.config
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.web.client.RestTemplateBuilder
import org.springframework.http.MediaType
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
import org.springframework.test.context.ContextConfiguration
import org.springframework.web.client.RestTemplate
import spock.lang.Specification
@SpringBootTest
-@ContextConfiguration(classes = [NcmpConfiguration.DmiProperties])
+@ContextConfiguration(classes = [NcmpConfiguration.DmiProperties, HttpClientConfiguration])
class NcmpConfigurationSpec extends Specification{
@Autowired
NcmpConfiguration.DmiProperties dmiProperties
-
+
+ @Autowired
+ HttpClientConfiguration httpClientConfiguration
+
def mockRestTemplateBuilder = new RestTemplateBuilder()
def 'NcmpConfiguration Construction.'() {
@@ -48,11 +53,14 @@ class NcmpConfigurationSpec extends Specification{
dmiProperties.authPassword == 'some-password'
}
- def 'Rest Template creation.'() {
+ def 'Rest Template creation with CloseableHttpClient and MappingJackson2HttpMessageConverter.'() {
when: 'a rest template is created'
- def result = NcmpConfiguration.restTemplate(mockRestTemplateBuilder)
+ def result = NcmpConfiguration.restTemplate(mockRestTemplateBuilder, httpClientConfiguration)
then: 'the rest template is returned'
assert result instanceof RestTemplate
+ and: 'the rest template is created with httpclient5'
+ assert result.getRequestFactory() instanceof HttpComponentsClientHttpRequestFactory
+ assert ((HttpComponentsClientHttpRequestFactory) result.getRequestFactory()).getHttpClient() instanceof CloseableHttpClient;
and: 'a jackson media converter has been added'
def lastMessageConverter = result.getMessageConverters().get(result.getMessageConverters().size()-1)
lastMessageConverter instanceof MappingJackson2HttpMessageConverter
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionPersistenceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistenceSpec.groovy
index 541a4f7ba1..da1a122359 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/subscriptions/SubscriptionPersistenceSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/deprecated/subscriptions/SubscriptionPersistenceSpec.groovy
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.subscriptions
+package org.onap.cps.ncmp.api.impl.deprecated.subscriptions
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NO_TIMESTAMP
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy
index b08b51ba23..468a402c00 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/ClientCmSubscriptionNcmpInEventMapperSpec.groovy
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription
import com.fasterxml.jackson.databind.ObjectMapper
import org.mapstruct.factory.Mappers
@@ -39,7 +39,7 @@ class ClientCmSubscriptionNcmpInEventMapperSpec extends Specification {
def 'Map clients subscription event to ncmps subscription event'() {
given: 'a Subscription Event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
when: 'the client event is mapped to a ncmp subscription event'
def result = objectUnderTest.toCmSubscriptionDmiInEvent(testEventToMap)
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy
index 95dee77bf3..1d38d3f023 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventConsumerSpec.groovy
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
@@ -27,7 +27,7 @@ import com.hazelcast.map.IMap
import io.cloudevents.CloudEvent
import io.cloudevents.core.builder.CloudEventBuilder
import org.apache.kafka.clients.consumer.ConsumerRecord
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistenceImpl
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistenceImpl
import org.onap.cps.ncmp.api.kafka.MessagingBaseSpec
import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent
import org.onap.cps.ncmp.utils.TestUtils
@@ -115,7 +115,7 @@ class CmSubscriptionDmiOutEventConsumerSpec extends MessagingBaseSpec {
}
def getDmiOutEvent() {
- def cmSubscriptionDmiOutEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json')
+ def cmSubscriptionDmiOutEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiOutEvent.json')
return jsonObjectMapper.convertJsonString(cmSubscriptionDmiOutEventJsonData, CmSubscriptionDmiOutEvent.class)
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy
index b13a2ceba1..1c91cb5d57 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec.groovy
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription
import com.fasterxml.jackson.databind.ObjectMapper
import org.mapstruct.factory.Mappers
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus
import org.onap.cps.ncmp.events.cmsubscription1_0_0.dmi_to_ncmp.CmSubscriptionDmiOutEvent
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
@@ -41,7 +41,7 @@ class CmSubscriptionDmiOutEventToYangModelSubscriptionEventMapperSpec extends Sp
def 'Map dmi out event to yang model subscription event'() {
given: 'a dmi out event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiOutEvent.json')
def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionDmiOutEvent.class)
when: 'the event is mapped to a yang model subscription'
def result = objectUnderTest.toYangModelSubscriptionEvent(testEventToMap)
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec.groovy
index 07b0925dcf..17b0984eb9 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec.groovy
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription
import com.fasterxml.jackson.databind.ObjectMapper
import org.mapstruct.factory.Mappers
@@ -42,7 +42,7 @@ class CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec extends Specific
def 'Map cm subscription event to ncmp out event'() {
given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionEvent.json')
+ def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
when: 'cm subscription event is mapped to ncmp out event'
def result = objectUnderTest.toCmSubscriptionNcmpOutEvent(cmSubscriptionEvent)
@@ -62,7 +62,7 @@ class CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec extends Specific
def 'Map cm subscription event to ncmp out event with the given scenarios causes an exception'() {
given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionEvent.json')
+ def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
and: 'set cm subscription status with given scenarios'
cmSubscriptionEvent.setCmSubscriptionStatus(subscriptionStatusList)
@@ -79,7 +79,7 @@ class CmSubscriptionEventToCmSubscriptionNcmpOutEventMapperSpec extends Specific
def 'Map cm subscription event to ncmp out event without any exception'() {
given: 'a cm subscription Event'
- def subscriptionResponseJsonData = TestUtils.getResourceFileContent('cmSubscriptionEvent.json')
+ def subscriptionResponseJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, CmSubscriptionEvent.class)
when: 'cm subscription event is mapped to ncmp out event'
objectUnderTest.toCmSubscriptionNcmpOutEvent(subscriptionResponseEvent)
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy
index 31e8839582..9484e19a49 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventConsumerSpec.groovy
@@ -18,13 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription
import com.fasterxml.jackson.databind.ObjectMapper
import io.cloudevents.CloudEvent
import io.cloudevents.core.builder.CloudEventBuilder
import org.apache.kafka.clients.consumer.ConsumerRecord
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionPersistence
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistence
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent
import org.onap.cps.ncmp.api.kafka.MessagingBaseSpec
import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent
@@ -52,7 +52,7 @@ class CmSubscriptionNcmpInEventConsumerSpec extends MessagingBaseSpec {
def 'Consume, persist and forward valid CM create message'() {
given: 'an event with data category CM'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def testEventSent = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
testEventSent.getData().getDataType().setDataCategory(dataCategory)
def testCloudEventSent = CloudEventBuilder.v1()
@@ -86,7 +86,7 @@ class CmSubscriptionNcmpInEventConsumerSpec extends MessagingBaseSpec {
def 'Consume event with wrong datastore causes an exception'() {
given: 'an event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def testEventSent = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
and: 'datastore is set to a passthrough-running datastore'
testEventSent.getData().getPredicates().setDatastore('operational')
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy
index ce117eef57..ef3ea88bbd 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription
import static org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper.toTargetEvent
@@ -27,8 +27,8 @@ import com.hazelcast.map.IMap
import io.cloudevents.CloudEvent
import org.mapstruct.factory.Mappers
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
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionPersistence
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus
import org.onap.cps.ncmp.api.impl.utils.CmSubscriptionEventCloudMapper
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelSubscriptionEvent.TargetCmHandle
@@ -73,7 +73,7 @@ class CmSubscriptionNcmpInEventForwarderSpec extends MessagingBaseSpec {
def 'Forward valid CM create subscription and simulate timeout'() {
given: 'a ncmp in event'
- def ncmpInEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def ncmpInEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def ncmpInEventJson = jsonObjectMapper.convertJsonString(ncmpInEventJsonData, CmSubscriptionNcmpInEvent.class)
and: 'the InventoryPersistence returns private properties for the supplied CM Handles'
1 * mockInventoryPersistence.getYangModelCmHandles(["CMHandle1", "CMHandle2", "CMHandle3"]) >> [
@@ -116,7 +116,7 @@ class CmSubscriptionNcmpInEventForwarderSpec extends MessagingBaseSpec {
def 'Forward CM create subscription where target CM Handles are #scenario'() {
given: 'a ncmp in event'
- def ncmpInEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def ncmpInEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def ncmpInEventJson = jsonObjectMapper.convertJsonString(ncmpInEventJsonData, CmSubscriptionNcmpInEvent.class)
and: 'the target CMHandles are set to #scenario'
ncmpInEventJson.getData().getPredicates().setTargets(invalidTargets)
@@ -133,7 +133,7 @@ class CmSubscriptionNcmpInEventForwarderSpec extends MessagingBaseSpec {
def 'Forward valid CM create subscription where targets are not associated to any existing CMHandles'() {
given: 'a ncmp in event'
- def ncmpInEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def ncmpInEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def ncmpInEventJson = jsonObjectMapper.convertJsonString(ncmpInEventJsonData, CmSubscriptionNcmpInEvent.class)
and: 'the InventoryPersistence returns no private properties for the supplied CM Handles'
1 * mockInventoryPersistence.getYangModelCmHandles(["CMHandle1", "CMHandle2", "CMHandle3"]) >> []
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy
index 3d034fcdcc..6dcc997ec2 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/deprecated/cmsubscription/CmSubscriptionNcmpInEventMapperSpec.groovy
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription
import com.fasterxml.jackson.databind.ObjectMapper
import org.mapstruct.factory.Mappers
-import org.onap.cps.ncmp.api.impl.subscriptions.SubscriptionStatus
+import org.onap.cps.ncmp.api.impl.deprecated.subscriptions.SubscriptionStatus
import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
@@ -41,7 +41,7 @@ class CmSubscriptionNcmpInEventMapperSpec extends Specification {
def 'Map subscription event to yang model subscription event where #scenario'() {
given: 'a Subscription Event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
when: 'the event is mapped to a yang model subscription'
def result = objectUnderTest.toYangModelSubscriptionEvent(testEventToMap)
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/deprecated/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy
index a0567cb4cb..725d32437e 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/deprecated/cmsubscription/CmSubscriptionNcmpOutEventPublisherSpec.groovy
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.events.cmsubscription
+package org.onap.cps.ncmp.api.impl.events.deprecated.cmsubscription
import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUCCESSFULLY_APPLIED_SUBSCRIPTION
import static org.onap.cps.ncmp.api.NcmpResponseStatus.SUBSCRIPTION_PENDING
@@ -30,7 +30,7 @@ import io.cloudevents.CloudEvent
import io.cloudevents.core.builder.CloudEventBuilder
import org.mapstruct.factory.Mappers
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.deprecated.subscriptions.SubscriptionPersistence
import org.onap.cps.ncmp.api.impl.utils.DataNodeBaseSpec
import org.onap.cps.ncmp.api.impl.utils.SubscriptionOutcomeCloudMapper
import org.onap.cps.ncmp.api.models.CmSubscriptionEvent
@@ -64,10 +64,10 @@ class CmSubscriptionNcmpOutEventPublisherSpec extends DataNodeBaseSpec {
def 'Send response to the client apps successfully'() {
given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionEvent.json')
+ def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
and: 'a ncmp out event'
- def ncmpOutEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent2.json')
+ def ncmpOutEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent2.json')
def ncmpOutEvent = jsonObjectMapper.convertJsonString(ncmpOutEventJsonData, CmSubscriptionNcmpOutEvent.class)
and: 'a random id for the cloud event'
SubscriptionOutcomeCloudMapper.randomId = 'some-id'
@@ -89,10 +89,10 @@ class CmSubscriptionNcmpOutEventPublisherSpec extends DataNodeBaseSpec {
def 'Create ncmp out message as expected'() {
given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionEvent.json')
+ def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
and: 'a ncmp out event'
- def ncmpOutEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent.json')
+ def ncmpOutEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json')
def ncmpOutEvent = jsonObjectMapper.convertJsonString(ncmpOutEventJsonData, CmSubscriptionNcmpOutEvent.class)
and: 'a status code and status message a per #scenarios'
ncmpOutEvent.getData().setStatusCode(statusCode)
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImplSpec.groovy
index bb4eebd40e..297f18c989 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/InventoryPersistenceImplSpec.groovy
@@ -22,6 +22,8 @@
package org.onap.cps.ncmp.api.impl.inventory
+import org.onap.cps.api.CpsAnchorService
+
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME
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
@@ -30,12 +32,8 @@ import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NO_TIME
import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
import com.fasterxml.jackson.databind.ObjectMapper
-import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
-import org.onap.cps.ncmp.api.impl.inventory.CmHandleState
-import org.onap.cps.ncmp.api.impl.inventory.CompositeState
-import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistenceImpl
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
import org.onap.cps.spi.CascadeDeleteAllowed
import org.onap.cps.spi.FetchDescendantsOption
@@ -58,12 +56,12 @@ class InventoryPersistenceImplSpec extends Specification {
def mockCpsModuleService = Mock(CpsModuleService)
- def mockCpsAdminService = Mock(CpsAdminService)
+ def mockCpsAnchorService = Mock(CpsAnchorService)
def mockCpsValidator = Mock(CpsValidator)
def objectUnderTest = new InventoryPersistenceImpl(spiedJsonObjectMapper, mockCpsDataService, mockCpsModuleService,
- mockCpsValidator, mockCpsAdminService)
+ mockCpsValidator, mockCpsAnchorService)
def formattedDateAndTime = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
.format(OffsetDateTime.of(2022, 12, 31, 20, 30, 40, 1, ZoneOffset.UTC))
@@ -284,7 +282,7 @@ class InventoryPersistenceImplSpec extends Specification {
when: 'the method to get cm handles is called'
objectUnderTest.getCmHandleIdsWithGivenModules(['sample-module-name'])
then: 'the admin persistence service method to query anchors is invoked once with the same parameter'
- 1 * mockCpsAdminService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, ['sample-module-name'])
+ 1 * mockCpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, ['sample-module-name'])
}
def 'Replace list content'() {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtilsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtilsSpec.groovy
index 099fc5ac18..8f3d8d97ba 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtilsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtilsSpec.groovy
@@ -108,9 +108,24 @@ class ModuleOperationsUtilsSpec extends Specification{
assert compositeState.lockReason.lockReasonCategory == MODULE_SYNC_FAILED
assert compositeState.lockReason.details.contains(expectedDetails)
where:
- scenario | lockReason || expectedDetails
- 'does not exist' | null || 'Attempt #1 failed: new error message'
- 'exists' | CompositeState.LockReason.builder().details("Attempt #2 failed: some error message").build() || 'Attempt #3 failed: new error message'
+ scenario | lockReason || expectedDetails
+ 'does not exist' | null || 'Attempt #1 failed: new error message'
+ 'exists' | CompositeState.LockReason.builder().details("Attempt #2 failed: some error message").build() || 'Attempt #3 failed: new error message'
+ }
+
+ def 'Update lock reason details that contains #scenario'() {
+ given: 'A locked state'
+ def compositeState = new CompositeStateBuilder().withCmHandleState(CmHandleState.LOCKED)
+ .withLockReason(MODULE_UPGRADE, "Upgrade to ModuleSetTag: " + moduleSetTag).build()
+ when: 'update cm handle details'
+ objectUnderTest.updateLockReasonDetailsAndAttempts(compositeState, MODULE_UPGRADE_FAILED, 'new error message')
+ then: 'the composite state lock reason and details are updated'
+ assert compositeState.lockReason.lockReasonCategory == MODULE_UPGRADE_FAILED
+ assert compositeState.lockReason.details.contains("Upgrade to ModuleSetTag: " + expectedDetails)
+ where:
+ scenario | moduleSetTag || expectedDetails
+ 'a module set tag' | 'someModuleSetTag' || 'someModuleSetTag'
+ 'empty module set tag' | '' || 'not-specified'
}
def 'Get all locked Cm-Handle where Lock Reason is MODULE_SYNC_FAILED cm handle #scenario'() {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy
index 5384f31cc1..de783ed2ca 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncServiceSpec.groovy
@@ -20,13 +20,14 @@
package org.onap.cps.ncmp.api.impl.inventory.sync
+import org.onap.cps.api.CpsAnchorService
+
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME
import static org.onap.cps.ncmp.api.impl.inventory.LockReasonCategory.MODULE_UPGRADE
import org.onap.cps.ncmp.api.impl.inventory.CmHandleState
import org.onap.cps.spi.FetchDescendantsOption
import org.onap.cps.spi.model.DataNode
-import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.spi.model.DataNodeBuilder
@@ -45,14 +46,14 @@ class ModuleSyncServiceSpec extends Specification {
def mockCpsModuleService = Mock(CpsModuleService)
def mockDmiModelOperations = Mock(DmiModelOperations)
- def mockCpsAdminService = Mock(CpsAdminService)
+ def mockCpsAnchorService = Mock(CpsAnchorService)
def mockCmHandleQueries = Mock(CmHandleQueries)
def mockCpsDataService = Mock(CpsDataService)
def mockJsonObjectMapper = Mock(JsonObjectMapper)
def mockModuleSetTagCache = [:]
- def objectUnderTest = new ModuleSyncService(mockDmiModelOperations, mockCpsModuleService, mockCpsAdminService,
- mockCmHandleQueries, mockCpsDataService, mockJsonObjectMapper, mockModuleSetTagCache)
+ def objectUnderTest = new ModuleSyncService(mockDmiModelOperations, mockCpsModuleService,
+ mockCmHandleQueries, mockCpsDataService, mockCpsAnchorService, mockJsonObjectMapper, mockModuleSetTagCache)
def expectedDataspaceName = NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME
def static cmHandleWithModuleSetTag = new DataNodeBuilder().withXpath("//cm-handles[@module-set-tag='tag-1'][@id='otherId']").withAnchor('otherId').build()
@@ -62,7 +63,7 @@ class ModuleSyncServiceSpec extends Specification {
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
@@ -76,9 +77,9 @@ class ModuleSyncServiceSpec extends Specification {
when: 'module sync is triggered'
objectUnderTest.syncAndCreateOrUpgradeSchemaSetAndAnchor(yangModelCmHandle)
then: 'create schema set from module is invoked with correct parameters'
- 1 * mockCpsModuleService.createOrUpgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'ch-1', newModuleNameContentToMap, moduleReferences)
+ 1 * mockCpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'ch-1', newModuleNameContentToMap, moduleReferences)
and: 'anchor is created with the correct parameters'
- 1 * mockCpsAdminService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'ch-1', 'ch-1')
+ 1 * mockCpsAnchorService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'ch-1', 'ch-1')
where: 'the following parameters are used'
scenario | existingModuleResourcesInCps | identifiedNewModuleReferences | newModuleNameContentToMap | moduleSetTag
'one new module' | [['module2': '2'], ['module3': '3']] | [['module1': '1']] | [module1: 'some yang source'] | ''
@@ -91,7 +92,7 @@ class ModuleSyncServiceSpec extends Specification {
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: 'cache or DMI operations returns some module references for upgraded cm handle'
@@ -110,15 +111,17 @@ class ModuleSyncServiceSpec extends Specification {
mockCmHandleQueries.cmHandleHasState('otherId', CmHandleState.READY) >> true
when: 'module sync is triggered'
objectUnderTest.syncAndCreateOrUpgradeSchemaSetAndAnchor(yangModelCmHandle)
- then: 'create schema set from module is invoked for the upgraded cm handle'
- 1 * mockCpsModuleService.createOrUpgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'upgraded-ch', [:], moduleReferences)
+ then: 'update schema set from module is invoked for the upgraded cm handle'
+ expectedCallsToUpgradeSchemaSet * mockCpsModuleService.upgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'upgraded-ch', [:], moduleReferences)
+ and: 'create schema set from module is invoked for the upgraded cm handle'
+ expectedCallsToCeateSchemaSet * mockCpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'upgraded-ch', [:], moduleReferences)
and: 'No anchor is created for the upgraded cm handle'
- 0 * mockCpsAdminService.createAnchor(*_)
+ 0 * mockCpsAnchorService.createAnchor(*_)
where: 'the following parameters are used'
- scenario | populateCache | existingCmHandlesWithSameTag
- 'new' | false | []
- 'in cache' | true | []
- 'in database' | false | [cmHandleWithModuleSetTag]
+ scenario | populateCache | existingCmHandlesWithSameTag || expectedCallsToUpgradeSchemaSet | expectedCallsToCeateSchemaSet
+ 'new' | false | [] || 0 | 1
+ 'in cache' | true | [] || 1 | 0
+ 'in database' | false | [cmHandleWithModuleSetTag] || 1 | 0
}
def 'upgrade model for a existing cm handle'() {
@@ -127,7 +130,7 @@ class ModuleSyncServiceSpec extends Specification {
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')]
@@ -138,7 +141,7 @@ class ModuleSyncServiceSpec extends Specification {
when: 'module upgrade is triggered'
objectUnderTest.syncAndCreateOrUpgradeSchemaSetAndAnchor(yangModelCmHandle)
then: 'the upgrade is delegated to the module service (with the correct parameters)'
- 1 * mockCpsModuleService.createOrUpgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'cmHandleId-1', Collections.emptyMap(), moduleReferences)
+ 1 * mockCpsModuleService.upgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, 'cmHandleId-1', Collections.emptyMap(), moduleReferences)
}
def 'Delete Schema Set for CmHandle'() {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmSubscriptionEventCloudMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/CmSubscriptionEventCloudMapperSpec.groovy
index fa2828a4f1..d61a026b73 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmSubscriptionEventCloudMapperSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/CmSubscriptionEventCloudMapperSpec.groovy
@@ -18,11 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.utils
+package org.onap.cps.ncmp.api.impl.util.deprecated
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.ObjectMapper
import io.cloudevents.core.builder.CloudEventBuilder
+import org.onap.cps.ncmp.api.impl.utils.CmSubscriptionEventCloudMapper
import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_dmi.CmSubscriptionDmiInEvent
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
@@ -45,7 +46,7 @@ class CmSubscriptionEventCloudMapperSpec extends Specification {
def 'Map the subscription event to data of the cloud event'() {
given: 'a subscription event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiInEvent.json')
def testEventData = jsonObjectMapper.convertJsonString(jsonData,
CmSubscriptionDmiInEvent.class)
def testCloudEvent = CloudEventBuilder.v1()
@@ -70,7 +71,7 @@ class CmSubscriptionEventCloudMapperSpec extends Specification {
def jsonProcessingException = new JsonProcessingException('The Cloud Event could not be constructed')
spyObjectMapper.writeValueAsBytes(_) >> { throw jsonProcessingException }
and: 'a subscription event of ncmp version'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiInEvent.json')
def testEventData = jsonObjectMapper.convertJsonString(jsonData,
CmSubscriptionDmiInEvent.class)
when: 'the subscription event map to cloud event'
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/SubscriptionOutcomeCloudMapperSpec.groovy
index d5670eb40d..9d79a8b4bb 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/SubscriptionOutcomeCloudMapperSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/util/deprecated/SubscriptionOutcomeCloudMapperSpec.groovy
@@ -18,11 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.utils
+package org.onap.cps.ncmp.api.impl.util.deprecated
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.ObjectMapper
import io.cloudevents.core.builder.CloudEventBuilder
+import org.onap.cps.ncmp.api.impl.utils.SubscriptionOutcomeCloudMapper
import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.CmSubscriptionNcmpOutEvent
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
@@ -45,7 +46,7 @@ class SubscriptionOutcomeCloudMapperSpec extends Specification {
def 'Map the subscription outcome to cloud event'() {
given: 'a subscription event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json')
def testEventData = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpOutEvent.class)
def testCloudEvent = CloudEventBuilder.v1()
.withData(objectMapper.writeValueAsBytes(testEventData))
@@ -69,7 +70,7 @@ class SubscriptionOutcomeCloudMapperSpec extends Specification {
def jsonProcessingException = new JsonProcessingException('The Cloud Event could not be constructed')
spyObjectMapper.writeValueAsBytes(_) >> { throw jsonProcessingException }
and: 'a cloud event having a subscription outcome in the data part'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json')
def testEventData = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpOutEvent.class)
when: 'the subscription outcome map to cloud event'
def expectedResult = objectUnderTest.toCloudEvent(testEventData, 'some-key', 'some-event-type')
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy
index 2b17e5d413..c83a540a37 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DmiServiceUrlBuilderSpec.groovy
@@ -32,7 +32,7 @@ import spock.lang.Specification
class DmiServiceUrlBuilderSpec extends Specification {
static YangModelCmHandle yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle('dmiServiceName',
- 'dmiDataServiceName', 'dmiModuleServiceName', new NcmpServiceCmHandle(cmHandleId: 'some-cm-handle-id'),'')
+ 'dmiDataServiceName', 'dmiModuleServiceName', new NcmpServiceCmHandle(cmHandleId: 'some-cm-handle-id'),'my-module-set-tag', 'my-alternate-id')
NcmpConfiguration.DmiProperties dmiProperties = new NcmpConfiguration.DmiProperties()
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandleSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandleSpec.groovy
index ca0015e995..493db8c160 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandleSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandleSpec.groovy
@@ -47,9 +47,12 @@ class YangModelCmHandleSpec extends Specification {
.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,'')
+ def objectUnderTest = YangModelCmHandle.toYangModelCmHandle('', '', '', ncmpServiceCmHandle,'my-module-set-tag', 'my-alternate-id')
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'
+ assert objectUnderTest.moduleSetTag == 'my-module-set-tag'
+ assert objectUnderTest.alternateId == 'my-alternate-id'
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'
@@ -64,7 +67,7 @@ class YangModelCmHandleSpec extends Specification {
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:
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/NcmpServiceCmHandleSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/NcmpServiceCmHandleSpec.groovy
deleted file mode 100644
index e42b914d2a..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/NcmpServiceCmHandleSpec.groovy
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * 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.
- * 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.models
-
-import org.onap.cps.ncmp.api.impl.inventory.CmHandleState
-import org.onap.cps.ncmp.api.impl.inventory.CompositeState
-import spock.lang.Specification
-
-class NcmpServiceCmHandleSpec extends Specification {
-
-
- def 'NCMP Service CmHandle check for deep copy operation'() {
- given: 'ncmp service cm handle'
- def originalNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: 'cmhandleid',
- dmiProperties: ['property1': 'value1', 'property2': 'value2'],
- publicProperties: ['pubproperty1': 'value1', 'pubproperty2': 'value2'],
- compositeState: new CompositeState(cmHandleState: CmHandleState.ADVISED, dataSyncEnabled: Boolean.FALSE))
- when: 'we create a deep copy'
- def deepCopiedNcmpServiceCmHandle = new NcmpServiceCmHandle(originalNcmpServiceCmHandle)
- and: 'we change the original ncmp service cmhandle'
- originalNcmpServiceCmHandle.dmiProperties = ['newProperty1': 'newValue1']
- originalNcmpServiceCmHandle.publicProperties = ['newPublicProperty1': 'newPubValue1']
- originalNcmpServiceCmHandle.compositeState = new CompositeState(cmHandleState: CmHandleState.DELETED, dataSyncEnabled: Boolean.TRUE)
- then: 'no change in the copied dmi and public properties of ncmp service cmhandle'
- deepCopiedNcmpServiceCmHandle.dmiProperties == ['property1': 'value1', 'property2': 'value2']
- deepCopiedNcmpServiceCmHandle.publicProperties == ['pubproperty1': 'value1', 'pubproperty2': 'value2']
- and: 'no change in the composite state'
- deepCopiedNcmpServiceCmHandle.compositeState.cmHandleState == CmHandleState.ADVISED
- deepCopiedNcmpServiceCmHandle.compositeState.dataSyncEnabled == Boolean.FALSE
- }
-
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy
index e5ed21f1c4..f9ecd63376 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/AbstractModelLoaderSpec.groovy
@@ -23,7 +23,8 @@ package org.onap.cps.ncmp.init
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.core.read.ListAppender
-import org.onap.cps.api.CpsAdminService
+import org.onap.cps.api.CpsDataspaceService
+import org.onap.cps.api.CpsAnchorService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException
@@ -37,10 +38,11 @@ import spock.lang.Specification
class AbstractModelLoaderSpec extends Specification {
- def mockCpsAdminService = Mock(CpsAdminService)
+ def mockCpsDataspaceService = Mock(CpsDataspaceService)
def mockCpsModuleService = Mock(CpsModuleService)
def mockCpsDataService = Mock(CpsDataService)
- def objectUnderTest = Spy(new TestModelLoader(mockCpsAdminService, mockCpsModuleService, mockCpsDataService))
+ def mockCpsAnchorService = Mock(CpsAnchorService)
+ def objectUnderTest = Spy(new TestModelLoader(mockCpsDataspaceService, mockCpsModuleService, mockCpsDataService, mockCpsAnchorService))
def applicationContext = new AnnotationConfigApplicationContext()
@@ -49,7 +51,7 @@ class AbstractModelLoaderSpec extends Specification {
def loggingListAppender
void setup() {
- yangResourceToContentMap = objectUnderTest.createYangResourcesToContentMap('subscription.yang')
+ yangResourceToContentMap = objectUnderTest.createYangResourcesToContentMap('cm-data-subscriptions@2023-11-13.yang')
logger.setLevel(Level.DEBUG)
loggingListAppender = new ListAppender()
logger.addAppender(loggingListAppender)
@@ -89,7 +91,7 @@ class AbstractModelLoaderSpec extends Specification {
def 'Create schema set.'() {
when: 'creating a schema set'
- objectUnderTest.createSchemaSet('some dataspace','new name','subscription.yang')
+ objectUnderTest.createSchemaSet('some dataspace','new name','cm-data-subscriptions@2023-11-13.yang')
then: 'the operation is delegated to the admin service'
1 * mockCpsModuleService.createSchemaSet('some dataspace','new name',_)
}
@@ -98,7 +100,7 @@ class AbstractModelLoaderSpec extends Specification {
given: 'the module service throws an already defined exception'
mockCpsModuleService.createSchemaSet(*_) >> { throw AlreadyDefinedException.forSchemaSet('name','context',null) }
when: 'attempt to create a schema set'
- objectUnderTest.createSchemaSet('some dataspace','new name','subscription.yang')
+ objectUnderTest.createSchemaSet('some dataspace','new name','cm-data-subscriptions@2023-11-13.yang')
then: 'the exception is ignored i.e. no exception thrown up'
noExceptionThrown()
and: 'the exception message is logged'
@@ -141,12 +143,12 @@ class AbstractModelLoaderSpec extends Specification {
when: 'creating an anchor'
objectUnderTest.createAnchor('some dataspace','some schema set','new name')
then: 'the operation is delegated to the admin service'
- 1 * mockCpsAdminService.createAnchor('some dataspace','some schema set', 'new name')
+ 1 * mockCpsAnchorService.createAnchor('some dataspace','some schema set', 'new name')
}
def 'Create anchor with already defined exception.'() {
given: 'the admin service throws an already defined exception'
- mockCpsAdminService.createAnchor(*_)>> { throw AlreadyDefinedException.forAnchor('name','context',null) }
+ mockCpsAnchorService.createAnchor(*_)>> { throw AlreadyDefinedException.forAnchor('name','context',null) }
when: 'attempt to create anchor'
objectUnderTest.createAnchor('some dataspace','some schema set','new name')
then: 'the exception is ignored i.e. no exception thrown up'
@@ -158,7 +160,7 @@ class AbstractModelLoaderSpec extends Specification {
def 'Create anchor with any other exception.'() {
given: 'the admin service throws a exception'
- mockCpsAdminService.createAnchor(*_)>> { throw new RuntimeException('test message') }
+ mockCpsAnchorService.createAnchor(*_)>> { throw new RuntimeException('test message') }
when: 'attempt to create anchor'
objectUnderTest.createAnchor('some dataspace','some schema set','new name')
then: 'a startup exception with correct message and details is thrown'
@@ -201,12 +203,12 @@ class AbstractModelLoaderSpec extends Specification {
when: 'a schema set for an anchor is updated'
objectUnderTest.updateAnchorSchemaSet('some dataspace', 'anchor', 'new schema set')
then: 'the request is delegated to the admin service'
- 1 * mockCpsAdminService.updateAnchorSchemaSet('some dataspace', 'anchor', 'new schema set')
+ 1 * mockCpsAnchorService.updateAnchorSchemaSet('some dataspace', 'anchor', 'new schema set')
}
def 'Update anchor schema set with exception.'() {
given: 'the admin service throws an exception'
- mockCpsAdminService.updateAnchorSchemaSet(*_) >> { throw new RuntimeException('test message') }
+ mockCpsAnchorService.updateAnchorSchemaSet(*_) >> { throw new RuntimeException('test message') }
when: 'a schema set for an anchor is updated'
objectUnderTest.updateAnchorSchemaSet('some dataspace', 'anchor', 'new schema set')
then: 'a startup exception with correct message and details is thrown'
@@ -217,10 +219,11 @@ class AbstractModelLoaderSpec extends Specification {
class TestModelLoader extends AbstractModelLoader {
- TestModelLoader(final CpsAdminService cpsAdminService,
+ TestModelLoader(final CpsDataspaceService cpsDataspaceService,
final CpsModuleService cpsModuleService,
- final CpsDataService cpsDataService) {
- super(cpsAdminService, cpsModuleService, cpsDataService)
+ final CpsDataService cpsDataService,
+ final CpsAnchorService cpsAnchorService) {
+ super(cpsDataspaceService, cpsModuleService, cpsDataService, cpsAnchorService)
super.maximumAttemptCount = 2
super.retryTimeMs = 1
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy
index 06627129a9..aed495ec45 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy
@@ -20,12 +20,14 @@
package org.onap.cps.ncmp.init
+import org.onap.cps.api.CpsAnchorService
+
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.core.read.ListAppender
-import org.onap.cps.api.CpsAdminService
+import org.onap.cps.api.CpsDataspaceService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.spi.model.Dataspace
@@ -36,10 +38,11 @@ import spock.lang.Specification
class CmDataSubscriptionModelLoaderSpec extends Specification {
- def mockCpsAdminService = Mock(CpsAdminService)
+ def mockCpsDataspaceService = Mock(CpsDataspaceService)
def mockCpsModuleService = Mock(CpsModuleService)
def mockCpsDataService = Mock(CpsDataService)
- def objectUnderTest = new CmDataSubscriptionModelLoader(mockCpsAdminService, mockCpsModuleService, mockCpsDataService)
+ def mockCpsAnchorService = Mock(CpsAnchorService)
+ def objectUnderTest = new CmDataSubscriptionModelLoader(mockCpsDataspaceService, mockCpsModuleService, mockCpsDataService, mockCpsAnchorService)
def applicationContext = new AnnotationConfigApplicationContext()
@@ -65,13 +68,13 @@ class CmDataSubscriptionModelLoaderSpec extends Specification {
given:'model loader is enabled'
objectUnderTest.subscriptionModelLoaderEnabled = true
and: 'dataspace is ready for use'
- mockCpsAdminService.getDataspace(NCMP_DATASPACE_NAME) >> new Dataspace('')
+ mockCpsDataspaceService.getDataspace(NCMP_DATASPACE_NAME) >> new Dataspace('')
when: 'the application is ready'
objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent))
then: 'the module service to create schema set is called once'
1 * mockCpsModuleService.createSchemaSet(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', expectedYangResourcesToContentMap)
and: 'the admin service to create an anchor set is called once'
- 1 * mockCpsAdminService.createAnchor(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', 'cm-data-subscriptions')
+ 1 * mockCpsAnchorService.createAnchor(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', 'cm-data-subscriptions')
and: 'the data service to create a top level datanode is called once'
1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '{"datastores":{}}', _)
}
@@ -82,7 +85,7 @@ class CmDataSubscriptionModelLoaderSpec extends Specification {
when: 'application is ready'
objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent))
then: 'no interaction with admin service'
- 0 * mockCpsAdminService.getDataspace(_)
+ 0 * mockCpsDataspaceService.getDataspace(_)
then: 'a message is logged that the function is disabled'
def logs = loggingListAppender.list.toString()
assert logs.contains('Subscription Model Loader is disabled')
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy
index 43e0f69b3f..5557993abd 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/InventoryModelLoaderSpec.groovy
@@ -20,13 +20,15 @@
package org.onap.cps.ncmp.init
+import org.onap.cps.api.CpsAnchorService
+
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 ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.core.read.ListAppender
-import org.onap.cps.api.CpsAdminService
+import org.onap.cps.api.CpsDataspaceService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.spi.model.Dataspace
@@ -37,10 +39,11 @@ import spock.lang.Specification
class InventoryModelLoaderSpec extends Specification {
- def mockCpsAdminService = Mock(CpsAdminService)
+ def mockCpsAdminService = Mock(CpsDataspaceService)
def mockCpsModuleService = Mock(CpsModuleService)
def mockCpsDataService = Mock(CpsDataService)
- def objectUnderTest = new InventoryModelLoader(mockCpsAdminService, mockCpsModuleService, mockCpsDataService)
+ def mockCpsAnchorService = Mock(CpsAnchorService)
+ def objectUnderTest = new InventoryModelLoader(mockCpsAdminService, mockCpsModuleService, mockCpsDataService, mockCpsAnchorService)
def applicationContext = new AnnotationConfigApplicationContext()
@@ -49,7 +52,7 @@ class InventoryModelLoaderSpec extends Specification {
def loggingListAppender
void setup() {
- expectedYangResourceToContentMap = objectUnderTest.createYangResourcesToContentMap('dmi-registry@2023-08-23.yang')
+ expectedYangResourceToContentMap = objectUnderTest.createYangResourcesToContentMap('dmi-registry@2023-11-27.yang')
logger.setLevel(Level.DEBUG)
loggingListAppender = new ListAppender()
logger.addAppender(loggingListAppender)
@@ -68,9 +71,9 @@ class InventoryModelLoaderSpec extends Specification {
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-08-23', expectedYangResourceToContentMap)
+ 1 * mockCpsModuleService.createSchemaSet(NCMP_DATASPACE_NAME, 'dmi-registry-2023-11-27', expectedYangResourceToContentMap)
and: 'the admin service is used to update the anchor'
- 1 * mockCpsAdminService.updateAnchorSchemaSet(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, 'dmi-registry-2023-08-23')
+ 1 * mockCpsAnchorService.updateAnchorSchemaSet(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, 'dmi-registry-2023-11-27')
and: 'No schema sets are being removed by the module service (yet)'
0 * mockCpsModuleService.deleteSchemaSet(NCMP_DATASPACE_NAME, _, _)
}
diff --git a/cps-ncmp-service/src/test/resources/cmSubscriptionDmiInEvent.json b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionDmiInEvent.json
index f31362a1c6..f31362a1c6 100644
--- a/cps-ncmp-service/src/test/resources/cmSubscriptionDmiInEvent.json
+++ b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionDmiInEvent.json
diff --git a/cps-ncmp-service/src/test/resources/cmSubscriptionDmiOutEvent.json b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionDmiOutEvent.json
index ae14b5ca21..ae14b5ca21 100644
--- a/cps-ncmp-service/src/test/resources/cmSubscriptionDmiOutEvent.json
+++ b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionDmiOutEvent.json
diff --git a/cps-ncmp-service/src/test/resources/cmSubscriptionEvent.json b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionEvent.json
index c38cb79211..c38cb79211 100644
--- a/cps-ncmp-service/src/test/resources/cmSubscriptionEvent.json
+++ b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionEvent.json
diff --git a/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpInEvent.json b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json
index 803fa48bdf..803fa48bdf 100644
--- a/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpInEvent.json
+++ b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json
diff --git a/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent.json b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json
index 856f238c6e..856f238c6e 100644
--- a/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent.json
+++ b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json
diff --git a/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent2.json b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionNcmpOutEvent2.json
index 35ff0241df..35ff0241df 100644
--- a/cps-ncmp-service/src/test/resources/cmSubscriptionNcmpOutEvent2.json
+++ b/cps-ncmp-service/src/test/resources/deprecatedCmSubscription/cmSubscriptionNcmpOutEvent2.json