Fix errors in serializers and deserializers
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / services / FlowCapableTransactionServiceImplTest.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.services;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
13 import static org.mockito.Mockito.verify;
14
15 import org.junit.Test;
16 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
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
23 /**
24  * Test for {@link FlowCapableTransactionServiceImpl}.
25  */
26 public class FlowCapableTransactionServiceImplTest extends ServiceMocking {
27
28     private static final Long DUMMY_XID_VALUE = 100L;
29     FlowCapableTransactionServiceImpl flowCapableTransactionService;
30
31     @Override
32     protected void setup() {
33         flowCapableTransactionService = new FlowCapableTransactionServiceImpl(mockedRequestContextStack, mockedDeviceContext);
34     }
35
36     @Test
37     public void testBuildRequest() throws Exception {
38         SendBarrierInput sendBarrierInput = buildSendBarrierInput();
39
40         final OfHeader request = flowCapableTransactionService.buildRequest(new Xid(DUMMY_XID_VALUE), sendBarrierInput);
41         assertEquals(DUMMY_XID_VALUE, request.getXid());
42         assertTrue(request instanceof BarrierInput);
43     }
44
45     @Test
46     public void testSendBarrier() throws Exception {
47         SendBarrierInput sendBarrierInput = buildSendBarrierInput();
48         flowCapableTransactionService.sendBarrier(sendBarrierInput);
49         verify(mockedRequestContextStack).createRequestContext();
50     }
51
52     private SendBarrierInput buildSendBarrierInput() {
53         return new SendBarrierInputBuilder()
54                 .setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier())).build();
55     }
56 }