Release version 1.1.1 of CDS dockers
[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.1.2-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.modules</groupId>
35             <artifactId>execution-service</artifactId>
36         </dependency>
37         <dependency>
38             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
39             <artifactId>resource-resolution</artifactId>
40         </dependency>
41         <dependency>
42             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
43             <artifactId>netconf-executor</artifactId>
44         </dependency>
45         <dependency>
46             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
47             <artifactId>restconf-executor</artifactId>
48         </dependency>
49         <dependency>
50             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
51             <artifactId>cli-executor</artifactId>
52         </dependency>
53         <dependency>
54             <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
55             <artifactId>message-prioritization</artifactId>
56         </dependency>
57         <dependency>
58             <groupId>org.jetbrains.kotlin</groupId>
59             <artifactId>kotlin-test-junit</artifactId>
60             <scope>test</scope>
61         </dependency>
62         <dependency>
63             <groupId>org.jetbrains.kotlinx</groupId>
64             <artifactId>kotlinx-coroutines-test</artifactId>
65             <scope>test</scope>
66         </dependency>
67         <dependency>
68             <groupId>junit</groupId>
69             <artifactId>junit</artifactId>
70             <version>4.12</version>
71             <scope>test</scope>
72         </dependency>
73         <dependency>
74             <groupId>io.mockk</groupId>
75             <artifactId>mockk</artifactId>
76             <version>1.10.0</version>
77             <scope>test</scope>
78         </dependency>
79         <dependency>
80             <groupId>com.squareup.okhttp3</groupId>
81             <artifactId>okhttp</artifactId>
82             <version>3.14.0</version>
83         </dependency>
84     </dependencies>
85
86     <build>
87         <sourceDirectory>${project.basedir}/Scripts/kotlin</sourceDirectory>
88         <testSourceDirectory>${project.basedir}/Tests/kotlin</testSourceDirectory>
89         <resources>
90             <resource>
91                 <directory>${project.basedir}/Environments</directory>
92             </resource>
93         </resources>
94         <plugins>
95             <plugin>
96                 <groupId>org.jacoco</groupId>
97                 <artifactId>jacoco-maven-plugin</artifactId>
98                 <executions>
99                     <execution>
100                         <id>pre-unit-test</id>
101                         <phase>none</phase>
102                     </execution>
103                     <execution>
104                         <id>default-prepare-agent</id>
105                         <phase>none</phase>
106                     </execution>
107                     <execution>
108                         <id>post-unit-test</id>
109                         <phase>none</phase>
110                     </execution>
111                     <execution>
112                         <id>default-report</id>
113                         <phase>none</phase>
114                     </execution>
115                     <execution>
116                         <id>pre-integration-test</id>
117                         <phase>none</phase>
118                     </execution>
119                     <execution>
120                         <id>post-integration-test</id>
121                         <phase>none</phase>
122                     </execution>
123                     <execution>
124                         <id>default-check</id>
125                         <phase>none</phase>
126                     </execution>
127                 </executions>
128             </plugin>
129             <plugin>
130                 <groupId>org.jetbrains.kotlin</groupId>
131                 <artifactId>kotlin-maven-plugin</artifactId>
132                 <executions>
133                     <execution>
134                         <id>compile</id>
135                         <phase>compile</phase>
136                         <goals>
137                             <goal>compile</goal>
138                         </goals>
139                         <configuration>
140                             <sourceDirs>
141                                 <sourceDir>${project.basedir}/Scripts/kotlin</sourceDir>
142                             </sourceDirs>
143                         </configuration>
144                     </execution>
145                     <execution>
146                         <id>test-compile</id>
147                         <phase>test-compile</phase>
148                         <goals>
149                             <goal>test-compile</goal>
150                         </goals>
151                         <configuration>
152                             <sourceDirs>
153                                 <sourceDir>${project.basedir}/Tests/kotlin</sourceDir>
154                             </sourceDirs>
155                         </configuration>
156                     </execution>
157                 </executions>
158             </plugin>
159             <plugin>
160                 <groupId>org.apache.maven.plugins</groupId>
161                 <artifactId>maven-site-plugin</artifactId>
162                 <executions>
163                     <execution>
164                         <id>attach-descriptor</id>
165                         <phase>none</phase>
166                     </execution>
167                 </executions>
168             </plugin>
169             <plugin>
170                 <artifactId>maven-checkstyle-plugin</artifactId>
171                 <executions>
172                     <execution>
173                         <id>check-license</id>
174                         <phase>none</phase>
175                     </execution>
176                     <execution>
177                         <id>check-style</id>
178                         <phase>none</phase>
179                     </execution>
180                 </executions>
181             </plugin>
182             <plugin>
183                 <artifactId>maven-assembly-plugin</artifactId>
184                 <dependencies>
185                     <dependency>
186                         <groupId>org.onap.ccsdk.cds.components.cba</groupId>
187                         <artifactId>cba-assembly-descriptor</artifactId>
188                         <version>${ccsdk.cds.version}</version>
189                         <exclusions>
190                             <exclusion>
191                                 <groupId>*</groupId>
192                                 <artifactId>*</artifactId>
193                             </exclusion>
194                         </exclusions>
195                     </dependency>
196                 </dependencies>
197                 <executions>
198                     <execution>
199                         <id>make-assembly</id>
200                         <phase>package</phase>
201                         <goals>
202                             <goal>single</goal>
203                         </goals>
204                         <configuration>
205                             <descriptorRefs>
206                                 <descriptorRef>cba_zip</descriptorRef>
207                             </descriptorRefs>
208                         </configuration>
209                     </execution>
210                 </executions>
211             </plugin>
212             <plugin>
213                 <groupId>org.apache.maven.plugins</groupId>
214                 <artifactId>maven-failsafe-plugin</artifactId>
215                 <executions>
216                     <execution>
217                         <id>default</id>
218                         <phase>none</phase>
219                     </execution>
220                     <execution>
221                         <id>integration-tests</id>
222                         <phase>none</phase>
223                     </execution>
224                 </executions>
225             </plugin>
226             <plugin>
227                 <artifactId>maven-surefire-plugin</artifactId>
228                 <executions>
229                     <execution>
230                         <id>default-test</id>
231                         <phase>test</phase>
232                         <goals>
233                             <goal>test</goal>
234                         </goals>
235                     </execution>
236                 </executions>
237             </plugin>
238         </plugins>
239     </build>
240
241     <profiles>
242         <profile>
243             <id>deploy-cba</id>
244             <build>
245                 <plugins>
246                     <plugin>
247                         <groupId>org.codehaus.gmaven</groupId>
248                         <artifactId>groovy-maven-plugin</artifactId>
249                         <dependencies>
250                             <dependency>
251                                 <groupId>com.squareup.okhttp3</groupId>
252                                 <artifactId>okhttp</artifactId>
253                                 <version>3.14.0</version>
254                             </dependency>
255                             <dependency>
256                                 <groupId>commons-io</groupId>
257                                 <artifactId>commons-io</artifactId>
258                                 <version>${commons-io-version}</version>
259                             </dependency>
260                         </dependencies>
261                         <executions>
262                             <execution>
263                                 <id>deploy-cba</id>
264                                 <phase>install</phase>
265                                 <goals>
266                                     <goal>execute</goal>
267                                 </goals>
268                                 <configuration>
269                                     <source>
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
277
278                                         import java.io.File
279
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'
286
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'
291
292                                         def throwIfPropMissing(prop) {
293                                         value = properties[prop]
294                                         if (!value || "".equals(value)) {
295                                         throw new RuntimeException("Property missing: $prop")
296                                         }
297                                         return value
298                                         }
299
300                                         def buildRequest(endpoint, fileName) {
301                                         body = new MultipartBody.Builder()
302                                         .setType(MultipartBody.FORM)
303                                         .addFormDataPart("file",
304                                         fileName,
305                                         RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName)))
306                                         .build()
307
308                                         return new Request.Builder()
309                                         .url("$protocol://$host:$port/$endpoint")
310                                         .addHeader('Authorization', Credentials.basic(userName, password))
311                                         .post(body)
312                                         .build()
313                                         }
314
315                                         def logAndThrow(msg) {
316                                         if(response) {
317                                         log.error(response.body().string())
318                                         }
319                                         throw new RuntimeException(msg)
320                                         }
321
322                                         response = null
323                                         try {
324                                         def client = new OkHttpClient()
325
326                                         response = client.newCall(buildRequest(enrichEndpoint, cba)).execute()
327                                         if (!response || !response.isSuccessful()) {
328                                         logAndThrow("Failed to enrich CBA")
329                                         }
330
331                                         IOUtils.copy(
332                                         response.body().byteStream(),
333                                         new FileOutputStream(new File(target, enrichedCba))
334                                         )
335                                         log.info("Created enriched cba: $enrichedCba")
336
337                                         response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute()
338                                         if (!response || !response.isSuccessful()) {
339                                         logAndThrow("Failed to publish CBA")
340                                         }
341
342                                         log.info("CBA Deployed")
343                                         log.info(response.body().string())
344                                         } finally {
345                                         if (response) {
346                                         response.close()
347                                         }
348                                         }
349                                     </source>
350                                 </configuration>
351                             </execution>
352                         </executions>
353                     </plugin>
354                 </plugins>
355             </build>
356         </profile>
357     </profiles>
358 </project>