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.
18 <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">
19 <modelVersion>4.0.0</modelVersion>
22 <groupId>org.onap.ccsdk.cds.components.cba</groupId>
23 <artifactId>blueprint-model</artifactId>
24 <version>1.5.0-SNAPSHOT</version>
27 <artifactId>test-blueprint-kotlin-parent</artifactId>
28 <packaging>pom</packaging>
30 <name>Components Model Catalog - Blueprints Model - Test Kotlin Parent</name>
34 <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
35 <artifactId>blueprintsprocessor-application</artifactId>
36 <version>${project.parent.version}</version>
39 <groupId>org.springframework.boot</groupId>
40 <artifactId>spring-boot-starter-test</artifactId>
45 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
46 <artifactId>execution-service</artifactId>
49 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
50 <artifactId>resource-resolution</artifactId>
53 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
54 <artifactId>netconf-executor</artifactId>
57 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
58 <artifactId>restconf-executor</artifactId>
61 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
62 <artifactId>cli-executor</artifactId>
65 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
66 <artifactId>message-prioritization</artifactId>
69 <groupId>org.jetbrains.kotlin</groupId>
70 <artifactId>kotlin-test-junit</artifactId>
74 <groupId>org.jetbrains.kotlinx</groupId>
75 <artifactId>kotlinx-coroutines-test</artifactId>
79 <groupId>junit</groupId>
80 <artifactId>junit</artifactId>
81 <version>4.12</version>
85 <groupId>io.mockk</groupId>
86 <artifactId>mockk</artifactId>
87 <version>1.10.0</version>
91 <groupId>com.squareup.okhttp3</groupId>
92 <artifactId>okhttp</artifactId>
93 <version>4.9.3</version>
98 <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
99 <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
102 <directory>${project.basedir}/Environments</directory>
107 <directory>${project.basedir}/Tests/resources</directory>
112 <groupId>org.jacoco</groupId>
113 <artifactId>jacoco-maven-plugin</artifactId>
116 <id>pre-unit-test</id>
120 <id>default-prepare-agent</id>
124 <id>post-unit-test</id>
128 <id>default-report</id>
132 <id>pre-integration-test</id>
136 <id>post-integration-test</id>
140 <id>default-check</id>
146 <groupId>org.jetbrains.kotlin</groupId>
147 <artifactId>kotlin-maven-plugin</artifactId>
151 <phase>compile</phase>
157 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
162 <id>test-compile</id>
163 <phase>test-compile</phase>
165 <goal>test-compile</goal>
169 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
176 <groupId>org.apache.maven.plugins</groupId>
177 <artifactId>maven-site-plugin</artifactId>
180 <id>attach-descriptor</id>
186 <artifactId>maven-checkstyle-plugin</artifactId>
189 <id>check-license</id>
199 <artifactId>maven-assembly-plugin</artifactId>
202 <groupId>org.onap.ccsdk.cds.components.cba</groupId>
203 <artifactId>cba-assembly-descriptor</artifactId>
204 <version>${ccsdk.cds.version}</version>
208 <artifactId>*</artifactId>
215 <id>make-assembly</id>
216 <phase>package</phase>
222 <descriptorRef>cba_zip</descriptorRef>
229 <groupId>org.apache.maven.plugins</groupId>
230 <artifactId>maven-failsafe-plugin</artifactId>
237 <id>integration-tests</id>
243 <artifactId>maven-surefire-plugin</artifactId>
244 <version>${maven-surefire-plugin.version}</version>
247 <id>default-test</id>
250 <!-- Sets the VM argument line used when unit tests are run. -->
251 <argLine>-Xmx1024m </argLine>
252 <reuseForks>false</reuseForks>
253 <forkCount>1</forkCount>
262 <artifactId>maven-resources-plugin</artifactId>
263 <version>2.6</version>
266 <id>copy-test-resources</id>
268 <goal>testResources</goal>
270 <phase>process-test-resources</phase>
283 <groupId>org.codehaus.gmaven</groupId>
284 <artifactId>groovy-maven-plugin</artifactId>
287 <groupId>com.squareup.okhttp3</groupId>
288 <artifactId>okhttp</artifactId>
289 <version>3.14.0</version>
292 <groupId>commons-io</groupId>
293 <artifactId>commons-io</artifactId>
294 <version>${commons-io-version}</version>
300 <phase>install</phase>
306 import okhttp3.Credentials
307 import okhttp3.MediaType
308 import okhttp3.MultipartBody
309 import okhttp3.OkHttpClient
310 import okhttp3.Request
311 import okhttp3.RequestBody
312 import org.apache.commons.io.IOUtils
316 target = "${basedir.absolutePath}/target"
317 userName = throwIfPropMissing('cds.username')
318 password = throwIfPropMissing('cds.password')
319 protocol = properties['cds.protocol'] ?: 'http'
320 host = properties['cds.host'] ?: 'localhost'
321 port = properties['cds.port'] ?: '8081'
323 def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
324 def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
325 def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
326 def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'
328 def throwIfPropMissing(prop) {
329 value = properties[prop]
330 if (!value || "".equals(value)) {
331 throw new RuntimeException("Property missing: $prop")
336 def buildRequest(endpoint, fileName) {
337 body = new MultipartBody.Builder()
338 .setType(MultipartBody.FORM)
339 .addFormDataPart("file",
341 RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
344 return new Request.Builder()
345 .url("$protocol://$host:$port/$endpoint")
346 .addHeader('Authorization', Credentials.basic(userName, password))
351 def logAndThrow(msg) {
353 log.error(response.body().string())
355 throw new RuntimeException(msg)
360 def client = new OkHttpClient()
362 response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
363 if (!response || !response.isSuccessful()) {
364 logAndThrow("Failed to enrich CBA")
368 response.body().byteStream(),
369 new FileOutputStream(new File(target, enrichedCba))
371 log.info("Created enriched cba: $enrichedCba")
373 response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
374 if (!response || !response.isSuccessful()) {
375 logAndThrow("Failed to publish CBA")
378 log.info("CBA Deployed")
379 log.info(response.body().string())