CM Subscription: Link method to publish to DMI in service layer
[cps.git] / cps-ncmp-service / src / test / groovy / org / onap / cps / ncmp / api / impl / events / cmsubscription / CmNotificationSubscriptionMappersHandlerSpec.groovy
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2024 Nordix Foundation
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
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.ncmp.api.impl.events.cmsubscription
22
23 import org.onap.cps.ncmp.api.impl.events.cmsubscription.mapper.CmNotificationSubscriptionDmiInEventMapper
24 import org.onap.cps.ncmp.api.impl.events.cmsubscription.mapper.CmNotificationSubscriptionNcmpOutEventMapper
25 import spock.lang.Specification
26
27 class CmNotificationSubscriptionMappersHandlerSpec extends Specification{
28
29     def mockCmNotificationDmiInEventMapper = Mock(CmNotificationSubscriptionDmiInEventMapper)
30     def mockCmNotificationNcmpOutEventMapper = Mock(CmNotificationSubscriptionNcmpOutEventMapper)
31
32     def objectUnderTest = new CmNotificationSubscriptionMappersHandler(mockCmNotificationDmiInEventMapper,
33         mockCmNotificationNcmpOutEventMapper)
34
35     def 'Get cm notification subscription DMI in event'() {
36         given: 'a list of predicates'
37             def testListOfPredicates = []
38         when: 'method to create a cm notification subscription dmi in event is called with predicates'
39             objectUnderTest.toCmNotificationSubscriptionDmiInEvent(testListOfPredicates)
40         then: 'the parameters is delegated to the correct dmi in event mapper method'
41             1 * mockCmNotificationDmiInEventMapper.toCmNotificationSubscriptionDmiInEvent(testListOfPredicates)
42     }
43
44     def 'Get cm notification subscription ncmp out event'() {
45         given: 'a subscription details map'
46             def testSubscriptionDetailsMap = [:]
47         when: 'method to create cm notification subscription ncmp out event is called with the following parameters'
48             objectUnderTest.toCmNotificationSubscriptionNcmpOutEvent("test-id", testSubscriptionDetailsMap)
49         then: 'the parameters is delegated to the correct ncmp out event mapper method'
50             1 * mockCmNotificationNcmpOutEventMapper.toCmNotificationSubscriptionNcmpOutEvent("test-id",
51             testSubscriptionDetailsMap)
52     }
53
54     def 'Get cm notification subscription ncmp out event for a rejected request'() {
55         given: 'a list of target filters'
56             def testRejectedTargetFilters = []
57         when: 'method to create cm notification subscription ncmp out event is called with the following parameters'
58             objectUnderTest.toCmNotificationSubscriptionNcmpOutEventForRejectedRequest(
59                 "test-id", testRejectedTargetFilters)
60         then: 'the parameters is delegated to the correct ncmp out event mapper method'
61             1 * mockCmNotificationNcmpOutEventMapper.toCmNotificationSubscriptionNcmpOutEventForRejectedRequest(
62                 "test-id", testRejectedTargetFilters)
63     }
64 }