diff options
author | Dhrumin Desai <dd303q@att.com> | 2021-09-29 08:34:18 -0400 |
---|---|---|
committer | Dhrumin Desai <dd303q@att.com> | 2021-10-04 21:30:28 -0400 |
commit | a494a322554924f6f9c3d6cc79240f54d3a8da0b (patch) | |
tree | 60477325bd8d86d2fb50965ec47eb6a9bd541e06 /mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java | |
parent | 0d1b8727a44b0add010b79e495b799e538057d20 (diff) |
Improved helm-generator code to make it more testable and improved code coverage
Issue-ID: DCAEGEN2-2911
Issue-ID: DCAEGEN2-2917
Change-Id: Ifc1f336b627b37a9356a3a72b33fcac18bdaa686
Signed-off-by: Dhrumin Desai <dd303q@att.com>
Diffstat (limited to 'mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java')
-rw-r--r-- | mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java index ed861b0..ab0b964 100644 --- a/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java +++ b/mod2/helm-generator/helmchartgenerator-core/src/main/java/org/onap/dcaegen2/platform/helmchartgenerator/distribution/ChartMuseumDistributor.java @@ -40,14 +40,19 @@ import java.util.Objects; @Slf4j public class ChartMuseumDistributor implements ChartDistributor { - @Value("${chartmuseum.baseurl}") - private String chartMuseumUrl; + private final String chartMuseumUrl; - @Value("${chartmuseum.auth.basic.username}") - private String username; + private final String username; - @Value("${chartmuseum.auth.basic.password}") - private String password; + private final String password; + + public ChartMuseumDistributor( @Value("${chartmuseum.baseurl}") String chartMuseumUrl, + @Value("${chartmuseum.auth.basic.username}") String username, + @Value("${chartmuseum.auth.basic.password}")String password) { + this.chartMuseumUrl = chartMuseumUrl; + this.username = username; + this.password = password; + } /** * distributes chart to Chart Museum @@ -60,6 +65,9 @@ public class ChartMuseumDistributor implements ChartDistributor { try { Response response = client.newCall(request).execute(); log.info(Objects.requireNonNull(response.body()).string()); + if(!response.isSuccessful()){ + throw new RuntimeException("Distribution Failed."); + } } catch (IOException e) { throw new RuntimeException(e.getMessage()); } @@ -70,7 +78,7 @@ public class ChartMuseumDistributor implements ChartDistributor { MediaType mediaType = MediaType.parse("application/octet-stream"); RequestBody body = RequestBody.create(chartFile, mediaType); return new Request.Builder() - .url(chartMuseumUrl) + .url(chartMuseumUrl + "/api/charts") .method("POST", body) .addHeader("Content-Type", "application/octet-stream") .addHeader("Authorization", credential) |