summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src/test/groovy')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy28
1 files changed, 21 insertions, 7 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy
index 907208228c..650916e5c9 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy
@@ -44,10 +44,10 @@ class SubscriptionModelLoaderSpec extends Specification {
def mockCpsDataService = Mock(CpsDataService)
def objectUnderTest = new SubscriptionModelLoader(mockCpsAdminService, mockCpsModuleService, mockCpsDataService)
- def SUBSCRIPTION_DATASPACE_NAME = objectUnderTest.SUBSCRIPTION_DATASPACE_NAME;
- def SUBSCRIPTION_ANCHOR_NAME = objectUnderTest.SUBSCRIPTION_ANCHOR_NAME;
- def SUBSCRIPTION_SCHEMASET_NAME = objectUnderTest.SUBSCRIPTION_SCHEMASET_NAME;
- def SUBSCRIPTION_REGISTRY_DATANODE_NAME = objectUnderTest.SUBSCRIPTION_REGISTRY_DATANODE_NAME;
+ def SUBSCRIPTION_DATASPACE_NAME = objectUnderTest.SUBSCRIPTION_DATASPACE_NAME
+ def SUBSCRIPTION_ANCHOR_NAME = objectUnderTest.SUBSCRIPTION_ANCHOR_NAME
+ def SUBSCRIPTION_SCHEMASET_NAME = objectUnderTest.SUBSCRIPTION_SCHEMASET_NAME
+ def SUBSCRIPTION_REGISTRY_DATANODE_NAME = objectUnderTest.SUBSCRIPTION_REGISTRY_DATANODE_NAME
def sampleYangContentMap = ['subscription.yang':'module subscription { *sample content* }']
@@ -67,7 +67,7 @@ class SubscriptionModelLoaderSpec extends Specification {
@AfterEach
void teardown() {
- ((Logger) LoggerFactory.getLogger(SubscriptionModelLoader.class)).detachAndStopAllAppenders();
+ ((Logger) LoggerFactory.getLogger(SubscriptionModelLoader.class)).detachAndStopAllAppenders()
}
def 'Onboard subscription model successfully via application ready event'() {
@@ -83,6 +83,20 @@ class SubscriptionModelLoaderSpec extends Specification {
1 * mockCpsDataService.saveData(SUBSCRIPTION_DATASPACE_NAME, SUBSCRIPTION_ANCHOR_NAME, '{"' + SUBSCRIPTION_REGISTRY_DATANODE_NAME + '":{}}', _)
}
+ def 'No subscription model onboarding when subscription model loader is disabled' () {
+ when: 'model loader is disabled'
+ objectUnderTest.subscriptionModelLoaderEnabled = false
+ and: 'application is ready'
+ objectUnderTest.onApplicationEvent(applicationReadyEvent)
+ then: 'the module service to create schema set was not called'
+ 0 * mockCpsModuleService.createSchemaSet(*_)
+ and: 'the admin service to create an anchor set was not called'
+ 0 * mockCpsAdminService.createAnchor(*_)
+ and: 'the data service to create a top level datanode was not called'
+ 0 * mockCpsDataService.saveData(*_)
+ }
+
+
def 'Create schema set from model file'() {
given: 'the method to create yang resource to content map returns the correct map'
def yangResourceToContentMap = objectUnderTest.createYangResourceToContentMap()
@@ -111,7 +125,7 @@ class SubscriptionModelLoaderSpec extends Specification {
def yangResourceToContentMap = objectUnderTest.createYangResourceToContentMap()
and: 'creating a schema set throws an exception'
mockCpsModuleService.createSchemaSet(SUBSCRIPTION_DATASPACE_NAME, SUBSCRIPTION_SCHEMASET_NAME, yangResourceToContentMap) >>
- { throw new NcmpStartUpException("Creating schema set failed", ""); }
+ { throw new NcmpStartUpException("Creating schema set failed", "") }
when: 'the method to onboard model is called'
objectUnderTest.onboardSubscriptionModel()
then: 'the log message contains the correct exception message'
@@ -147,7 +161,7 @@ class SubscriptionModelLoaderSpec extends Specification {
def 'Create top level node fails due to an AlreadyDefined exception'() {
given: 'the saving of the node data will throw an Already Defined exception'
mockCpsDataService.saveData(*_) >>
- { AlreadyDefinedException.forDataNode('/xpath', "sampleContextName", null) }
+ { throw AlreadyDefinedException.forDataNode('/xpath', "sampleContextName", null) }
when: 'the method to onboard model is called'
objectUnderTest.onboardSubscriptionModel()
then: 'no exception thrown'