Add missing license headers
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / util / MdSalRegistrationUtilsTest.java
1 /*
2  * Copyright (c) 2015 Cisco 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 package org.opendaylight.openflowplugin.impl.util;
10
11
12 import static org.mockito.Matchers.any;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.times;
15 import static org.mockito.Mockito.verify;
16 import static org.mockito.Mockito.when;
17
18 import java.math.BigInteger;
19 import org.junit.Test;
20 import org.mockito.Matchers;
21 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
22 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
23 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
24 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
25 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
26 import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
29 import org.opendaylight.yangtools.yang.binding.RpcService;
30
31 public class MdSalRegistrationUtilsTest {
32
33     /**
34      * Number of currently registrated services (can be changed)
35      * (RpcContext, DeviceContext)}
36      */
37     private static final int NUMBER_OF_RPC_SERVICE_REGISTRATION = 13;
38
39     @Test
40     public void registerServiceTest() {
41
42         final RpcContext mockedRpcContext = mock(RpcContext.class);
43         final DeviceContext mockedDeviceContext = mock(DeviceContext.class);
44         final ConnectionContext mockedConnectionContext = mock(ConnectionContext.class);
45
46         final DeviceState mockedDeviceState = mock(DeviceState.class);
47         final DeviceInfo mockedDeviceInfo = mock(DeviceInfo.class);
48         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
49         when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
50
51         final FeaturesReply mockedFeatures = mock(FeaturesReply.class);
52         when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures);
53
54         final BigInteger mockedDataPathId = mock(BigInteger.class);
55         when(mockedFeatures.getDatapathId()).thenReturn(mockedDataPathId);
56         when(mockedDeviceInfo.getDatapathId()).thenReturn(mockedDataPathId);
57
58         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
59
60         final ExtensionConverterProvider extensionConverterProvider = mock(ExtensionConverterProvider.class);
61         MdSalRegistrationUtils.registerServices(mockedRpcContext, mockedDeviceContext, extensionConverterProvider);
62         verify(mockedRpcContext, times(NUMBER_OF_RPC_SERVICE_REGISTRATION)).registerRpcServiceImplementation(
63                 Matchers.<Class<RpcService>> any(), any(RpcService.class));
64     }
65
66 }