summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-rest')
-rw-r--r--cps-ncmp-rest/pom.xml2
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy6
-rw-r--r--cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutorSpec.groovy31
3 files changed, 18 insertions, 21 deletions
diff --git a/cps-ncmp-rest/pom.xml b/cps-ncmp-rest/pom.xml
index 27c640a633..f363c01f66 100644
--- a/cps-ncmp-rest/pom.xml
+++ b/cps-ncmp-rest/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.4.3-SNAPSHOT</version>
+ <version>3.4.4-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy
index f06af6c10a..4edbf3569f 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy
@@ -44,7 +44,7 @@ class NcmpDatastoreRequestHandlerSpec extends Specification {
def 'Attempt to execute async get request with #scenario.'() {
given: 'notification feature is turned on/off'
objectUnderTest.notificationFeatureEnabled = notificationFeatureEnabled
- and: ' a flag to track the network service call'
+ and: 'a flag to track the network service call'
def networkServiceMethodCalled = false
and: 'the (mocked) service will use the flag to indicate if it is called'
mockNetworkCmProxyDataService.getResourceDataForCmHandle('ds', 'ch1', 'resource1', 'options', _, _) >> {
@@ -54,7 +54,7 @@ class NcmpDatastoreRequestHandlerSpec extends Specification {
objectUnderTest.executeRequest('ds', 'ch1', 'resource1', 'options', topic, false)
then: 'the task is executed in an async fashion or not'
expectedCalls * spiedCpsNcmpTaskExecutor.executeTask(*_)
- and: 'the service request is always invoked within 1 seconds'
+ and: 'the service request is invoked'
new PollingConditions().within(1) {
assert networkServiceMethodCalled == true
}
@@ -97,7 +97,7 @@ class NcmpDatastoreRequestHandlerSpec extends Specification {
objectUnderTest.executeRequest('myTopic', dataOperationRequest)
then: 'the task is executed in an async fashion'
1 * spiedCpsNcmpTaskExecutor.executeTask(*_)
- and: 'the network service is invoked within 1 seconds'
+ and: 'the network service is invoked'
new PollingConditions().within(1) {
assert networkServiceMethodCalled == true
}
diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutorSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutorSpec.groovy
index 55590168d9..010eda964d 100644
--- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutorSpec.groovy
+++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutorSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation
+ * Copyright (C) 2023-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,10 +24,9 @@ import ch.qos.logback.classic.Level
import ch.qos.logback.classic.Logger
import ch.qos.logback.classic.spi.ILoggingEvent
import ch.qos.logback.core.read.ListAppender
-import org.junit.jupiter.api.AfterEach
-import org.junit.jupiter.api.BeforeEach
import org.slf4j.LoggerFactory
import spock.lang.Specification
+import spock.util.concurrent.PollingConditions
class CpsNcmpTaskExecutorSpec extends Specification {
@@ -35,25 +34,23 @@ class CpsNcmpTaskExecutorSpec extends Specification {
def logger = Spy(ListAppender<ILoggingEvent>)
def enoughTime = 100
- @BeforeEach
void setup() {
- ((Logger) LoggerFactory.getLogger(CpsNcmpTaskExecutor.class)).addAppender(logger);
- logger.start();
+ ((Logger) LoggerFactory.getLogger(CpsNcmpTaskExecutor.class)).addAppender(logger)
+ logger.start()
}
- @AfterEach
- void teardown() {
- ((Logger) LoggerFactory.getLogger(CpsNcmpTaskExecutor.class)).detachAndStopAllAppenders();
+ void cleanup() {
+ ((Logger) LoggerFactory.getLogger(CpsNcmpTaskExecutor.class)).detachAndStopAllAppenders()
}
def 'Execute successful task.'() {
when: 'task is executed'
objectUnderTest.executeTask(taskSupplier(), enoughTime)
- and: 'wait a little for async execution completion'
- Thread.sleep(10)
then: 'an event is logged with level INFO'
- def loggingEvent = getLoggingEvent()
- assert loggingEvent.level == Level.INFO
+ new PollingConditions().within(1) {
+ def loggingEvent = getLoggingEvent()
+ assert loggingEvent.level == Level.INFO
+ }
and: 'the log indicates the task completed successfully'
assert loggingEvent.formattedMessage == 'Async task completed successfully.'
}
@@ -61,11 +58,11 @@ class CpsNcmpTaskExecutorSpec extends Specification {
def 'Execute failing task.'() {
when: 'task is executed'
objectUnderTest.executeTask(taskSupplierForFailingTask(), enoughTime)
- and: 'wait a little for async execution completion'
- Thread.sleep(10)
then: 'an event is logged with level ERROR'
- def loggingEvent = getLoggingEvent()
- assert loggingEvent.level == Level.ERROR
+ new PollingConditions().within(1) {
+ def loggingEvent = getLoggingEvent()
+ assert loggingEvent.level == Level.ERROR
+ }
and: 'the original error message is logged'
assert loggingEvent.formattedMessage.contains('original exception message')
}