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.6.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>
43 <groupId>org.junit.vintage</groupId>
44 <artifactId>junit-vintage-engine</artifactId>
48 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
49 <artifactId>execution-service</artifactId>
52 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
53 <artifactId>resource-resolution</artifactId>
56 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
57 <artifactId>netconf-executor</artifactId>
60 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
61 <artifactId>restconf-executor</artifactId>
64 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
65 <artifactId>cli-executor</artifactId>
68 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
69 <artifactId>message-prioritization</artifactId>
72 <groupId>org.jetbrains.kotlin</groupId>
73 <artifactId>kotlin-test-junit</artifactId>
77 <groupId>org.jetbrains.kotlinx</groupId>
78 <artifactId>kotlinx-coroutines-test</artifactId>
82 <groupId>junit</groupId>
83 <artifactId>junit</artifactId>
84 <version>4.13.1</version>
88 <groupId>io.mockk</groupId>
89 <artifactId>mockk</artifactId>
90 <version>1.10.0</version>
94 <groupId>com.squareup.okhttp3</groupId>
95 <artifactId>okhttp</artifactId>
96 <version>4.10.0</version>
101 <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
102 <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
105 <directory>${project.basedir}/Environments</directory>
110 <directory>${project.basedir}/Tests/resources</directory>
115 <groupId>org.jacoco</groupId>
116 <artifactId>jacoco-maven-plugin</artifactId>
119 <id>pre-unit-test</id>
123 <id>default-prepare-agent</id>
127 <id>post-unit-test</id>
131 <id>default-report</id>
135 <id>pre-integration-test</id>
139 <id>post-integration-test</id>
143 <id>default-check</id>
149 <groupId>org.jetbrains.kotlin</groupId>
150 <artifactId>kotlin-maven-plugin</artifactId>
154 <phase>compile</phase>
160 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
165 <id>test-compile</id>
166 <phase>test-compile</phase>
168 <goal>test-compile</goal>
172 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
179 <groupId>org.apache.maven.plugins</groupId>
180 <artifactId>maven-site-plugin</artifactId>
183 <id>attach-descriptor</id>
189 <artifactId>maven-checkstyle-plugin</artifactId>
192 <id>check-license</id>
202 <artifactId>maven-assembly-plugin</artifactId>
205 <groupId>org.onap.ccsdk.cds.components.cba</groupId>
206 <artifactId>cba-assembly-descriptor</artifactId>
207 <version>${ccsdk.cds.version}</version>
211 <artifactId>*</artifactId>
218 <id>make-assembly</id>
219 <phase>package</phase>
225 <descriptorRef>cba_zip</descriptorRef>
232 <groupId>org.apache.maven.plugins</groupId>
233 <artifactId>maven-failsafe-plugin</artifactId>
240 <id>integration-tests</id>
246 <artifactId>maven-surefire-plugin</artifactId>
247 <version>${maven-surefire-plugin.version}</version>
250 <id>default-test</id>
253 <!-- Sets the VM argument line used when unit tests are run. -->
254 <argLine>-Xmx1024m </argLine>
255 <reuseForks>false</reuseForks>
256 <forkCount>1</forkCount>
265 <artifactId>maven-resources-plugin</artifactId>
266 <version>2.6</version>
269 <id>copy-test-resources</id>
271 <goal>testResources</goal>
273 <phase>process-test-resources</phase>
286 <groupId>org.codehaus.gmaven</groupId>
287 <artifactId>groovy-maven-plugin</artifactId>
290 <groupId>com.squareup.okhttp3</groupId>
291 <artifactId>okhttp</artifactId>
292 <version>4.10.0</version>
295 <groupId>commons-io</groupId>
296 <artifactId>commons-io</artifactId>
297 <version>${commons-io-version}</version>
303 <phase>install</phase>
309 import okhttp3.Credentials
310 import okhttp3.MediaType
311 import okhttp3.MultipartBody
312 import okhttp3.OkHttpClient
313 import okhttp3.Request
314 import okhttp3.RequestBody
315 import org.apache.commons.io.IOUtils
319 target = "${basedir.absolutePath}/target"
320 userName = throwIfPropMissing('cds.username')
321 password = throwIfPropMissing('cds.password')
322 protocol = properties['cds.protocol'] ?: 'http'
323 host = properties['cds.host'] ?: 'localhost'
324 port = properties['cds.port'] ?: '8081'
326 def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
327 def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
328 def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
329 def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'
331 def throwIfPropMissing(prop) {
332 value = properties[prop]
333 if (!value || "".equals(value)) {
334 throw new RuntimeException("Property missing: $prop")
339 def buildRequest(endpoint, fileName) {
340 body = new MultipartBody.Builder()
341 .setType(MultipartBody.FORM)
342 .addFormDataPart("file",
344 RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
347 return new Request.Builder()
348 .url("$protocol://$host:$port/$endpoint")
349 .addHeader('Authorization', Credentials.basic(userName, password))
354 def logAndThrow(msg) {
356 log.error(response.body().string())
358 throw new RuntimeException(msg)
363 def client = new OkHttpClient()
365 response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
366 if (!response || !response.isSuccessful()) {
367 logAndThrow("Failed to enrich CBA")
371 response.body().byteStream(),
372 new FileOutputStream(new File(target, enrichedCba))
374 log.info("Created enriched cba: $enrichedCba")
376 response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
377 if (!response || !response.isSuccessful()) {
378 logAndThrow("Failed to publish CBA")
381 log.info("CBA Deployed")
382 log.info(response.body().string())