Use released version 2.5.1 parent poms
[ccsdk/cds.git] / components / model-catalog / blueprint-model / test-blueprint-kotlin-parent / pom.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3   ~ Copyright © 2020 Bell Canada
4   ~
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
8   ~
9   ~     http://www.apache.org/licenses/LICENSE-2.0
10   ~
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.
16   -->
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>
19
20     <parent>
21         <groupId>org.onap.ccsdk.cds.components.cba</groupId>
22         <artifactId>blueprint-model</artifactId>
23         <version>1.5.0-SNAPSHOT</version>
24     </parent>
25
26     <artifactId>test-blueprint-kotlin-parent</artifactId>
27     <packaging>pom</packaging>
28
29     <name>Components Model Catalog - Blueprints Model - Test Kotlin Parent</name>
30
31     <dependencies>
32         <dependency>
33             <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
34             <artifactId>blueprintsprocessor-application</artifactId>
35             <version>${project.parent.version}</version>
36         </dependency>
37         <dependency>
38             <groupId>org.springframework.boot</groupId>
39             <artifactId>spring-boot-starter-test</artifactId>
40             <scope>test</scope>
41         </dependency>
42
43         <dependency>
44             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.modules</groupId>
45             <artifactId>execution-service</artifactId>
46         </dependency>
47         <dependency>
48             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
49             <artifactId>resource-resolution</artifactId>
50         </dependency>
51         <dependency>
52             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
53             <artifactId>netconf-executor</artifactId>
54         </dependency>
55         <dependency>
56             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
57             <artifactId>restconf-executor</artifactId>
58         </dependency>
59         <dependency>
60             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
61             <artifactId>cli-executor</artifactId>
62         </dependency>
63         <dependency>
64             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
65             <artifactId>message-prioritization</artifactId>
66         </dependency>
67         <dependency>
68             <groupId>org.jetbrains.kotlin</groupId>
69             <artifactId>kotlin-test-junit</artifactId>
70             <scope>test</scope>
71         </dependency>
72         <dependency>
73             <groupId>org.jetbrains.kotlinx</groupId>
74             <artifactId>kotlinx-coroutines-test</artifactId>
75             <scope>test</scope>
76         </dependency>
77         <dependency>
78             <groupId>junit</groupId>
79             <artifactId>junit</artifactId>
80             <version>4.12</version>
81             <scope>test</scope>
82         </dependency>
83         <dependency>
84             <groupId>io.mockk</groupId>
85             <artifactId>mockk</artifactId>
86             <version>1.10.0</version>
87             <scope>test</scope>
88         </dependency>
89         <dependency>
90             <groupId>com.squareup.okhttp3</groupId>
91             <artifactId>okhttp</artifactId>
92             <version>4.9.3</version>
93         </dependency>
94     </dependencies>
95
96     <build>
97         <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
98         <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
99         <resources>
100             <resource>
101                 <directory>${project.basedir}/Environments</directory>
102             </resource>
103         </resources>
104         <testResources>
105             <testResource>
106                 <directory>${project.basedir}/Tests/resources</directory>
107             </testResource>
108         </testResources>
109         <plugins>
110             <plugin>
111                 <groupId>org.jacoco</groupId>
112                 <artifactId>jacoco-maven-plugin</artifactId>
113                 <executions>
114                     <execution>
115                         <id>pre-unit-test</id>
116                         <phase>none</phase>
117                     </execution>
118                     <execution>
119                         <id>default-prepare-agent</id>
120                         <phase>none</phase>
121                     </execution>
122                     <execution>
123                         <id>post-unit-test</id>
124                         <phase>none</phase>
125                     </execution>
126                     <execution>
127                         <id>default-report</id>
128                         <phase>none</phase>
129                     </execution>
130                     <execution>
131                         <id>pre-integration-test</id>
132                         <phase>none</phase>
133                     </execution>
134                     <execution>
135                         <id>post-integration-test</id>
136                         <phase>none</phase>
137                     </execution>
138                     <execution>
139                         <id>default-check</id>
140                         <phase>none</phase>
141                     </execution>
142                 </executions>
143             </plugin>
144             <plugin>
145                 <groupId>org.jetbrains.kotlin</groupId>
146                 <artifactId>kotlin-maven-plugin</artifactId>
147                 <executions>
148                     <execution>
149                         <id>compile</id>
150                         <phase>compile</phase>
151                         <goals>
152                             <goal>compile</goal>
153                         </goals>
154                         <configuration>
155                             <sourceDirs>
156                                 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
157                             </sourceDirs>
158                         </configuration>
159                     </execution>
160                     <execution>
161                         <id>test-compile</id>
162                         <phase>test-compile</phase>
163                         <goals>
164                             <goal>test-compile</goal>
165                         </goals>
166                         <configuration>
167                             <sourceDirs>
168                                 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
169                             </sourceDirs>
170                         </configuration>
171                     </execution>
172                 </executions>
173             </plugin>
174             <plugin>
175                 <groupId>org.apache.maven.plugins</groupId>
176                 <artifactId>maven-site-plugin</artifactId>
177                 <executions>
178                     <execution>
179                         <id>attach-descriptor</id>
180                         <phase>none</phase>
181                     </execution>
182                 </executions>
183             </plugin>
184             <plugin>
185                 <artifactId>maven-checkstyle-plugin</artifactId>
186                 <executions>
187                     <execution>
188                         <id>check-license</id>
189                         <phase>none</phase>
190                     </execution>
191                     <execution>
192                         <id>check-style</id>
193                         <phase>none</phase>
194                     </execution>
195                 </executions>
196             </plugin>
197             <plugin>
198                 <artifactId>maven-assembly-plugin</artifactId>
199                 <dependencies>
200                     <dependency>
201                         <groupId>org.onap.ccsdk.cds.components.cba</groupId>
202                         <artifactId>cba-assembly-descriptor</artifactId>
203                         <version>${ccsdk.cds.version}</version>
204                         <exclusions>
205                             <exclusion>
206                                 <groupId>*</groupId>
207                                 <artifactId>*</artifactId>
208                             </exclusion>
209                         </exclusions>
210                     </dependency>
211                 </dependencies>
212                 <executions>
213                     <execution>
214                         <id>make-assembly</id>
215                         <phase>package</phase>
216                         <goals>
217                             <goal>single</goal>
218                         </goals>
219                         <configuration>
220                             <descriptorRefs>
221                                 <descriptorRef>cba_zip</descriptorRef>
222                             </descriptorRefs>
223                         </configuration>
224                     </execution>
225                 </executions>
226             </plugin>
227             <plugin>
228                 <groupId>org.apache.maven.plugins</groupId>
229                 <artifactId>maven-failsafe-plugin</artifactId>
230                 <executions>
231                     <execution>
232                         <id>default</id>
233                         <phase>none</phase>
234                     </execution>
235                     <execution>
236                         <id>integration-tests</id>
237                         <phase>none</phase>
238                     </execution>
239                 </executions>
240             </plugin>
241             <plugin>
242                 <artifactId>maven-surefire-plugin</artifactId>
243                 <version>${maven-surefire-plugin.version}</version>
244                 <executions>
245                     <execution>
246                         <id>default-test</id>
247                         <phase>test</phase>
248                         <configuration>
249                             <!-- Sets the VM argument line used when unit tests are run. -->
250                             <argLine>-Xmx1024m </argLine>
251                             <reuseForks>false</reuseForks>
252                             <forkCount>1</forkCount>
253                         </configuration>
254                         <goals>
255                             <goal>test</goal>
256                         </goals>
257                     </execution>
258                 </executions>
259             </plugin>
260             <plugin>
261                 <artifactId>maven-resources-plugin</artifactId>
262                 <version>2.6</version>
263                 <executions>
264                     <execution>
265                         <id>copy-test-resources</id>
266                         <goals>
267                             <goal>testResources</goal>
268                         </goals>
269                         <phase>process-test-resources</phase>
270                     </execution>
271                 </executions>
272             </plugin>
273         </plugins>
274     </build>
275
276     <profiles>
277         <profile>
278             <id>deploy-cba</id>
279             <build>
280                 <plugins>
281                     <plugin>
282                         <groupId>org.codehaus.gmaven</groupId>
283                         <artifactId>groovy-maven-plugin</artifactId>
284                         <dependencies>
285                             <dependency>
286                                 <groupId>com.squareup.okhttp3</groupId>
287                                 <artifactId>okhttp</artifactId>
288                                 <version>3.14.0</version>
289                             </dependency>
290                             <dependency>
291                                 <groupId>commons-io</groupId>
292                                 <artifactId>commons-io</artifactId>
293                                 <version>${commons-io-version}</version>
294                             </dependency>
295                         </dependencies>
296                         <executions>
297                             <execution>
298                                 <id>deploy-cba</id>
299                                 <phase>install</phase>
300                                 <goals>
301                                     <goal>execute</goal>
302                                 </goals>
303                                 <configuration>
304                                     <source>
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
312
313                                         import java.io.File
314
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'
321
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'
326
327                                         def throwIfPropMissing(prop) {
328                                             value = properties[prop]
329                                             if (!value || "".equals(value)) {
330                                                 throw new RuntimeException("Property missing: $prop")
331                                             }
332                                             return value
333                                         }
334
335                                         def buildRequest(endpoint, fileName) {
336                                             body = new MultipartBody.Builder()
337                                                     .setType(MultipartBody.FORM)
338                                                     .addFormDataPart("file",
339                                                             fileName,
340                                                             RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
341                                                     .build()
342
343                                             return new Request.Builder()
344                                                     .url("$protocol://$host:$port/$endpoint")
345                                                     .addHeader('Authorization', Credentials.basic(userName, password))
346                                                     .post(body)
347                                                     .build()
348                                         }
349
350                                         def logAndThrow(msg) {
351                                             if(response) {
352                                                 log.error(response.body().string())
353                                             }
354                                             throw new RuntimeException(msg)
355                                         }
356
357                                         response = null
358                                         try {
359                                             def client = new OkHttpClient()
360
361                                             response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
362                                             if (!response || !response.isSuccessful()) {
363                                                 logAndThrow("Failed to enrich CBA")
364                                             }
365
366                                             IOUtils.copy(
367                                                     response.body().byteStream(),
368                                                     new FileOutputStream(new File(target, enrichedCba))
369                                             )
370                                             log.info("Created enriched cba: $enrichedCba")
371
372                                             response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
373                                             if (!response || !response.isSuccessful()) {
374                                                 logAndThrow("Failed to publish CBA")
375                                             }
376
377                                             log.info("CBA Deployed")
378                                             log.info(response.body().string())
379                                         } finally {
380                                             if (response) {
381                                                 response.close()
382                                             }
383                                         }
384                                     </source>
385                                 </configuration>
386                             </execution>
387                         </executions>
388                     </plugin>
389                 </plugins>
390             </build>
391         </profile>
392     </profiles>
393 </project>