Remove unused routedRpcRegistration
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / services / sal / FlowCapableTransactionServiceImplTest.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.services.sal;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12 import static org.mockito.Mockito.verify;
13
14 import org.junit.Test;
15 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
16 import org.opendaylight.openflowplugin.impl.services.ServiceMocking;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInputBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
22 import org.opendaylight.yangtools.yang.common.Uint32;
23
24 /**
25  * Test for {@link FlowCapableTransactionServiceImpl}.
26  */
27 public class FlowCapableTransactionServiceImplTest extends ServiceMocking {
28
29     private static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(100);
30     FlowCapableTransactionServiceImpl flowCapableTransactionService;
31
32     @Override
33     protected void setup() {
34         flowCapableTransactionService =
35                 new FlowCapableTransactionServiceImpl(mockedRequestContextStack, mockedDeviceContext);
36     }
37
38     @Test
39     public void testBuildRequest() {
40         SendBarrierInput sendBarrierInput = buildSendBarrierInput();
41
42         final OfHeader request = flowCapableTransactionService.buildRequest(new Xid(DUMMY_XID_VALUE), sendBarrierInput);
43         assertEquals(DUMMY_XID_VALUE, request.getXid());
44         assertTrue(request instanceof BarrierInput);
45     }
46
47     @Test
48     public void testSendBarrier() {
49         SendBarrierInput sendBarrierInput = buildSendBarrierInput();
50         flowCapableTransactionService.sendBarrier(sendBarrierInput);
51         verify(mockedRequestContextStack).createRequestContext();
52     }
53
54     private SendBarrierInput buildSendBarrierInput() {
55         return new SendBarrierInputBuilder()
56                 .setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier())).build();
57     }
58 }