Decompose RPC implementation classes
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / services / sal / SendBarrierImplTest.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.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;
23
24 /**
25  * Test for {@link SendBarrierImpl}.
26  */
27 public class SendBarrierImplTest extends ServiceMocking {
28     private static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(100);
29
30     private SendBarrierImpl sendBarrier;
31
32     @Override
33     protected void setup() {
34         sendBarrier = new SendBarrierImpl(mockedRequestContextStack, mockedDeviceContext);
35     }
36
37     @Test
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);
42     }
43
44     @Test
45     public void testSendBarrier() {
46         sendBarrier.invoke(buildSendBarrierInput());
47         verify(mockedRequestContextStack).createRequestContext();
48     }
49
50     private @NonNull SendBarrierInput buildSendBarrierInput() {
51         return new SendBarrierInputBuilder().setNode(new NodeRef(mockedDeviceInfo.getNodeInstanceIdentifier())).build();
52     }
53 }