<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.cps</groupId>
<artifactId>checkstyle</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<profiles>
<profile>
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.cps</groupId>
<artifactId>cps-bom</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<description>This artifact contains dependencyManagement declarations of all published CPS components.</description>
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.cps</groupId>
<artifactId>cps-dependencies</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
@Value("${notification.enabled:true}")
private boolean notificationFeatureEnabled;
+ @Value("${ncmp.model-loader.subscription:false}")
+ private boolean subscriptionModelLoaderEnabled;
+
/**
* Consume the specified event.
*
}
if ("CM".equals(event.getDataType().getDataCategory())) {
log.debug("Consuming event {} ...", subscriptionEvent);
- persistSubscriptionEvent(subscriptionEvent);
+ if (subscriptionModelLoaderEnabled) {
+ persistSubscriptionEvent(subscriptionEvent);
+ }
if ("CREATE".equals(subscriptionEvent.getEventType().value())) {
log.info("Subscription for ClientID {} with name {} ...",
event.getSubscription().getClientID(),
def testEventSent = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class)
and: 'notifications are enabled'
objectUnderTest.notificationFeatureEnabled = true
+ and: 'subscription model loader is enabled'
+ objectUnderTest.subscriptionModelLoaderEnabled = true
when: 'the valid event is consumed'
objectUnderTest.consumeSubscriptionEvent(testEventSent)
then: 'the event is mapped to a yangModelSubscription'
1 * mockSubscriptionEventForwarder.forwardCreateSubscriptionEvent(testEventSent)
}
- def 'Consume and persist valid CM create message where notifications are disabled'() {
+ def 'Consume valid CM create message where notifications and model loader are disabled'() {
given: 'an event with data category CM'
def jsonData = TestUtils.getResourceFileContent('avcSubscriptionCreationEvent.json')
def testEventSent = jsonObjectMapper.convertJsonString(jsonData, SubscriptionEvent.class)
and: 'notifications are disabled'
objectUnderTest.notificationFeatureEnabled = false
+ and: 'subscription model loader is disabled'
+ objectUnderTest.subscriptionModelLoaderEnabled = false
when: 'the valid event is consumed'
objectUnderTest.consumeSubscriptionEvent(testEventSent)
- then: 'the event is mapped to a yangModelSubscription'
- 1 * mockSubscriptionEventMapper.toYangModelSubscriptionEvent(testEventSent) >> yangModelSubscriptionEvent
- and: 'the event is persisted'
- 1 * mockSubscriptionPersistence.saveSubscriptionEvent(yangModelSubscriptionEvent)
+ then: 'the event is not mapped to a yangModelSubscription'
+ 0 * mockSubscriptionEventMapper.toYangModelSubscriptionEvent(*_) >> yangModelSubscriptionEvent
+ and: 'the event is not persisted'
+ 0 * mockSubscriptionPersistence.saveSubscriptionEvent(*_)
and: 'the event is not forwarded'
0 * mockSubscriptionEventForwarder.forwardCreateSubscriptionEvent(*_)
}
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
<parent>\r
<groupId>org.onap.cps</groupId>\r
<artifactId>cps-parent</artifactId>\r
- <version>3.2.7-SNAPSHOT</version>\r
+ <version>3.3.0-SNAPSHOT</version>\r
<relativePath>../cps-parent/pom.xml</relativePath>\r
</parent>\r
\r
'mix of partial key and non key leaf' | '//author[@FirstName="Joe" and @title="Dune"]' || ["/shops/shop[@id='1']/categories[@code='1']/book/author[@FirstName='Joe' and @Surname='Bloggs']"]
}
- @Sql([CLEAR_DATA, SET_DATA])
- def 'Query for attribute by cps path of type ancestor with #scenario.'() {
- when: 'the given cps path is parsed'
- def result = objectUnderTest.queryDataNodes(DATASPACE_NAME, ANCHOR_FOR_SHOP_EXAMPLE, cpsPath, INCLUDE_ALL_DESCENDANTS)
- then: 'the xpaths of the retrieved data nodes are as expected'
- result.size() == expectedXPaths.size()
- if (result.size() > 0) {
- def resultXpaths = result.stream().map(it -> it.xpath).collect(Collectors.toSet())
- resultXpaths.containsAll(expectedXPaths)
- result.each {
- assert it.childDataNodes.size() == expectedNumberOfChildren
- }
- }
- where: 'the following data is used'
- scenario | cpsPath || expectedXPaths || expectedNumberOfChildren
- 'multiple list-ancestors' | '//book/ancestor::categories' || ["/shops/shop[@id='1']/categories[@code='2']", "/shops/shop[@id='1']/categories[@code='1']"] || 1
- 'one ancestor with list value' | '//book/ancestor::categories[@code=1]' || ["/shops/shop[@id='1']/categories[@code='1']"] || 1
- 'top ancestor' | '//shop[@id=1]/ancestor::shops' || ['/shops'] || 5
- 'list with index value in the xpath prefix' | '//categories[@code=1]/book/ancestor::shop[@id=1]' || ["/shops/shop[@id='1']"] || 3
- 'ancestor with parent list' | '//book/ancestor::shop[@id=1]/categories[@code=2]' || ["/shops/shop[@id='1']/categories[@code='2']"] || 1
- 'ancestor with parent' | '//phonenumbers[@type="mob"]/ancestor::info/contact' || ["/shops/shop[@id='3']/info/contact"] || 3
- 'ancestor combined with text condition' | '//book/title[text()="Dune"]/ancestor::shop' || ["/shops/shop[@id='1']"] || 3
- 'ancestor with parent that does not exist' | '//book/ancestor::parentDoesNoExist/categories' || [] || null
- 'ancestor does not exist' | '//book/ancestor::ancestorDoesNotExist' || [] || null
- }
-
- def 'Cps Path query with syntax error throws a CPS Path Exception.'() {
- when: 'trying to execute a query with a syntax (parsing) error'
- objectUnderTest.queryDataNodes(DATASPACE_NAME, ANCHOR_FOR_SHOP_EXAMPLE, 'cpsPath that cannot be parsed' , OMIT_DESCENDANTS)
- then: 'a cps path exception is thrown'
- thrown(CpsPathException)
- }
-
@Sql([CLEAR_DATA, SET_DATA])
def 'Cps Path query across anchors for leaf value(s) with : #scenario.'() {
when: 'a query is executed to get a data node by the given cps path'
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
package org.onap.cps.integration.functional
+import org.onap.cps.api.CpsQueryService
import org.onap.cps.integration.base.FunctionalSpecBase
import org.onap.cps.spi.FetchDescendantsOption
+import org.onap.cps.spi.exceptions.CpsPathException
+import org.springframework.test.context.jdbc.Sql
+
+import java.util.stream.Collectors
+
+import static org.onap.cps.spi.FetchDescendantsOption.DIRECT_CHILDREN_ONLY
+import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
+import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS
+import static org.onap.cps.spi.FetchDescendantsOption.getFetchDescendantsOption
class CpsQueryServiceIntegrationSpec extends FunctionalSpecBase {
- def objectUnderTest
+ CpsQueryService objectUnderTest
def setup() { objectUnderTest = cpsQueryService }
def 'Query bookstore using CPS path where #scenario.'() {
when: 'query data nodes for bookstore container'
- def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, cpsPath, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS)
+ def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, cpsPath, INCLUDE_ALL_DESCENDANTS)
then: 'the result contains expected number of nodes'
assert result.size() == expectedResultSize
and: 'the result contains the expected leaf values'
'the and condition is used' | '//books[@lang="English" and @price=15]' || 2 | [lang:"English", price:15]
'the and is used where result does not exist' | '//books[@lang="English" and @price=1000]' || 0 | []
}
+
+ def 'Query for attribute by cps path of type ancestor with #scenario.'() {
+ when: 'the given cps path is parsed'
+ def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, cpsPath, OMIT_DESCENDANTS)
+ then: 'the xpaths of the retrieved data nodes are as expected'
+ assert result.xpath.sort() == expectedXPaths.sort()
+ where: 'the following data is used'
+ scenario | cpsPath || expectedXPaths
+ 'multiple list-ancestors' | '//books/ancestor::categories' || ["/bookstore/categories[@code='1']", "/bookstore/categories[@code='2']", "/bookstore/categories[@code='3']"]
+ 'one ancestor with list value' | '//books/ancestor::categories[@code="1"]' || ["/bookstore/categories[@code='1']"]
+ 'top ancestor' | '//books/ancestor::bookstore' || ["/bookstore"]
+ 'list with index value in the xpath prefix' | '//categories[@code="1"]/books/ancestor::bookstore' || ["/bookstore"]
+ 'ancestor with parent list' | '//books/ancestor::bookstore/categories' || ["/bookstore/categories[@code='1']", "/bookstore/categories[@code='2']", "/bookstore/categories[@code='3']"]
+ 'ancestor with parent' | '//books/ancestor::bookstore/categories[@code="2"]' || ["/bookstore/categories[@code='2']"]
+ 'ancestor combined with text condition' | '//books/title[text()="Matilda"]/ancestor::bookstore' || ["/bookstore"]
+ 'ancestor with parent that does not exist' | '//books/ancestor::parentDoesNoExist/categories' || []
+ 'ancestor does not exist' | '//books/ancestor::ancestorDoesNotExist' || []
+ }
+
+ def 'Query for attribute by cps path of type ancestor with #scenario descendants.'() {
+ when: 'the given cps path is parsed'
+ def result = objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, '//books/ancestor::bookstore', fetchDescendantsOption)
+ then: 'the xpaths of the retrieved data nodes are as expected'
+ assert countDataNodesInTree(result) == expectedNumberOfNodes
+ where: 'the following data is used'
+ scenario | fetchDescendantsOption || expectedNumberOfNodes
+ 'no' | OMIT_DESCENDANTS || 1
+ 'direct' | DIRECT_CHILDREN_ONLY || 4
+ 'all' | INCLUDE_ALL_DESCENDANTS || 8
+ }
+
+ def 'Cps Path query with syntax error throws a CPS Path Exception.'() {
+ when: 'trying to execute a query with a syntax (parsing) error'
+ objectUnderTest.queryDataNodes(FUNCTIONAL_TEST_DATASPACE, BOOKSTORE_ANCHOR, 'cpsPath that cannot be parsed' , OMIT_DESCENDANTS)
+ then: 'a cps path exception is thrown'
+ thrown(CpsPathException)
+ }
+
}
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
\r
<groupId>org.onap.cps</groupId>\r
<artifactId>cps-aggregator</artifactId>\r
- <version>3.2.7-SNAPSHOT</version>\r
+ <version>3.3.0-SNAPSHOT</version>\r
<packaging>pom</packaging>\r
\r
<name>cps</name>\r
<modelVersion>4.0.0</modelVersion>
<groupId>org.onap.cps</groupId>
<artifactId>spotbugs</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.3.0-SNAPSHOT</version>
<properties>
<nexusproxy>https://nexus.onap.org</nexusproxy>
# because they are used in Jenkins, whose plug-in doesn't support this
major=3
-minor=2
-patch=7
+minor=3
+patch=0
base_version=${major}.${minor}.${patch}