Coverage - registrator and translator libraty util.
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / util / MdSalRegistratorUtilsTest.java
1 /*
2  *
3  *  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
4  *  *
5  *  * This program and the accompanying materials are made available under the
6  *  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  *  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  *
9  *
10  */
11
12 package org.opendaylight.openflowplugin.impl.util;
13
14
15 import static org.mockito.Mockito.*;
16 import static org.mockito.Matchers.*;
17
18 import java.math.BigInteger;
19 import org.junit.Test;
20
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.rpc.RpcContext;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
25 import org.opendaylight.yangtools.yang.binding.RpcService;
26
27 public class MdSalRegistratorUtilsTest {
28
29     /**
30      * Number of currently registrated services (can be changed) in {@link MdSalRegistratorUtils#registerServices
31      * (RpcContext, DeviceContext)}
32      */
33     private static final int NUMBER_OF_RPC_SERVICE_REGISTRATION = 9;
34
35     @Test
36     public void registerServiceTest() {
37
38         final RpcContext mockedRpcContext = mock(RpcContext.class);
39         final DeviceContext mockedDeviceContext = mock(DeviceContext.class);
40         final ConnectionContext mockedConnectionContext = mock(ConnectionContext.class);
41
42         final FeaturesReply mockedFeatures = mock(FeaturesReply.class);
43         when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeatures);
44
45         final BigInteger mockedDataPathId = mock(BigInteger.class);
46         when(mockedFeatures.getDatapathId()).thenReturn(mockedDataPathId);
47
48         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedConnectionContext);
49         MdSalRegistratorUtils.registerServices(mockedRpcContext,mockedDeviceContext);
50         verify(mockedRpcContext, times(NUMBER_OF_RPC_SERVICE_REGISTRATION)).registerRpcServiceImplementation(any
51                         (RpcService.class.getClass()), any(RpcService.class));
52     }
53
54 }