2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023 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
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.ncmp.api.impl.events.deprecated.cmsubscription
23 import com.fasterxml.jackson.databind.ObjectMapper
24 import org.mapstruct.factory.Mappers
25 import org.onap.cps.ncmp.events.cmsubscription1_0_0.client_to_ncmp.CmSubscriptionNcmpInEvent
26 import org.onap.cps.ncmp.utils.TestUtils
27 import org.onap.cps.utils.JsonObjectMapper
28 import org.springframework.beans.factory.annotation.Autowired
29 import org.springframework.boot.test.context.SpringBootTest
30 import spock.lang.Specification
32 @SpringBootTest(classes = [JsonObjectMapper, ObjectMapper])
33 class ClientCmSubscriptionNcmpInEventMapperSpec extends Specification {
35 CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper objectUnderTest = Mappers.getMapper(CmSubscriptionNcmpInEventToCmSubscriptionDmiInEventMapper)
38 JsonObjectMapper jsonObjectMapper
40 def 'Map clients subscription event to ncmps subscription event'() {
41 given: 'a Subscription Event'
42 def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
43 def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
44 when: 'the client event is mapped to a ncmp subscription event'
45 def result = objectUnderTest.toCmSubscriptionDmiInEvent(testEventToMap)
46 then: 'the resulting ncmp subscription event contains the correct clientId'
47 assert result.getData().getSubscription().getClientID() == "SCO-9989752"
48 and: 'subscription name'
49 assert result.getData().getSubscription().getName() == "cm-subscription-001"
50 and: 'is tagged value is false'
51 assert result.getData().getSubscription().getIsTagged() == false
52 and: 'data category is CM'
53 assert result.getData().getDataType().getDataCategory() == 'CM'
54 and: 'predicate targets is null'
55 assert result.getData().getPredicates().getTargets() == []
56 and: 'datastore is passthrough-running'
57 assert result.getData().getPredicates().getDatastore() == 'ncmp-datastore:passthrough-running'