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