2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
27 import java.util.UUID;
28 import org.junit.Test;
30 public class ControlLoopEventTest {
32 private class TestControlLoopEvent extends ControlLoopEvent {
33 private static final long serialVersionUID = 1L;
35 public TestControlLoopEvent() {
39 public TestControlLoopEvent(ControlLoopEvent event) {
46 ControlLoopEvent event = new TestControlLoopEvent();
48 assertEquals("1.0.2", event.getVersion());
50 event = new TestControlLoopEvent(null);
51 assertEquals("1.0.2", event.getVersion());
53 event.setClosedLoopControlName("name");
54 assertEquals("name", event.getClosedLoopControlName());
56 event.setClosedLoopEventClient("client");
57 assertEquals("client", event.getClosedLoopEventClient());
59 event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
60 assertEquals(ControlLoopEventStatus.ONSET, event.getClosedLoopEventStatus());
62 event.setFrom("from");
63 assertEquals("from", event.getFrom());
65 event.setPayload("payload");
66 assertEquals("payload", event.getPayload());
68 event.setPolicyName("policyname");
69 assertEquals("policyname", event.getPolicyName());
71 event.setPolicyScope("scope");
72 assertEquals("scope", event.getPolicyScope());
74 event.setPolicyVersion("1");
75 assertEquals("1", event.getPolicyVersion());
77 UUID id = UUID.randomUUID();
78 event.setRequestId(id);
79 assertEquals(id, event.getRequestId());
81 event.setTarget("target");
82 assertEquals("target", event.getTarget());
84 event.setTargetType(ControlLoopTargetType.VF);
85 assertEquals(ControlLoopTargetType.VF, event.getTargetType());
87 event.setVersion("foo");
88 assertEquals("foo", event.getVersion());
90 ControlLoopEvent event2 = new TestControlLoopEvent(event);
91 assertTrue(event2.isEventStatusValid());
93 event2.setClosedLoopEventStatus(null);
94 assertFalse(event2.isEventStatusValid());