aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/test/groovy/org
diff options
context:
space:
mode:
authorToineSiebelink <toine.siebelink@est.tech>2024-08-26 17:10:03 +0100
committerToineSiebelink <toine.siebelink@est.tech>2024-08-26 17:10:28 +0100
commit3a4dcb5af00b85ae3f48709dfa0f9d797e02aabd (patch)
tree44640185deea0720c6835da7ad962d70b4e3a4c1 /cps-ncmp-service/src/test/groovy/org
parent64ff45847a3466cb24a8dab57b65be753ee3cd03 (diff)
Policy Executor and DMI WebClient configurations
- separated dmi and policy executor http client configuration Issue-ID: CPS-2324 Change-Id: Ib4e757da188673e163abe6078dfd6ddae447eaab Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/test/groovy/org')
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/DmiHttpClientConfigSpec.groovy (renamed from cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/HttpClientConfigurationSpec.groovy)56
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/PolicyExecutorHttpClientConfigSpec.groovy48
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/PolicyExecutorSpec.groovy1
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiWebClientConfigurationSpec.groovy77
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiWebClientsConfigurationSpec.groovy70
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/policyexecutor/PolicyExecutorWebClientConfigurationSpec.groovy53
7 files changed, 201 insertions, 106 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/HttpClientConfigurationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/DmiHttpClientConfigSpec.groovy
index 1d3b22fb73..e0ae204c8d 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/HttpClientConfigurationSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/DmiHttpClientConfigSpec.groovy
@@ -28,46 +28,46 @@ import org.springframework.test.context.ContextConfiguration
import spock.lang.Specification
@SpringBootTest
-@ContextConfiguration(classes = [HttpClientConfiguration])
-@EnableConfigurationProperties(HttpClientConfiguration)
-class HttpClientConfigurationSpec extends Specification {
+@ContextConfiguration(classes = [DmiHttpClientConfig])
+@EnableConfigurationProperties(DmiHttpClientConfig)
+class DmiHttpClientConfigSpec extends Specification {
@Autowired
- HttpClientConfiguration httpClientConfiguration
+ DmiHttpClientConfig dmiHttpClientConfig
def 'Test http client configuration properties of data with custom and default values'() {
- expect: 'properties are populated correctly for data'
- with(httpClientConfiguration.dataServices) {
- assert connectionTimeoutInSeconds == 123
- assert readTimeoutInSeconds == 33
- assert writeTimeoutInSeconds == 30
- assert maximumConnectionsTotal == 100
- assert pendingAcquireMaxCount == 22
- assert maximumInMemorySizeInMegabytes == 7
+ expect: 'properties are populated correctly for data services'
+ with(dmiHttpClientConfig.dataServices) {
+ assert maximumInMemorySizeInMegabytes == 1
+ assert maximumConnectionsTotal == 2
+ assert pendingAcquireMaxCount == 3
+ assert connectionTimeoutInSeconds == 4
+ assert readTimeoutInSeconds == 5
+ assert writeTimeoutInSeconds == 6
}
}
def 'Test http client configuration properties of model with custom and default values'() {
- expect: 'properties are populated correctly for model'
- with(httpClientConfiguration.modelServices) {
- assert connectionTimeoutInSeconds == 456
- assert readTimeoutInSeconds == 30
- assert writeTimeoutInSeconds == 30
- assert maximumConnectionsTotal == 111
- assert pendingAcquireMaxCount == 44
- assert maximumInMemorySizeInMegabytes == 8
+ expect: 'properties are populated correctly for model services'
+ with(dmiHttpClientConfig.modelServices) {
+ assert maximumInMemorySizeInMegabytes == 11
+ assert maximumConnectionsTotal == 12
+ assert pendingAcquireMaxCount == 13
+ assert connectionTimeoutInSeconds == 14
+ assert readTimeoutInSeconds == 15
+ assert writeTimeoutInSeconds == 16
}
}
def 'Test http client configuration properties of health with default values'() {
- expect: 'properties are populated correctly for health'
- with(httpClientConfiguration.healthCheckServices) {
- assert connectionTimeoutInSeconds == 30
- assert readTimeoutInSeconds == 30
- assert writeTimeoutInSeconds == 30
- assert maximumConnectionsTotal == 10
- assert pendingAcquireMaxCount == 5
- assert maximumInMemorySizeInMegabytes == 1
+ expect: 'properties are populated correctly for health check services'
+ with(dmiHttpClientConfig.healthCheckServices) {
+ assert maximumInMemorySizeInMegabytes == 21
+ assert maximumConnectionsTotal == 22
+ assert pendingAcquireMaxCount == 23
+ assert connectionTimeoutInSeconds == 24
+ assert readTimeoutInSeconds == 25
+ assert writeTimeoutInSeconds == 26
}
}
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/PolicyExecutorHttpClientConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/PolicyExecutorHttpClientConfigSpec.groovy
new file mode 100644
index 0000000000..1946a452b1
--- /dev/null
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/config/PolicyExecutorHttpClientConfigSpec.groovy
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 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.
+ * 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.config
+
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.test.context.ContextConfiguration
+import spock.lang.Specification
+
+@SpringBootTest
+@ContextConfiguration(classes = [PolicyExecutorHttpClientConfig])
+@EnableConfigurationProperties
+class PolicyExecutorHttpClientConfigSpec extends Specification {
+
+ @Autowired
+ PolicyExecutorHttpClientConfig policyExecutorHttpClientConfig
+
+ def 'Test http client configuration properties of data with custom and default values'() {
+ expect: 'properties are populated correctly for all services'
+ with(policyExecutorHttpClientConfig.allServices) {
+ assert maximumInMemorySizeInMegabytes == 31
+ assert maximumConnectionsTotal == 32
+ assert pendingAcquireMaxCount == 33
+ assert connectionTimeoutInSeconds == 34
+ assert readTimeoutInSeconds == 35
+ assert writeTimeoutInSeconds == 36
+ }
+ }
+}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
index 8b369bf549..2324d48a93 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/DmiDataOperationsSpec.groovy
@@ -28,6 +28,7 @@ import org.onap.cps.ncmp.api.data.models.DataOperationRequest
import org.onap.cps.ncmp.api.exceptions.DmiClientRequestException
import org.onap.cps.ncmp.config.CpsApplicationContext
import org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent
+import org.onap.cps.ncmp.impl.data.policyexecutor.PolicyExecutor
import org.onap.cps.ncmp.impl.dmi.DmiOperationsBaseSpec
import org.onap.cps.ncmp.impl.dmi.DmiProperties
import org.onap.cps.ncmp.impl.dmi.UrlTemplateParameters
@@ -37,7 +38,6 @@ import org.onap.cps.ncmp.utils.TestUtils
import org.onap.cps.utils.JsonObjectMapper
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/PolicyExecutorSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/PolicyExecutorSpec.groovy
index 654206776b..4b09afa2ae 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/PolicyExecutorSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/data/PolicyExecutorSpec.groovy
@@ -4,6 +4,7 @@ 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.onap.cps.ncmp.impl.data.policyexecutor.PolicyExecutor
import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiWebClientConfigurationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiWebClientConfigurationSpec.groovy
deleted file mode 100644
index fca47d8c24..0000000000
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiWebClientConfigurationSpec.groovy
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 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.
- * 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.impl.dmi
-
-
-import org.onap.cps.ncmp.config.HttpClientConfiguration
-import org.springframework.boot.context.properties.EnableConfigurationProperties
-import org.springframework.boot.test.context.SpringBootTest
-import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.TestPropertySource
-import org.springframework.web.reactive.function.client.WebClient
-import spock.lang.Specification
-
-@SpringBootTest
-@ContextConfiguration(classes = [HttpClientConfiguration])
-@TestPropertySource(properties = ['ncmp.dmi.httpclient.data-services.connectionTimeoutInSeconds=1', 'ncmp.dmi.httpclient.model-services.maximumInMemorySizeInMegabytes=1'])
-@EnableConfigurationProperties
-class DmiWebClientConfigurationSpec extends Specification {
-
- def webClientBuilder = Mock(WebClient.Builder) {
- defaultHeaders(_) >> it
- clientConnector(_) >> it
- codecs(_) >> it
- build() >> Mock(WebClient)
- }
-
- def httpClientConfiguration = Spy(HttpClientConfiguration.class)
-
- def objectUnderTest = new DmiWebClientConfiguration(httpClientConfiguration)
-
- def 'Web Client Configuration construction.'() {
- expect: 'the system can create an instance'
- new DmiWebClientConfiguration(httpClientConfiguration) != null
- }
-
- def 'Creating a web client instance data service.'() {
- given: 'Web client configuration is invoked'
- def dataServicesWebClient = objectUnderTest.dataServicesWebClient(webClientBuilder)
- expect: 'the system can create an instance for data service'
- assert dataServicesWebClient != null
- assert dataServicesWebClient instanceof WebClient
- }
-
- def 'Creating a web client instance model service.'() {
- given: 'Web client configuration invoked'
- def modelServicesWebClient = objectUnderTest.modelServicesWebClient(webClientBuilder)
- expect: 'the system can create an instance for model service'
- assert modelServicesWebClient != null
- assert modelServicesWebClient instanceof WebClient
- }
-
- def 'Creating a web client instance health service.'() {
- given: 'Web client configuration invoked'
- def healthChecksWebClient = objectUnderTest.healthChecksWebClient(webClientBuilder)
- expect: 'the system can create an instance for health service'
- assert healthChecksWebClient != null
- assert healthChecksWebClient instanceof WebClient
- }
-}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiWebClientsConfigurationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiWebClientsConfigurationSpec.groovy
new file mode 100644
index 0000000000..cb209beef0
--- /dev/null
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/dmi/DmiWebClientsConfigurationSpec.groovy
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 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.
+ * 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.impl.dmi
+
+
+import org.onap.cps.ncmp.config.DmiHttpClientConfig
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.web.reactive.function.client.WebClient
+import spock.lang.Specification
+
+@SpringBootTest
+@ContextConfiguration(classes = [DmiHttpClientConfig])
+@EnableConfigurationProperties
+class DmiWebClientsConfigurationSpec extends Specification {
+
+ def webClientBuilder = Mock(WebClient.Builder) {
+ defaultHeaders(_) >> it
+ clientConnector(_) >> it
+ codecs(_) >> it
+ build() >> Mock(WebClient)
+ }
+
+ def dmiHttpClientConfiguration = Spy(DmiHttpClientConfig.class)
+
+ def objectUnderTest = new DmiWebClientsConfiguration(dmiHttpClientConfiguration)
+
+ def 'Web client for data services.'() {
+ when: 'creating a web client for dmi data services'
+ def result = objectUnderTest.dataServicesWebClient(webClientBuilder)
+ then: 'a web client is created successfully'
+ assert result != null
+ assert result instanceof WebClient
+ }
+
+ def 'Web client model services.'() {
+ when: 'creating a web client for dmi model services'
+ def result = objectUnderTest.modelServicesWebClient(webClientBuilder)
+ then: 'a web client is created successfully'
+ assert result != null
+ assert result instanceof WebClient
+ }
+
+ def 'Web client health check services.'() {
+ when: 'creating a web client for dmi health check services'
+ def result = objectUnderTest.healthChecksWebClient(webClientBuilder)
+ then: 'a web client is created successfully'
+ assert result != null
+ assert result instanceof WebClient
+ }
+}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/policyexecutor/PolicyExecutorWebClientConfigurationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/policyexecutor/PolicyExecutorWebClientConfigurationSpec.groovy
new file mode 100644
index 0000000000..cf5e1a383c
--- /dev/null
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/policyexecutor/PolicyExecutorWebClientConfigurationSpec.groovy
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 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.
+ * 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.impl.policyexecutor
+
+import org.onap.cps.ncmp.config.PolicyExecutorHttpClientConfig
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.web.reactive.function.client.WebClient
+import spock.lang.Specification
+
+@SpringBootTest
+@ContextConfiguration(classes = [PolicyExecutorHttpClientConfig])
+@EnableConfigurationProperties
+class PolicyExecutorWebClientConfigurationSpec extends Specification {
+
+ def webClientBuilder = Mock(WebClient.Builder) {
+ defaultHeaders(_) >> it
+ clientConnector(_) >> it
+ codecs(_) >> it
+ build() >> Mock(WebClient)
+ }
+
+ def httpClientConfiguration = Spy(PolicyExecutorHttpClientConfig.class)
+
+ def objectUnderTest = new PolicyExecutorWebClientConfiguration(httpClientConfiguration)
+
+ def 'Web client policy executor.'() {
+ when: 'create a web client for policy executor'
+ def result = objectUnderTest.policyExecutorWebClient(webClientBuilder)
+ then: 'a web client is created successfully'
+ assert result != null
+ assert result instanceof WebClient
+ }
+}