diff options
author | Lathish <lathishbabu.ganesan@est.tech> | 2022-02-16 16:15:25 +0530 |
---|---|---|
committer | Lathish <lathishbabu.ganesan@est.tech> | 2022-02-23 07:26:47 +0000 |
commit | d4788de99fff5dd0681f8efb4debf018e1e0f090 (patch) | |
tree | 506014c712ce0dc8b8510d48436cb7d3e59bbf4a /participant/participant-impl/participant-impl-kubernetes/src/test/java | |
parent | 43098043c4ef31d9d5dead66568d7d9482a6b165 (diff) |
Fix helm exception when there are no repo's configured
Issue-ID: POLICY-3874
Change-Id: I6734654049abeeb391b58df566992ab102a2894c
Signed-off-by: Lathish <lathishbabu.ganesan@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-kubernetes/src/test/java')
2 files changed, 16 insertions, 0 deletions
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java index 7f1943c97..d85ab6d9f 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClientTest.java @@ -111,6 +111,7 @@ class HelmClientTest { mockedClient.when(() -> HelmClient.executeCommand(any())) .thenReturn(new String()); when(repo.getRepoName()).thenReturn("RepoName"); + when(repo.getAddress()).thenReturn("http://localhost:8080"); assertDoesNotThrow(() -> helmClient.addRepository(repo)); mockedClient.when(() -> HelmClient.executeCommand(any())) diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java index 73c5c98a1..c59e7fb5d 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/rest/ChartControllerTest.java @@ -22,6 +22,7 @@ package org.onap.policy.clamp.acm.participant.kubernetes.rest; import static org.hamcrest.CoreMatchers.is; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; @@ -225,6 +226,7 @@ class ChartControllerTest { @Test void testConfigureRepo() throws Exception { RequestBuilder requestBuilder; + when(chartService.configureRepository(any())).thenReturn(true); requestBuilder = MockMvcRequestBuilders.post(CONFIGURE_REPO_URL).accept(MediaType.APPLICATION_JSON_VALUE) .content(getInstallationJson(charts.get(0).getChartId().getName(), charts.get(0).getChartId().getVersion())) @@ -234,6 +236,19 @@ class ChartControllerTest { } + @Test + void testConfigureRepoAlreadyExist() throws Exception { + RequestBuilder requestBuilder; + when(chartService.configureRepository(any())).thenReturn(false); + + 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().isConflict()); + + } + private String getInstallationJson(String name, String version) { JSONObject jsonObj = new JSONObject(); |