d335c2b4a992d8047ed954fc737c03c02f8a6de6
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / api / openflow / device / RpcManagerImplTest.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 package org.opendaylight.openflowplugin.api.openflow.device;
9
10 import static org.mockito.Mockito.mock;
11 import static org.mockito.Mockito.times;
12 import static org.mockito.Mockito.when;
13 import static org.mockito.Mockito.verify;
14
15 import org.junit.Test;
16 import org.mockito.Matchers;
17 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
18 import org.opendaylight.openflowplugin.impl.rpc.RpcManagerImpl;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
20 import org.opendaylight.yangtools.yang.binding.RpcService;
21
22 public class RpcManagerImplTest {
23
24     private static final int AWAITED_NUM_OF_CALL_ADD_ROUTED_RPC = 13;
25
26     final ProviderContext mockedProviderContext = mock(ProviderContext.class);
27     final RpcManagerImpl rpcManager = new RpcManagerImpl(mockedProviderContext);
28     final DeviceContext mockedRequestContext = mock(DeviceContext.class);
29
30     @Test
31     public void deviceConnectedTest() {
32
33         rpcManager.deviceConnected(mockedRequestContext);
34
35         verify(mockedProviderContext, times(AWAITED_NUM_OF_CALL_ADD_ROUTED_RPC)).addRoutedRpcImplementation(
36                 Matchers.any(Class.class), Matchers.any(RpcService.class));
37     }
38
39     /**
40      * Tests behavior of RpcContextImpl when calling rpc from MD-SAL
41      */
42     @Test
43     public void invokeRpcTest() {
44         
45         rpcManager.deviceConnected(mockedRequestContext);
46 //        when(mockedProviderContext.getRpcService(SalFlowService.class)).thenReturn(value);
47         final SalFlowService salFlowService = mockedProviderContext.getRpcService(SalFlowService.class);
48
49     }
50 }