Merge "Rpc manager not needed to instantiate DeviceManager"
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / device / DeviceManagerImplTest.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.impl.device;
9
10 import org.junit.After;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Ignore;
14 import org.junit.Test;
15 import org.junit.runner.RunWith;
16 import org.mockito.ArgumentCaptor;
17 import org.mockito.Mock;
18 import org.mockito.Mockito;
19 import org.mockito.runners.MockitoJUnitRunner;
20 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
21 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
22 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
23 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcManager;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCase;
27
28
29 /**
30  * test of {@link DeviceManagerImpl} - lightweight version, using basic ways (TDD)
31  */
32 @RunWith(MockitoJUnitRunner.class)
33 public class DeviceManagerImplTest {
34
35     private DeviceManagerImpl deviceManager;
36     @Mock
37     private ConnectionContext connectionContext;
38     @Mock
39     private ConnectionAdapter connectionAdapter;
40     @Mock
41     private FeaturesReply features;
42     @Mock
43     private DataBroker dataBroker;
44     @Mock
45     private RpcManager rpcManager;
46
47     /**
48      * @throws java.lang.Exception
49      */
50     @Before
51     public void setUp() throws Exception {
52         Mockito.when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter);
53         Mockito.when(connectionContext.getFeatures()).thenReturn(features);
54         Mockito.when(features.getVersion()).thenReturn((short) 42);
55         deviceManager = new DeviceManagerImpl(dataBroker);
56     }
57
58     /**
59      * @throws java.lang.Exception
60      */
61     @After
62     public void tearDown() throws Exception {
63     }
64
65     /**
66      * Test method for {@link org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl#deviceConnected(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)}.
67      */
68     @Test
69     @Ignore // FIXME : fix the test ASAP
70     public void testDeviceConnected() {
71         deviceManager.deviceConnected(connectionContext);
72
73         final ArgumentCaptor<MultipartRequestInput> mpInputCaptor = ArgumentCaptor.forClass(MultipartRequestInput.class);
74         Mockito.verify(connectionAdapter).multipartRequest(mpInputCaptor.capture());
75
76         Assert.assertTrue(mpInputCaptor.getAllValues().get(0).getMultipartRequestBody() instanceof MultipartRequestDescCase);
77         //Assert.assertTrue(mpInputCaptor.getAllValues().get(1).getMultipartRequestBody() instanceof MultipartRequestGroupDescCase);
78     }
79
80     /**
81      * Test method for {@link org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl#sendMessage(org.opendaylight.yangtools.yang.binding.DataObject, org.opendaylight.openflowplugin.api.openflow.device.RequestContext)}.
82      */
83     @Test
84     public void testSendMessage() {
85     }
86
87     /**
88      * Test method for {@link org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl#sendRequest(org.opendaylight.yangtools.yang.binding.DataObject, org.opendaylight.openflowplugin.api.openflow.device.RequestContext)}.
89      */
90     @Test
91     public void testSendRequest() {
92     }
93
94     /**
95      * Test method for {@link org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl#addRequestContextReadyHandler(org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextReadyHandler)}.
96      */
97     @Test
98     public void testAddRequestContextReadyHandler() {
99     }
100
101     @Test
102     public void testHookRequest() {
103
104     }
105
106 }