2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.sal;
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.openflowplugin.impl.services.ServiceMocking;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInputBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
25 * Test for {@link FlowCapableTransactionServiceImpl}.
27 public class FlowCapableTransactionServiceImplTest extends ServiceMocking {
29 private static final Long DUMMY_XID_VALUE = 100L;
30 FlowCapableTransactionServiceImpl flowCapableTransactionService;
33 protected void setup() {
34 flowCapableTransactionService =
35 new FlowCapableTransactionServiceImpl(mockedRequestContextStack, mockedDeviceContext);
39 public void testBuildRequest() {
40 SendBarrierInput sendBarrierInput = buildSendBarrierInput();
42 final OfHeader request = flowCapableTransactionService.buildRequest(new Xid(DUMMY_XID_VALUE), sendBarrierInput);
43 assertEquals(DUMMY_XID_VALUE, request.getXid());
44 assertTrue(request instanceof BarrierInput);
48 public void testSendBarrier() {
49 SendBarrierInput sendBarrierInput = buildSendBarrierInput();
50 flowCapableTransactionService.sendBarrier(sendBarrierInput);
51 verify(mockedRequestContextStack).createRequestContext();
54 private SendBarrierInput buildSendBarrierInput() {
55 return new SendBarrierInputBuilder()
56 .setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier())).build();