summaryrefslogtreecommitdiffstats
path: root/cps-service
diff options
context:
space:
mode:
Diffstat (limited to 'cps-service')
-rw-r--r--cps-service/pom.xml2
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java19
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java16
-rw-r--r--cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java4
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java21
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java2
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java42
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java10
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java2
-rw-r--r--cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java4
-rw-r--r--cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java8
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy18
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy7
-rw-r--r--cps-service/src/test/resources/application.yml10
14 files changed, 119 insertions, 46 deletions
diff --git a/cps-service/pom.xml b/cps-service/pom.xml
index c69ead09e9..c8daccca4d 100644
--- a/cps-service/pom.xml
+++ b/cps-service/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>2.0.1-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
index 5c40331d74..1dccf49c9b 100644
--- a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
@@ -21,6 +21,7 @@
package org.onap.cps.api;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -51,12 +52,12 @@ public interface CpsModuleService {
* @param dataspaceName Dataspace name
* @param schemaSetName schema set name
* @param newYangResourcesModuleNameToContentMap YANG resources map where key is a module name and value is content
- * @param existingModuleReferences List of YANG resources module references of the modules
+ * @param moduleReferences List of YANG resources module references of the modules
* needed for this handle that are already in CPS
*/
void createSchemaSetFromModules(@NonNull String dataspaceName, @NonNull String schemaSetName,
@NonNull Map<String, String> newYangResourcesModuleNameToContentMap,
- @NonNull List<ModuleReference> existingModuleReferences);
+ @NonNull List<ModuleReference> moduleReferences);
/**
* Read schema set in the given dataspace.
@@ -80,9 +81,19 @@ public interface CpsModuleService {
@NonNull CascadeDeleteAllowed cascadeDeleteAllowed);
/**
- * Retrieve all modules and revisions known by CPS for all Yang Resources.
+ * Retrieve module references for the given dataspace name.
*
+ * @param dataspaceName dataspace name
+ * @return a list of ModuleReference objects
+ */
+ Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName);
+
+ /**
+ * Retrieve module references for the given dataspace name and anchor name.
+ *
+ * @param dataspaceName dataspace name
+ * @param anchorName anchor name
* @return a list of ModuleReference objects
*/
- List<ModuleReference> getAllYangResourcesModuleReferences();
+ Collection<ModuleReference> getYangResourcesModuleReferences(String dataspaceName, String anchorName);
}
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
index 0597d380a5..10326413c3 100644
--- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
@@ -21,6 +21,7 @@
package org.onap.cps.api.impl;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.onap.cps.api.CpsModuleService;
@@ -53,9 +54,9 @@ public class CpsModuleServiceImpl implements CpsModuleService {
@Override
public void createSchemaSetFromModules(final String dataspaceName, final String schemaSetName,
final Map<String, String> newYangResourcesModuleNameToContentMap,
- final List<ModuleReference> existingModuleReferences) {
+ final List<ModuleReference> moduleReferences) {
cpsModulePersistenceService.storeSchemaSetFromModules(dataspaceName, schemaSetName,
- newYangResourcesModuleNameToContentMap, existingModuleReferences);
+ newYangResourcesModuleNameToContentMap, moduleReferences);
}
@@ -64,7 +65,7 @@ public class CpsModuleServiceImpl implements CpsModuleService {
final var yangTextSchemaSourceSet = yangTextSchemaSourceSetCache
.get(dataspaceName, schemaSetName);
return SchemaSet.builder().name(schemaSetName).dataspaceName(dataspaceName)
- .moduleReferences(yangTextSchemaSourceSet.getModuleReferences()).build();
+ .extendedModuleReferences(yangTextSchemaSourceSet.getModuleReferences()).build();
}
@Override
@@ -74,8 +75,13 @@ public class CpsModuleServiceImpl implements CpsModuleService {
}
@Override
- public List<ModuleReference> getAllYangResourcesModuleReferences() {
- return cpsModulePersistenceService.getAllYangResourcesModuleReferences();
+ public Collection<ModuleReference> getYangResourceModuleReferences(final String dataspaceName) {
+ return cpsModulePersistenceService.getYangResourceModuleReferences(dataspaceName);
}
+ @Override
+ public Collection<ModuleReference> getYangResourcesModuleReferences(final String dataspaceName,
+ final String anchorName) {
+ return cpsModulePersistenceService.getYangResourceModuleReferences(dataspaceName, anchorName);
+ }
}
diff --git a/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java b/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java
index 4c961598e4..2667ef4909 100644
--- a/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java
+++ b/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java
@@ -22,6 +22,7 @@ package org.onap.cps.config;
import javax.validation.constraints.Min;
import lombok.Setter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -32,7 +33,8 @@ import org.springframework.validation.annotation.Validated;
@EnableAsync
@Configuration
-@ConfigurationProperties("notification.async-executor")
+@ConditionalOnProperty(name = "notification.async.enabled", havingValue = "true", matchIfMissing = false)
+@ConfigurationProperties("notification.async.executor")
@Validated
@Setter
public class AsyncConfig {
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
index 7ad109d815..9b50f9e917 100755
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
@@ -21,6 +21,7 @@
package org.onap.cps.spi;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -48,11 +49,11 @@ public interface CpsModulePersistenceService {
* @param dataspaceName Dataspace name
* @param schemaSetName Schema set name
* @param newYangResourcesModuleNameToContentMap YANG resources map where key is a module name and value is content
- * @param moduleReferenceList List of YANG resources module references
+ * @param moduleReferences List of YANG resources module references
*/
void storeSchemaSetFromModules(@NonNull String dataspaceName, @NonNull String schemaSetName,
@NonNull Map<String, String> newYangResourcesModuleNameToContentMap,
- @NonNull List<ModuleReference> moduleReferenceList);
+ @NonNull List<ModuleReference> moduleReferences);
/**
* Deletes Schema Set.
@@ -89,9 +90,19 @@ public interface CpsModulePersistenceService {
@NonNull String anchorName);
/**
- * Returns all YANG resources module references.
+ * Returns YANG resources module references for the given dataspace name.
*
- * @return List of all YANG resources module information in the database
+ * @param dataspaceName dataspace name
+ * @return Collection of all YANG resources module information in the database
+ */
+ Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName);
+
+ /**
+ * Get YANG resource module references for the given anchor name and dataspace name.
+ *
+ * @param dataspaceName dataspace name
+ * @param anchorName anchor name
+ * @return a collection of module names and revisions
*/
- List<ModuleReference> getAllYangResourcesModuleReferences();
+ Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName, String anchorName);
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java b/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
index 5773bc45c9..8e9dff873a 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
@@ -38,7 +38,7 @@ public class DataNode {
private String dataspace;
private String schemaSetName;
private String anchorName;
- private ModuleReference moduleReference;
+ private ExtendedModuleReference extendedModuleReference;
private String xpath;
private Map<String, Object> leaves = Collections.emptyMap();
private Collection<String> xpathsChildren;
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java b/cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java
new file mode 100644
index 0000000000..5e9c8d0cd7
--- /dev/null
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java
@@ -0,0 +1,42 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright 2020-2021 Pantheon.tech
+ * ================================================================================
+ * 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.spi.model;
+
+import java.io.Serializable;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class ExtendedModuleReference implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private String namespace;
+ private String revision;
+
+}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java b/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
index f9aa2b5904..9b73f8ff0f 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
@@ -1,7 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * Modifications Copyright 2020-2021 Pantheon.tech
+ * Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,10 +32,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public class ModuleReference implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private String name;
- private String namespace;
+ private static final long serialVersionUID = -1761408847591042599L;
+ private String moduleName;
private String revision;
-
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java b/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
index caf7800d9b..4df7893e2c 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
@@ -35,5 +35,5 @@ public class SchemaSet implements Serializable {
private static final long serialVersionUID = 1464791260718603291L;
private String name;
private String dataspaceName;
- private List<ModuleReference> moduleReferences;
+ private List<ExtendedModuleReference> extendedModuleReferences;
}
diff --git a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java
index 32ee324c54..2c9d374b14 100644
--- a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java
+++ b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java
@@ -21,7 +21,7 @@ package org.onap.cps.yang;
import java.util.List;
import org.checkerframework.checker.nullness.qual.NonNull;
-import org.onap.cps.spi.model.ModuleReference;
+import org.onap.cps.spi.model.ExtendedModuleReference;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
@@ -35,7 +35,7 @@ public interface YangTextSchemaSourceSet {
* @return list of ModuleRef
*/
@NonNull
- List<ModuleReference> getModuleReferences();
+ List<ExtendedModuleReference> getModuleReferences();
/**
* Return SchemaContext for given YangSchema.
diff --git a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
index 3a65369dc7..5cbfd6222d 100644
--- a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
+++ b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
import lombok.NoArgsConstructor;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.spi.exceptions.ModelValidationException;
-import org.onap.cps.spi.model.ModuleReference;
+import org.onap.cps.spi.model.ExtendedModuleReference;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -88,14 +88,14 @@ public final class YangTextSchemaSourceSetBuilder {
}
@Override
- public List<ModuleReference> getModuleReferences() {
+ public List<ExtendedModuleReference> getModuleReferences() {
return schemaContext.getModules().stream()
.map(YangTextSchemaSourceSetImpl::toModuleReference)
.collect(Collectors.toList());
}
- private static ModuleReference toModuleReference(final Module module) {
- return ModuleReference.builder()
+ private static ExtendedModuleReference toModuleReference(final Module module) {
+ return ExtendedModuleReference.builder()
.name(module.getName())
.namespace(module.getQNameModule().getNamespace().toString())
.revision(module.getRevision().map(Revision::toString).orElse(null))
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
index d719b3d24e..2c23aa1bc8 100644
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
@@ -25,6 +25,7 @@ package org.onap.cps.api.impl
import org.onap.cps.TestUtils
import org.onap.cps.spi.CpsModulePersistenceService
import org.onap.cps.spi.exceptions.ModelValidationException
+import org.onap.cps.spi.model.ExtendedModuleReference
import org.onap.cps.spi.model.ModuleReference
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
@@ -63,7 +64,7 @@ class CpsModuleServiceImplSpec extends Specification {
def 'Create schema set from new modules and existing modules.'() {
given: 'a list of existing modules module reference'
- def moduleReferenceForExistingModule = new ModuleReference("test", "test.org", "2021-10-12")
+ def moduleReferenceForExistingModule = new ExtendedModuleReference("test", "test.org", "2021-10-12")
def listOfExistingModulesModuleReference = [moduleReferenceForExistingModule]
when: 'create schema set from modules method is invoked'
objectUnderTest.createSchemaSetFromModules("someDataspaceName", "someSchemaSetName", [newModule: "newContent"], listOfExistingModulesModuleReference)
@@ -90,7 +91,7 @@ class CpsModuleServiceImplSpec extends Specification {
then: 'the correct schema set is returned'
result.getName().contains('someSchemaSet')
result.getDataspaceName().contains('someDataspace')
- result.getModuleReferences().contains(new ModuleReference('stores', 'org:onap:ccsdk:sample', '2020-09-15'))
+ result.getExtendedModuleReferences().contains(new ExtendedModuleReference('stores', 'org:onap:ccsdk:sample', '2020-09-15'))
}
def 'Schema set caching.'() {
@@ -117,9 +118,18 @@ class CpsModuleServiceImplSpec extends Specification {
def 'Get all yang resources module references.'(){
given: 'an already present module reference'
+ def moduleReferences = [new ExtendedModuleReference()]
+ mockModuleStoreService.getYangResourceModuleReferences('someDataspaceName') >> moduleReferences
+ expect: 'the list provided by persistence service is returned as result'
+ objectUnderTest.getYangResourceModuleReferences('someDataspaceName') == moduleReferences
+ }
+
+
+ def 'Get all yang resources module references for the given dataspace name and anchor name.'(){
+ given: 'the module store service service returns a list module references'
def moduleReferences = [new ModuleReference()]
- mockModuleStoreService.getAllYangResourcesModuleReferences() >> moduleReferences
+ mockModuleStoreService.getYangResourceModuleReferences('someDataspaceName', 'someAnchorName') >> moduleReferences
expect: 'the list provided by persistence service is returned as result'
- objectUnderTest.getAllYangResourcesModuleReferences() == moduleReferences
+ objectUnderTest.getYangResourcesModuleReferences('someDataspaceName', 'someAnchorName') == moduleReferences
}
}
diff --git a/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy
index 875113d225..ca704edb4c 100644
--- a/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy
@@ -36,7 +36,6 @@ import spock.lang.Specification
import java.util.concurrent.TimeUnit
@SpringBootTest
-@EnableAsync
@EnableConfigurationProperties
@ContextConfiguration(classes = [NotificationProperties, NotificationService, NotificationErrorHandler, AsyncConfig])
class NotificationServiceSpec extends Specification {
@@ -105,10 +104,4 @@ class NotificationServiceSpec extends Specification {
1 * spyNotificationErrorHandler.onException(_, _, _, _)
}
- NotificationService createNotificationService(boolean notificationEnabled) {
- spyNotificationProperties = Spy(notificationProperties)
- spyNotificationProperties.isEnabled() >> notificationEnabled
- return new NotificationService(spyNotificationProperties, mockNotificationPublisher,
- mockCpsDataUpdatedEventFactory, spyNotificationErrorHandler)
- }
}
diff --git a/cps-service/src/test/resources/application.yml b/cps-service/src/test/resources/application.yml
index b1546d74f3..436c3d4c34 100644
--- a/cps-service/src/test/resources/application.yml
+++ b/cps-service/src/test/resources/application.yml
@@ -22,10 +22,12 @@ notification:
enabled-dataspaces: ".*-published,.*-important"
enabled: true
topic: cps-event
- async-executor:
- core-pool-size: 2
- max-pool-size: 10
- queue-capacity: 0
+ async:
+ enabled: true
+ executor:
+ core-pool-size: 2
+ max-pool-size: 10
+ queue-capacity: 0
spring:
kafka: