diff options
author | rajesh.kumar <rk00747546@techmahindra.com> | 2022-09-14 05:11:32 +0000 |
---|---|---|
committer | rajesh.kumar <rk00747546@techmahindra.com> | 2022-12-09 09:57:44 +0000 |
commit | 71e4f8339e0240f90ad0a42a9360be52553f0d82 (patch) | |
tree | 8fe47799cde6365d40ee84de568b224fcdff22f5 /cps-rest/src | |
parent | fdaccbf398d84b7b19a95e11c017b5c6d2019ffe (diff) |
Added API to get all schema sets for a given dataspace.
Issue-ID: CPS-1187
Change-ID: I73f97f986a817d423f93a8d922dcd9647b0914aa
Signed-off-by: rajesh.kumar <rk00747546@techmahindra.com>
Diffstat (limited to 'cps-rest/src')
-rwxr-xr-x | cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java | 14 | ||||
-rwxr-xr-x | cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy | 15 |
2 files changed, 29 insertions, 0 deletions
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java index a29f8d2969..285a15c6a3 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java @@ -110,6 +110,20 @@ public class AdminRestController implements CpsAdminApi { } /** + * Get list of schema sets for a given dataspace name. + * + * @param dataspaceName dataspace name + * @return a {@Link ResponseEntity} of schema sets & {@link HttpStatus} OK + */ + @Override + public ResponseEntity<List<SchemaSetDetails>> getSchemaSets(final String dataspaceName) { + final Collection<SchemaSet> schemaSets = cpsModuleService.getSchemaSets(dataspaceName); + final List<SchemaSetDetails> schemaSetDetails = schemaSets.stream().map(cpsRestInputMapper::toSchemaSetDetails) + .collect(Collectors.toList()); + return new ResponseEntity<>(schemaSetDetails, HttpStatus.OK); + } + + /** * Delete a {@link SchemaSet} based on given dataspace name & schemaset name. * * @param dataspaceName dataspace name 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 e9612fc395..7120ce49f3 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 @@ -278,6 +278,21 @@ class AdminRestControllerSpec extends Specification { response.getContentAsString().contains(schemaSetName) } + def 'Get all schema sets for a given dataspace name.'() { + given: 'service method returns all schema sets for a dataspace' + mockCpsModuleService.getSchemaSets(dataspaceName) >> + [new SchemaSet(name: schemaSetName, dataspaceName: dataspaceName), + new SchemaSet(name: "test-schemaset", dataspaceName: dataspaceName)] + and: 'an endpoint' + def schemaSetEndpoint = "$basePath/v1/dataspaces/$dataspaceName/schema-sets" + when: 'get schema sets API is invoked' + def response = mvc.perform(get(schemaSetEndpoint)).andReturn().response + then: 'the correct schema sets is returned' + assert response.status == HttpStatus.OK.value() + assert response.getContentAsString() == '[{"dataspaceName":"my_dataspace","moduleReferences":[],"name":' + + '"my_schema_set"},{"dataspaceName":"my_dataspace","moduleReferences":[],"name":"test-schemaset"}]' + } + def 'Create Anchor.'() { given: 'request parameters' def requestParams = new LinkedMultiValueMap<>() |