summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java4
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java25
4 files changed, 48 insertions, 4 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/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java
index e77dd69ee..676747d04 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandlerTest.java
@@ -132,11 +132,11 @@ class ControlLoopHandlerTest {
stateChange.setTimestamp(Instant.ofEpochMilli(3000));
var clh = setTestControlLoopHandler(id, uuid);
- clh.handleControlLoopStateChange(stateChange);
+ clh.handleControlLoopStateChange(stateChange, List.of());
var newid = new ToscaConceptIdentifier("id", "1.2.3");
stateChange.setControlLoopId(newid);
stateChange.setParticipantId(newid);
- assertDoesNotThrow(() -> clh.handleControlLoopStateChange(stateChange));
+ assertDoesNotThrow(() -> clh.handleControlLoopStateChange(stateChange, List.of()));
List<ControlLoopElementDefinition> clElementDefinitions = new ArrayList<>();
var cld = new ControlLoopElementDefinition();
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());