2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.controlloop;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertTrue;
28 import java.util.UUID;
29 import org.junit.Test;
31 public class ControlLoopEventTest {
33 private class TestControlLoopEvent extends ControlLoopEvent {
34 private static final long serialVersionUID = 1L;
36 public TestControlLoopEvent() {
40 public TestControlLoopEvent(ControlLoopEvent event) {
47 ControlLoopEvent event = new TestControlLoopEvent();
49 assertEquals("1.0.2", event.getVersion());
51 event = new TestControlLoopEvent(null);
52 assertEquals("1.0.2", event.getVersion());
54 event.setClosedLoopControlName("name");
55 assertEquals("name", event.getClosedLoopControlName());
57 event.setClosedLoopEventClient("client");
58 assertEquals("client", event.getClosedLoopEventClient());
60 event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
61 assertEquals(ControlLoopEventStatus.ONSET, event.getClosedLoopEventStatus());
63 event.setFrom("from");
64 assertEquals("from", event.getFrom());
66 event.setPayload("payload");
67 assertEquals("payload", event.getPayload());
69 event.setPolicyName("policyname");
70 assertEquals("policyname", event.getPolicyName());
72 event.setPolicyScope("scope");
73 assertEquals("scope", event.getPolicyScope());
75 event.setPolicyVersion("1");
76 assertEquals("1", event.getPolicyVersion());
78 UUID id = UUID.randomUUID();
79 event.setRequestId(id);
80 assertEquals(id, event.getRequestId());
82 event.setTarget("target");
83 assertEquals("target", event.getTarget());
85 event.setTargetType(ControlLoopTargetType.VF);
86 assertEquals(ControlLoopTargetType.VF, event.getTargetType());
88 event.setVersion("foo");
89 assertEquals("foo", event.getVersion());
91 ControlLoopEvent event2 = new TestControlLoopEvent(event);
92 assertTrue(event2.isEventStatusValid());
94 event2.setClosedLoopEventStatus(null);
95 assertFalse(event2.isEventStatusValid());