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;
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);
+ }
}
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;
}
}
+ @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)) {
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());
+ }
+ }
}
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;
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
return clUpdateMsg;
}
+ /**
+ * 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.
*