From a6f024b0dc5c0bc94dfe4fae90ec63ff0b3fd656 Mon Sep 17 00:00:00 2001 From: ToineSiebelink Date: Tue, 24 Jun 2025 16:50:01 +0100 Subject: [PATCH] Add dm-service-name cm-handle searches to integration tests - Split cm handle search tests in North- and Southbound test classes - Added test variations with and without (additional) cm handle properties - Too many functional NCMP test: grouped them in folder by feature names (semi-automatically updated copyright to all moved files even if not strictly necessary - Reformatted and cleaned up (descriptions) northbound tests - Minor reformatting of production code - Increase margin on performance timer accuracy test (unrelated but caused test to fail sometimes) Issue-ID:CPS-1872 Change-Id: I3bbf3b2b6b4301bbed0eb72d76ec7125e89f0217 Signed-off-by: ToineSiebelink --- .../NetworkCmProxyInventoryController.java | 4 +- .../ncmp/rest/util/RestOutputCmHandleMapper.java | 3 +- .../integration/ResourceMeterAccuracyTest.groovy | 6 +- .../CmNotificationSubscriptionSpec.groovy | 4 +- .../ncmp/{ => data}/AlternateIdSpec.groovy | 4 +- .../{ => data}/BearerTokenPassthroughSpec.groovy | 4 +- .../DmiUrlEncodingPassthroughSpec.groovy | 7 +-- .../{ => data}/LegacyBatchDataOperationSpec.groovy | 2 +- .../{ => datajobs}/DataJobResultServiceSpec.groovy | 4 +- .../{ => datajobs}/DataJobStatusServiceSpec.groovy | 2 +- .../ncmp/{ => datajobs}/WriteSubJobSpec.groovy | 4 +- .../ncmp/{ => inventory}/CmHandleCreateSpec.groovy | 14 ++--- .../CmHandleSearchesNorthBoundRestApiSpec.groovy} | 38 ++++++------- .../CmHandleSearchesSouthBoundRestApiSpec.groovy | 64 ++++++++++++++++++++++ .../ncmp/{ => inventory}/CmHandleUpdateSpec.groovy | 4 +- .../{ => inventory}/CmHandleUpgradeSpec.groovy | 4 +- .../ModuleSyncWatchdogIntegrationSpec.groovy | 4 +- .../ModulesRestApiSpec.groovy} | 6 +- .../PolicyExecutorIntegrationSpec.groovy | 4 +- 19 files changed, 118 insertions(+), 64 deletions(-) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => cmnotificationsubscription}/CmNotificationSubscriptionSpec.groovy (97%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => data}/AlternateIdSpec.groovy (94%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => data}/BearerTokenPassthroughSpec.groovy (97%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => data}/DmiUrlEncodingPassthroughSpec.groovy (92%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => data}/LegacyBatchDataOperationSpec.groovy (99%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => datajobs}/DataJobResultServiceSpec.groovy (93%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => datajobs}/DataJobStatusServiceSpec.groovy (94%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => datajobs}/WriteSubJobSpec.groovy (96%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => inventory}/CmHandleCreateSpec.groovy (94%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{RestApiSpec.groovy => inventory/CmHandleSearchesNorthBoundRestApiSpec.groovy} (84%) create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleSearchesSouthBoundRestApiSpec.groovy rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => inventory}/CmHandleUpdateSpec.groovy (96%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => inventory}/CmHandleUpgradeSpec.groovy (98%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => inventory}/ModuleSyncWatchdogIntegrationSpec.groovy (98%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{YangModulesSpec.groovy => inventory/ModulesRestApiSpec.groovy} (96%) rename integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/{ => policyexecutor}/PolicyExecutorIntegrationSpec.groovy (96%) diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java index e8cc0b9234..3a5102ceeb 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java @@ -95,8 +95,8 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor final boolean includeCmHandlePropertiesParameter = Boolean.TRUE.equals(includeCmHandlePropertiesInQuery); final List restOutputCmHandles = networkCmProxyInventoryFacade.executeCmHandleInventorySearch(cmHandleQueryApiParameters) - .map(handle -> restOutputCmHandleMapper - .toRestOutputCmHandle(handle, includeCmHandlePropertiesParameter)) + .map(ncmpServiceCmHandle -> restOutputCmHandleMapper + .toRestOutputCmHandle(ncmpServiceCmHandle, includeCmHandlePropertiesParameter)) .collectList().block(); return ResponseEntity.ok(restOutputCmHandles); } diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java index 32d87167e4..000d96fc67 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/util/RestOutputCmHandleMapper.java @@ -52,8 +52,7 @@ public class RestOutputCmHandleMapper { restOutputCmHandle.setCmHandleProperties(null); } restOutputCmHandle.setState( - cmHandleStateMapper.toCmHandleCompositeStateExternalLockReason( - ncmpServiceCmHandle.getCompositeState())); + cmHandleStateMapper.toCmHandleCompositeStateExternalLockReason(ncmpServiceCmHandle.getCompositeState())); if (ncmpServiceCmHandle.getCurrentTrustLevel() != null) { restOutputCmHandle.setTrustLevel(ncmpServiceCmHandle.getCurrentTrustLevel().toString()); } diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/ResourceMeterAccuracyTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/ResourceMeterAccuracyTest.groovy index 0bb4720626..f2ae32503f 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/ResourceMeterAccuracyTest.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/ResourceMeterAccuracyTest.groovy @@ -33,9 +33,9 @@ class ResourceMeterAccuracyTest extends Specification { objectUnderTest.start() TimeUnit.SECONDS.sleep(2) objectUnderTest.stop() - then: 'the resource meter reports a duration within 20ms of the expected duration' - assert objectUnderTest.getTotalTimeInSeconds() >= 1.98 - assert objectUnderTest.getTotalTimeInSeconds() <= 2.02 + then: 'the resource meter reports a duration within 40ms of the expected duration' + assert objectUnderTest.getTotalTimeInSeconds() >= 1.96 + assert objectUnderTest.getTotalTimeInSeconds() <= 2.04 } } diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmNotificationSubscriptionSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/cmnotificationsubscription/CmNotificationSubscriptionSpec.groovy similarity index 97% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmNotificationSubscriptionSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/cmnotificationsubscription/CmNotificationSubscriptionSpec.groovy index a5f7d08c58..6ccd51c414 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmNotificationSubscriptionSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/cmnotificationsubscription/CmNotificationSubscriptionSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.cmnotificationsubscription import org.onap.cps.integration.base.CpsIntegrationSpecBase import org.onap.cps.ncmp.impl.cmnotificationsubscription.utils.CmSubscriptionPersistenceService diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/AlternateIdSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/AlternateIdSpec.groovy similarity index 94% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/AlternateIdSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/AlternateIdSpec.groovy index b1b777c79f..8f3005689d 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/AlternateIdSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/AlternateIdSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024-2025 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.data import org.onap.cps.integration.base.CpsIntegrationSpecBase import org.springframework.http.HttpStatus diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/BearerTokenPassthroughSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/BearerTokenPassthroughSpec.groovy similarity index 97% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/BearerTokenPassthroughSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/BearerTokenPassthroughSpec.groovy index a81058fbd6..5c6a598407 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/BearerTokenPassthroughSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/BearerTokenPassthroughSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.data import org.onap.cps.integration.base.CpsIntegrationSpecBase import org.springframework.http.HttpHeaders diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DmiUrlEncodingPassthroughSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/DmiUrlEncodingPassthroughSpec.groovy similarity index 92% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DmiUrlEncodingPassthroughSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/DmiUrlEncodingPassthroughSpec.groovy index 4e9b809eff..fc699fa39b 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DmiUrlEncodingPassthroughSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/DmiUrlEncodingPassthroughSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,16 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.data import org.onap.cps.integration.base.CpsIntegrationSpecBase import org.springframework.http.MediaType -import static org.springframework.http.HttpMethod.DELETE import static org.springframework.http.HttpMethod.GET -import static org.springframework.http.HttpMethod.PATCH import static org.springframework.http.HttpMethod.POST -import static org.springframework.http.HttpMethod.PUT import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.request import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/LegacyBatchDataOperationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/LegacyBatchDataOperationSpec.groovy similarity index 99% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/LegacyBatchDataOperationSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/LegacyBatchDataOperationSpec.groovy index ee15c4b94f..eb1484b73c 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/LegacyBatchDataOperationSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/data/LegacyBatchDataOperationSpec.groovy @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.data import io.cloudevents.CloudEvent import io.cloudevents.kafka.CloudEventDeserializer diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobResultServiceSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/datajobs/DataJobResultServiceSpec.groovy similarity index 93% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobResultServiceSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/datajobs/DataJobResultServiceSpec.groovy index 4d04eeeb81..b21d58445e 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobResultServiceSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/datajobs/DataJobResultServiceSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.datajobs import org.onap.cps.integration.base.CpsIntegrationSpecBase import org.onap.cps.ncmp.api.datajobs.DataJobResultService diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobStatusServiceSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/datajobs/DataJobStatusServiceSpec.groovy similarity index 94% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobStatusServiceSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/datajobs/DataJobStatusServiceSpec.groovy index 162b51844c..58fa5bdb8e 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/DataJobStatusServiceSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/datajobs/DataJobStatusServiceSpec.groovy @@ -1,4 +1,4 @@ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.datajobs import org.onap.cps.integration.base.CpsIntegrationSpecBase import org.onap.cps.ncmp.api.datajobs.DataJobStatusService diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/WriteSubJobSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/datajobs/WriteSubJobSpec.groovy similarity index 96% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/WriteSubJobSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/datajobs/WriteSubJobSpec.groovy index 46c641cd23..b3597aee9a 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/WriteSubJobSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/datajobs/WriteSubJobSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024-2025 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.datajobs import org.onap.cps.integration.base.CpsIntegrationSpecBase import org.onap.cps.ncmp.api.datajobs.DataJobService diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleCreateSpec.groovy similarity index 94% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleCreateSpec.groovy index d3a5c9a2ec..9263b2df17 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleCreateSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024-2025 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.inventory import java.time.Duration import org.apache.kafka.clients.consumer.KafkaConsumer @@ -157,11 +157,11 @@ class CmHandleCreateSpec extends CpsIntegrationSpecBase { when: 'a batch of CM-handles is registered for creation with various alternate IDs' def cmHandlesToCreate = [ - new NcmpServiceCmHandle(cmHandleId: 'ch-3', alternateId: NO_ALTERNATE_ID), - new NcmpServiceCmHandle(cmHandleId: 'ch-4', alternateId: 'unique-alt-id'), - new NcmpServiceCmHandle(cmHandleId: 'ch-5', alternateId: 'existing-alt-id'), - new NcmpServiceCmHandle(cmHandleId: 'ch-6', alternateId: 'duplicate-alt-id'), - new NcmpServiceCmHandle(cmHandleId: 'ch-7', alternateId: 'duplicate-alt-id'), + new NcmpServiceCmHandle(cmHandleId: 'ch-3', alternateId: NO_ALTERNATE_ID), + new NcmpServiceCmHandle(cmHandleId: 'ch-4', alternateId: 'unique-alt-id'), + new NcmpServiceCmHandle(cmHandleId: 'ch-5', alternateId: 'existing-alt-id'), + new NcmpServiceCmHandle(cmHandleId: 'ch-6', alternateId: 'duplicate-alt-id'), + new NcmpServiceCmHandle(cmHandleId: 'ch-7', alternateId: 'duplicate-alt-id'), ] def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: DMI1_URL, createdCmHandles: cmHandlesToCreate) def dmiPluginRegistrationResponse = objectUnderTest.updateDmiRegistration(dmiPluginRegistration) diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/RestApiSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleSearchesNorthBoundRestApiSpec.groovy similarity index 84% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/RestApiSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleSearchesNorthBoundRestApiSpec.groovy index 77349fe0a5..d8a28ac910 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/RestApiSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleSearchesNorthBoundRestApiSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024-2025 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.inventory import static org.hamcrest.Matchers.containsInAnyOrder import static org.hamcrest.Matchers.hasSize @@ -30,19 +30,18 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import org.onap.cps.integration.base.CpsIntegrationSpecBase import org.springframework.http.MediaType -class RestApiSpec extends CpsIntegrationSpecBase { +class CmHandleSearchesNorthBoundRestApiSpec extends CpsIntegrationSpecBase { - def 'Register CM Handles using REST API.'() { + def 'Register CM Handles using REST API (setup).'() { given: 'DMI will return modules' dmiDispatcher1.moduleNamesPerCmHandleId = [ 'ch-1': ['M1', 'M2'], 'ch-2': ['M1', 'M2'], 'ch-3': ['M1', 'M3'] ] - when: 'a POST request is made to register the CM Handles' + when: 'register the CM Handles' def requestBody = '{"dmiPlugin":"'+DMI1_URL+'","createdCmHandles":[{"cmHandle":"ch-1","alternateId":"alt-1"},{"cmHandle":"ch-2","alternateId":"alt-2"},{"cmHandle":"ch-3","alternateId":"alt-3"}]}' - mvc.perform(post('/ncmpInventory/v1/ch').contentType(MediaType.APPLICATION_JSON).content(requestBody)) - .andExpect(status().is2xxSuccessful()) + mvc.perform(post('/ncmpInventory/v1/ch').contentType(MediaType.APPLICATION_JSON).content(requestBody)).andExpect(status().is2xxSuccessful()) and: 'the module sync watchdog is triggered' moduleSyncWatchdog.moduleSyncAdvisedCmHandles() then: 'CM-handles go to READY state' @@ -56,19 +55,17 @@ class RestApiSpec extends CpsIntegrationSpecBase { def 'Search for CM Handles by module using REST API.'() { given: 'a JSON request body containing search parameter' def requestBodyWithModuleCondition = """{ - "cmHandleQueryParameters": [ - { + "cmHandleQueryParameters": [ { "conditionName": "hasAllModules", "conditionParameters": [ {"moduleName": "%s"} ] - } - ] + } ] }""".formatted(moduleName) - expect: "a search for module ${moduleName} returns expected CM handles" + expect: 'a search for module #moduleName returns expected CM handles' mvc.perform(post('/ncmp/v1/ch/id-searches'+outputAlternateId).contentType(MediaType.APPLICATION_JSON).content(requestBodyWithModuleCondition)) .andExpect(status().is2xxSuccessful()) .andExpect(jsonPath('$[*]', containsInAnyOrder(expectedCmHandleReferences.toArray()))) .andExpect(jsonPath('$', hasSize(expectedCmHandleReferences.size()))); - where: + where: 'the following parameters are used' moduleName | outputAlternateId || expectedCmHandleReferences 'M1' | '?outputAlternateId=false' || ['ch-1', 'ch-2', 'ch-3'] 'M2' | '?outputAlternateId=false' || ['ch-1', 'ch-2'] @@ -77,36 +74,33 @@ class RestApiSpec extends CpsIntegrationSpecBase { 'M2' | '?outputAlternateId=true' || ['alt-1', 'alt-2'] 'M3' | '?outputAlternateId=true' || ['alt-3'] 'M1' | '' || ['ch-1', 'ch-2', 'ch-3'] - } def 'Search for CM Handles using Cps Path Query.'() { given: 'a JSON request body containing search parameter' def requestBodyWithSearchCondition = """{ - "cmHandleQueryParameters": [ - { + "cmHandleQueryParameters": [ { "conditionName": "cmHandleWithCpsPath", "conditionParameters": [ {"cpsPath" : "%s"} ] - } - ] + } ] }""".formatted(cpsPath) - expect: "a search for cps path ${cpsPath} returns expected CM handles" + expect: 'a search for cps path #cpsPath returns expected CM handles' mvc.perform(post('/ncmp/v1/ch/id-searches').contentType(MediaType.APPLICATION_JSON).content(requestBodyWithSearchCondition)) .andExpect(status().is2xxSuccessful()) .andExpect(jsonPath('$[*]', containsInAnyOrder(expectedCmHandles.toArray()))) .andExpect(jsonPath('$', hasSize(expectedCmHandles.size()))); - where: + where: 'the following parameters are used' scenario | cpsPath || expectedCmHandles 'All Ready CM handles' | "//state[@cm-handle-state='READY']" || ['ch-1', 'ch-2', 'ch-3'] 'Having Alternate ID alt-3' | "//cm-handles[@alternate-id='alt-3']" || ['ch-3'] } def 'De-register CM handles using REST API.'() { - when: 'a POST request is made to deregister the CM Handle' + when: 'deregister the CM Handles' def requestBody = '{"dmiPlugin":"'+DMI1_URL+'", "removedCmHandles": ["ch-1", "ch-2", "ch-3"]}' mvc.perform(post('/ncmpInventory/v1/ch').contentType(MediaType.APPLICATION_JSON).content(requestBody)) .andExpect(status().is2xxSuccessful()) - then: 'the CM handles are not found using GET' + then: 'the CM handles are gone' (1..3).each { mvc.perform(get('/ncmp/v1/ch/ch-'+it)).andExpect(status().is4xxClientError()) } diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleSearchesSouthBoundRestApiSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleSearchesSouthBoundRestApiSpec.groovy new file mode 100644 index 0000000000..b4154d25ba --- /dev/null +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleSearchesSouthBoundRestApiSpec.groovy @@ -0,0 +1,64 @@ +/* + * ============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.integration.functional.ncmp.inventory + +import org.onap.cps.integration.base.CpsIntegrationSpecBase +import org.springframework.http.MediaType + +import static org.hamcrest.Matchers.containsInAnyOrder +import static org.hamcrest.Matchers.hasSize +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status + +class CmHandleSearchesSouthBoundRestApiSpec extends CpsIntegrationSpecBase { + + def 'Search for CM Handles by dmi-service using REST API.'() { + given: 'register some CM Handles for dmi service #DMI1_URL (has to be done in same test otherwise URL/Port changes)' + def requestBody = '{"dmiPlugin":"'+DMI1_URL+'","createdCmHandles":[{"cmHandle":"ch-1"},{"cmHandle":"ch-2"}]}' + mvc.perform(post('/ncmpInventory/v1/ch').contentType(MediaType.APPLICATION_JSON).content(requestBody)).andExpect(status().is2xxSuccessful()) + and: 'a cm-handle search on dmi service name request (body)' + def dmiPluginNameSearchValue = useCorrectDmiForSearch ? DMI1_URL : 'non existing dmi' + def requestBodyWithModuleCondition = """{ + "cmHandleQueryParameters": [ { + "conditionName": "cmHandleWithDmiPlugin", + "conditionParameters": [ {"dmiPluginName": "%s"} ] + } ] + }""".formatted(dmiPluginNameSearchValue) + when: 'the search is executed it returns expected CM handles' + def result = mvc.perform(post("/ncmpInventory/v1/ch/searchCmHandles?includeCmHandlePropertiesInQuery=${includeCmHandleProperties}").contentType(MediaType.APPLICATION_JSON).content(requestBodyWithModuleCondition)) + .andExpect(status().is2xxSuccessful()) + .andExpect(jsonPath('$', hasSize(expectedCmHandleReferences.size()))) + .andExpect(jsonPath('$[*].cmHandle', containsInAnyOrder(expectedCmHandleReferences.toArray()))) + .andReturn() + then: 'the result response only contains additional properties when requested' + assert result.response.contentAsString.contains('cmHandleProperties') == includeCmHandleProperties + cleanup: 'deregister the CM Handles' + requestBody = '{"dmiPlugin":"'+DMI1_URL+'", "removedCmHandles": ["ch-1", "ch-2"]}' + mvc.perform(post('/ncmpInventory/v1/ch').contentType(MediaType.APPLICATION_JSON).content(requestBody)).andExpect(status().is2xxSuccessful()) + where: 'the following parameters are used' + useCorrectDmiForSearch | includeCmHandleProperties || expectedCmHandleReferences + true | true || ['ch-1', 'ch-2'] + true | false || ['ch-1', 'ch-2'] + false | false || [] + } + +} diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpdateSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleUpdateSpec.groovy similarity index 96% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpdateSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleUpdateSpec.groovy index 22bbaa81df..8b3fc24abf 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpdateSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleUpdateSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024-2025 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.inventory import org.onap.cps.integration.base.CpsIntegrationSpecBase import org.onap.cps.ncmp.api.NcmpResponseStatus diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpgradeSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleUpgradeSpec.groovy similarity index 98% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpgradeSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleUpgradeSpec.groovy index 43540a9675..62ea22b74e 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleUpgradeSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/CmHandleUpgradeSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024-2025 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.inventory import org.onap.cps.integration.base.CpsIntegrationSpecBase import org.onap.cps.ncmp.api.inventory.models.CmHandleRegistrationResponse diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/ModuleSyncWatchdogIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModuleSyncWatchdogIntegrationSpec.groovy similarity index 98% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/ModuleSyncWatchdogIntegrationSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModuleSyncWatchdogIntegrationSpec.groovy index 8bbe0ca194..5c949af5ed 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/ModuleSyncWatchdogIntegrationSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModuleSyncWatchdogIntegrationSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024-2025 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.inventory import com.hazelcast.map.IMap import io.micrometer.core.instrument.MeterRegistry diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/YangModulesSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModulesRestApiSpec.groovy similarity index 96% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/YangModulesSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModulesRestApiSpec.groovy index e01af55c35..e9e1962e8a 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/YangModulesSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModulesRestApiSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.inventory import org.onap.cps.integration.base.CpsIntegrationSpecBase @@ -33,7 +33,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -class YangModulesSpec extends CpsIntegrationSpecBase { +class ModulesRestApiSpec extends CpsIntegrationSpecBase { def setup() { dmiDispatcher1.moduleNamesPerCmHandleId['ch-1'] = ['M1', 'M2'] diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/PolicyExecutorIntegrationSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/policyexecutor/PolicyExecutorIntegrationSpec.groovy similarity index 96% rename from integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/PolicyExecutorIntegrationSpec.groovy rename to integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/policyexecutor/PolicyExecutorIntegrationSpec.groovy index f897393a53..81d6246f1e 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/PolicyExecutorIntegrationSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/policyexecutor/PolicyExecutorIntegrationSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2024 Nordix Foundation + * Copyright (C) 2024-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. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.cps.integration.functional.ncmp +package org.onap.cps.integration.functional.ncmp.policyexecutor import com.fasterxml.jackson.databind.ObjectMapper import org.onap.cps.integration.base.CpsIntegrationSpecBase -- 2.16.6