summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-parent/pom.xml2
-rwxr-xr-xcps-rest/docs/api/swagger/openapi.yml35
-rw-r--r--cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java7
-rw-r--r--cps-rest/src/test/groovy/org/onap/cps/rest/controller/AdminRestControllerSpec.groovy39
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java7
-rw-r--r--cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java5
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java2
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java12
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java15
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java1
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java13
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java1
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java39
-rw-r--r--cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java6
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy17
15 files changed, 160 insertions, 41 deletions
diff --git a/cps-parent/pom.xml b/cps-parent/pom.xml
index 55db1a198e..97dba3a7a2 100644
--- a/cps-parent/pom.xml
+++ b/cps-parent/pom.xml
@@ -20,7 +20,7 @@
<base.image>openjdk:11-jre-slim</base.image>
<java.version>11</java.version>
<jib-maven-plugin.version>2.6.0</jib-maven-plugin.version>
- <minimum-coverage>0.35</minimum-coverage>
+ <minimum-coverage>0.44</minimum-coverage>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<oparent.version>3.1.0</oparent.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/cps-rest/docs/api/swagger/openapi.yml b/cps-rest/docs/api/swagger/openapi.yml
index d2c720e01c..2acd2b1641 100755
--- a/cps-rest/docs/api/swagger/openapi.yml
+++ b/cps-rest/docs/api/swagger/openapi.yml
@@ -67,6 +67,41 @@ paths:
403:
description: Forbidden
content: {}
+ /v1/dataspaces/{dataspace-name}/schema-sets/{schema-set-name}:
+ get:
+ tags:
+ - cps-admin
+ summary: Read a schema set given a schema set and a dataspace
+ operationId: getSchemaSet
+ parameters:
+ - name: dataspace-name
+ in: path
+ description: dataspace-name
+ required: true
+ schema:
+ type: string
+ - name: schema-set-name
+ in: path
+ description: schema-name
+ required: true
+ schema:
+ type: string
+ responses:
+ 200:
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: object
+ 401:
+ description: Unauthorized
+ content: {}
+ 403:
+ description: Forbidden
+ content: {}
+ 404:
+ description: Not Found
+ content: {}
/v1/dataspaces/{dataspace-name}/schema-sets:
post:
tags:
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 9549580bac..407a767389 100644
--- 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
@@ -28,6 +28,7 @@ import org.onap.cps.api.CpsAdminService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.rest.api.CpsAdminApi;
import org.onap.cps.spi.model.Anchor;
+import org.onap.cps.spi.model.SchemaSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -59,6 +60,12 @@ public class AdminRestController implements CpsAdminApi {
return new ResponseEntity<>(schemaSetName, HttpStatus.CREATED);
}
+ @Override
+ public ResponseEntity<Object> getSchemaSet(final String dataspaceName, final String schemaSetName) {
+ final SchemaSet schemaSet = cpsModuleService.getSchemaSet(dataspaceName, schemaSetName);
+ return new ResponseEntity<>(schemaSet, HttpStatus.OK);
+ }
+
/**
* Create a new anchor.
*
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 9919649cb0..078253a64e 100644
--- 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
@@ -25,9 +25,9 @@ import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.spi.model.Anchor
import org.onap.cps.spi.exceptions.DataspaceAlreadyDefinedException
+import org.onap.cps.spi.model.SchemaSet
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
@@ -57,6 +57,8 @@ class AdminRestControllerSpec extends Specification {
MockMvc mvc
def anchorsEndpoint = '/v1/dataspaces/my_dataspace/anchors'
+ def schemaSetsEndpoint = '/v1/dataspaces/test-dataspace/schema-sets'
+ def schemaSetEndpoint = schemaSetsEndpoint + '/my_schema_set'
def anchor = new Anchor(name: 'my_anchor')
def anchorList = [anchor]
@@ -66,7 +68,7 @@ class AdminRestControllerSpec extends Specification {
def response = performCreateDataspaceRequest("new-dataspace")
then: 'Service method is invoked with expected parameters'
1 * mockCpsAdminService.createDataspace("new-dataspace")
- and:
+ and: 'Dataspace is create successfully'
response.status == HttpStatus.CREATED.value()
}
@@ -76,7 +78,7 @@ class AdminRestControllerSpec extends Specification {
mockCpsAdminService.createDataspace("existing-dataspace") >> { throw thrownException }
when:
def response = performCreateDataspaceRequest("existing-dataspace")
- then:
+ then: 'Dataspace creation fails'
response.status == HttpStatus.BAD_REQUEST.value()
}
@@ -99,7 +101,7 @@ class AdminRestControllerSpec extends Specification {
def multipartFile = createMultipartFile("filename.doc", "content")
when:
def response = performCreateSchemaSetRequest(multipartFile)
- then:
+ then: 'Create schema fails'
response.status == HttpStatus.BAD_REQUEST.value()
}
@@ -118,13 +120,24 @@ class AdminRestControllerSpec extends Specification {
def performCreateSchemaSetRequest(multipartFile) {
return mvc.perform(
MockMvcRequestBuilders
- .multipart('/v1/dataspaces/test-dataspace/schema-sets')
+ .multipart(schemaSetsEndpoint)
.file(multipartFile)
.param('schemaSetName', 'test-schema-set')
).andReturn().response
}
- def 'when createAnchor API is called, the response status is 201. '() {
+ def 'Get existing schema set'() {
+ given:
+ mockCpsModuleService.getSchemaSet('test-dataspace', 'my_schema_set') >>
+ new SchemaSet(name: 'my_schema_set', dataspaceName: 'test-dataspace')
+ when: 'get schema set API is invoked'
+ def response = mvc.perform(get(schemaSetEndpoint)).andReturn().response
+ then: 'the correct schema set is returned'
+ response.status == HttpStatus.OK.value()
+ response.getContentAsString().contains('my_schema_set')
+ }
+
+ def 'Create Anchor'() {
given:
def requestParams = new LinkedMultiValueMap<>()
requestParams.add('schema-set-name', 'my_schema-set')
@@ -132,19 +145,19 @@ class AdminRestControllerSpec extends Specification {
when: 'post is invoked'
def response = mvc.perform(post(anchorsEndpoint).contentType(MediaType.APPLICATION_JSON)
.params(requestParams as MultiValueMap)).andReturn().response
- then: 'Status is 201 and the response is the name of the created anchor -> my_anchor'
+ then: 'Anchor is created successfully'
1 * mockCpsAdminService.createAnchor('my_dataspace', 'my_schema-set', 'my_anchor')
- assert response.status == HttpStatus.CREATED.value()
- assert response.getContentAsString().contains('my_anchor')
+ response.status == HttpStatus.CREATED.value()
+ response.getContentAsString().contains('my_anchor')
}
- def 'when get all anchors for a dataspace API is called, the response status is 200 '() {
+ def 'Get existing anchor'() {
given:
mockCpsAdminService.getAnchors('my_dataspace') >> anchorList
when: 'get all anchors API is invoked'
def response = mvc.perform(get(anchorsEndpoint)).andReturn().response
- then: 'Status is 200 and the response is Collection of Anchors containing anchor name -> my_anchor'
- assert response.status == HttpStatus.OK.value()
- assert response.getContentAsString().contains('my_anchor')
+ then: 'the correct anchor is returned'
+ response.status == HttpStatus.OK.value()
+ response.getContentAsString().contains('my_anchor')
}
}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
index 3e3a4b43e4..23a384306f 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
@@ -32,11 +32,9 @@ import org.onap.cps.spi.entities.Dataspace;
import org.onap.cps.spi.entities.SchemaSet;
import org.onap.cps.spi.entities.YangResource;
import org.onap.cps.spi.exceptions.SchemaSetAlreadyDefinedException;
-import org.onap.cps.spi.model.ModuleReference;
import org.onap.cps.spi.repository.DataspaceRepository;
import org.onap.cps.spi.repository.SchemaSetRepository;
import org.onap.cps.spi.repository.YangResourceRepository;
-import org.onap.cps.yang.YangTextSchemaSourceSetBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Component;
@@ -102,11 +100,10 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
}
@Override
- public Collection<ModuleReference> getModuleReferences(final String dataspaceName, final String schemaSetName) {
+ public Map<String, String> getYangSchemaResources(final String dataspaceName, final String schemaSetName) {
final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName);
final SchemaSet schemaSet = schemaSetRepository.getByDataspaceAndName(dataspace, schemaSetName);
- final Map<String, String> yangResourceNameToContent = schemaSet.getYangResources().stream().collect(
+ return schemaSet.getYangResources().stream().collect(
Collectors.toMap(YangResource::getName, YangResource::getContent));
- return YangTextSchemaSourceSetBuilder.of(yangResourceNameToContent).getModuleReferences();
}
}
diff --git a/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java b/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java
index 46f017bed7..77c8003a17 100644
--- a/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java
+++ b/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java
@@ -100,10 +100,13 @@ public class CpsModulePersistenceServiceTest {
@Test
@SqlGroup({@Sql(CLEAR_DATA), @Sql(SET_DATA)})
public void testStoreSchemaSetWithNewYangResource() {
+ final Map<String, String> yangResourcesNameToContentMap = toMap(NEW_RESOURCE_NAME, NEW_RESOURCE_CONTENT);
cpsModulePersistenceService.storeSchemaSet(DATASPACE_NAME, SCHEMA_SET_NAME_NEW,
- toMap(NEW_RESOURCE_NAME, NEW_RESOURCE_CONTENT));
+ yangResourcesNameToContentMap);
assertSchemaSetPersisted(DATASPACE_NAME, SCHEMA_SET_NAME_NEW,
NEW_RESOURCE_ABSTRACT_ID, NEW_RESOURCE_NAME, NEW_RESOURCE_CONTENT, NEW_RESOURCE_CHECKSUM);
+ assertEquals(yangResourcesNameToContentMap,
+ cpsModulePersistenceService.getYangSchemaResources(DATASPACE_NAME, SCHEMA_SET_NAME_NEW));
}
@Test
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java b/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java
index 581550fb5c..853bd958f8 100644
--- a/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java
@@ -50,7 +50,7 @@ public interface CpsAdminService {
void createAnchor(@NonNull String dataspaceName, @NonNull String schemaSetName, @NonNull String anchorName);
/**
- * Read all anchors in the given a dataspace.
+ * Read all anchors in the given dataspace.
*
* @param dataspaceName dataspace name
* @return a collection of anchors
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
index e7b02fbad8..5f63f97f1e 100644
--- a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
@@ -21,8 +21,7 @@ package org.onap.cps.api;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
-import org.onap.cps.spi.exceptions.CpsException;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.onap.cps.spi.model.SchemaSet;
/**
* Responsible for managing module sets.
@@ -40,5 +39,12 @@ public interface CpsModuleService {
void createSchemaSet(@NonNull String dataspaceName, @NonNull String schemaSetName,
@NonNull Map<String, String> yangResourcesNameToContentMap);
-
+ /**
+ * Read schema set in the given dataspace.
+ *
+ * @param dataspaceName dataspace name
+ * @param schemaSetName schema set name
+ * @return a SchemaSet
+ */
+ SchemaSet getSchemaSet(@NonNull String dataspaceName, @NonNull String schemaSetName);
}
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
index 8a437dbdee..04a6fe1cee 100644
--- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
@@ -19,10 +19,11 @@
package org.onap.cps.api.impl;
-
import java.util.Map;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.spi.CpsModulePersistenceService;
+import org.onap.cps.spi.model.SchemaSet;
+import org.onap.cps.yang.YangTextSchemaSourceSet;
import org.onap.cps.yang.YangTextSchemaSourceSetBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -42,4 +43,16 @@ public class CpsModuleServiceImpl implements CpsModuleService {
.storeSchemaSet(dataspaceName, schemaSetName, yangResourcesNameToContentMap);
}
+ @Override
+ public SchemaSet getSchemaSet(final String dataspaceName, final String schemaSetName) {
+ final Map<String, String> yangResourceNameToContent =
+ cpsModulePersistenceService.getYangSchemaResources(dataspaceName, schemaSetName);
+ final YangTextSchemaSourceSet yangTextSchemaSourceSet = YangTextSchemaSourceSetBuilder
+ .of(yangResourceNameToContent);
+ return SchemaSet.builder()
+ .name(schemaSetName)
+ .dataspaceName(dataspaceName)
+ .moduleReferences(yangTextSchemaSourceSet.getModuleReferences())
+ .build();
+ }
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
index ba53003ace..5643aedb72 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
@@ -57,5 +57,4 @@ public interface CpsAdminPersistenceService {
*/
@NonNull
Collection<Anchor> getAnchors(@NonNull String dataspaceName);
-
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
index 63f1f36c73..a82d69acbd 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
@@ -20,9 +20,8 @@
package org.onap.cps.spi;
-import java.util.Collection;
import java.util.Map;
-import org.onap.cps.spi.model.ModuleReference;
+import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Service to manage modules.
@@ -36,14 +35,16 @@ public interface CpsModulePersistenceService {
* @param schemaSetName schema set name
* @param yangResourcesNameToContentMap YANG resources (files) map where key is a name and value is content
*/
- void storeSchemaSet(String dataspaceName, String schemaSetName, Map<String, String> yangResourcesNameToContentMap);
+ void storeSchemaSet(@NonNull String dataspaceName, @NonNull String schemaSetName,
+ @NonNull Map<String, String> yangResourcesNameToContentMap);
/**
- * Returns Modules references per specific namespace / schemaSetName.
+ * Returns YANG resources per specific namespace / schemaSetName.
*
* @param namespace module namespace
* @param schemaSetName schema set name
- * @return collection of ModuleRef
+ * @return YANG resources (files) map where key is a name and value is content
*/
- Collection<ModuleReference> getModuleReferences(String namespace, String schemaSetName);
+ @NonNull
+ Map<String, String> getYangSchemaResources(@NonNull String namespace, @NonNull String schemaSetName);
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java b/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
index 5af355dcdb..aa198a9c71 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
@@ -31,6 +31,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public class ModuleReference {
+ private String name;
private String namespace;
private String revision;
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java b/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
new file mode 100644
index 0000000000..caf7800d9b
--- /dev/null
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
@@ -0,0 +1,39 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Pantheon.tech
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.spi.model;
+
+import java.io.Serializable;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SchemaSet implements Serializable {
+
+ private static final long serialVersionUID = 1464791260718603291L;
+ private String name;
+ private String dataspaceName;
+ private List<ModuleReference> moduleReferences;
+}
diff --git a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
index 6d825445c3..ae0f2cd3e8 100644
--- a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
+++ b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
@@ -49,11 +49,6 @@ public final class YangTextSchemaSourceSetBuilder {
private final ImmutableMap.Builder<String, String> yangModelMap = new ImmutableMap.Builder<>();
- public YangTextSchemaSourceSetBuilder put(final String fileName, final String content) {
- this.yangModelMap.put(fileName, content);
- return this;
- }
-
public YangTextSchemaSourceSetBuilder putAll(final Map<String, String> yangResourceNameToContent) {
this.yangModelMap.putAll(yangResourceNameToContent);
return this;
@@ -95,6 +90,7 @@ public final class YangTextSchemaSourceSetBuilder {
private static ModuleReference toModuleReference(final Module module) {
return ModuleReference.builder()
+ .name(module.getName())
.namespace(module.getNamespace().toString())
.revision(module.getRevision().map(Revision::toString).orElse(null))
.build();
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
index a93411bfe9..ebe4fe7bce 100644
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
@@ -21,11 +21,9 @@
package org.onap.cps.api.impl
import org.onap.cps.TestUtils
-import org.onap.cps.spi.CpsModulePersistenceService
+import org.onap.cps.spi.CpsModulePersistenceService;
import org.onap.cps.spi.exceptions.ModelValidationException
-import org.onap.cps.utils.YangUtils
-import org.opendaylight.yangtools.yang.common.Revision
-import org.opendaylight.yangtools.yang.model.api.SchemaContext
+import org.onap.cps.spi.model.ModuleReference
import spock.lang.Specification
class CpsModuleServiceImplSpec extends Specification {
@@ -54,4 +52,15 @@ class CpsModuleServiceImplSpec extends Specification {
thrown(ModelValidationException.class)
}
+ def 'Get schema set by name and namespace.'() {
+ given: 'an already present schema set'
+ def yangResourcesNameToContentMap = TestUtils.getYangResourcesAsMap('bookstore.yang')
+ mockModuleStoreService.getYangSchemaResources('someDataspace', 'someSchemaSet') >> yangResourcesNameToContentMap
+ when: 'get schema set method is invoked'
+ def result = objectUnderTest.getSchemaSet('someDataspace', 'someSchemaSet')
+ then: 'the correct schema set is returned'
+ result.getName().contains('someSchemaSet')
+ result.getDataspaceName().contains('someDataspace')
+ result.getModuleReferences().contains(new ModuleReference('stores', 'org:onap:ccsdk:sample', '2020-09-15'))
+ }
}