2a8cec9bdb3d1fc9418b3ff272d53bb46b076935
[transportpce.git] / olm / src / test / java / org / opendaylight / transportpce / olm / OlmProviderTest.java
1 /*
2  * Copyright © 2018 Orange Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9
10 package org.opendaylight.transportpce.olm;
11
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.controller.md.sal.binding.api.MountPoint;
15 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
16 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
17 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
18 import org.opendaylight.transportpce.common.crossconnect.CrossConnectImpl;
19 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
20 import org.opendaylight.transportpce.common.device.DeviceTransactionManagerImpl;
21 import org.opendaylight.transportpce.common.mapping.PortMapping;
22 import org.opendaylight.transportpce.common.mapping.PortMappingImpl;
23 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
24 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfacesImpl;
25 import org.opendaylight.transportpce.olm.power.PowerMgmt;
26 import org.opendaylight.transportpce.olm.service.OlmPowerService;
27 import org.opendaylight.transportpce.olm.service.OlmPowerServiceImpl;
28 import org.opendaylight.transportpce.olm.stub.MountPointServiceStub;
29 import org.opendaylight.transportpce.olm.stub.MountPointStub;
30 import org.opendaylight.transportpce.olm.stub.RpcProviderRegistryStub;
31 import org.opendaylight.transportpce.olm.stub.RpcProviderRegistryStub2;
32 import org.opendaylight.transportpce.test.AbstractTest;
33
34 public class OlmProviderTest extends AbstractTest {
35
36     private MountPoint mountPoint;
37     private MountPointService mountPointService;
38     private DeviceTransactionManager deviceTransactionManager;
39     private CrossConnect crossConnect;
40     private OpenRoadmInterfaces openRoadmInterfaces;
41     private PortMapping portMapping;
42     private PowerMgmt powerMgmt;
43     private OlmPowerService olmPowerService;
44     private RpcProviderRegistry rpcProviderRegistry;
45     private OlmProvider olmProvider;
46
47     @Before
48     public void setUp() {
49         this.mountPoint = new MountPointStub(this.getDataBroker());
50         this.mountPointService = new MountPointServiceStub(mountPoint);
51         this.deviceTransactionManager = new DeviceTransactionManagerImpl(mountPointService, 3000);
52         this.crossConnect = new CrossConnectImpl(this.deviceTransactionManager);
53         this.openRoadmInterfaces = new OpenRoadmInterfacesImpl((this.deviceTransactionManager));
54         this.portMapping = new PortMappingImpl(this.getDataBroker(), this.deviceTransactionManager,
55             this.openRoadmInterfaces);
56         this.powerMgmt = new PowerMgmt(this.getDataBroker(), this.openRoadmInterfaces, this.crossConnect,
57             this.deviceTransactionManager);
58         this.olmPowerService = new OlmPowerServiceImpl(this.getDataBroker(), this.powerMgmt,
59             this.deviceTransactionManager, this.portMapping);
60         this.rpcProviderRegistry = new RpcProviderRegistryStub();
61         this.olmProvider = new OlmProvider(this.rpcProviderRegistry, this.olmPowerService);
62
63     }
64
65
66     @Test
67     public void testInitAndClose() {
68         this.olmProvider.init();
69         this.olmProvider.close();
70     }
71
72
73     @Test
74     public void testClose2() {
75         this.rpcProviderRegistry = new RpcProviderRegistryStub2();
76         this.olmProvider = new OlmProvider(this.rpcProviderRegistry, this.olmPowerService);
77         this.olmProvider.init();
78         this.olmProvider.close();
79     }
80
81 }