2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.openflowplugin.impl.services;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
13 import static org.mockito.Mockito.verify;
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;
24 * Test for {@link FlowCapableTransactionServiceImpl}.
26 public class FlowCapableTransactionServiceImplTest extends ServiceMocking {
28 private static final Long DUMMY_XID_VALUE = 100L;
29 FlowCapableTransactionServiceImpl flowCapableTransactionService;
32 protected void setup() {
33 flowCapableTransactionService = new FlowCapableTransactionServiceImpl(mockedRequestContextStack, mockedDeviceContext);
37 public void testBuildRequest() throws Exception {
38 SendBarrierInput sendBarrierInput = buildSendBarrierInput();
40 final OfHeader request = flowCapableTransactionService.buildRequest(new Xid(DUMMY_XID_VALUE), sendBarrierInput);
41 assertEquals(DUMMY_XID_VALUE, request.getXid());
42 assertTrue(request instanceof BarrierInput);
46 public void testSendBarrier() throws Exception {
47 SendBarrierInput sendBarrierInput = buildSendBarrierInput();
48 flowCapableTransactionService.sendBarrier(sendBarrierInput);
49 verify(mockedRequestContextStack).createRequestContext();
52 private SendBarrierInput buildSendBarrierInput() {
53 return new SendBarrierInputBuilder()
54 .setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier())).build();