summaryrefslogtreecommitdiffstats
path: root/integration-test/src
diff options
context:
space:
mode:
authorLee Anjella Macabuhay <lee.anjella.macabuhay@est.tech>2024-03-26 10:42:15 +0000
committerGerrit Code Review <gerrit@onap.org>2024-03-26 10:42:15 +0000
commit13a9b02bb46f77c6300a93f5e581206e58947e1e (patch)
treecd4ffd19dabf120895cb64fdb414e4218e377c80 /integration-test/src
parent3c8fd515de889c3daaeffb44cac1eb2d8902729c (diff)
parent00245eeb7a41f434565b2f0102d86f2900113017 (diff)
Merge "Code review cleanup for: Add kafka messaging support to integration test module"
Diffstat (limited to 'integration-test/src')
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy15
-rw-r--r--integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy12
2 files changed, 15 insertions, 12 deletions
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
index 5020dceef6..2603c48edf 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
@@ -21,6 +21,7 @@
package org.onap.cps.integration.base
import java.time.OffsetDateTime
+import java.time.format.DateTimeFormatter
import org.onap.cps.api.CpsAnchorService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsDataspaceService
@@ -39,6 +40,7 @@ import org.onap.cps.spi.exceptions.DataspaceNotFoundException
import org.onap.cps.spi.model.DataNode
import org.onap.cps.spi.repository.DataspaceRepository
import org.onap.cps.spi.utils.SessionManager
+import org.onap.cps.utils.JsonObjectMapper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.autoconfigure.domain.EntityScan
@@ -56,13 +58,11 @@ import spock.lang.Shared
import spock.lang.Specification
import spock.util.concurrent.PollingConditions
-import java.time.format.DateTimeFormatter
-
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo
-import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DMI_REGISTRY_ANCHOR
import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DMI_REGISTRY_PARENT
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = [CpsDataspaceService])
@Testcontainers
@@ -77,10 +77,10 @@ abstract class CpsIntegrationSpecBase extends Specification {
DatabaseTestContainer databaseTestContainer = DatabaseTestContainer.getInstance()
@Shared
- KafkaTestContainer kafkaTestContainer = KafkaTestContainer.getInstance();
+ KafkaTestContainer kafkaTestContainer = KafkaTestContainer.getInstance()
@Autowired
- MockMvc mvc;
+ MockMvc mvc
@Autowired
CpsDataspaceService cpsDataspaceService
@@ -115,6 +115,9 @@ abstract class CpsIntegrationSpecBase extends Specification {
@Autowired
ModuleSyncWatchdog moduleSyncWatchdog
+ @Autowired
+ JsonObjectMapper jsonObjectMapper
+
MockRestServiceServer mockDmiServer = null
static final DMI_URL = 'http://mock-dmi-server'
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy
index d20ac337bf..f03872d56b 100644
--- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy
+++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/NcmpCmHandleCreateSpec.groovy
@@ -20,7 +20,8 @@
package org.onap.cps.integration.functional
-
+import java.time.Duration
+import java.time.OffsetDateTime
import org.apache.kafka.common.TopicPartition
import org.apache.kafka.common.serialization.StringDeserializer
import org.onap.cps.integration.KafkaTestContainer
@@ -31,16 +32,14 @@ import org.onap.cps.ncmp.api.impl.inventory.LockReasonCategory
import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse
import org.onap.cps.ncmp.api.models.DmiPluginRegistration
import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle
+import org.onap.cps.ncmp.events.lcm.v1.LcmEvent
import spock.util.concurrent.PollingConditions
-import java.time.Duration
-import java.time.OffsetDateTime
-
class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
NetworkCmProxyDataService objectUnderTest
- def kafkaConsumer = KafkaTestContainer.getConsumer("ncmp-group", StringDeserializer.class);
+ def kafkaConsumer = KafkaTestContainer.getConsumer('ncmp-group', StringDeserializer.class)
static final MODULE_REFERENCES_RESPONSE_A = readResourceDataFile('mock-dmi-responses/bookStoreAWithModules_M1_M2_Response.json')
static final MODULE_RESOURCES_RESPONSE_A = readResourceDataFile('mock-dmi-responses/bookStoreAWithModules_M1_M2_ResourcesResponse.json')
@@ -82,7 +81,8 @@ class NcmpCmHandleCreateSpec extends CpsIntegrationSpecBase {
def records = message.records(new TopicPartition('ncmp-events', 0))
and: 'the newest lcm event notification is received with READY state'
- assert records.last().value().toString().contains('"cmHandleState":"READY"')
+ def notificationMessage = jsonObjectMapper.convertJsonString(records.last().value().toString(), LcmEvent)
+ assert notificationMessage.event.newValues.cmHandleState.value() == 'READY'
and: 'the CM-handle has expected modules'
assert ['M1', 'M2'] == objectUnderTest.getYangResourcesModuleReferences('ch-1').moduleName.sort()