Merge "Code Coverage on clamp-participant-dcae"
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 a96581e..3f5e425 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 @@
         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 f730f36..f3aa176 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 @@
 
 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 @@
     }
 
     @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 @@
     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 ab181d4..40f2f5f 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 @@
         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 0b2712b..4579b52 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 @@
     }
 
     /**
+     * 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