Fix yangtools reference
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / services / singlelayer / SingleLayerPortServiceTest.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.singlelayer;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.junit.Test;
13 import org.opendaylight.openflowplugin.impl.services.ServiceMocking;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
20 import org.opendaylight.yangtools.yang.common.Uint32;
21
22 public class SingleLayerPortServiceTest extends ServiceMocking {
23     private static final Uint32 PORT_ID = Uint32.valueOf(42);
24     private SingleLayerPortService<UpdatePortOutput> service;
25
26     @Override
27     protected void setup() {
28         service = new SingleLayerPortService<>(mockedRequestContextStack, mockedDeviceContext, UpdatePortOutput.class);
29     }
30
31     @Test
32     public void buildRequest() {
33         final Port input = new PortBuilder()
34                 .setPortNumber(new PortNumberUni(PORT_ID))
35                 .setPortModOrder(Uint32.ZERO)
36                 .build();
37
38         final OfHeader ofHeader = service.buildRequest(DUMMY_XID, input);
39         assertEquals(PortMessage.class, ofHeader.implementedInterface());
40
41         final PortMessage result = (PortMessage) ofHeader;
42
43         assertEquals(PORT_ID, result.getPortNumber().getUint32());
44     }
45 }