Merge "Drop Felix Gogo"
[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.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
28 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
30 import org.opendaylight.yangtools.yang.binding.RpcService;
31
32 public class MdSalRegistrationUtilsTest {
33
34     /**
35      * Number of currently registrated services (can be changed)
36      * (RpcContext, DeviceContext)}
37      */
38     private static final int NUMBER_OF_RPC_SERVICE_REGISTRATION = 13;
39
40     @Test
41     public void registerServiceTest() {
42
43         final RpcContext mockedRpcContext = mock(RpcContext.class);
44         final DeviceContext mockedDeviceContext = mock(DeviceContext.class);
45         final ConnectionContext mockedConnectionContext = mock(ConnectionContext.class);
46
47         final DeviceState mockedDeviceState = mock(DeviceState.class);
48         final DeviceInfo mockedDeviceInfo = mock(DeviceInfo.class);
49         when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
50         when(mockedDeviceContext.getDeviceInfo()).thenReturn(mockedDeviceInfo);
51
52         final FeaturesReply mockedFeatures = mock(FeaturesReply.class);
53         when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures);
54
55         final BigInteger mockedDataPathId = mock(BigInteger.class);
56         when(mockedFeatures.getDatapathId()).thenReturn(mockedDataPathId);
57         when(mockedDeviceInfo.getDatapathId()).thenReturn(mockedDataPathId);
58
59         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
60
61         final ExtensionConverterProvider extensionConverterProvider = mock(ExtensionConverterProvider.class);
62         final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
63         MdSalRegistrationUtils.registerServices(mockedRpcContext, mockedDeviceContext, extensionConverterProvider, convertorManager);
64         verify(mockedRpcContext, times(NUMBER_OF_RPC_SERVICE_REGISTRATION)).registerRpcServiceImplementation(
65                 Matchers.<Class<RpcService>> any(), any(RpcService.class));
66     }
67
68 }