From 5ee631b91871fefafce35c5399aef10984f1207f Mon Sep 17 00:00:00 2001 From: lapentafd Date: Tue, 2 Nov 2021 09:10:54 +0000 Subject: Clamp code coverage Issue-ID: POLICY-3452 Change-Id: I35c10562c5e11698491a5d93adcf417784395534 Signed-off-by: lapentafd --- .../participant/kubernetes/helm/HelmClientTest.java | 5 ++++- .../kubernetes/rest/ChartControllerTest.java | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'participant/participant-impl') diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java index 79a37f8e6..41b1fbeb5 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java @@ -89,7 +89,10 @@ class HelmClientTest { .thenReturn("success"); doReturn(new File("/target/tmp/override.yaml")).when(chartStore) .getOverrideFile(any()); - assertDoesNotThrow(() -> helmClient.installChart(charts.get(0))); + var chartinfo = charts.get(0); + assertDoesNotThrow(() -> helmClient.installChart(chartinfo)); + chartinfo.setNamespace(""); + assertDoesNotThrow(() -> helmClient.installChart(chartinfo)); } @Test diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java index bbb57c320..2af2a0171 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java @@ -73,6 +73,7 @@ class ChartControllerTest { private static String UNINSTALL_CHART_URL = "/helm/uninstall/"; private static String ONBOARD_CHART_URL = "/helm/onboard/chart"; private static String DELETE_CHART_URL = "/helm/chart"; + private static String CONFIGURE_REPO_URL = "/helm/repo"; @Autowired private MockMvc mockMvc; @@ -217,6 +218,23 @@ class ChartControllerTest { } + /** + * Test endpoint for configuring a helm repository. + * @throws Exception in case of error. + */ + @Test + void testConfigureRepo() throws Exception { + RequestBuilder requestBuilder; + + requestBuilder = MockMvcRequestBuilders.post(CONFIGURE_REPO_URL).accept(MediaType.APPLICATION_JSON_VALUE) + .content(getInstallationJson(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion())) + .contentType(MediaType.APPLICATION_JSON_VALUE); + + mockMvc.perform(requestBuilder).andExpect(status().isCreated()); + + } + + private String getInstallationJson(String name, String version) { JSONObject jsonObj = new JSONObject(); jsonObj.put("name", name); -- cgit 1.2.3-korg