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