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