diff options
Diffstat (limited to 'participant/participant-impl/participant-impl-kubernetes')
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 |