2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the 'License');
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an 'AS IS' BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.cps.integration.functional.ncmp.inventory
23 import org.onap.cps.integration.base.CpsIntegrationSpecBase
24 import org.onap.cps.ncmp.api.inventory.models.NcmpServiceCmHandle
25 import org.onap.cps.ncmp.init.DataMigration
26 import org.springframework.beans.factory.annotation.Autowired
27 import org.springframework.test.context.TestPropertySource
29 @TestPropertySource(properties = ["ncmp.inventory.model.upgrade.r20250722.enabled=true"])
30 class DataMigrationIntegrationSpec extends CpsIntegrationSpecBase {
33 DataMigration objectUnderTest
35 def 'Migrate inventory with batch processing.'() {
36 given: 'DMI will return modules when requested'
37 dmiDispatcher1.moduleNamesPerCmHandleId = (1..2).collectEntries{ ['ch-'+it, ['M1']] }
38 and: 'multiple CM handles registered, (top level) status is null'
40 registerCmHandle(DMI1_URL, 'ch-'+it, NO_MODULE_SET_TAG)
41 def someCmHandle = networkCmProxyInventoryFacade.getNcmpServiceCmHandle('ch-'+it)
42 assert someCmHandle.getCmHandleStatus() == null
43 assert someCmHandle.getCompositeState().getCmHandleState().name() == 'READY'
45 when: 'migration is executed'
46 objectUnderTest.migrateInventoryToModelRelease20250722(1)
47 then: 'all CM handles are processed successfully,' +
48 'the (top level) status is set to the same value as the name of the complex state value'
50 def someCmHandle = networkCmProxyInventoryFacade.getNcmpServiceCmHandle('ch-'+it)
51 assert someCmHandle.getCmHandleStatus() == 'READY'
52 assert someCmHandle.getCompositeState().getCmHandleState().name() == 'READY'
54 cleanup: 'deregister CM handles'
55 deregisterCmHandles(DMI1_URL, (1..2).collect{ 'ch-'+it })