summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcps-ncmp-rest/docs/openapi/ncmproxy.yml4
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java2
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy10
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java2
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java2
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java2
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java34
-rw-r--r--cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy3
-rw-r--r--cps-ri/src/test/resources/data/schemaset.sql8
9 files changed, 37 insertions, 30 deletions
diff --git a/cps-ncmp-rest/docs/openapi/ncmproxy.yml b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
index 5e2957f340..2e5eba754d 100755
--- a/cps-ncmp-rest/docs/openapi/ncmproxy.yml
+++ b/cps-ncmp-rest/docs/openapi/ncmproxy.yml
@@ -266,10 +266,10 @@ resourceDataForPassthroughRunning:
content:
application/json:
schema:
- type: object
+ type: string
application/yang-data+json:
schema:
- type: object
+ type: string
responses:
201:
$ref: 'components.yaml#/components/responses/Created'
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index b78241662e..a4d94cebfd 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -214,7 +214,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
@Override
public ResponseEntity<Void> createResourceDataRunningForCmHandle(final String cmHandle,
final String resourceIdentifier,
- final Object requestBody,
+ final String requestBody,
final String contentType) {
networkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle(cmHandle,
resourceIdentifier, requestBody, contentType);
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
index 613243e28b..9f2b4e19a3 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyControllerSpec.groovy
@@ -232,7 +232,7 @@ class NetworkCmProxyControllerSpec extends Specification {
response.getContentAsString() == '{valid-json}'
}
- def 'Create Resource Data from pass-through running using POST.' () {
+ def 'Create Resource Data from pass-through running with #scenario.' () {
given: 'resource data url'
def getUrl = "$ncmpBasePathV1/ch/testCmHandle/data/ds/ncmp-datastore:passthrough-running" +
"/testResourceIdentifier"
@@ -240,13 +240,17 @@ class NetworkCmProxyControllerSpec extends Specification {
def response = mvc.perform(
post(getUrl)
.contentType(MediaType.APPLICATION_JSON_VALUE)
- .accept(MediaType.APPLICATION_JSON_VALUE).content('{"some-json":"value"}')
+ .accept(MediaType.APPLICATION_JSON_VALUE).content(requestBody)
).andReturn().response
then: 'ncmp service method to create resource called'
1 * mockNetworkCmProxyDataService.createResourceDataPassThroughRunningForCmHandle('testCmHandle',
- 'testResourceIdentifier', ['some-json':'value'], 'application/json;charset=UTF-8')
+ 'testResourceIdentifier', requestBody, 'application/json;charset=UTF-8')
and: 'resource is created'
response.status == HttpStatus.CREATED.value()
+ where: 'given request body'
+ scenario | requestBody
+ 'body contains " and new line' | 'body with " quote and \n new line'
+ 'body contains normal string' | 'normal request body'
}
def 'Get module references for the given dataspace and cm handle.' () {
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
index 60669b9169..2f91ed30e1 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
@@ -153,7 +153,7 @@ public interface NetworkCmProxyDataService {
*/
void createResourceDataPassThroughRunningForCmHandle(@NotNull String cmHandle,
@NotNull String resourceIdentifier,
- @NotNull Object requestBody,
+ @NotNull String requestBody,
String contentType);
/**
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index 719508b6c5..dc5dc77334 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -206,7 +206,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
@Override
public void createResourceDataPassThroughRunningForCmHandle(final @NotNull String cmHandle,
final @NotNull String resourceIdentifier,
- final @NotNull Object requestBody,
+ final @NotNull String requestBody,
final String contentType) {
final var cmHandleDataNode = fetchDataNodeFromDmiRegistryForCmHandle(cmHandle);
final var dmiServiceName = String.valueOf(cmHandleDataNode.getLeaves().get(NCMP_DMI_SERVICE_NAME));
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java
index 9ed78de6e7..4f6f0ef491 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/GenericRequestBody.java
@@ -49,6 +49,6 @@ public class GenericRequestBody {
private OperationEnum operation;
private String dataType;
- private Object data;
+ private String data;
private Map<String, String> cmHandleProperties;
}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java
index b16b284a2a..764e2dfc74 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java
@@ -38,29 +38,31 @@ public interface YangResourceRepository extends JpaRepository<YangResourceEntity
List<YangResourceEntity> findAllByChecksumIn(@NotNull Set<String> checksum);
@Query(value = "SELECT DISTINCT\n"
- + "yr.module_name AS module_name,\n"
- + "yr.revision AS revision\n"
+ + "yang_resource.module_name AS module_name,\n"
+ + "yang_resource.revision AS revision\n"
+ "FROM\n"
- + "dataspace d\n"
- + "JOIN schema_set ss ON ss.dataspace_id = d.id\n"
- + "JOIN schema_set_yang_resources ssyr ON ssyr.schema_set_id = ss.id\n"
- + "JOIN yang_resource yr ON yr.id = ssyr.yang_resource_id\n"
+ + "dataspace dataspace\n"
+ + "JOIN schema_set schema_set ON schema_set.dataspace_id = dataspace.id\n"
+ + "JOIN schema_set_yang_resources schema_set_yang_resource ON schema_set_yang_resource.schema_set_id = "
+ + "schema_set.id\n"
+ + "JOIN yang_resource yang_resource ON yang_resource.id = schema_set_yang_resource.yang_resource_id\n"
+ "WHERE\n"
- + "d.name = :dataspaceName", nativeQuery = true)
+ + "dataspace.name = :dataspaceName", nativeQuery = true)
Set<YangResourceModuleReference> findAllModuleReferences(@Param("dataspaceName") String dataspaceName);
@Query(value = "SELECT DISTINCT\n"
- + "yr.module_Name AS module_name,\n"
- + "yr.revision AS revision\n"
+ + "yang_resource.module_Name AS module_name,\n"
+ + "yang_resource.revision AS revision\n"
+ "FROM\n"
- + "dataspace d\n"
- + "JOIN anchor a ON a.dataspace_id = d.id\n"
- + "JOIN schema_set ss ON ss.dataspace_id = a.dataspace_id\n"
- + "JOIN schema_set_yang_resources ssyr ON ssyr.schema_set_id = ss.id\n"
- + "JOIN yang_resource yr ON yr.id = ssyr.yang_resource_id\n"
+ + "dataspace dataspace\n"
+ + "JOIN anchor anchor ON anchor.dataspace_id = dataspace.id\n"
+ + "JOIN schema_set schema_set ON schema_set.id = anchor.schema_set_id\n"
+ + "JOIN schema_set_yang_resources schema_set_yang_resource ON schema_set_yang_resource.schema_set_id = "
+ + "schema_set.id\n"
+ + "JOIN yang_resource yang_resource ON yang_resource.id = schema_set_yang_resource.yang_resource_id\n"
+ "WHERE\n"
- + "d.name = :dataspaceName AND\n"
- + "a.name =:anchorName", nativeQuery = true)
+ + "dataspace.name = :dataspaceName AND\n"
+ + "anchor.name =:anchorName", nativeQuery = true)
Set<YangResourceModuleReference> findAllModuleReferences(
@Param("dataspaceName") String dataspaceName, @Param("anchorName") String anchorName);
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy
index 7e42200799..a223e7135f 100644
--- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy
+++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy
@@ -154,8 +154,7 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase
when: 'all yang resources module references are retrieved for the given anchor'
def result = objectUnderTest.getYangResourceModuleReferences(dataspaceName, anchorName)
then: 'the correct module names and revisions are returned'
- result.sort() == [new ModuleReference(moduleName: null, revision: null), new ModuleReference(moduleName: 'MODULE-NAME-002', revision: 'REVISION-002'),
- new ModuleReference(moduleName: 'MODULE-NAME-003', revision: 'REVISION-002'),
+ result.sort() == [ new ModuleReference(moduleName: 'MODULE-NAME-003', revision: 'REVISION-002'),
new ModuleReference(moduleName: 'MODULE-NAME-004', revision: 'REVISION-004')]
}
diff --git a/cps-ri/src/test/resources/data/schemaset.sql b/cps-ri/src/test/resources/data/schemaset.sql
index 61600356b9..2b0a8961b6 100644
--- a/cps-ri/src/test/resources/data/schemaset.sql
+++ b/cps-ri/src/test/resources/data/schemaset.sql
@@ -29,7 +29,8 @@ INSERT INTO SCHEMA_SET (ID, NAME, DATASPACE_ID) VALUES
(2100, 'SCHEMA-SET-100', 1001), -- for removal, not referenced by anchors
(2101, 'SCHEMA-SET-101', 1001), -- for removal, having anchor and data associated
(2003, 'SCHEMA-SET-003', 1002),
- (2004, 'SCHEMA-SET-004', 1002);
+ (2004, 'SCHEMA-SET-004', 1002),
+ (2005, 'SCHEMA-SET-005', 1001);
INSERT INTO YANG_RESOURCE (ID, NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) VALUES
(3001, 'module1@2020-02-02.yang', 'CONTENT-001', 'e8bdda931099310de66532e08c3fafec391db29f55c81927b168f6aa8f81b73b',null,null),
@@ -42,14 +43,15 @@ INSERT INTO YANG_RESOURCE (ID, NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) V
INSERT INTO SCHEMA_SET_YANG_RESOURCES (SCHEMA_SET_ID, YANG_RESOURCE_ID) VALUES
(2001, 3001), (2001, 3002),
- (2002, 3003), (2002, 3004),
+ (2002, 3003), (2005, 3004),
(2100, 3003), (2100, 3100), -- orphan removal case
(2101, 3003), (2101, 3004),
(2003, 3005), (2004, 3006);
INSERT INTO ANCHOR (ID, NAME, DATASPACE_ID, SCHEMA_SET_ID) VALUES -- anchors for removal
(6001, 'ANCHOR1', 1001, 2101),
- (6002, 'ANCHOR2', 1001, 2101);
+ (6002, 'ANCHOR2', 1001, 2101),
+ (6003, 'ANCHOR3', 1001, 2005);
INSERT INTO FRAGMENT (ID, XPATH, ANCHOR_ID, DATASPACE_ID) VALUES
(7001, '/XPATH', 6001, 1001); \ No newline at end of file