diff options
Diffstat (limited to 'ms/blueprintsprocessor/application')
7 files changed, 90 insertions, 63 deletions
diff --git a/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties b/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties index 16e5b32d3..3405edab7 100755 --- a/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties +++ b/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties @@ -26,7 +26,7 @@ server.port=8081 ### START -Controller Blueprints Properties # Load Resource Source Mappings -resourceSourceMappings=processor-db=source-processor-db,primary-db=source-processor-db,input=source-input,default=source-default,primary-config-data=source-rest,primary-aai-data=source-rest,capability=source-capability +resourceSourceMappings=processor-db=source-db,input=source-input,default=source-default,config-data=source-rest,aai-data=source-rest,capability=source-capability # Controller Blueprints Core Configuration controllerblueprints.blueprintDeployPath=blueprints/deploy @@ -67,14 +67,14 @@ blueprintsprocessor.blueprintDeployPath=blueprints/deploy blueprintsprocessor.blueprintArchivePath=blueprints/archive blueprintsprocessor.blueprintWorkingPath=blueprints/work # Primary Database Configuration -blueprintsprocessor.db.primary.url=jdbc:mysql://localhost:3306/sdnctl -blueprintsprocessor.db.primary.username=sdnctl -blueprintsprocessor.db.primary.password=sdnctl -blueprintsprocessor.db.primary.driverClassName=org.mariadb.jdbc.Driver -blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=update -blueprintsprocessor.db.primary.hibernateDDLAuto=none -blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy -blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.MySQL5InnoDBDialect +blueprintsprocessor.db.url=jdbc:mysql://localhost:3306/sdnctl +blueprintsprocessor.db.username=sdnctl +blueprintsprocessor.db.password=sdnctl +blueprintsprocessor.db.driverClassName=org.mariadb.jdbc.Driver +blueprintsprocessor.db.hibernateHbm2ddlAuto=update +blueprintsprocessor.db.hibernateDDLAuto=none +blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy +blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.MySQL5InnoDBDialect # Python executor ### If testing in docker, use the absolute paths as Docker view of filesystem will not respect relative paths. diff --git a/ms/blueprintsprocessor/application/src/main/resources/application.properties b/ms/blueprintsprocessor/application/src/main/resources/application.properties index bc297efb4..3ea588da3 100755 --- a/ms/blueprintsprocessor/application/src/main/resources/application.properties +++ b/ms/blueprintsprocessor/application/src/main/resources/application.properties @@ -16,7 +16,7 @@ # Web server config ### START -Controller Blueprints Properties # Load Resource Source Mappings -resourceSourceMappings=processor-db=source-processor-db,primary-db=source-processor-db,input=source-input,default=source-default,primary-config-data=source-rest,primary-aai-data=source-rest,capability=source-capability +resourceSourceMappings=processor-db=source-db,input=source-input,default=source-default,config-data=source-rest,aai-data=source-rest,capability=source-capability # Controller Blueprints Core Configuration controllerblueprints.blueprintDeployPath=/opt/app/onap/blueprints/deploy @@ -48,14 +48,14 @@ blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive blueprintsprocessor.blueprintWorkingPath=/opt/app/onap/blueprints/working # Primary Database Configuration -blueprintsprocessor.db.primary.url=jdbc:mysql://db:3306/sdnctl -blueprintsprocessor.db.primary.username=sdnctl -blueprintsprocessor.db.primary.password=sdnctl -blueprintsprocessor.db.primary.driverClassName=org.mariadb.jdbc.Driver -blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=update -blueprintsprocessor.db.primary.hibernateDDLAuto=update -blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy -blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.MySQL5InnoDBDialect +blueprintsprocessor.db.url=jdbc:mysql://db:3306/sdnctl +blueprintsprocessor.db.username=sdnctl +blueprintsprocessor.db.password=sdnctl +blueprintsprocessor.db.driverClassName=org.mariadb.jdbc.Driver +blueprintsprocessor.db.hibernateHbm2ddlAuto=update +blueprintsprocessor.db.hibernateDDLAuto=update +blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy +blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.MySQL5InnoDBDialect # Python executor blueprints.processor.functions.python.executor.executionPath=/opt/app/onap/scripts/jython/ccsdk_blueprints @@ -85,16 +85,16 @@ blueprintsprocessor.grpcclient.remote-python.token=Basic Y2NzZGthcHBzOmNjc2RrYXB # Primary Config Data REST client settings -blueprintsprocessor.restclient.primary-config-data.type=basic-auth -blueprintsprocessor.restclient.primary-config-data.url=http://sdnc:8282 -blueprintsprocessor.restclient.primary-config-data.username=admin -blueprintsprocessor.restclient.primary-config-data.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U +blueprintsprocessor.restclient.config-data.type=basic-auth +blueprintsprocessor.restclient.config-data.url=http://sdnc:8282 +blueprintsprocessor.restclient.config-data.username=admin +blueprintsprocessor.restclient.config-data.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U # Primary AAI Data REST Client settings -blueprintsprocessor.restclient.primary-aai-data.type=basic-auth -blueprintsprocessor.restclient.primary-aai-data.url=https://aai.onap:8443 -blueprintsprocessor.restclient.primary-aai-data.username=aai@aai.onap.org -blueprintsprocessor.restclient.primary-aai-data.password=demo123456! +blueprintsprocessor.restclient.aai-data.type=basic-auth +blueprintsprocessor.restclient.aai-data.url=https://aai.onap:8443 +blueprintsprocessor.restclient.aai-data.username=aai@aai.onap.org +blueprintsprocessor.restclient.aai-data.password=demo123456! # Kafka-message-lib Configuration blueprintsprocessor.messageclient.self-service-api.topic=producer.t diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintsAcceptanceTest.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintsAcceptanceTest.kt index adb6de101..dfa0a8563 100644 --- a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintsAcceptanceTest.kt +++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintsAcceptanceTest.kt @@ -131,10 +131,10 @@ class BlueprintsAcceptanceTest(private val blueprintName: String, private val fi uploadBlueprint(blueprintName) - // Configure mocked external services - val expectationPerClient = uat.externalServices.associateBy( + // Configure mocked external services and save their expected requests for further validation + val requestsPerClient = uat.externalServices.associateBy( { service -> createRestClientMock(service.selector, service.expectations) }, - { service -> service.expectations } + { service -> service.expectations.map { it.request } } ) // Run processes @@ -144,14 +144,14 @@ class BlueprintsAcceptanceTest(private val blueprintName: String, private val fi JsonNormalizer.getNormalizer(mapper, process.responseNormalizerSpec)) } - // Validate request payloads to external services - for ((mockClient, expectations) in expectationPerClient) { - expectations.forEach { expectation -> + // Validate requests to external services + for ((mockClient, requests) in requestsPerClient) { + requests.forEach { request -> verify(mockClient, atLeastOnce()).exchangeResource( - eq(expectation.request.method), - eq(expectation.request.path), - argThat { assertJsonEqual(expectation.request.body, this) }, - expectation.request.requestHeadersMatcher()) + eq(request.method), + eq(request.path), + argThat { assertJsonEqual(request.body, this) }, + argThat(RequiredMapEntriesMatcher(request.headers))) } // Don't mind the invocations to the overloaded exchangeResource(String, String, String) verify(mockClient, atLeast(0)).exchangeResource(any(), any(), any()) diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/MoreMatchers.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/MoreMatchers.kt new file mode 100644 index 000000000..71e07ab4c --- /dev/null +++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/MoreMatchers.kt @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 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.ccsdk.cds.blueprintsprocessor + +import com.google.common.collect.Maps +import org.mockito.ArgumentMatcher + +class RequiredMapEntriesMatcher<K, V>(private val requiredEntries: Map<K, V>) : ArgumentMatcher<Map<K, V>> { + override fun matches(argument: Map<K, V>?): Boolean { + val missingEntries = Maps.difference(requiredEntries, argument).entriesOnlyOnLeft() + return missingEntries.isEmpty() + } + + override fun toString(): String { + return requiredEntries.toString() + } +} diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/UatDefinition.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/UatDefinition.kt index ce2061168..abb1dfcd1 100644 --- a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/UatDefinition.kt +++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/UatDefinition.kt @@ -24,8 +24,6 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.node.MissingNode -import com.nhaarman.mockitokotlin2.any -import com.nhaarman.mockitokotlin2.eq import org.yaml.snakeyaml.Yaml import java.nio.file.Path @@ -35,13 +33,8 @@ data class ProcessDefinition(val name: String, val request: JsonNode, val expect data class RequestDefinition(val method: String, @JsonDeserialize(using = PathDeserializer::class) val path: String, - @JsonAlias("content-type") - val contentType: String? = null, - val body: JsonNode = MissingNode.getInstance()) { - fun requestHeadersMatcher(): Map<String, String> { - return if (contentType != null) eq(mapOf("Content-Type" to contentType)) else any() - } -} + val headers: Map<String, String> = emptyMap(), + val body: JsonNode = MissingNode.getInstance()) data class ResponseDefinition(val status: Int = 200, val body: JsonNode = MissingNode.getInstance()) { companion object { diff --git a/ms/blueprintsprocessor/application/src/test/resources/application-test.properties b/ms/blueprintsprocessor/application/src/test/resources/application-test.properties index b8b80f2dd..74c8a2380 100644 --- a/ms/blueprintsprocessor/application/src/test/resources/application-test.properties +++ b/ms/blueprintsprocessor/application/src/test/resources/application-test.properties @@ -20,14 +20,14 @@ blueprintsprocessor.httpPort=0 blueprintsprocessor.grpcEnable=true blueprintsprocessor.grpcPort=0 -blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;MODE=MySQL;DB_CLOSE_DELAY=-1 -blueprintsprocessor.db.primary.username=sa -blueprintsprocessor.db.primary.password= -blueprintsprocessor.db.primary.driverClassName=org.h2.Driver -blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop -blueprintsprocessor.db.primary.hibernateDDLAuto=update -blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy -blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect +blueprintsprocessor.db.url=jdbc:h2:mem:testdb;MODE=MySQL;DB_CLOSE_DELAY=-1 +blueprintsprocessor.db.username=sa +blueprintsprocessor.db.password= +blueprintsprocessor.db.driverClassName=org.h2.Driver +blueprintsprocessor.db.hibernateHbm2ddlAuto=create-drop +blueprintsprocessor.db.hibernateDDLAuto=update +blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy +blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.H2Dialect # The properties bellow are set programmatically #blueprintsprocessor.blueprintDeployPath= @@ -47,4 +47,4 @@ blueprints.processor.functions.python.executor.modulePaths=\ blueprintsprocessor.cliExecutor.enabled=true blueprintprocessor.netconfExecutor.enabled=true -blueprintsprocessor.restconfEnabled=true
\ No newline at end of file +blueprintsprocessor.restconfEnabled=true diff --git a/ms/blueprintsprocessor/application/src/test/resources/application.properties b/ms/blueprintsprocessor/application/src/test/resources/application.properties index 06f3e948c..e50ebdefb 100644 --- a/ms/blueprintsprocessor/application/src/test/resources/application.properties +++ b/ms/blueprintsprocessor/application/src/test/resources/application.properties @@ -19,7 +19,7 @@ server.port=8080 ### START -Controller Blueprints Properties # Load Resource Source Mappings -resourceSourceMappings=processor-db=source-processor-db,primary-db=source-processor-db,input=source-input,default=source-default,primary-config-data=source-rest,primary-aai-data=source-rest,capability=source-capability +resourceSourceMappings=processor-db=source-db,input=source-input,default=source-default,config-data=source-rest,aai-data=source-rest,capability=source-capability # Controller Blueprints Core Configuration controllerblueprints.blueprintDeployPath=/opt/app/onap/blueprints/deploy @@ -49,14 +49,14 @@ blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive blueprintsprocessor.blueprintWorkingPath=/opt/app/onap/blueprints/work # Primary Database Configuration -blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE -blueprintsprocessor.db.primary.username=sa -blueprintsprocessor.db.primary.password= -blueprintsprocessor.db.primary.driverClassName=org.h2.Driver -blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop -blueprintsprocessor.db.primary.hibernateDDLAuto=update -blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy -blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect +blueprintsprocessor.db.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE +blueprintsprocessor.db.username=sa +blueprintsprocessor.db.password= +blueprintsprocessor.db.driverClassName=org.h2.Driver +blueprintsprocessor.db.hibernateHbm2ddlAuto=create-drop +blueprintsprocessor.db.hibernateDDLAuto=update +blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy +blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.H2Dialect # Python executor blueprints.processor.functions.python.executor.executionPath=/opt/app/onap/scripts/jython/ccsdk_blueprints blueprints.processor.functions.python.executor.modulePaths=/opt/app/onap/scripts/jython/ccsdk_blueprints |