def 'Map clients subscription event to ncmps subscription event'() {
given: 'a Subscription Event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
when: 'the client event is mapped to a ncmp subscription event'
def result = objectUnderTest.toCmSubscriptionDmiInEvent(testEventToMap)
}
def getDmiOutEvent() {
- def cmSubscriptionDmiOutEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json')
+ def cmSubscriptionDmiOutEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiOutEvent.json')
return jsonObjectMapper.convertJsonString(cmSubscriptionDmiOutEventJsonData, CmSubscriptionDmiOutEvent.class)
}
def 'Map dmi out event to yang model subscription event'() {
given: 'a dmi out event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiOutEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiOutEvent.json')
def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionDmiOutEvent.class)
when: 'the event is mapped to a yang model subscription'
def result = objectUnderTest.toYangModelSubscriptionEvent(testEventToMap)
def 'Map cm subscription event to ncmp out event'() {
given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionEvent.json')
+ def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
when: 'cm subscription event is mapped to ncmp out event'
def result = objectUnderTest.toCmSubscriptionNcmpOutEvent(cmSubscriptionEvent)
def 'Map cm subscription event to ncmp out event with the given scenarios causes an exception'() {
given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionEvent.json')
+ def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
and: 'set cm subscription status with given scenarios'
cmSubscriptionEvent.setCmSubscriptionStatus(subscriptionStatusList)
def 'Map cm subscription event to ncmp out event without any exception'() {
given: 'a cm subscription Event'
- def subscriptionResponseJsonData = TestUtils.getResourceFileContent('cmSubscriptionEvent.json')
+ def subscriptionResponseJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
def subscriptionResponseEvent = jsonObjectMapper.convertJsonString(subscriptionResponseJsonData, CmSubscriptionEvent.class)
when: 'cm subscription event is mapped to ncmp out event'
objectUnderTest.toCmSubscriptionNcmpOutEvent(subscriptionResponseEvent)
def 'Consume, persist and forward valid CM create message'() {
given: 'an event with data category CM'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def testEventSent = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
testEventSent.getData().getDataType().setDataCategory(dataCategory)
def testCloudEventSent = CloudEventBuilder.v1()
def 'Consume event with wrong datastore causes an exception'() {
given: 'an event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def testEventSent = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
and: 'datastore is set to a passthrough-running datastore'
testEventSent.getData().getPredicates().setDatastore('operational')
def 'Forward valid CM create subscription and simulate timeout'() {
given: 'a ncmp in event'
- def ncmpInEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def ncmpInEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def ncmpInEventJson = jsonObjectMapper.convertJsonString(ncmpInEventJsonData, CmSubscriptionNcmpInEvent.class)
and: 'the InventoryPersistence returns private properties for the supplied CM Handles'
1 * mockInventoryPersistence.getYangModelCmHandles(["CMHandle1", "CMHandle2", "CMHandle3"]) >> [
def 'Forward CM create subscription where target CM Handles are #scenario'() {
given: 'a ncmp in event'
- def ncmpInEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def ncmpInEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def ncmpInEventJson = jsonObjectMapper.convertJsonString(ncmpInEventJsonData, CmSubscriptionNcmpInEvent.class)
and: 'the target CMHandles are set to #scenario'
ncmpInEventJson.getData().getPredicates().setTargets(invalidTargets)
def 'Forward valid CM create subscription where targets are not associated to any existing CMHandles'() {
given: 'a ncmp in event'
- def ncmpInEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def ncmpInEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def ncmpInEventJson = jsonObjectMapper.convertJsonString(ncmpInEventJsonData, CmSubscriptionNcmpInEvent.class)
and: 'the InventoryPersistence returns no private properties for the supplied CM Handles'
1 * mockInventoryPersistence.getYangModelCmHandles(["CMHandle1", "CMHandle2", "CMHandle3"]) >> []
def 'Map subscription event to yang model subscription event where #scenario'() {
given: 'a Subscription Event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpInEvent.json')
def testEventToMap = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpInEvent.class)
when: 'the event is mapped to a yang model subscription'
def result = objectUnderTest.toYangModelSubscriptionEvent(testEventToMap)
def 'Send response to the client apps successfully'() {
given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionEvent.json')
+ def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
and: 'a ncmp out event'
- def ncmpOutEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent2.json')
+ def ncmpOutEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent2.json')
def ncmpOutEvent = jsonObjectMapper.convertJsonString(ncmpOutEventJsonData, CmSubscriptionNcmpOutEvent.class)
and: 'a random id for the cloud event'
SubscriptionOutcomeCloudMapper.randomId = 'some-id'
def 'Create ncmp out message as expected'() {
given: 'a cm subscription event'
- def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionEvent.json')
+ def cmSubscriptionEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionEvent.json')
def cmSubscriptionEvent = jsonObjectMapper.convertJsonString(cmSubscriptionEventJsonData, CmSubscriptionEvent.class)
and: 'a ncmp out event'
- def ncmpOutEventJsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent.json')
+ def ncmpOutEventJsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json')
def ncmpOutEvent = jsonObjectMapper.convertJsonString(ncmpOutEventJsonData, CmSubscriptionNcmpOutEvent.class)
and: 'a status code and status message a per #scenarios'
ncmpOutEvent.getData().setStatusCode(statusCode)
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.utils
+package org.onap.cps.ncmp.api.impl.util.deprecated
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.ObjectMapper
import io.cloudevents.core.builder.CloudEventBuilder
+import org.onap.cps.ncmp.api.impl.utils.CmSubscriptionEventCloudMapper
import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_dmi.CmSubscriptionDmiInEvent
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
def 'Map the subscription event to data of the cloud event'() {
given: 'a subscription event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiInEvent.json')
def testEventData = jsonObjectMapper.convertJsonString(jsonData,
CmSubscriptionDmiInEvent.class)
def testCloudEvent = CloudEventBuilder.v1()
def jsonProcessingException = new JsonProcessingException('The Cloud Event could not be constructed')
spyObjectMapper.writeValueAsBytes(_) >> { throw jsonProcessingException }
and: 'a subscription event of ncmp version'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionDmiInEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionDmiInEvent.json')
def testEventData = jsonObjectMapper.convertJsonString(jsonData,
CmSubscriptionDmiInEvent.class)
when: 'the subscription event map to cloud event'
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.utils
+package org.onap.cps.ncmp.api.impl.util.deprecated
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.ObjectMapper
import io.cloudevents.core.builder.CloudEventBuilder
+import org.onap.cps.ncmp.api.impl.utils.SubscriptionOutcomeCloudMapper
import org.onap.cps.ncmp.events.cmsubscription1_0_0.ncmp_to_client.CmSubscriptionNcmpOutEvent
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
def 'Map the subscription outcome to cloud event'() {
given: 'a subscription event'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json')
def testEventData = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpOutEvent.class)
def testCloudEvent = CloudEventBuilder.v1()
.withData(objectMapper.writeValueAsBytes(testEventData))
def jsonProcessingException = new JsonProcessingException('The Cloud Event could not be constructed')
spyObjectMapper.writeValueAsBytes(_) >> { throw jsonProcessingException }
and: 'a cloud event having a subscription outcome in the data part'
- def jsonData = TestUtils.getResourceFileContent('cmSubscriptionNcmpOutEvent.json')
+ def jsonData = TestUtils.getResourceFileContent('deprecatedCmSubscription/cmSubscriptionNcmpOutEvent.json')
def testEventData = jsonObjectMapper.convertJsonString(jsonData, CmSubscriptionNcmpOutEvent.class)
when: 'the subscription outcome map to cloud event'
def expectedResult = objectUnderTest.toCloudEvent(testEventData, 'some-key', 'some-event-type')