Move to a new java module(test-dcm-rest ): DataJobRequest 29/143329/5
authorshikha0203 <shivani.khare@est.tech>
Wed, 18 Feb 2026 11:36:39 +0000 (11:36 +0000)
committershikha0203 <shivani.khare@est.tech>
Thu, 19 Feb 2026 15:19:49 +0000 (15:19 +0000)
- test-dcm-rest module created
- DataJobRequest and DataJobControllerForTest moved to test module
- Architecture test added
- No production module depends on test-dcm-rest
- Build with and without dcm-test-rest using profiles (separate story)

Issue-ID: CPS-3062
Change-Id: Ia4731507a476b00dff31e8719b4a4dd447a345cd
Signed-off-by: shikha0203 <shivani.khare@est.tech>
cps-application/src/test/java/org/onap/cps/architecture/NcmpArchitectureTest.java
cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/datajobs/models/DataJobRequestSpec.groovy [deleted file]
integration-test/pom.xml
jacoco-report/pom.xml
pom.xml
test-dcm-rest/README.md [new file with mode: 0644]
test-dcm-rest/pom.xml [new file with mode: 0644]
test-dcm-rest/src/main/java/org/onap/cps/ncmp/testapi/controller/DataJobControllerForTest.java [moved from cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/DataJobControllerForTest.java with 95% similarity]
test-dcm-rest/src/main/java/org/onap/cps/ncmp/testapi/controller/models/DataJobRequest.java [moved from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/models/DataJobRequest.java with 79% similarity]
test-dcm-rest/src/test/groovy/org/onap/cps/ncmp/testapi/controller/DataJobControllerForTestSpec.groovy [moved from cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/DataJobControllerForTestSpec.groovy with 92% similarity]

index 3422117..857c232 100644 (file)
@@ -34,6 +34,12 @@ public class NcmpArchitectureTest extends ArchitectureTestBase {
             classes().that().resideInAPackage("org.onap.cps.ncmp.rest..").should().onlyHaveDependentClassesThat()
                     .resideInAPackage("org.onap.cps.ncmp.rest..");
 
+    @ArchTest
+    static final ArchRule nothingDependsOnTestCpsNcmpRest =
+            classes().that().resideInAPackage("org.onap.cps.ncmp.testapi..").should().onlyHaveDependentClassesThat()
+                    .resideInAPackage("org.onap.cps.ncmp.testapi..")
+                    .allowEmptyShould(true);
+
     @ArchTest
     static final ArchRule ncmpRestControllerShouldOnlyDependOnNcmpService =
             classes().that().resideInAPackage("org.onap.cps.ncmp.rest..")
index e97c586..9ff36cb 100644 (file)
@@ -107,9 +107,6 @@ class NetworkCmProxyRestExceptionHandlerSpec extends Specification {
     @SpringBean
     NcmpPassthroughResourceRequestHandler StubbedNcmpPassthroughResourceRequestHandler = Stub()
 
-    @SpringBean
-    DataJobControllerForTest stubbedDataJobControllerForTest = Stub()
-
     @SpringBean
     RestOutputCmHandleMapper mockRestOutputCmHandleMapper = Mock()
 
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/datajobs/models/DataJobRequestSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/datajobs/models/DataJobRequestSpec.groovy
deleted file mode 100644 (file)
index fa11ace..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *  ============LICENSE_START=======================================================
- *  Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
- *  ================================================================================
- *  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.ncmp.api.datajobs.models
-
-import spock.lang.Specification
-
-class DataJobRequestSpec extends Specification {
-
-    def dataJobMetaData = new DataJobMetadata('some destination', 'some accept type', 'some content type')
-    def writeOperation = new WriteOperation('some path', 'some operation', 'some id', 'some value')
-    def dataJobWriteRequest = new DataJobWriteRequest([writeOperation])
-
-    def objectUnderTest = new DataJobRequest(dataJobMetaData, dataJobWriteRequest)
-
-    //TODO This class is only used for a test Controller. Maybe it can be removed, see https://lf-onap.atlassian.net/browse/CPS-3062
-    def 'a Data Job Request.'() {
-        expect: 'a data job request consisting out of meta data and a write request'
-            assert objectUnderTest.dataJobMetadata == dataJobMetaData
-            assert  objectUnderTest.dataJobWriteRequest == dataJobWriteRequest
-    }
-}
index 700c2d1..855d595 100644 (file)
             <artifactId>cps-ncmp-rest</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>test-dcm-rest</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>cps-ri</artifactId>
index 2bfeb32..0404d77 100644 (file)
             <artifactId>policy-executor-stub</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>test-dcm-rest</artifactId>
+            <version>${project.version}</version>
+        </dependency>
 
     </dependencies>
 
diff --git a/pom.xml b/pom.xml
index 479dd08..0bf45a8 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -66,6 +66,7 @@
         <module>cps-application</module>\r
         <module>jacoco-report</module>\r
         <module>policy-executor-stub</module>\r
+        <module>test-dcm-rest</module>\r
     </modules>\r
 \r
     <distributionManagement>\r
diff --git a/test-dcm-rest/README.md b/test-dcm-rest/README.md
new file mode 100644 (file)
index 0000000..872da49
--- /dev/null
@@ -0,0 +1,25 @@
+# Test DCM REST Module
+
+## Purpose
+
+This module contains REST controllers and models used exclusively for testing and performance measurement purposes.
+
+## Contents
+
+- `DataJobControllerForTest`: A REST controller that exposes an internal test endpoint for data job write operations
+- `DataJobRequest`: A request model used by the test controller
+
+## Important Notes
+
+- This module should ONLY be used in test/development environments
+- The endpoint is marked with `@Hidden` to exclude it from production API documentation
+- The endpoint path `/do-not-use/dataJobs` clearly indicates its test-only nature
+- No production module should depend on this module (enforced by architecture tests)
+
+## Architecture
+
+This module depends on:
+- `cps-ncmp-service` (for DataJobService and related models)
+- Spring Boot Web (for REST controller support)
+
+No other module should depend on `test-dcm-rest`.
diff --git a/test-dcm-rest/pom.xml b/test-dcm-rest/pom.xml
new file mode 100644 (file)
index 0000000..bee0931
--- /dev/null
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ============LICENSE_START=======================================================
+  Copyright (C) 2026 OpenInfra Foundation Europe. All rights reserved.
+  ================================================================================
+  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=========================================================
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.cps</groupId>
+        <artifactId>cps-parent</artifactId>
+        <version>3.7.7-SNAPSHOT</version>
+        <relativePath>../cps-parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>test-dcm-rest</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>cps-ncmp-service</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.swagger.core.v3</groupId>
+            <artifactId>swagger-annotations</artifactId>
+        </dependency>
+        <!-- T E S T   D E P E N D E N C I E S -->
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.spockframework</groupId>
+            <artifactId>spock-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
+ *  Copyright (C) 2025-2026 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.cps.ncmp.rest.controller;
+package org.onap.cps.ncmp.testapi.controller;
 
 import io.swagger.v3.oas.annotations.Hidden;
 import java.util.List;
@@ -26,9 +26,9 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.onap.cps.ncmp.api.datajobs.DataJobService;
 import org.onap.cps.ncmp.api.datajobs.models.DataJobMetadata;
-import org.onap.cps.ncmp.api.datajobs.models.DataJobRequest;
 import org.onap.cps.ncmp.api.datajobs.models.DataJobWriteRequest;
 import org.onap.cps.ncmp.api.datajobs.models.SubJobWriteResponse;
+import org.onap.cps.ncmp.testapi.controller.models.DataJobRequest;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -76,4 +76,3 @@ public class DataJobControllerForTest {
         return ResponseEntity.ok(subJobWriteResponses);
     }
 }
-
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
+ *  Copyright (C) 2025-2026 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.cps.ncmp.api.datajobs.models;
+package org.onap.cps.ncmp.testapi.controller.models;
+
+import org.onap.cps.ncmp.api.datajobs.models.DataJobMetadata;
+import org.onap.cps.ncmp.api.datajobs.models.DataJobWriteRequest;
 
 public record DataJobRequest(DataJobMetadata dataJobMetadata, DataJobWriteRequest dataJobWriteRequest) {
 }
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
+ *  Copyright (C) 2025-2026 OpenInfra Foundation Europe. All rights reserved.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.cps.ncmp.rest.controller
+package org.onap.cps.ncmp.testapi.controller
 
 import org.onap.cps.ncmp.api.datajobs.DataJobService
 import org.onap.cps.ncmp.api.datajobs.models.DataJobMetadata
-import org.onap.cps.ncmp.api.datajobs.models.DataJobRequest
 import org.onap.cps.ncmp.api.datajobs.models.DataJobWriteRequest
 import org.onap.cps.ncmp.api.datajobs.models.WriteOperation
+import org.onap.cps.ncmp.testapi.controller.models.DataJobRequest
 import org.springframework.http.HttpStatus
 import spock.lang.Specification