aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-kubernetes/src/test
diff options
context:
space:
mode:
authorlapentafd <francesco.lapenta@est.tech>2021-11-17 16:51:16 +0000
committerlapentafd <francesco.lapenta@est.tech>2021-11-17 16:51:22 +0000
commitbb4b558d8c253381b1ab04bd300f495dc10a1a7c (patch)
tree7928e574c3d4e1ef4ed6648e254ebf0d43c1ab1b /participant/participant-impl/participant-impl-kubernetes/src/test
parent225dcb4d6f801d88094a9512d79c82c4189c07f6 (diff)
Code coverage clamp participant
Issue-ID: POLICY-3452 Change-Id: I5de10918f91ff2857cf81cc362c9cbecfcb01ec1 Signed-off-by: lapentafd <francesco.lapenta@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-kubernetes/src/test')
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java19
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java23
2 files changed, 42 insertions, 0 deletions
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java
index 1f8e76952..d7f09705b 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java
@@ -27,6 +27,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
@@ -106,6 +107,10 @@ class ControlLoopElementHandlerTest {
.uninstallChart(charts.get(0));
assertDoesNotThrow(() -> controlLoopElementHandler
+ .controlLoopElementStateChange(commonTestData.getControlLoopId(), controlLoopElementId1,
+ ControlLoopState.PASSIVE, ControlLoopOrderedState.PASSIVE));
+
+ assertDoesNotThrow(() -> controlLoopElementHandler
.controlLoopElementStateChange(commonTestData.getControlLoopId(), controlLoopElementId1,
ControlLoopState.PASSIVE, ControlLoopOrderedState.UNINITIALISED));
@@ -141,4 +146,18 @@ class ControlLoopElementHandlerTest {
assertThat(controlLoopElementHandler.getChartMap().containsKey(elementId2)).isFalse();
}
+
+ @Test
+ void test_handleStatistics() throws PfModelException {
+ UUID elementId1 = UUID.randomUUID();
+ controlLoopElementHandler.getChartMap().put(elementId1, charts.get(0));
+ when(participantIntermediaryApi.getControlLoopElement(elementId1)).thenReturn(new ControlLoopElement());
+ assertDoesNotThrow(() -> controlLoopElementHandler.handleStatistics(elementId1));
+ }
+
+ @Test
+ void test_checkPodStatus() {
+ var chartInfo = charts.get(0);
+ assertDoesNotThrow(() -> controlLoopElementHandler.checkPodStatus(chartInfo, 1, 1));
+ }
}
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 41b1fbeb5..335dbcb21 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
@@ -29,6 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
@@ -46,6 +47,7 @@ import org.mockito.Spy;
import org.onap.policy.clamp.controlloop.participant.kubernetes.exception.ServiceException;
import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartInfo;
import org.onap.policy.clamp.controlloop.participant.kubernetes.models.ChartList;
+import org.onap.policy.clamp.controlloop.participant.kubernetes.models.HelmRepository;
import org.onap.policy.clamp.controlloop.participant.kubernetes.service.ChartStore;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -68,6 +70,9 @@ class HelmClientTest {
@Mock
ChartStore chartStore;
+ @Mock
+ HelmRepository repo;
+
private static MockedStatic<HelmClient> mockedClient;
@BeforeAll
@@ -90,9 +95,27 @@ class HelmClientTest {
doReturn(new File("/target/tmp/override.yaml")).when(chartStore)
.getOverrideFile(any());
var chartinfo = charts.get(0);
+
assertDoesNotThrow(() -> helmClient.installChart(chartinfo));
chartinfo.setNamespace("");
assertDoesNotThrow(() -> helmClient.installChart(chartinfo));
+
+ mockedClient.when(() -> HelmClient.executeCommand(any()))
+ .thenReturn(new String());
+ assertDoesNotThrow(() -> helmClient.installChart(chartinfo));
+
+ }
+
+ @Test
+ void test_addRepository() throws IOException {
+ mockedClient.when(() -> HelmClient.executeCommand(any()))
+ .thenReturn(new String());
+ when(repo.getRepoName()).thenReturn("RepoName");
+ assertDoesNotThrow(() -> helmClient.addRepository(repo));
+
+ mockedClient.when(() -> HelmClient.executeCommand(any()))
+ .thenReturn("failed");
+ assertDoesNotThrow(() -> helmClient.addRepository(repo));
}
@Test