summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2021-11-03 14:28:22 +0000
committerGerrit Code Review <gerrit@onap.org>2021-11-03 14:28:22 +0000
commit7bc53b8dd7c12dc108ad2625ad6d4c14804e76a6 (patch)
tree383b704a9e4aa4072c634b57617a7c92338ebe79
parenta48252db26e2ccd031ddb2046d87737d47c248a6 (diff)
parent5ee631b91871fefafce35c5399aef10984f1207f (diff)
Merge "Clamp code coverage"
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java5
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java18
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java25
3 files changed, 46 insertions, 2 deletions
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);
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
index d8892c8b9..ae1c59851 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
@@ -23,6 +23,9 @@ package org.onap.policy.clamp.controlloop.runtime.instantiation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import java.io.IOException;
import java.util.ArrayList;
@@ -34,6 +37,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ClElementStatisticsProvider;
@@ -63,7 +67,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
*
*/
class ControlLoopInstantiationProviderTest {
-
+ private static final String ID_NAME = "PMSH_Instance1";
+ private static final String ID_VERSION = "1.2.3";
private static final String CL_INSTANTIATION_CREATE_JSON = "src/test/resources/rest/controlloops/ControlLoops.json";
private static final String CL_INSTANTIATION_UPDATE_JSON =
"src/test/resources/rest/controlloops/ControlLoopsUpdate.json";
@@ -157,6 +162,24 @@ class ControlLoopInstantiationProviderTest {
}
@Test
+ void testIntanceResponses() throws PfModelException {
+ var instantiationProvider = new ControlLoopInstantiationProvider(clProvider, commissioningProvider,
+ supervisionHandler, participantProvider);
+ var instancePropertyList = instantiationProvider.createInstanceProperties(serviceTemplate);
+ assertNull(instancePropertyList.getErrorDetails());
+ var id = new ToscaConceptIdentifier(ID_NAME, ID_VERSION);
+ assertEquals(id, instancePropertyList.getAffectedInstanceProperties().get(0));
+ var instanceOrderState = instantiationProvider.getInstantiationOrderState(ID_NAME, ID_VERSION);
+ assertEquals(ControlLoopOrderedState.UNINITIALISED, instanceOrderState.getOrderedState());
+ assertEquals(ID_NAME, instanceOrderState.getControlLoopIdentifierList().get(0).getName());
+
+ assertNotNull(clProvider.getControlLoop(id));
+ var instanceResponse = instantiationProvider.deleteInstanceProperties(ID_NAME, ID_VERSION);
+ assertEquals(ID_NAME, instanceResponse.getAffectedControlLoops().get(0).getName());
+ assertNull(clProvider.getControlLoop(id));
+ }
+
+ @Test
void testInstantiationCrud() throws Exception {
participantProvider.createParticipants(CommonTestData.createParticipants());