From ea457a94cda951ff17b84b107be0b96a4537fabc Mon Sep 17 00:00:00 2001 From: Frank Kimmlingen Date: Wed, 7 Sep 2022 11:23:52 +0200 Subject: Make UatExecutor accessible inside a CBA JUnit test Issue-ID: CCSDK-3748 Signed-off-by: Frank Kimmlingen Change-Id: Icbc0a44d91fd08f2e06a12bcdf016655a2b2282d (cherry picked from commit 43496fb210dd08bd934fedf2e5e1bba4636000d1) --- .../test-blueprint-kotlin-parent/pom.xml | 114 ++++++++++++++------- 1 file changed, 75 insertions(+), 39 deletions(-) (limited to 'components/model-catalog/blueprint-model/test-blueprint-kotlin-parent/pom.xml') diff --git a/components/model-catalog/blueprint-model/test-blueprint-kotlin-parent/pom.xml b/components/model-catalog/blueprint-model/test-blueprint-kotlin-parent/pom.xml index 63f704ea5..6fd02e78d 100644 --- a/components/model-catalog/blueprint-model/test-blueprint-kotlin-parent/pom.xml +++ b/components/model-catalog/blueprint-model/test-blueprint-kotlin-parent/pom.xml @@ -29,6 +29,17 @@ Components Model Catalog - Blueprints Model - Test Kotlin Parent + + org.onap.ccsdk.cds.blueprintsprocessor + blueprintsprocessor-application + ${project.parent.version} + + + org.springframework.boot + spring-boot-starter-test + test + + org.onap.ccsdk.cds.blueprintsprocessor.modules execution-service @@ -90,6 +101,11 @@ ${project.basedir}/Environments + + + ${project.basedir}/Tests/resources + + org.jacoco @@ -224,16 +240,36 @@ maven-surefire-plugin + ${maven-surefire-plugin.version} default-test test + + + -Xmx1024m + false + 1 + test + + maven-resources-plugin + 2.6 + + + copy-test-resources + + testResources + + process-test-resources + + + @@ -289,61 +325,61 @@ def publishEndpoint = properties['cds.publish.endpoint'] ?: 'api/v1/blueprint-model/publish' def throwIfPropMissing(prop) { - value = properties[prop] - if (!value || "".equals(value)) { - throw new RuntimeException("Property missing: $prop") - } - return value + value = properties[prop] + if (!value || "".equals(value)) { + throw new RuntimeException("Property missing: $prop") + } + return value } def buildRequest(endpoint, fileName) { - body = new MultipartBody.Builder() - .setType(MultipartBody.FORM) - .addFormDataPart("file", - fileName, - RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName))) - .build() + body = new MultipartBody.Builder() + .setType(MultipartBody.FORM) + .addFormDataPart("file", + fileName, + RequestBody.create(MediaType.parse('application/zip'), new File(target, fileName))) + .build() - return new Request.Builder() - .url("$protocol://$host:$port/$endpoint") - .addHeader('Authorization', Credentials.basic(userName, password)) - .post(body) - .build() + return new Request.Builder() + .url("$protocol://$host:$port/$endpoint") + .addHeader('Authorization', Credentials.basic(userName, password)) + .post(body) + .build() } def logAndThrow(msg) { - if(response) { - log.error(response.body().string()) - } - throw new RuntimeException(msg) + if(response) { + log.error(response.body().string()) + } + throw new RuntimeException(msg) } response = null try { - def client = new OkHttpClient() + def client = new OkHttpClient() - response = client.newCall(buildRequest(enrichEndpoint, cba)).execute() - if (!response || !response.isSuccessful()) { - logAndThrow("Failed to enrich CBA") - } + response = client.newCall(buildRequest(enrichEndpoint, cba)).execute() + if (!response || !response.isSuccessful()) { + logAndThrow("Failed to enrich CBA") + } - IOUtils.copy( - response.body().byteStream(), - new FileOutputStream(new File(target, enrichedCba)) - ) - log.info("Created enriched cba: $enrichedCba") + IOUtils.copy( + response.body().byteStream(), + new FileOutputStream(new File(target, enrichedCba)) + ) + log.info("Created enriched cba: $enrichedCba") - response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute() - if (!response || !response.isSuccessful()) { - logAndThrow("Failed to publish CBA") - } + response = client.newCall(buildRequest(publishEndpoint, enrichedCba)).execute() + if (!response || !response.isSuccessful()) { + logAndThrow("Failed to publish CBA") + } - log.info("CBA Deployed") - log.info(response.body().string()) + log.info("CBA Deployed") + log.info(response.body().string()) } finally { - if (response) { - response.close() - } + if (response) { + response.close() + } } -- cgit 1.2.3-korg