final boolean includeCmHandlePropertiesParameter = Boolean.TRUE.equals(includeCmHandlePropertiesInQuery);
final List<RestOutputCmHandle> restOutputCmHandles =
networkCmProxyInventoryFacade.executeCmHandleInventorySearch(cmHandleQueryApiParameters)
- .map(handle -> restOutputCmHandleMapper
- .toRestOutputCmHandle(handle, includeCmHandlePropertiesParameter))
+ .map(ncmpServiceCmHandle -> restOutputCmHandleMapper
+ .toRestOutputCmHandle(ncmpServiceCmHandle, includeCmHandlePropertiesParameter))
.collectList().block();
return ResponseEntity.ok(restOutputCmHandles);
}
restOutputCmHandle.setCmHandleProperties(null);
}
restOutputCmHandle.setState(
- cmHandleStateMapper.toCmHandleCompositeStateExternalLockReason(
- ncmpServiceCmHandle.getCompositeState()));
+ cmHandleStateMapper.toCmHandleCompositeStateExternalLockReason(ncmpServiceCmHandle.getCompositeState()));
if (ncmpServiceCmHandle.getCurrentTrustLevel() != null) {
restOutputCmHandle.setTrustLevel(ncmpServiceCmHandle.getCurrentTrustLevel().toString());
}
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
}
}
/*
* ============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.
* ============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
/*
* ============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.
* ============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
/*
* ============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.
* ============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
/*
* ============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.
* ============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
* ============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
/*
* ============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.
* ============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
-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
/*
* ============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.
* ============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
/*
* ============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.
* ============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
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)
/*
* ============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.
* ============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
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'
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']
'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())
}
--- /dev/null
+/*
+ * ============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 || []
+ }
+
+}
/*
* ============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.
* ============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
/*
* ============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.
* ============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
/*
* ============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.
* ============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
/*
* ============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.
* ============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 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']
/*
* ============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.
* ============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