summaryrefslogtreecommitdiffstats
path: root/participant
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-07-14 14:39:17 +0000
committerGerrit Code Review <gerrit@onap.org>2021-07-14 14:39:17 +0000
commit258fdc2ddb8b5e130ccc2b287c10c3fd782b7ee9 (patch)
tree71679e43e29bd252765aff1ca27ecc642d8dd2e5 /participant
parent3ad8cf5d4c404b8b5e61396067a180a86384451d (diff)
parent57d4094f980c90d3f74f7d983d153bbe2a0c9bbd (diff)
Merge "Code Coverage on clamp-participant-dcae"
Diffstat (limited to 'participant')
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/endtoend/PartecipantDcaeTest.java13
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClientTest.java34
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandlerTest.java6
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/rest/TestListenerUtils.java9
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