aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy/org/onap
diff options
context:
space:
mode:
authorsourabh_sourabh <sourabh.sourabh@est.tech>2023-06-26 11:15:57 +0100
committersourabh_sourabh <sourabh.sourabh@est.tech>2023-06-27 16:01:37 +0100
commitede42ea3e267d321713cff1daf44d8627ada933d (patch)
tree157b81055ec61eea2b0d9f7bae4c4cba7dc50ab2 /cps-ncmp-service/src/test/groovy/org/onap
parent7ae1bcf4b463aec8c153feacfe32db4360e9c11d (diff)
NCMP : Handle non-existing and non-ready cm handles
- Modified data operation schema to contains cm handle as steing and response content field name as result. - Added a new common cloud event builder for NCMP to create an event. - Added data operation event creater that uses cloud event builder to create a cloud event. - Introduced a new method onto json object mapper to convert json object to bytes. - Modified EventDateTimeFormatter and added a new method to convert date timestamp into offsetdateTime. - Added a new code into ResourceRequestUtil to identify non-ready cm handle and non-existing cm handle and later publish it as cloud event to tha client given topic. - Introduced CpsApplicationContext to get spring mannaged bean into non spring managed java object. Issue-ID: CPS-1583, CPS-1614 Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech> Change-Id: I24a39d2cb2c54dea25cd2f17e7748e21cd83a088 Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/test/groovy/org/onap')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/NcmpAsyncDataOperationEventConsumerSpec.groovy4
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/EventPublisherSpec.groovy86
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avc/AvcEventConsumerSpec.groovy5
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy8
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/context/CpsApplicationContextSpec.groovy19
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtilsSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataOperationRequestUtilsSpec.groovy)60
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy29
7 files changed, 183 insertions, 28 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/NcmpAsyncDataOperationEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/NcmpAsyncDataOperationEventConsumerSpec.groovy
index 7f8469aaf..635328871 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/NcmpAsyncDataOperationEventConsumerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/NcmpAsyncDataOperationEventConsumerSpec.groovy
@@ -92,7 +92,7 @@ class NcmpAsyncDataOperationEventConsumerSpec extends MessagingBaseSpec {
response.operationId == 'some-operation-id'
response.statusCode == 'any-success-status-code'
response.statusMessage == 'Successfully applied changes'
- response.responseContent as String == '[some-key:some-value]'
+ response.result as String == '[some-key:some-value]'
}
def 'Filter an event with type #eventType'() {
@@ -110,7 +110,7 @@ class NcmpAsyncDataOperationEventConsumerSpec extends MessagingBaseSpec {
def createConsumerRecord(eventTypeAsString) {
def jsonData = TestUtils.getResourceFileContent('dataOperationEvent.json')
- def testEventSentAsBytes = objectMapper.writeValueAsBytes(jsonObjectMapper.convertJsonString(jsonData, DataOperationEvent.class))
+ def testEventSentAsBytes = jsonObjectMapper.asJsonBytes(jsonObjectMapper.convertJsonString(jsonData, DataOperationEvent.class))
CloudEvent cloudEvent = getCloudEvent(eventTypeAsString, testEventSentAsBytes)
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/EventPublisherSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/EventPublisherSpec.groovy
new file mode 100644
index 000000000..59a43caf9
--- /dev/null
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/EventPublisherSpec.groovy
@@ -0,0 +1,86 @@
+/*
+ * ============LICENSE_START========================================================
+ * Copyright (c) 2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ncmp.api.impl.events
+
+import ch.qos.logback.classic.Level
+import ch.qos.logback.classic.Logger
+import ch.qos.logback.core.read.ListAppender
+import org.apache.kafka.clients.producer.ProducerRecord
+import org.apache.kafka.clients.producer.RecordMetadata
+import org.apache.kafka.common.TopicPartition
+import org.onap.cps.ncmp.init.SubscriptionModelLoader
+import org.slf4j.LoggerFactory
+import org.springframework.kafka.support.SendResult
+import spock.lang.Specification
+
+class EventPublisherSpec extends Specification {
+
+ def objectUnderTest = new EventsPublisher(null, null)
+ def logger = (Logger) LoggerFactory.getLogger(objectUnderTest.getClass())
+ def loggingListAppender
+
+ void setup() {
+ logger.setLevel(Level.DEBUG)
+ loggingListAppender = new ListAppender()
+ logger.addAppender(loggingListAppender)
+ loggingListAppender.start()
+ }
+
+ void cleanup() {
+ ((Logger) LoggerFactory.getLogger(SubscriptionModelLoader.class)).detachAndStopAllAppenders()
+ }
+
+ def 'Callback handling on success.'() {
+ given: 'a send result'
+ def producerRecord = new ProducerRecord('topic-1', 'my value')
+ def topicPartition = new TopicPartition('topic-2', 0)
+ def recordMetadata = new RecordMetadata(topicPartition, 0, 0, 0, 0, 0)
+ def sendResult = new SendResult(producerRecord, recordMetadata)
+ when: 'the callback handler processes success'
+ def callbackHandler = objectUnderTest.handleCallback('topic-3')
+ callbackHandler.onSuccess(sendResult)
+ then: 'an event is logged with level DEBUG'
+ def loggingEvent = getLoggingEvent()
+ loggingEvent.level == Level.DEBUG
+ and: 'it contains the topic (from the record metadata) and the "value" (from the producer record)'
+ loggingEvent.formattedMessage.contains('topic-2')
+ loggingEvent.formattedMessage.contains('my value')
+ }
+
+
+ def 'Callback handling on failure.'() {
+ when: 'the callback handler processes a failure'
+ def callbackHandler = objectUnderTest.handleCallback('my topic')
+ callbackHandler.onFailure(new Exception('my exception'))
+ then: 'an event is logged with level ERROR'
+ def loggingEvent = getLoggingEvent()
+ loggingEvent.level == Level.ERROR
+ and: 'it contains the topic and exception message'
+ loggingEvent.formattedMessage.contains('my topic')
+ loggingEvent.formattedMessage.contains('my exception')
+ }
+
+ def getLoggingEvent() {
+ return loggingListAppender.list[0]
+ }
+
+
+}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avc/AvcEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avc/AvcEventConsumerSpec.groovy
index 5cc70e280..22852bea4 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avc/AvcEventConsumerSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/avc/AvcEventConsumerSpec.groovy
@@ -55,9 +55,6 @@ class AvcEventConsumerSpec extends MessagingBaseSpec {
@Autowired
JsonObjectMapper jsonObjectMapper
- @Autowired
- ObjectMapper objectMapper
-
def cloudEventKafkaConsumer = new KafkaConsumer<>(eventConsumerConfigProperties('ncmp-group', CloudEventDeserializer))
def 'Consume and forward valid message'() {
@@ -69,7 +66,7 @@ class AvcEventConsumerSpec extends MessagingBaseSpec {
def jsonData = TestUtils.getResourceFileContent('sampleAvcInputEvent.json')
def testEventSent = jsonObjectMapper.convertJsonString(jsonData, AvcEvent.class)
def testCloudEventSent = CloudEventBuilder.v1()
- .withData(objectMapper.writeValueAsBytes(testEventSent))
+ .withData(jsonObjectMapper.asJsonBytes(testEventSent))
.withId('sample-eventid')
.withType('sample-test-type')
.withSource(URI.create('sample-test-source'))
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
index c7ee4e074..59e62e34d 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
@@ -23,8 +23,11 @@ package org.onap.cps.ncmp.api.impl.operations
import com.fasterxml.jackson.databind.ObjectMapper
import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration
+import org.onap.cps.ncmp.api.impl.events.EventsPublisher
import org.onap.cps.ncmp.api.impl.utils.DmiServiceUrlBuilder
+import org.onap.cps.ncmp.api.impl.utils.context.CpsApplicationContext
import org.onap.cps.ncmp.api.models.DataOperationRequest
+import org.onap.cps.ncmp.event.model.NcmpAsyncRequestResponseEvent
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
@@ -42,7 +45,7 @@ import static org.onap.cps.ncmp.api.impl.operations.OperationType.READ
import static org.onap.cps.ncmp.api.impl.operations.OperationType.UPDATE
@SpringBootTest
-@ContextConfiguration(classes = [NcmpConfiguration.DmiProperties, DmiDataOperations])
+@ContextConfiguration(classes = [EventsPublisher, CpsApplicationContext, NcmpConfiguration.DmiProperties, DmiDataOperations])
class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
@SpringBean
@@ -59,6 +62,9 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
@Autowired
DmiDataOperations objectUnderTest
+ @SpringBean
+ EventsPublisher eventsPublisher = Stub()
+
def 'call get resource data for #expectedDatastoreInUrl from DMI without topic #scenario.'() {
given: 'a cm handle for #cmHandleId'
mockYangModelCmHandleRetrieval(dmiProperties)
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/context/CpsApplicationContextSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/context/CpsApplicationContextSpec.groovy
new file mode 100644
index 000000000..b7fa44925
--- /dev/null
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/context/CpsApplicationContextSpec.groovy
@@ -0,0 +1,19 @@
+package org.onap.cps.ncmp.api.impl.utils.context
+
+import com.fasterxml.jackson.databind.ObjectMapper
+import org.onap.cps.utils.JsonObjectMapper
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.test.context.ContextConfiguration
+import spock.lang.Specification;
+
+@SpringBootTest(classes = [ObjectMapper, JsonObjectMapper])
+@ContextConfiguration(classes = [CpsApplicationContext.class])
+class CpsApplicationContextSpec extends Specification {
+
+ def 'Verify if cps application context contains a requested bean.'() {
+ when: 'cps bean is requested from application context'
+ def jsonObjectMapper = CpsApplicationContext.getCpsBean(JsonObjectMapper.class)
+ then: 'requested bean of JsonObjectMapper is not null'
+ assert jsonObjectMapper != null
+ }
+}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataOperationRequestUtilsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtilsSpec.groovy
index 334b455ef..401254f54 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/DataOperationRequestUtilsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/data/operation/ResourceDataOperationRequestUtilsSpec.groovy
@@ -18,23 +18,46 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.cps.ncmp.api.impl.utils
+package org.onap.cps.ncmp.api.impl.utils.data.operation
import com.fasterxml.jackson.databind.ObjectMapper
+import io.cloudevents.CloudEvent
+import io.cloudevents.core.CloudEventUtils
+import io.cloudevents.jackson.PojoCloudEventDataMapper
+import io.cloudevents.kafka.CloudEventDeserializer
+import io.cloudevents.kafka.impl.KafkaHeaders
+import org.apache.kafka.clients.consumer.KafkaConsumer
+import org.onap.cps.ncmp.api.impl.events.EventsPublisher
+import org.onap.cps.ncmp.api.impl.utils.context.CpsApplicationContext
import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle
import org.onap.cps.ncmp.api.inventory.CmHandleState
import org.onap.cps.ncmp.api.inventory.CompositeStateBuilder
+import org.onap.cps.ncmp.api.kafka.MessagingBaseSpec
import org.onap.cps.ncmp.api.models.DataOperationRequest
+import org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent
import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
-import spock.lang.Specification
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import java.time.Duration
-class DataOperationRequestUtilsSpec extends Specification {
+@ContextConfiguration(classes = [EventsPublisher, CpsApplicationContext, ObjectMapper])
+class ResourceDataOperationRequestUtilsSpec extends MessagingBaseSpec {
+
+ def cloudEventKafkaConsumer = new KafkaConsumer<>(eventConsumerConfigProperties('test', CloudEventDeserializer))
+ def static clientTopic = 'my-topic-name'
+ def static dataOperationType = 'org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent'
@SpringBean
JsonObjectMapper jsonObjectMapper = new JsonObjectMapper(new ObjectMapper())
+ @SpringBean
+ EventsPublisher eventPublisher = new EventsPublisher<CloudEvent>(legacyEventKafkaTemplate, cloudEventKafkaTemplate)
+
+ @Autowired
+ ObjectMapper objectMapper
+
def 'Process per data operation request with #serviceName.'() {
given: 'data operation request with 3 operations'
def dataOperationRequestJsonData = TestUtils.getResourceFileContent('dataOperationRequest.json')
@@ -42,7 +65,7 @@ class DataOperationRequestUtilsSpec extends Specification {
and: '4 known cm handles: ch1-dmi1, ch2-dmi1, ch3-dmi2, ch4-dmi2'
def yangModelCmHandles = getYangModelCmHandles()
when: 'data operation request is processed'
- def operationsOutPerDmiServiceName = ResourceDataOperationRequestUtils.processPerDefinitionInDataOperationsRequest(dataOperationRequest, yangModelCmHandles)
+ def operationsOutPerDmiServiceName = ResourceDataOperationRequestUtils.processPerDefinitionInDataOperationsRequest(clientTopic,'request-id', dataOperationRequest, yangModelCmHandles)
and: 'converted to a json node'
def dmiDataOperationRequestBody = jsonObjectMapper.asJsonString(operationsOutPerDmiServiceName.get(serviceName))
def dmiDataOperationRequestBodyAsJsonNode = jsonObjectMapper.convertToJsonNode(dmiDataOperationRequestBody).get(operationIndex)
@@ -65,9 +88,37 @@ class DataOperationRequestUtilsSpec extends Specification {
'dmi2' | 2 || 'operational-15' | 'ncmp-datastore:passthrough-operational' | ['ch4-dmi2']
}
+ def 'Process per data operation request with non-ready, non-existing cm handle and publish event to client specified topic'() {
+ given: 'consumer subscribing to client topic'
+ cloudEventKafkaConsumer.subscribe([clientTopic])
+ and: 'data operation request having non-ready and non-existing cm handle ids'
+ def dataOperationRequestJsonData = TestUtils.getResourceFileContent('dataOperationRequest.json')
+ def dataOperationRequest = jsonObjectMapper.convertJsonString(dataOperationRequestJsonData, DataOperationRequest.class)
+ when: 'data operation request is processed'
+ ResourceDataOperationRequestUtils.processPerDefinitionInDataOperationsRequest(clientTopic, 'request-id', dataOperationRequest, yangModelCmHandles)
+ and: 'subscribed client specified topic is polled and first record is selected'
+ def consumerRecordOut = cloudEventKafkaConsumer.poll(Duration.ofMillis(1500))[0]
+ then: 'verify cloud compliant headers'
+ def consumerRecordOutHeaders = consumerRecordOut.headers()
+ assert KafkaHeaders.getParsedKafkaHeader(consumerRecordOutHeaders, 'ce_id') != null
+ assert KafkaHeaders.getParsedKafkaHeader(consumerRecordOutHeaders, 'ce_type') == dataOperationType
+ and: 'verify that extension is included into header'
+ assert KafkaHeaders.getParsedKafkaHeader(consumerRecordOutHeaders, 'ce_correlationid') == 'request-id'
+ assert KafkaHeaders.getParsedKafkaHeader(consumerRecordOutHeaders, 'ce_destination') == clientTopic
+ and: 'map consumer record to expected event type'
+ def dataOperationResponseEvent = CloudEventUtils.mapData(consumerRecordOut.value(),
+ PojoCloudEventDataMapper.from(objectMapper, DataOperationEvent.class)).getValue()
+ and: 'data operation response event response size is 3'
+ dataOperationResponseEvent.data.responses.size() == 3
+ and: 'verify published response data as json string'
+ jsonObjectMapper.asJsonString(dataOperationResponseEvent.data.responses)
+ == '[{"operationId":"operational-14","ids":["unknown-cm-handle"],"statusCode":"100","statusMessage":"cm handle id(s) not found"},{"operationId":"operational-14","ids":["non-ready-cm handle"],"statusCode":"101","statusMessage":"cm handle(s) not ready"},{"operationId":"running-12","ids":["non-ready-cm handle"],"statusCode":"101","statusMessage":"cm handle(s) not ready"}]'
+ }
+
static def getYangModelCmHandles() {
def dmiProperties = [new YangModelCmHandle.Property('prop', 'some DMI property')]
def readyState = new CompositeStateBuilder().withCmHandleState(CmHandleState.READY).withLastUpdatedTimeNow().build()
+ def advisedState = new CompositeStateBuilder().withCmHandleState(CmHandleState.ADVISED).withLastUpdatedTimeNow().build()
return [new YangModelCmHandle(id: 'ch1-dmi1', dmiServiceName: 'dmi1', dmiProperties: dmiProperties, compositeState: readyState),
new YangModelCmHandle(id: 'ch2-dmi1', dmiServiceName: 'dmi1', dmiProperties: dmiProperties, compositeState: readyState),
new YangModelCmHandle(id: 'ch6-dmi1', dmiServiceName: 'dmi1', dmiProperties: dmiProperties, compositeState: readyState),
@@ -75,6 +126,7 @@ class DataOperationRequestUtilsSpec extends Specification {
new YangModelCmHandle(id: 'ch3-dmi2', dmiServiceName: 'dmi2', dmiProperties: dmiProperties, compositeState: readyState),
new YangModelCmHandle(id: 'ch4-dmi2', dmiServiceName: 'dmi2', dmiProperties: dmiProperties, compositeState: readyState),
new YangModelCmHandle(id: 'ch7-dmi2', dmiServiceName: 'dmi2', dmiProperties: dmiProperties, compositeState: readyState),
+ new YangModelCmHandle(id: 'non-ready-cm handle', dmiServiceName: 'dmi2', dmiProperties: dmiProperties, compositeState: advisedState)
]
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy
index a14a0f286..b4e7813db 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/SubscriptionModelLoaderSpec.groovy
@@ -23,8 +23,6 @@ package org.onap.cps.ncmp.init
import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.core.read.ListAppender
-import org.junit.jupiter.api.AfterEach
-import org.junit.jupiter.api.BeforeEach
import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
@@ -53,22 +51,19 @@ class SubscriptionModelLoaderSpec extends Specification {
def applicationReadyEvent = new ApplicationReadyEvent(new SpringApplication(), null, applicationContext, null)
def yangResourceToContentMap
- def logger
- def appender
+ def logger = (Logger) LoggerFactory.getLogger(objectUnderTest.getClass())
+ def loggingListAppender
- @BeforeEach
void setup() {
yangResourceToContentMap = objectUnderTest.createYangResourceToContentMap()
- logger = (Logger) LoggerFactory.getLogger(objectUnderTest.getClass())
- appender = new ListAppender()
logger.setLevel(Level.DEBUG)
- appender.start()
- logger.addAppender(appender)
+ loggingListAppender = new ListAppender()
+ logger.addAppender(loggingListAppender)
+ loggingListAppender.start()
applicationContext.refresh()
}
- @AfterEach
- void teardown() {
+ void cleanup() {
((Logger) LoggerFactory.getLogger(SubscriptionModelLoader.class)).detachAndStopAllAppenders()
applicationContext.close()
}
@@ -123,7 +118,7 @@ class SubscriptionModelLoaderSpec extends Specification {
and: 'the data service to create a top level datanode was not called'
0 * mockCpsDataService.saveData(*_)
and: 'the log message contains the correct exception message'
- def logs = appender.list.toString()
+ def logs = loggingListAppender.list.toString()
assert logs.contains("Retrieval of NCMP dataspace fails")
}
@@ -168,7 +163,7 @@ class SubscriptionModelLoaderSpec extends Specification {
when: 'the method to onboard model is called'
objectUnderTest.onboardSubscriptionModel(yangResourceToContentMap)
then: 'the log message contains the correct exception message'
- def debugMessage = appender.list[0].toString()
+ def debugMessage = loggingListAppender.list[0].toString()
assert debugMessage.contains("Creating schema set failed")
and: 'exception is thrown'
thrown(NcmpStartUpException)
@@ -183,7 +178,7 @@ class SubscriptionModelLoaderSpec extends Specification {
then: 'no exception thrown'
noExceptionThrown()
and: 'the log message contains the correct exception message'
- def infoMessage = appender.list[0].toString()
+ def infoMessage = loggingListAppender.list[0].toString()
assert infoMessage.contains("already exists")
}
@@ -194,7 +189,7 @@ class SubscriptionModelLoaderSpec extends Specification {
when: 'the method to onboard model is called'
objectUnderTest.onboardSubscriptionModel(yangResourceToContentMap)
then: 'the log message contains the correct exception message'
- def debugMessage = appender.list[0].toString()
+ def debugMessage = loggingListAppender.list[0].toString()
assert debugMessage.contains("Schema Set not found")
and: 'exception is thrown'
thrown(NcmpStartUpException)
@@ -209,7 +204,7 @@ class SubscriptionModelLoaderSpec extends Specification {
then: 'no exception thrown'
noExceptionThrown()
and: 'the log message contains the correct exception message'
- def infoMessage = appender.list[0].toString()
+ def infoMessage = loggingListAppender.list[0].toString()
assert infoMessage.contains("already exists")
}
@@ -220,7 +215,7 @@ class SubscriptionModelLoaderSpec extends Specification {
when: 'the method to onboard model is called'
objectUnderTest.onboardSubscriptionModel(yangResourceToContentMap)
then: 'the log message contains the correct exception message'
- def debugMessage = appender.list[0].toString()
+ def debugMessage = loggingListAppender.list[0].toString()
assert debugMessage.contains("Creating data node for subscription model failed: Invalid JSON")
and: 'exception is thrown'
thrown(NcmpStartUpException)