diff options
author | lapentafd <francesco.lapenta@est.tech> | 2021-07-09 11:52:54 +0100 |
---|---|---|
committer | lapentafd <francesco.lapenta@est.tech> | 2021-07-13 15:53:14 +0100 |
commit | 57d4094f980c90d3f74f7d983d153bbe2a0c9bbd (patch) | |
tree | 55cc1bf9261080f366e6b6862e3019551f67171c /participant | |
parent | 22a9e7eed2eaed9846cdf07cecb712764b23b651 (diff) |
Code Coverage on clamp-participant-dcae
Added assertions to existing tests
Issue-ID: POLICY-3452
Change-Id: I653b899f31595ef2bd1164e6caa6a736399c947a
Signed-off-by: lapentafd <francesco.lapenta@est.tech>
Diffstat (limited to 'participant')
4 files changed, 61 insertions, 1 deletions
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java index a96581e6c..3f5e42542 100644 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java @@ -20,6 +20,7 @@ package org.onap.policy.clamp.controlloop.participant.dcae.endtoend; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.mockserver.model.HttpRequest.request; @@ -160,4 +161,16 @@ class PartecipantDcaeTest { assertEquals(participantHandler.getParticipantId(), participantControlLoopUpdateMsg.getParticipantId()); assertEquals(1, participantHandler.getControlLoopHandler().getControlLoops().getControlLoopList().size()); } + + @Test + void testControlLoopUpdateListenerString() throws CoderException { + ParticipantControlLoopUpdate participantControlLoopUpdateMsg = TestListenerUtils.createControlLoopUpdateMsg(); + participantControlLoopUpdateMsg.getControlLoop().setOrderedState(ControlLoopOrderedState.UNINITIALISED); + + assertThat(participantControlLoopUpdateMsg.toString()).contains("state=UNINITIALISED"); + ParticipantControlLoopUpdate copyParticipantControlLoopUpdateMsg = + TestListenerUtils.createCopyControlLoopUpdateMsg(participantControlLoopUpdateMsg); + assertThat(copyParticipantControlLoopUpdateMsg.toString()).contains("state=UNINITIALISED"); + assertNotEquals(participantControlLoopUpdateMsg, copyParticipantControlLoopUpdateMsg); + } } diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java index f730f36f4..f3aa17655 100644 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java @@ -22,6 +22,7 @@ package org.onap.policy.clamp.controlloop.participant.dcae.httpclient; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response; @@ -98,6 +99,17 @@ class ClampHttpClientTest { } @Test + void test_create() throws Exception { + try (ClampHttpClient client = new ClampHttpClient(parameters)) { + + assertThat(client.create(LOOP, null)).isNull(); + + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @Test void test_deploy() throws Exception { try (ClampHttpClient client = new ClampHttpClient(parameters)) { @@ -128,4 +140,26 @@ class ClampHttpClientTest { void test_getStatusEmptyMap() { assertThat(ClampHttpClient.getStatusCode(new Loop())).isEqualTo(ClampHttpClient.STATUS_NOT_FOUND); } + + @Test + void test_stop() throws Exception { + try (ClampHttpClient client = new ClampHttpClient(parameters)) { + + assertFalse(client.stop(LOOP)); + + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @Test + void test_delete() throws Exception { + try (ClampHttpClient client = new ClampHttpClient(parameters)) { + + assertFalse(client.delete(LOOP)); + + } catch (Exception e) { + fail(e.getMessage()); + } + } } diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java index ab181d476..40f2f5f7b 100644 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java @@ -20,6 +20,7 @@ package org.onap.policy.clamp.controlloop.participant.dcae.main.handler; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -74,10 +75,13 @@ class ControlLoopElementHandlerTest { ParticipantIntermediaryApi intermediaryApi = mock(ParticipantIntermediaryApi.class); controlLoopElementHandler.setIntermediaryApi(intermediaryApi); - controlLoopElementHandler.controlLoopElementStateChange(UUID.randomUUID(), ControlLoopState.PASSIVE, + UUID controlLoopElementId = UUID.randomUUID(); + controlLoopElementHandler.controlLoopElementStateChange(controlLoopElementId, ControlLoopState.PASSIVE, ControlLoopOrderedState.UNINITIALISED); verify(clampClient).undeploy(eq(LOOP)); + controlLoopElementHandler.handleStatistics(controlLoopElementId); + assertThat(intermediaryApi.getControlLoopElement(controlLoopElementId)).isNull(); } @Test diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java index 0b2712b7a..4579b52bf 100644 --- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java +++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java @@ -183,6 +183,15 @@ public class TestListenerUtils { } /** + * Method to create a deep copy of ControlLoopUpdateMsg. + * + * @return ParticipantControlLoopUpdate message + */ + public static ParticipantControlLoopUpdate createCopyControlLoopUpdateMsg(ParticipantControlLoopUpdate cpy) { + return new ParticipantControlLoopUpdate(cpy); + } + + /** * Method to create ParticipantHealthCheck message. * * @return ParticipantHealthCheck message |