From bb4b558d8c253381b1ab04bd300f495dc10a1a7c Mon Sep 17 00:00:00 2001 From: lapentafd Date: Wed, 17 Nov 2021 16:51:16 +0000 Subject: Code coverage clamp participant Issue-ID: POLICY-3452 Change-Id: I5de10918f91ff2857cf81cc362c9cbecfcb01ec1 Signed-off-by: lapentafd --- .../http/handler/ClElementHandlerTest.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'participant/participant-impl/participant-impl-http') diff --git a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/handler/ClElementHandlerTest.java b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/handler/ClElementHandlerTest.java index d80436ef3..28b62c2c5 100644 --- a/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/handler/ClElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/controlloop/participant/http/handler/ClElementHandlerTest.java @@ -24,15 +24,20 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; +import java.io.IOException; import java.util.Map; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.Spy; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; +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.participant.http.main.handler.ControlLoopElementHandler; +import org.onap.policy.clamp.controlloop.participant.http.main.models.ConfigRequest; import org.onap.policy.clamp.controlloop.participant.http.utils.CommonTestData; import org.onap.policy.clamp.controlloop.participant.http.utils.ToscaUtils; import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi; @@ -63,6 +68,30 @@ class ClElementHandlerTest { serviceTemplate = ToscaUtils.readControlLoopFromTosca(); } + @Test + void test_controlLoopElementeStateChange() throws IOException { + var controlLoopId = commonTestData.getControlLoopId(); + var element = commonTestData.getControlLoopElement(); + var controlLoopElementId = element.getId(); + + var config = Mockito.mock(ConfigRequest.class); + assertDoesNotThrow(() -> controlLoopElementHandler.invokeHttpClient(config)); + + assertDoesNotThrow(() -> controlLoopElementHandler + .controlLoopElementStateChange(controlLoopId, + controlLoopElementId, ControlLoopState.PASSIVE, ControlLoopOrderedState.PASSIVE)); + + assertDoesNotThrow(() -> controlLoopElementHandler + .controlLoopElementStateChange(controlLoopId, + controlLoopElementId, ControlLoopState.PASSIVE, ControlLoopOrderedState.UNINITIALISED)); + + assertDoesNotThrow(() -> controlLoopElementHandler + .controlLoopElementStateChange(controlLoopId, + controlLoopElementId, ControlLoopState.PASSIVE, ControlLoopOrderedState.RUNNING)); + + controlLoopElementHandler.close(); + } + @Test void test_ControlLoopElementUpdate() { doNothing().when(controlLoopElementHandler).invokeHttpClient(any()); -- cgit 1.2.3-korg