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