summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiOperationsBaseSpec.groovy
blob: 4bf7dad8b98c45a1718b70ccdb4854a6995d0d9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package org.onap.cps.ncmp.api.impl.operations

import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.ncmp.api.impl.client.DmiRestClient
import org.onap.cps.ncmp.api.models.PersistenceCmHandle
import org.spockframework.spring.SpringBean
import spock.lang.Shared
import spock.lang.Specification

abstract class DmiOperationsBaseSpec extends Specification {

    @Shared
    def sampleAdditionalProperty = new PersistenceCmHandle.AdditionalProperty('prop1', 'val1')

    @SpringBean
    DmiRestClient mockDmiRestClient = Mock()

    @SpringBean
    PersistenceCmHandleRetriever mockCmHandlePropertiesRetriever = Mock()

    @SpringBean
    ObjectMapper spyObjectMapper = Spy()

    def persistenceCmHandle = new PersistenceCmHandle()
    def static dmiServiceName = 'some service name'
    def static cmHandleId = 'some cm handle'
    def static resourceIdentifier = 'parent/child'

    def mockPersistenceCmHandleRetrieval(additionalProperties) {
        persistenceCmHandle.dmiDataServiceName = dmiServiceName
        persistenceCmHandle.dmiServiceName = dmiServiceName
        persistenceCmHandle.additionalProperties = additionalProperties
        persistenceCmHandle.id = cmHandleId
        mockCmHandlePropertiesRetriever.retrieveCmHandleDmiServiceNameAndProperties(cmHandleId) >> persistenceCmHandle
    }
}