aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-10-02 09:50:57 -0400
committerPamela Dragosh <pdragosh@research.att.com>2018-10-02 19:35:18 -0400
commit8c87163466a4eb5a010a9977adf8a365faec8631 (patch)
treea8c8da5e692c78e90862fcabdf805aa4aac36231
parent1b34e893a66f6a7887d095b563ea17f97ab487a0 (diff)
Fixing sonar issues
Some trivial functional interface and ordering. Added some missing JUnit tests. Issue-ID: POLICY-1129 Change-Id: Iad6fe757a40819ca39e007b41dae1bf4b3f6cc0c Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ControlLoopPublisher.java1
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventStatusTest.java41
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventTest.java96
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTest.java117
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTypeTest.java49
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java89
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationWrapperTest.java50
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java39
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopEventTest.java37
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopNotificationTest.java38
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopEventTest.java49
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopNotificationTest.java58
-rw-r--r--controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/params/ControlLoopParamsTest.java50
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java48
14 files changed, 738 insertions, 24 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ControlLoopPublisher.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ControlLoopPublisher.java
index 2b1fbefc7..086e1173d 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ControlLoopPublisher.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/ControlLoopPublisher.java
@@ -25,6 +25,7 @@ import java.lang.reflect.Constructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@FunctionalInterface
public interface ControlLoopPublisher {
public void publish(Object object);
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventStatusTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventStatusTest.java
new file mode 100644
index 000000000..b4944fc42
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventStatusTest.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import org.junit.Test;
+
+public class ControlLoopEventStatusTest {
+
+ @Test
+ public void test() {
+ ControlLoopEventStatus status = ControlLoopEventStatus.ABATED;
+ assertEquals(ControlLoopEventStatus.ABATED, ControlLoopEventStatus.toStatus(status.toString()));
+ assertNotEquals(ControlLoopEventStatus.ONSET, ControlLoopEventStatus.toStatus(status.toString()));
+
+ status = ControlLoopEventStatus.ONSET;
+ assertEquals(ControlLoopEventStatus.ONSET, ControlLoopEventStatus.toStatus(status.toString()));
+ assertNotEquals(ControlLoopEventStatus.ABATED, ControlLoopEventStatus.toStatus(status.toString()));
+ assertEquals(ControlLoopEventStatus.ABATED, ControlLoopEventStatus.toStatus("abatement"));
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventTest.java
new file mode 100644
index 000000000..9da12aaab
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventTest.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.UUID;
+import org.junit.Test;
+
+public class ControlLoopEventTest {
+
+ private class TestControlLoopEvent extends ControlLoopEvent {
+ private static final long serialVersionUID = 1L;
+
+ public TestControlLoopEvent() {
+ super();
+ }
+
+ public TestControlLoopEvent(ControlLoopEvent event) {
+ super(event);
+ }
+ }
+
+ @Test
+ public void test() {
+ ControlLoopEvent event = new TestControlLoopEvent();
+
+ assertEquals("1.0.2", event.getVersion());
+
+ event = new TestControlLoopEvent(null);
+ assertEquals("1.0.2", event.getVersion());
+
+ event.setClosedLoopControlName("name");
+ assertEquals("name", event.getClosedLoopControlName());
+
+ event.setClosedLoopEventClient("client");
+ assertEquals("client", event.getClosedLoopEventClient());
+
+ event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
+ assertEquals(ControlLoopEventStatus.ONSET, event.getClosedLoopEventStatus());
+
+ event.setFrom("from");
+ assertEquals("from", event.getFrom());
+
+ event.setPayload("payload");
+ assertEquals("payload", event.getPayload());
+
+ event.setPolicyName("policyname");
+ assertEquals("policyname", event.getPolicyName());
+
+ event.setPolicyScope("scope");
+ assertEquals("scope", event.getPolicyScope());
+
+ event.setPolicyVersion("1");
+ assertEquals("1", event.getPolicyVersion());
+
+ UUID id = UUID.randomUUID();
+ event.setRequestId(id);
+ assertEquals(id, event.getRequestId());
+
+ event.setTarget("target");
+ assertEquals("target", event.getTarget());
+
+ event.setTargetType(ControlLoopTargetType.VF);
+ assertEquals(ControlLoopTargetType.VF, event.getTargetType());
+
+ event.setVersion("foo");
+ assertEquals("foo", event.getVersion());
+
+ ControlLoopEvent event2 = new TestControlLoopEvent(event);
+ assertTrue(event2.isEventStatusValid());
+
+ event2.setClosedLoopEventStatus(null);
+ assertFalse(event2.isEventStatusValid());
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTest.java
new file mode 100644
index 000000000..de03cc265
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTest.java
@@ -0,0 +1,117 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.util.Collections;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.policy.controlloop.util.Serialization;
+
+public class ControlLoopNotificationTest {
+
+ private class TestControlLoopNotification extends ControlLoopNotification {
+ private static final long serialVersionUID = 1L;
+
+ public TestControlLoopNotification() {
+ super();
+ }
+
+ public TestControlLoopNotification(ControlLoopEvent event) {
+ super(event);
+ }
+ }
+
+ @Test
+ public void test() {
+ ControlLoopNotification notification = new TestControlLoopNotification();
+
+ assertEquals("1.0.2", notification.getVersion());
+
+ notification.setClosedLoopControlName("name");
+ assertEquals("name", notification.getClosedLoopControlName());
+
+ notification.setClosedLoopEventClient("client");
+ assertEquals("client", notification.getClosedLoopEventClient());
+
+ notification.setFrom("from");
+ assertEquals("from", notification.getFrom());
+
+ notification.setHistory(Collections.emptyList());
+ assertTrue(notification.getHistory().size() == 0);
+
+ notification.setMessage("message");
+ assertEquals("message", notification.getMessage());
+
+ notification.setNotification(ControlLoopNotificationType.ACTIVE);
+ assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification());
+
+ ZonedDateTime time = ZonedDateTime.now(ZoneOffset.UTC);
+ notification.setNotificationTime(time);
+ assertEquals(time, notification.getNotificationTime());
+
+ notification.setOpsClTimer(Integer.valueOf(1000));
+ assertEquals(Integer.valueOf(1000), notification.getOpsClTimer());
+
+ notification.setPolicyName("name");
+ assertEquals("name", notification.getPolicyName());
+
+ notification.setPolicyScope("scope");
+ assertEquals("scope", notification.getPolicyScope());
+
+ notification.setPolicyVersion("1");
+ assertEquals("1", notification.getPolicyVersion());
+
+ UUID id = UUID.randomUUID();
+ notification.setRequestId(id);
+ assertEquals(id, notification.getRequestId());
+
+ notification.setTarget("target");
+ assertEquals("target", notification.getTarget());
+
+ notification.setTargetType(ControlLoopTargetType.VFC);
+ assertEquals(ControlLoopTargetType.VFC, notification.getTargetType());
+
+ VirtualControlLoopEvent event = new VirtualControlLoopEvent();
+ event.setClosedLoopControlName("controlloop");
+
+ TestControlLoopNotification notification2 = new TestControlLoopNotification(event);
+ assertEquals("controlloop", notification2.getClosedLoopControlName());
+
+ notification2.setVersion("1");
+ assertEquals("1", notification2.getVersion());
+
+ String json = Serialization.gsonPretty.toJson(notification);
+
+ TestControlLoopNotification notification3 = Serialization.gson.fromJson(json,
+ TestControlLoopNotification.class);
+
+ //
+ // There is no equals for the class - chose not to create one
+ //
+ assertEquals(notification.getRequestId(), notification3.getRequestId());
+
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTypeTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTypeTest.java
new file mode 100644
index 000000000..63103ac8f
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTypeTest.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+public class ControlLoopNotificationTypeTest {
+
+ @Test
+ public void test() {
+
+ assertEquals(ControlLoopNotificationType.ACTIVE, ControlLoopNotificationType.toType("ACTIVE"));
+ assertEquals(ControlLoopNotificationType.REJECTED, ControlLoopNotificationType.toType("REJECTED"));
+ assertEquals(ControlLoopNotificationType.OPERATION, ControlLoopNotificationType.toType("OPERATION"));
+ assertEquals(ControlLoopNotificationType.OPERATION_SUCCESS,
+ ControlLoopNotificationType.toType("OPERATION: SUCCESS"));
+ assertEquals(ControlLoopNotificationType.OPERATION_FAILURE,
+ ControlLoopNotificationType.toType("OPERATION: FAILURE"));
+ assertEquals(ControlLoopNotificationType.FINAL_FAILURE,
+ ControlLoopNotificationType.toType("FINAL: FAILURE"));
+ assertEquals(ControlLoopNotificationType.FINAL_SUCCESS,
+ ControlLoopNotificationType.toType("FINAL: SUCCESS"));
+ assertEquals(ControlLoopNotificationType.FINAL_OPENLOOP,
+ ControlLoopNotificationType.toType("FINAL: OPENLOOP"));
+
+ assertNull(ControlLoopNotificationType.toType("foo"));
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java
new file mode 100644
index 000000000..6c6a83e85
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Instant;
+import org.junit.Test;
+
+public class ControlLoopOperationTest {
+
+ @Test
+ public void test() {
+ ControlLoopOperation operation = new ControlLoopOperation();
+
+ assertEquals(operation, operation);
+ assertNotEquals(operation, new String());
+ assertNotEquals(operation, null);
+
+ assertTrue(operation.hashCode() != 0);
+ assertTrue(operation.toString().startsWith("ControlLoopOperation"));
+
+ assertNotNull(operation);
+
+ operation.setActor("actor");
+ assertEquals("actor", operation.getActor());
+
+ operation.setOperation("operation");
+ assertEquals("operation", operation.getOperation());
+
+ Instant now = Instant.now();
+ operation.setStart(now);
+ assertEquals(now, operation.getStart());
+ operation.setEnd(now);
+ assertEquals(now, operation.getEnd());
+
+ operation.setMessage("message");
+ assertEquals("message", operation.getMessage());
+
+ operation.setOutcome("outcome");
+ assertEquals("outcome", operation.getOutcome());
+
+ operation.setSubRequestId("1");
+ assertEquals("1", operation.getSubRequestId());
+
+ operation.setTarget("target");
+ assertEquals("target", operation.getTarget());
+
+ assertTrue(operation.hashCode() != 0);
+
+ ControlLoopOperation operation2 = new ControlLoopOperation(operation);
+ assertEquals(now, operation2.getEnd());
+
+ assertEquals(operation, operation2);
+
+ operation2.setActor("foo");
+ assertNotEquals(operation, operation2);
+
+ operation = new ControlLoopOperation(null);
+ assertNotNull(operation.getStart());
+
+ assertNotEquals(operation, operation2);
+
+ assertTrue(operation.toMessage().startsWith("actor="));
+ assertTrue(operation.toHistory().startsWith("actor="));
+
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationWrapperTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationWrapperTest.java
new file mode 100644
index 000000000..8d25c8eac
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationWrapperTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.UUID;
+import org.junit.Test;
+
+public class ControlLoopOperationWrapperTest {
+
+ @Test
+ public void test() {
+ ControlLoopOperationWrapper wrapper = new ControlLoopOperationWrapper();
+
+ assertNotNull(wrapper);
+
+ ControlLoopOperation operation = new ControlLoopOperation();
+ wrapper.setOperation(operation);
+ UUID id = UUID.randomUUID();
+ wrapper.setRequestId(id);
+
+ ControlLoopOperationWrapper wrapper2 = new ControlLoopOperationWrapper(wrapper.getRequestId(),
+ wrapper.getOperation());
+
+ assertEquals(operation, wrapper2.getOperation());
+ assertEquals(id, wrapper2.getRequestId());
+
+
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java
new file mode 100644
index 000000000..1afd1f674
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+public class ControlLoopTargetTypeTest {
+
+ @Test
+ public void test() {
+ assertEquals(ControlLoopTargetType.VM, ControlLoopTargetType.toType("VM"));
+ assertEquals(ControlLoopTargetType.VF, ControlLoopTargetType.toType("VF"));
+ assertEquals(ControlLoopTargetType.VFC, ControlLoopTargetType.toType("VFC"));
+ assertEquals(ControlLoopTargetType.VNF, ControlLoopTargetType.toType("VNF"));
+
+ assertNull(ControlLoopTargetType.toType("foo"));
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopEventTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopEventTest.java
new file mode 100644
index 000000000..b0f08e15b
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopEventTest.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+public class PhysicalControlLoopEventTest {
+
+ @Test
+ public void test() {
+ PhysicalControlLoopEvent event = new PhysicalControlLoopEvent();
+ assertNotNull(event);
+
+ PhysicalControlLoopEvent event2 = new PhysicalControlLoopEvent(event);
+ assertNotNull(event2);
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopNotificationTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopNotificationTest.java
new file mode 100644
index 000000000..e10707bc1
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopNotificationTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+public class PhysicalControlLoopNotificationTest {
+
+ @Test
+ public void test() {
+ PhysicalControlLoopNotification notification = new PhysicalControlLoopNotification();
+ assertNotNull(notification);
+
+ PhysicalControlLoopNotification notification2 = new PhysicalControlLoopNotification(
+ new PhysicalControlLoopEvent());
+ assertNotNull(notification2);
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopEventTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopEventTest.java
new file mode 100644
index 000000000..49837d191
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopEventTest.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.time.Instant;
+import org.junit.Test;
+
+public class VirtualControlLoopEventTest {
+
+ @Test
+ public void test() {
+ VirtualControlLoopEvent event = new VirtualControlLoopEvent();
+
+ assertNotNull(event);
+ assertNotNull(event.getAai());
+
+ Instant now = Instant.now();
+ event.setClosedLoopAlarmStart(now);
+ event.setClosedLoopAlarmEnd(now);
+
+ VirtualControlLoopEvent event2 = new VirtualControlLoopEvent(event);
+ assertEquals(now, event2.getClosedLoopAlarmStart());
+
+ event = new VirtualControlLoopEvent(null);
+ assertNull(event.getClosedLoopAlarmStart());
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopNotificationTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopNotificationTest.java
new file mode 100644
index 000000000..9adfebea2
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopNotificationTest.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Instant;
+import java.util.Collections;
+import org.junit.Test;
+
+public class VirtualControlLoopNotificationTest {
+
+ @Test
+ public void test() {
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification();
+ assertNotNull(notification);
+
+ notification.setAai(Collections.emptyMap());
+ assertTrue(notification.getAai().isEmpty());
+
+ Instant now = Instant.now();
+ notification.setClosedLoopAlarmStart(now);
+
+ notification.setClosedLoopAlarmEnd(now);
+
+ VirtualControlLoopEvent event = new VirtualControlLoopEvent();
+
+ Instant later = Instant.now();
+ event.setAai(Collections.emptyMap());
+ event.setClosedLoopAlarmStart(later);
+ event.setClosedLoopAlarmEnd(later);
+
+ notification = new VirtualControlLoopNotification(event);
+ assertEquals(later, notification.getClosedLoopAlarmStart());
+ assertEquals(later, notification.getClosedLoopAlarmEnd());
+
+ }
+}
diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/params/ControlLoopParamsTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/params/ControlLoopParamsTest.java
new file mode 100644
index 000000000..065345a1a
--- /dev/null
+++ b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/params/ControlLoopParamsTest.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * controlloop
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.params;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class ControlLoopParamsTest {
+
+ @Test
+ public void test() {
+ ControlLoopParams params = new ControlLoopParams();
+ assertNotNull(params);
+
+ params.setClosedLoopControlName("name");
+ params.setControlLoopYaml("yaml");
+ params.setPolicyName("name");
+ params.setPolicyScope("scope");
+ params.setPolicyVersion("1");
+
+ ControlLoopParams params2 = new ControlLoopParams(params);
+
+ assertTrue(params2.getClosedLoopControlName().equals("name"));
+ assertTrue(params2.getControlLoopYaml().equals("yaml"));
+ assertTrue(params2.getPolicyName().equals("name"));
+ assertTrue(params2.getPolicyScope().equals("scope"));
+ assertTrue(params2.getPolicyVersion().equals("1"));
+
+ }
+}
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java
index 19cca8c82..b924c2d14 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java
@@ -46,6 +46,30 @@ public class ControlLoop implements Serializable {
// Empty Constructor.
}
+ /**
+ * Constructor.
+ *
+ * @param controlLoop copy object
+ */
+ public ControlLoop(ControlLoop controlLoop) {
+ this.controlLoopName = controlLoop.controlLoopName;
+ this.services = new LinkedList<>();
+ if (controlLoop.services != null) {
+ for (Service service : controlLoop.services) {
+ this.services.add(service);
+ }
+ }
+ this.resources = new LinkedList<>();
+ if (controlLoop.resources != null) {
+ for (Resource resource : controlLoop.resources) {
+ this.resources.add(resource);
+ }
+ }
+ this.triggerPolicy = controlLoop.triggerPolicy;
+ this.timeout = controlLoop.timeout;
+ this.abatement = controlLoop.abatement;
+ }
+
public static String getCompilerVersion() {
return ControlLoop.COMPILER_VERSION;
}
@@ -114,30 +138,6 @@ public class ControlLoop implements Serializable {
this.pnf = pnf;
}
- /**
- * Constructor.
- *
- * @param controlLoop copy object
- */
- public ControlLoop(ControlLoop controlLoop) {
- this.controlLoopName = controlLoop.controlLoopName;
- this.services = new LinkedList<>();
- if (controlLoop.services != null) {
- for (Service service : controlLoop.services) {
- this.services.add(service);
- }
- }
- this.resources = new LinkedList<>();
- if (controlLoop.resources != null) {
- for (Resource resource : controlLoop.resources) {
- this.resources.add(resource);
- }
- }
- this.triggerPolicy = controlLoop.triggerPolicy;
- this.timeout = controlLoop.timeout;
- this.abatement = controlLoop.abatement;
- }
-
@Override
public String toString() {
return "ControlLoop [controlLoopName=" + controlLoopName + ", version=" + version + ", services=" + services