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</groupId>
34 <artifactId>blueprintsprocessor-application</artifactId>
35 <version>${project.parent.version}</version>
38 <groupId>org.springframework.boot</groupId>
39 <artifactId>spring-boot-starter-test</artifactId>
44 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
45 <artifactId>execution-service</artifactId>
48 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
49 <artifactId>resource-resolution</artifactId>
52 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
53 <artifactId>netconf-executor</artifactId>
56 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
57 <artifactId>restconf-executor</artifactId>
60 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
61 <artifactId>cli-executor</artifactId>
64 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
65 <artifactId>message-prioritization</artifactId>
68 <groupId>org.jetbrains.kotlin</groupId>
69 <artifactId>kotlin-test-junit</artifactId>
73 <groupId>org.jetbrains.kotlinx</groupId>
74 <artifactId>kotlinx-coroutines-test</artifactId>
78 <groupId>junit</groupId>
79 <artifactId>junit</artifactId>
80 <version>4.12</version>
84 <groupId>io.mockk</groupId>
85 <artifactId>mockk</artifactId>
86 <version>1.10.0</version>
90 <groupId>com.squareup.okhttp3</groupId>
91 <artifactId>okhttp</artifactId>
92 <version>4.9.3</version>
97 <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
98 <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
101 <directory>${project.basedir}/Environments</directory>
106 <directory>${project.basedir}/Tests/resources</directory>
111 <groupId>org.jacoco</groupId>
112 <artifactId>jacoco-maven-plugin</artifactId>
115 <id>pre-unit-test</id>
119 <id>default-prepare-agent</id>
123 <id>post-unit-test</id>
127 <id>default-report</id>
131 <id>pre-integration-test</id>
135 <id>post-integration-test</id>
139 <id>default-check</id>
145 <groupId>org.jetbrains.kotlin</groupId>
146 <artifactId>kotlin-maven-plugin</artifactId>
150 <phase>compile</phase>
156 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
161 <id>test-compile</id>
162 <phase>test-compile</phase>
164 <goal>test-compile</goal>
168 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
175 <groupId>org.apache.maven.plugins</groupId>
176 <artifactId>maven-site-plugin</artifactId>
179 <id>attach-descriptor</id>
185 <artifactId>maven-checkstyle-plugin</artifactId>
188 <id>check-license</id>
198 <artifactId>maven-assembly-plugin</artifactId>
201 <groupId>org.onap.ccsdk.cds.components.cba</groupId>
202 <artifactId>cba-assembly-descriptor</artifactId>
203 <version>${ccsdk.cds.version}</version>
207 <artifactId>*</artifactId>
214 <id>make-assembly</id>
215 <phase>package</phase>
221 <descriptorRef>cba_zip</descriptorRef>
228 <groupId>org.apache.maven.plugins</groupId>
229 <artifactId>maven-failsafe-plugin</artifactId>
236 <id>integration-tests</id>
242 <artifactId>maven-surefire-plugin</artifactId>
243 <version>${maven-surefire-plugin.version}</version>
246 <id>default-test</id>
249 <!-- Sets the VM argument line used when unit tests are run. -->
250 <argLine>-Xmx1024m </argLine>
251 <reuseForks>false</reuseForks>
252 <forkCount>1</forkCount>
261 <artifactId>maven-resources-plugin</artifactId>
262 <version>2.6</version>
265 <id>copy-test-resources</id>
267 <goal>testResources</goal>
269 <phase>process-test-resources</phase>
282 <groupId>org.codehaus.gmaven</groupId>
283 <artifactId>groovy-maven-plugin</artifactId>
286 <groupId>com.squareup.okhttp3</groupId>
287 <artifactId>okhttp</artifactId>
288 <version>3.14.0</version>
291 <groupId>commons-io</groupId>
292 <artifactId>commons-io</artifactId>
293 <version>${commons-io-version}</version>
299 <phase>install</phase>
305 import okhttp3.Credentials
306 import okhttp3.MediaType
307 import okhttp3.MultipartBody
308 import okhttp3.OkHttpClient
309 import okhttp3.Request
310 import okhttp3.RequestBody
311 import org.apache.commons.io.IOUtils
315 target = "${basedir.absolutePath}/target"
316 userName = throwIfPropMissing('cds.username')
317 password = throwIfPropMissing('cds.password')
318 protocol = properties['cds.protocol'] ?: 'http'
319 host = properties['cds.host'] ?: 'localhost'
320 port = properties['cds.port'] ?: '8081'
322 def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
323 def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
324 def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
325 def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'
327 def throwIfPropMissing(prop) {
328 value = properties[prop]
329 if (!value || "".equals(value)) {
330 throw new RuntimeException("Property missing: $prop")
335 def buildRequest(endpoint, fileName) {
336 body = new MultipartBody.Builder()
337 .setType(MultipartBody.FORM)
338 .addFormDataPart("file",
340 RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
343 return new Request.Builder()
344 .url("$protocol://$host:$port/$endpoint")
345 .addHeader('Authorization', Credentials.basic(userName, password))
350 def logAndThrow(msg) {
352 log.error(response.body().string())
354 throw new RuntimeException(msg)
359 def client = new OkHttpClient()
361 response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
362 if (!response || !response.isSuccessful()) {
363 logAndThrow("Failed to enrich CBA")
367 response.body().byteStream(),
368 new FileOutputStream(new File(target, enrichedCba))
370 log.info("Created enriched cba: $enrichedCba")
372 response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
373 if (!response || !response.isSuccessful()) {
374 logAndThrow("Failed to publish CBA")
377 log.info("CBA Deployed")
378 log.info(response.body().string())