summaryrefslogtreecommitdiffstats
path: root/cps-rest/src/test/groovy/org
diff options
context:
space:
mode:
authorrajesh.kumar <rk00747546@techmahindra.com>2022-09-06 11:47:18 +0000
committerrajesh.kumar <rk00747546@techmahindra.com>2022-11-18 06:37:38 +0000
commitcec0cb7254ede8a790ec6f70ad5e31d10e2d32d7 (patch)
tree07e240bf7e384290b7bff198395e50af51eea994 /cps-rest/src/test/groovy/org
parentd2a1f36a78fdc69d43b39f0a7852d47d78924ed5 (diff)
Added get APIs for dataspace.
Issue-ID: CPS-1186 Change-ID: I73f97f986a817d423f93a8d922dcd9647b0829aa Signed-off-by: rajesh.kumar <rk00747546@techmahindra.com>
Diffstat (limited to 'cps-rest/src/test/groovy/org')
-rwxr-xr-xcps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy28
1 files changed, 28 insertions, 0 deletions
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
index 41ad9ca5b2..e9612fc395 100755
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy
@@ -3,6 +3,7 @@
* Copyright (C) 2020-2021 Pantheon.tech
* Modifications Copyright (C) 2020-2021 Bell Canada.
* Modifications Copyright (C) 2021-2022 Nordix Foundation
+ * Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +35,7 @@ import org.onap.cps.api.CpsModuleService
import org.onap.cps.spi.exceptions.AlreadyDefinedException
import org.onap.cps.spi.exceptions.SchemaSetInUseException
import org.onap.cps.spi.model.Anchor
+import org.onap.cps.spi.model.Dataspace
import org.onap.cps.spi.model.SchemaSet
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
@@ -69,6 +71,7 @@ class AdminRestControllerSpec extends Specification {
def anchorName = 'my_anchor'
def schemaSetName = 'my_schema_set'
def anchor = new Anchor(name: anchorName, dataspaceName: dataspaceName, schemaSetName: schemaSetName)
+ def dataspace = new Dataspace(name: dataspaceName)
def 'Create new dataspace.'() {
given: 'an endpoint'
@@ -101,6 +104,31 @@ class AdminRestControllerSpec extends Specification {
response.status == HttpStatus.CONFLICT.value()
}
+ def 'Get a dataspace.'() {
+ given: 'service method returns a dataspace'
+ mockCpsAdminService.getDataspace(dataspaceName) >> dataspace
+ and: 'an endpoint'
+ def getDataspaceEndpoint = "$basePath/v1/admin/dataspaces/$dataspaceName"
+ when: 'get dataspace API is invoked'
+ def response = mvc.perform(get(getDataspaceEndpoint)).andReturn().response
+ then: 'the correct dataspace is returned'
+ response.status == HttpStatus.OK.value()
+ response.getContentAsString().contains(dataspaceName)
+ }
+
+ def 'Get all dataspaces.'() {
+ given: 'service method returns all dataspace'
+ mockCpsAdminService.getAllDataspaces() >> [dataspace, new Dataspace(name: "dataspace-test2")]
+ and: 'an endpoint'
+ def getAllDataspaceEndpoint = "$basePath/v1/admin/dataspaces"
+ when: 'get all dataspace API is invoked'
+ def response = mvc.perform(get(getAllDataspaceEndpoint)).andReturn().response
+ then: 'the correct dataspace is returned'
+ response.status == HttpStatus.OK.value()
+ response.getContentAsString().contains(dataspaceName)
+ response.getContentAsString().contains("dataspace-test2")
+ }
+
def 'Create schema set from yang file.'() {
def yangResourceMapCapture
given: 'single yang file'