diff options
author | 2023-10-17 11:03:16 +0100 | |
---|---|---|
committer | 2023-11-02 13:07:16 +0000 | |
commit | f41dd3b24da2cc956c3d6e27fc14e409f11c65c0 (patch) | |
tree | 83d17101101a07061b6d2172e9895f05bfc51dc7 /cps-ncmp-service/src/test | |
parent | e5c66c7fec638412e10d5abef14d2a7afc86cb23 (diff) |
Initial Registration with trustLevel on NCMP
- Updated NcmpServiceCmHandle class to include registration trustLevel
Issue-ID: CPS-1902
Signed-off-by: seanbeirne <sean.beirne@est.tech>
Change-Id: I7c97928f5cdd82f3036a57ea5f0c149e2872f4f1
Diffstat (limited to 'cps-ncmp-service/src/test')
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy index 0f40906b6..c87efce04 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplRegistrationSpec.groovy @@ -68,7 +68,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { def mockLcmEventsCmHandleStateHandler = Mock(LcmEventsCmHandleStateHandler) def mockCpsDataService = Mock(CpsDataService) def mockModuleSyncStartedOnCmHandles = Mock(IMap<String, Object>) - def mockTrustLevelPerDmiPlugin = Mock(IMap<String, TrustLevel>) + def trustLevelPerCmHandle = [:] def objectUnderTest = getObjectUnderTest() def 'DMI Registration: Create, Update, Delete & Upgrade operations are processed in the right order'() { @@ -128,13 +128,11 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration) then: 'create cm handles registration and sync modules is called with the correct plugin information' 1 * objectUnderTest.parseAndProcessCreatedCmHandlesInRegistration(dmiPluginRegistration) - and: 'dmi is added to the trustLevel map' - 1 * mockTrustLevelPerDmiPlugin.put(dmiPluginRegisteredName, TrustLevel.COMPLETE) where: - scenario | dmiPlugin | dmiModelPlugin | dmiDataPlugin | dmiPluginRegisteredName - 'combined DMI plugin' | 'service1' | '' | '' | 'service1' - 'data & model DMI plugins' | '' | 'service1' | 'service2' | 'service2' - 'data & model using same service' | '' | 'service1' | 'service1' | 'service1' + scenario | dmiPlugin | dmiModelPlugin | dmiDataPlugin + 'combined DMI plugin' | 'service1' | '' | '' + 'data & model DMI plugins' | '' | 'service1' | 'service2' + 'data & model using same service' | '' | 'service1' | 'service1' } def 'Create CM-handle Validation: Invalid DMI plugin service name with #scenario'() { @@ -193,6 +191,24 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { 'without dmi & public properties' | [:] | [:] || '[]' | '[]' } + def 'Add CM-Handle to trustLevelPerCmHandle Successfully with: #scenario.'() { + given: 'a registration with trustLevel and populated cache' + def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server') + dmiPluginRegistration.createdCmHandles = [new NcmpServiceCmHandle(cmHandleId: 'ch-1', registrationTrustLevel: TrustLevel.NONE), + new NcmpServiceCmHandle(cmHandleId: cmHandleId, registrationTrustLevel: registrationTrustLevel)] + when: 'registration is updated' + def response = objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration) + then: 'a successful response is received' + assert response.createdCmHandles.size() == expectedNumberOfCreatedCmHandles + and: 'trustLevel is set for the created cm-handle' + assert trustLevelPerCmHandle.get(cmHandleId) == expectedTrustLevel + where: + scenario | cmHandleId | registrationTrustLevel || expectedNumberOfCreatedCmHandles | expectedTrustLevel + 'new cmHandleId and trustLevel' | 'ch-new' | TrustLevel.COMPLETE || 2 | TrustLevel.COMPLETE + 'existing cmHandleId with null trustLevel' | 'ch-1' | null || 1 | TrustLevel.NONE + 'cmHandleId with null trustLevel' | 'ch-new' | null || 2 | TrustLevel.COMPLETE + } + def 'Create CM-Handle Multiple Requests: All cm-handles creation requests are processed with some failures'() { given: 'a registration with three cm-handles to be created' def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: 'my-server', @@ -387,7 +403,7 @@ class NetworkCmProxyDataServiceImplRegistrationSpec extends Specification { return Spy(new NetworkCmProxyDataServiceImpl(spiedJsonObjectMapper, mockDmiDataOperations, mockNetworkCmProxyDataServicePropertyHandler, mockInventoryPersistence, mockCmHandleQueries, stubbedNetworkCmProxyCmHandlerQueryService, mockLcmEventsCmHandleStateHandler, mockCpsDataService, - mockModuleSyncStartedOnCmHandles, mockTrustLevelPerDmiPlugin)) + mockModuleSyncStartedOnCmHandles, trustLevelPerCmHandle)) } def addPersistedYangModelCmHandles(ids) { |