summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-kubernetes/src
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2021-09-23 10:26:36 +0100
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>2021-09-23 10:26:36 +0100
commite8bb3d03cb10374438488994f066c9faf4eb1628 (patch)
tree9d750f1012d6a1710b08168a5b5efaf765ce2d94 /participant/participant-impl/participant-impl-kubernetes/src
parentb22ccc9d70912de69b2ada27808dd49a6dc1e0ea (diff)
Fix k8s participant junits ignored in mvn build
Updated rest end points in junits Fixed json parsing issue Issue-ID: POLICY-3678 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I05b2cac0b5d42f8ea6fef4e2ecfd84a90483b513
Diffstat (limited to 'participant/participant-impl/participant-impl-kubernetes/src')
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java23
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java2
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/resources/ChartList.json4
3 files changed, 15 insertions, 14 deletions
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 fcac64dd6..bbb57c320 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
@@ -29,7 +29,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.List;
+import org.apache.commons.io.FileUtils;
import org.json.JSONObject;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
@@ -65,9 +68,11 @@ class ChartControllerTest {
private static final Coder CODER = new StandardCoder();
private static final String CHART_INFO_YAML = "src/test/resources/ChartList.json";
private static List<ChartInfo> charts;
- private static String DEFAULT_CHART_URL = "/helm/charts";
+ private static String RETRIEVE_CHART_URL = "/helm/charts";
private static String INSTALL_CHART_URL = "/helm/install";
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";
@Autowired
private MockMvc mockMvc;
@@ -107,7 +112,7 @@ class ChartControllerTest {
@Test
void retrieveAllCharts() throws Exception {
RequestBuilder requestBuilder;
- requestBuilder = MockMvcRequestBuilders.get(DEFAULT_CHART_URL).accept(MediaType.APPLICATION_JSON_VALUE);
+ requestBuilder = MockMvcRequestBuilders.get(RETRIEVE_CHART_URL).accept(MediaType.APPLICATION_JSON_VALUE);
mockMvc.perform(requestBuilder).andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
@@ -180,7 +185,7 @@ class ChartControllerTest {
//Mocking successful scenario for void uninstall method
when(chartService.saveChart(charts.get(0), chartFile, null)).thenReturn(charts.get(0));
- requestBuilder = MockMvcRequestBuilders.multipart(DEFAULT_CHART_URL)
+ requestBuilder = MockMvcRequestBuilders.multipart(ONBOARD_CHART_URL)
.file(chartFile).file(overrideFile).param("info", getChartInfoJson());
mockMvc.perform(requestBuilder).andExpect(status().isOk());
@@ -197,7 +202,7 @@ class ChartControllerTest {
//Mocking successful scenario for void uninstall method
doNothing().when(chartService).deleteChart(charts.get(0));
- requestBuilder = MockMvcRequestBuilders.delete(DEFAULT_CHART_URL + "/" + charts.get(0)
+ requestBuilder = MockMvcRequestBuilders.delete(DELETE_CHART_URL + "/" + charts.get(0)
.getChartId().getName() + "/" + charts.get(0).getChartId().getVersion())
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE);
@@ -219,14 +224,8 @@ class ChartControllerTest {
return jsonObj.toString();
}
- private String getChartInfoJson() {
- JSONObject jsonObj = new JSONObject();
- jsonObj.put("chartName", charts.get(0).getChartId().getName());
- jsonObj.put("version", charts.get(0).getChartId().getVersion());
- jsonObj.put("namespace", charts.get(0).getNamespace());
- jsonObj.put("repository", charts.get(0).getRepository());
- jsonObj.put("releaseName", charts.get(0).getReleaseName());
- return jsonObj.toString();
+ private String getChartInfoJson() throws IOException {
+ return FileUtils.readFileToString(new File(CHART_INFO_YAML), StandardCharsets.UTF_8);
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java
index 4c8b5b3b3..f1c8d19df 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java
@@ -121,7 +121,7 @@ class ChartServiceTest {
doReturn("dummyRepoName").when(chartService).findChartRepo(any());
doNothing().when(helmClient).installChart(any());
chartService.installChart(charts.get(1));
- assertEquals("dummyRepoName", charts.get(1).getRepository());
+ assertEquals("dummyRepoName", charts.get(1).getRepository().getRepoName());
ChartInfo testChart = charts.get(1);
testChart.setRepository(null);
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/ChartList.json b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/ChartList.json
index 2f4ec2827..9822846f3 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/resources/ChartList.json
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/resources/ChartList.json
@@ -6,7 +6,9 @@
"version" : "1.0"
},
"namespace" : "onap",
- "repository" : "chartMuseum",
+ "repository" : {
+ "repoName": "chartMuseum"
+ },
"releaseName" : "helloworld"
},
{