From: shikha0203 Date: Wed, 18 Feb 2026 11:36:39 +0000 (+0000) Subject: Move to a new java module(test-dcm-rest ): DataJobRequest X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F29%2F143329%2F5;p=cps.git Move to a new java module(test-dcm-rest ): DataJobRequest - 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 --- diff --git a/cps-application/src/test/java/org/onap/cps/architecture/NcmpArchitectureTest.java b/cps-application/src/test/java/org/onap/cps/architecture/NcmpArchitectureTest.java index 342211755e..857c232638 100644 --- a/cps-application/src/test/java/org/onap/cps/architecture/NcmpArchitectureTest.java +++ b/cps-application/src/test/java/org/onap/cps/architecture/NcmpArchitectureTest.java @@ -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..") diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy index e97c586561..9ff36cb05e 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/NetworkCmProxyRestExceptionHandlerSpec.groovy @@ -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 index fa11ace187..0000000000 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/datajobs/models/DataJobRequestSpec.groovy +++ /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 - } -} diff --git a/integration-test/pom.xml b/integration-test/pom.xml index 700c2d1491..855d595b20 100644 --- a/integration-test/pom.xml +++ b/integration-test/pom.xml @@ -42,6 +42,12 @@ cps-ncmp-rest test + + ${project.groupId} + test-dcm-rest + ${project.version} + test + ${project.groupId} cps-ri diff --git a/jacoco-report/pom.xml b/jacoco-report/pom.xml index 2bfeb32aaa..0404d77258 100644 --- a/jacoco-report/pom.xml +++ b/jacoco-report/pom.xml @@ -63,6 +63,11 @@ policy-executor-stub ${project.version} + + ${project.groupId} + test-dcm-rest + ${project.version} + diff --git a/pom.xml b/pom.xml index 479dd08b46..0bf45a8846 100644 --- a/pom.xml +++ b/pom.xml @@ -66,6 +66,7 @@ cps-application jacoco-report policy-executor-stub + test-dcm-rest diff --git a/test-dcm-rest/README.md b/test-dcm-rest/README.md new file mode 100644 index 0000000000..872da496b6 --- /dev/null +++ b/test-dcm-rest/README.md @@ -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 index 0000000000..bee0931f19 --- /dev/null +++ b/test-dcm-rest/pom.xml @@ -0,0 +1,61 @@ + + + + + 4.0.0 + + org.onap.cps + cps-parent + 3.7.7-SNAPSHOT + ../cps-parent/pom.xml + + + test-dcm-rest + + + + ${project.groupId} + cps-ncmp-service + ${project.version} + + + org.springframework.boot + spring-boot-starter-web + + + io.swagger.core.v3 + swagger-annotations + + + + org.codehaus.groovy + groovy + test + + + org.spockframework + spock-core + test + + + diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/DataJobControllerForTest.java b/test-dcm-rest/src/main/java/org/onap/cps/ncmp/testapi/controller/DataJobControllerForTest.java similarity index 95% rename from cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/DataJobControllerForTest.java rename to test-dcm-rest/src/main/java/org/onap/cps/ncmp/testapi/controller/DataJobControllerForTest.java index d259d91796..ef7b1ecfb1 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/DataJobControllerForTest.java +++ b/test-dcm-rest/src/main/java/org/onap/cps/ncmp/testapi/controller/DataJobControllerForTest.java @@ -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); } } - diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/models/DataJobRequest.java b/test-dcm-rest/src/main/java/org/onap/cps/ncmp/testapi/controller/models/DataJobRequest.java similarity index 79% rename from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/models/DataJobRequest.java rename to test-dcm-rest/src/main/java/org/onap/cps/ncmp/testapi/controller/models/DataJobRequest.java index fe73a601b9..05ff8cf2be 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/datajobs/models/DataJobRequest.java +++ b/test-dcm-rest/src/main/java/org/onap/cps/ncmp/testapi/controller/models/DataJobRequest.java @@ -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,10 @@ * ============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) { } diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/DataJobControllerForTestSpec.groovy b/test-dcm-rest/src/test/groovy/org/onap/cps/ncmp/testapi/controller/DataJobControllerForTestSpec.groovy similarity index 92% rename from cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/DataJobControllerForTestSpec.groovy rename to test-dcm-rest/src/test/groovy/org/onap/cps/ncmp/testapi/controller/DataJobControllerForTestSpec.groovy index 6fc4a699e5..39025f4291 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/DataJobControllerForTestSpec.groovy +++ b/test-dcm-rest/src/test/groovy/org/onap/cps/ncmp/testapi/controller/DataJobControllerForTestSpec.groovy @@ -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,13 +18,13 @@ * ============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