79b9ad578f9b2882f2e308e1654b8a3e6c92439a
[cps.git] /
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.impl.cmnotificationsubscription
22
23
24 import org.onap.cps.ncmp.impl.cmnotificationsubscription.dmi.DmiInEventMapper
25 import org.onap.cps.ncmp.impl.cmnotificationsubscription.ncmp.NcmpOutEventMapper
26 import spock.lang.Specification
27
28 class MappersFacadeSpec extends Specification{
29
30     def mockCmNotificationDmiInEventMapper = Mock(DmiInEventMapper)
31     def mockCmNotificationNcmpOutEventMapper = Mock(NcmpOutEventMapper)
32
33     def objectUnderTest = new MappersFacade(mockCmNotificationDmiInEventMapper,
34         mockCmNotificationNcmpOutEventMapper)
35
36     def 'Get cm notification subscription DMI in event'() {
37         given: 'a list of predicates'
38             def testListOfPredicates = []
39         when: 'method to create a cm notification subscription dmi in event is called with predicates'
40             objectUnderTest.toDmiInEvent(testListOfPredicates)
41         then: 'the parameters is delegated to the correct dmi in event mapper method'
42             1 * mockCmNotificationDmiInEventMapper.toDmiInEvent(testListOfPredicates)
43     }
44
45     def 'Get cm notification subscription ncmp out event'() {
46         given: 'a subscription details map'
47             def testSubscriptionDetailsMap = [:]
48         when: 'method to create cm notification subscription ncmp out event is called with the following parameters'
49             objectUnderTest.toNcmpOutEvent("test-id", testSubscriptionDetailsMap)
50         then: 'the parameters is delegated to the correct ncmp out event mapper method'
51             1 * mockCmNotificationNcmpOutEventMapper.toNcmpOutEvent("test-id",
52             testSubscriptionDetailsMap)
53     }
54
55     def 'Get cm notification subscription ncmp out event for a rejected request'() {
56         given: 'a list of target filters'
57             def testRejectedTargetFilters = []
58         when: 'method to create cm notification subscription ncmp out event is called with the following parameters'
59             objectUnderTest.toNcmpOutEventForRejectedRequest(
60                 "test-id", testRejectedTargetFilters)
61         then: 'the parameters is delegated to the correct ncmp out event mapper method'
62             1 * mockCmNotificationNcmpOutEventMapper.toNcmpOutEventForRejectedRequest(
63                 "test-id", testRejectedTargetFilters)
64     }
65 }