Add m2 model, including the LCM application
[policy/drools-applications.git] / controlloop / m2 / adapters / src / test / java / org / onap / policy / m2 / adapters / VirtualOnsetAdapterTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * adapters
4  * ================================================================================
5  * Copyright (C) 2020 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.m2.adapters;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertTrue;
25
26 import org.junit.Test;
27
28 import org.onap.policy.controlloop.ControlLoopEvent;
29 import org.onap.policy.controlloop.ControlLoopNotification;
30 import org.onap.policy.controlloop.VirtualControlLoopEvent;
31 import org.onap.policy.controlloop.VirtualControlLoopNotification;
32 import org.onap.policy.m2.base.OnsetAdapter;
33
34 public class VirtualOnsetAdapterTest {
35
36     @Test
37     public void test() {
38         VirtualOnsetAdapter.register();
39         VirtualControlLoopEvent virtualControlLoopEvent = new VirtualControlLoopEvent();
40         VirtualOnsetAdapter virtualOnsetAdapter =
41             VirtualOnsetAdapter.class.cast(OnsetAdapter.get(virtualControlLoopEvent));
42         assertTrue(virtualOnsetAdapter != null);
43
44         ControlLoopNotification notification = virtualOnsetAdapter.createNotification(virtualControlLoopEvent);
45         assertTrue(notification != null);
46         // we want an exact class match, so 'instanceOf' is not being used
47         assertEquals(VirtualControlLoopNotification.class, notification.getClass());
48
49         ControlLoopEvent controlLoopEvent = new ControlLoopEvent() {};
50         notification = virtualOnsetAdapter.createNotification(controlLoopEvent);
51         assertTrue(notification != null);
52     }
53 }