1 <?xml version="1.0" encoding="UTF-8"?>
3 ~ Copyright © 2020 Bell Canada
5 ~ Licensed under the Apache License, Version 2.0 (the "License");
6 ~ you may not use this file except in compliance with the License.
7 ~ You may obtain a copy of the License at
9 ~ http://www.apache.org/licenses/LICENSE-2.0
11 ~ Unless required by applicable law or agreed to in writing, software
12 ~ distributed under the License is distributed on an "AS IS" BASIS,
13 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ~ See the License for the specific language governing permissions and
15 ~ limitations under the License.
17 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18 <modelVersion>4.0.0</modelVersion>
21 <groupId>org.onap.ccsdk.cds.components.cba</groupId>
22 <artifactId>blueprint-model</artifactId>
23 <version>1.4.0-SNAPSHOT</version>
26 <artifactId>test-blueprint-kotlin-parent</artifactId>
27 <packaging>pom</packaging>
29 <name>Components Model Catalog - Blueprints Model - Test Kotlin Parent</name>
33 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
34 <artifactId>execution-service</artifactId>
37 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
38 <artifactId>resource-resolution</artifactId>
41 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
42 <artifactId>netconf-executor</artifactId>
45 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
46 <artifactId>restconf-executor</artifactId>
49 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
50 <artifactId>cli-executor</artifactId>
53 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
54 <artifactId>message-prioritization</artifactId>
57 <groupId>org.jetbrains.kotlin</groupId>
58 <artifactId>kotlin-test-junit</artifactId>
62 <groupId>org.jetbrains.kotlinx</groupId>
63 <artifactId>kotlinx-coroutines-test</artifactId>
67 <groupId>junit</groupId>
68 <artifactId>junit</artifactId>
69 <version>4.12</version>
73 <groupId>io.mockk</groupId>
74 <artifactId>mockk</artifactId>
75 <version>1.10.0</version>
79 <groupId>com.squareup.okhttp3</groupId>
80 <artifactId>okhttp</artifactId>
81 <version>4.9.3</version>
86 <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
87 <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
90 <directory>${project.basedir}/Environments</directory>
95 <groupId>org.jacoco</groupId>
96 <artifactId>jacoco-maven-plugin</artifactId>
99 <id>pre-unit-test</id>
103 <id>default-prepare-agent</id>
107 <id>post-unit-test</id>
111 <id>default-report</id>
115 <id>pre-integration-test</id>
119 <id>post-integration-test</id>
123 <id>default-check</id>
129 <groupId>org.jetbrains.kotlin</groupId>
130 <artifactId>kotlin-maven-plugin</artifactId>
134 <phase>compile</phase>
140 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
145 <id>test-compile</id>
146 <phase>test-compile</phase>
148 <goal>test-compile</goal>
152 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
159 <groupId>org.apache.maven.plugins</groupId>
160 <artifactId>maven-site-plugin</artifactId>
163 <id>attach-descriptor</id>
169 <artifactId>maven-checkstyle-plugin</artifactId>
172 <id>check-license</id>
182 <artifactId>maven-assembly-plugin</artifactId>
185 <groupId>org.onap.ccsdk.cds.components.cba</groupId>
186 <artifactId>cba-assembly-descriptor</artifactId>
187 <version>${ccsdk.cds.version}</version>
191 <artifactId>*</artifactId>
198 <id>make-assembly</id>
199 <phase>package</phase>
205 <descriptorRef>cba_zip</descriptorRef>
212 <groupId>org.apache.maven.plugins</groupId>
213 <artifactId>maven-failsafe-plugin</artifactId>
220 <id>integration-tests</id>
226 <artifactId>maven-surefire-plugin</artifactId>
229 <id>default-test</id>
246 <groupId>org.codehaus.gmaven</groupId>
247 <artifactId>groovy-maven-plugin</artifactId>
250 <groupId>com.squareup.okhttp3</groupId>
251 <artifactId>okhttp</artifactId>
252 <version>3.14.0</version>
255 <groupId>commons-io</groupId>
256 <artifactId>commons-io</artifactId>
257 <version>${commons-io-version}</version>
263 <phase>install</phase>
269 import okhttp3.Credentials
270 import okhttp3.MediaType
271 import okhttp3.MultipartBody
272 import okhttp3.OkHttpClient
273 import okhttp3.Request
274 import okhttp3.RequestBody
275 import org.apache.commons.io.IOUtils
279 target = "${basedir.absolutePath}/target"
280 userName = throwIfPropMissing('cds.username')
281 password = throwIfPropMissing('cds.password')
282 protocol = properties['cds.protocol'] ?: 'http'
283 host = properties['cds.host'] ?: 'localhost'
284 port = properties['cds.port'] ?: '8081'
286 def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
287 def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
288 def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
289 def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'
291 def throwIfPropMissing(prop) {
292 value = properties[prop]
293 if (!value || "".equals(value)) {
294 throw new RuntimeException("Property missing: $prop")
299 def buildRequest(endpoint, fileName) {
300 body = new MultipartBody.Builder()
301 .setType(MultipartBody.FORM)
302 .addFormDataPart("file",
304 RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
307 return new Request.Builder()
308 .url("$protocol://$host:$port/$endpoint")
309 .addHeader('Authorization', Credentials.basic(userName, password))
314 def logAndThrow(msg) {
316 log.error(response.body().string())
318 throw new RuntimeException(msg)
323 def client = new OkHttpClient()
325 response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
326 if (!response || !response.isSuccessful()) {
327 logAndThrow("Failed to enrich CBA")
331 response.body().byteStream(),
332 new FileOutputStream(new File(target, enrichedCba))
334 log.info("Created enriched cba: $enrichedCba")
336 response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
337 if (!response || !response.isSuccessful()) {
338 logAndThrow("Failed to publish CBA")
341 log.info("CBA Deployed")
342 log.info(response.body().string())