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.2.1-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.modules</groupId>
35 <artifactId>execution-service</artifactId>
38 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
39 <artifactId>resource-resolution</artifactId>
42 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
43 <artifactId>netconf-executor</artifactId>
46 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
47 <artifactId>restconf-executor</artifactId>
50 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
51 <artifactId>cli-executor</artifactId>
54 <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
55 <artifactId>message-prioritization</artifactId>
58 <groupId>org.jetbrains.kotlin</groupId>
59 <artifactId>kotlin-test-junit</artifactId>
63 <groupId>org.jetbrains.kotlinx</groupId>
64 <artifactId>kotlinx-coroutines-test</artifactId>
68 <groupId>junit</groupId>
69 <artifactId>junit</artifactId>
70 <version>4.12</version>
74 <groupId>io.mockk</groupId>
75 <artifactId>mockk</artifactId>
76 <version>1.10.0</version>
80 <groupId>com.squareup.okhttp3</groupId>
81 <artifactId>okhttp</artifactId>
82 <version>3.14.0</version>
87 <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
88 <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
91 <directory>${project.basedir}/Environments</directory>
96 <groupId>org.jacoco</groupId>
97 <artifactId>jacoco-maven-plugin</artifactId>
100 <id>pre-unit-test</id>
104 <id>default-prepare-agent</id>
108 <id>post-unit-test</id>
112 <id>default-report</id>
116 <id>pre-integration-test</id>
120 <id>post-integration-test</id>
124 <id>default-check</id>
130 <groupId>org.jetbrains.kotlin</groupId>
131 <artifactId>kotlin-maven-plugin</artifactId>
135 <phase>compile</phase>
141 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
146 <id>test-compile</id>
147 <phase>test-compile</phase>
149 <goal>test-compile</goal>
153 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
160 <groupId>org.apache.maven.plugins</groupId>
161 <artifactId>maven-site-plugin</artifactId>
164 <id>attach-descriptor</id>
170 <artifactId>maven-checkstyle-plugin</artifactId>
173 <id>check-license</id>
183 <artifactId>maven-assembly-plugin</artifactId>
186 <groupId>org.onap.ccsdk.cds.components.cba</groupId>
187 <artifactId>cba-assembly-descriptor</artifactId>
188 <version>${ccsdk.cds.version}</version>
192 <artifactId>*</artifactId>
199 <id>make-assembly</id>
200 <phase>package</phase>
206 <descriptorRef>cba_zip</descriptorRef>
213 <groupId>org.apache.maven.plugins</groupId>
214 <artifactId>maven-failsafe-plugin</artifactId>
221 <id>integration-tests</id>
227 <artifactId>maven-surefire-plugin</artifactId>
230 <id>default-test</id>
247 <groupId>org.codehaus.gmaven</groupId>
248 <artifactId>groovy-maven-plugin</artifactId>
251 <groupId>com.squareup.okhttp3</groupId>
252 <artifactId>okhttp</artifactId>
253 <version>3.14.0</version>
256 <groupId>commons-io</groupId>
257 <artifactId>commons-io</artifactId>
258 <version>${commons-io-version}</version>
264 <phase>install</phase>
270 import okhttp3.Credentials
271 import okhttp3.MediaType
272 import okhttp3.MultipartBody
273 import okhttp3.OkHttpClient
274 import okhttp3.Request
275 import okhttp3.RequestBody
276 import org.apache.commons.io.IOUtils
280 target = "${basedir.absolutePath}/target"
281 userName = throwIfPropMissing('cds.username')
282 password = throwIfPropMissing('cds.password')
283 protocol = properties['cds.protocol'] ?: 'http'
284 host = properties['cds.host'] ?: 'localhost'
285 port = properties['cds.port'] ?: '8081'
287 def cba = "${project.artifact.artifactId}-${project.artifact.version}-cba.zip"
288 def enrichedCba = "${project.artifact.artifactId}-${project.artifact.version}-enriched-cba.zip"
289 def enrichEndpoint = properties['cds.enrich.endpoint'] ?: 'api/v1/blueprint-model/enrich'
290 def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish'
292 def throwIfPropMissing(prop) {
293 value = properties[prop]
294 if (!value || "".equals(value)) {
295 throw new RuntimeException("Property missing: $prop")
300 def buildRequest(endpoint, fileName) {
301 body = new MultipartBody.Builder()
302 .setType(MultipartBody.FORM)
303 .addFormDataPart("file",
305 RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
308 return new Request.Builder()
309 .url("$protocol://$host:$port/$endpoint")
310 .addHeader('Authorization', Credentials.basic(userName, password))
315 def logAndThrow(msg) {
317 log.error(response.body().string())
319 throw new RuntimeException(msg)
324 def client = new OkHttpClient()
326 response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
327 if (!response || !response.isSuccessful()) {
328 logAndThrow("Failed to enrich CBA")
332 response.body().byteStream(),
333 new FileOutputStream(new File(target, enrichedCba))
335 log.info("Created enriched cba: $enrichedCba")
337 response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
338 if (!response || !response.isSuccessful()) {
339 logAndThrow("Failed to publish CBA")
342 log.info("CBA Deployed")
343 log.info(response.body().string())