migrate model-impl from drools-applications
[policy/models.git] / models-interactions / model-impl / events / src / test / java / org / onap / policy / controlloop / ControlLoopEventTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * controlloop
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.policy.controlloop;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertTrue;
27
28 import java.util.UUID;
29 import org.junit.Test;
30
31 public class ControlLoopEventTest {
32
33     private class TestControlLoopEvent extends ControlLoopEvent {
34         private static final long serialVersionUID = 1L;
35
36         public TestControlLoopEvent() {
37             super();
38         }
39
40         public TestControlLoopEvent(ControlLoopEvent event) {
41             super(event);
42         }
43     }
44
45     @Test
46     public void test() {
47         ControlLoopEvent event = new TestControlLoopEvent();
48
49         assertEquals("1.0.2", event.getVersion());
50
51         event = new TestControlLoopEvent(null);
52         assertEquals("1.0.2", event.getVersion());
53
54         event.setClosedLoopControlName("name");
55         assertEquals("name", event.getClosedLoopControlName());
56
57         event.setClosedLoopEventClient("client");
58         assertEquals("client", event.getClosedLoopEventClient());
59
60         event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
61         assertEquals(ControlLoopEventStatus.ONSET, event.getClosedLoopEventStatus());
62
63         event.setFrom("from");
64         assertEquals("from", event.getFrom());
65
66         event.setPayload("payload");
67         assertEquals("payload", event.getPayload());
68
69         event.setPolicyName("policyname");
70         assertEquals("policyname", event.getPolicyName());
71
72         event.setPolicyScope("scope");
73         assertEquals("scope", event.getPolicyScope());
74
75         event.setPolicyVersion("1");
76         assertEquals("1", event.getPolicyVersion());
77
78         UUID id = UUID.randomUUID();
79         event.setRequestId(id);
80         assertEquals(id, event.getRequestId());
81
82         event.setTarget("target");
83         assertEquals("target", event.getTarget());
84
85         event.setTargetType(ControlLoopTargetType.VF);
86         assertEquals(ControlLoopTargetType.VF, event.getTargetType());
87
88         event.setVersion("foo");
89         assertEquals("foo", event.getVersion());
90
91         ControlLoopEvent event2 = new TestControlLoopEvent(event);
92         assertTrue(event2.isEventStatusValid());
93
94         event2.setClosedLoopEventStatus(null);
95         assertFalse(event2.isEventStatusValid());
96     }
97 }