aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service/src/test
diff options
context:
space:
mode:
authorhalil.cakal <halil.cakal@est.tech>2025-02-18 10:24:54 +0000
committerhalil.cakal <halil.cakal@est.tech>2025-02-20 16:41:23 +0000
commitdfc9aa481470129710746d3e614f0b394548312a (patch)
tree8ad4e0cd2905be3ceb48a3ff500b10e618f916f7 /cps-service/src/test
parent95ccf6ea91a5b995706302e2ef54a69151e8d87e (diff)
Handle duplicated yang resource exception when creating schema set
- catch and log duplicated yang resource during schema set creation - there may be other exception when the app started however there will be a tech. dept ticket for them thus please review this commit for only duplicated yang resource exception Issue-ID: CPS-2647 Change-Id: Idf6063cb8328efc667516f09d25ad6c4c6fd8186 Signed-off-by: halil.cakal <halil.cakal@est.tech>
Diffstat (limited to 'cps-service/src/test')
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/init/AbstractModelLoaderSpec.groovy13
1 files changed, 12 insertions, 1 deletions
diff --git a/cps-service/src/test/groovy/org/onap/cps/init/AbstractModelLoaderSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/init/AbstractModelLoaderSpec.groovy
index 0618cad951..c3cb4f205b 100644
--- a/cps-service/src/test/groovy/org/onap/cps/init/AbstractModelLoaderSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/init/AbstractModelLoaderSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2023-2024 Nordix Foundation
+ * Copyright (C) 2023-2025 Nordix Foundation
* Modification Copyright (C) 2024 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +28,7 @@ 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.api.exceptions.DuplicatedYangResourceException
import org.onap.cps.api.exceptions.ModelOnboardingException
import org.onap.cps.api.parameters.CascadeDeleteAllowed
import org.onap.cps.api.exceptions.AlreadyDefinedException
@@ -117,6 +118,16 @@ class AbstractModelLoaderSpec extends Specification {
1 * mockCpsModuleService.createSchemaSet('some dataspace','new name',_)
}
+ def 'Creating a schema set handles duplicated yang resource exception'() {
+ given: 'module service throws duplicated yang resource exception'
+ mockCpsModuleService.createSchemaSet(*_) >> { throw new DuplicatedYangResourceException('my-yang-resource', 'my-yang-resource-checksum', null) }
+ when: 'attempt to create a schema set'
+ objectUnderTest.createSchemaSet('some dataspace','some schema set','cps-notification-subscriptions@2024-07-03.yang')
+ then: 'exception is ignored, and correct exception message is logged'
+ noExceptionThrown()
+ assertLogContains('Ignoring yang resource duplication exception. Assuming model was created by another instance')
+ }
+
def 'Creating a schema set handles already defined exception.'() {
given: 'the module service throws an already defined exception'
mockCpsModuleService.createSchemaSet(*_) >> { throw AlreadyDefinedException.forSchemaSet('name','context',null) }