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
8 package org.opendaylight.openflowplugin.impl.services.sal;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12 import static org.mockito.Mockito.verify;
14 import org.eclipse.jdt.annotation.NonNull;
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.yangtools.yang.common.Uint32;
25 * Test for {@link SendBarrierImpl}.
27 public class SendBarrierImplTest extends ServiceMocking {
28 private static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(100);
30 private SendBarrierImpl sendBarrier;
33 protected void setup() {
34 sendBarrier = new SendBarrierImpl(mockedRequestContextStack, mockedDeviceContext);
38 public void testBuildRequest() {
39 final var request = sendBarrier.buildRequest(new Xid(DUMMY_XID_VALUE), buildSendBarrierInput());
40 assertEquals(DUMMY_XID_VALUE, request.getXid());
41 assertTrue(request instanceof BarrierInput);
45 public void testSendBarrier() {
46 sendBarrier.invoke(buildSendBarrierInput());
47 verify(mockedRequestContextStack).createRequestContext();
50 private @NonNull SendBarrierInput buildSendBarrierInput() {
51 return new SendBarrierInputBuilder().setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier())).build();