Add missing license headers
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / services / SalPortServiceImplTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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;
9
10 import static org.mockito.Mockito.verify;
11
12 import com.google.common.collect.Lists;
13 import java.util.List;
14 import org.junit.Test;
15 import org.junit.runner.RunWith;
16 import org.mockito.runners.MockitoJUnitRunner;
17 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.Port;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInputBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPort;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPortBuilder;
29
30 @RunWith(MockitoJUnitRunner.class)
31 public class SalPortServiceImplTest extends ServiceMocking {
32
33     private static final Long DUMMY_XID = 55L;
34     private static final Long DUMMY_PORT_NUMBER = 66L;
35     private static final String DUMMY_MAC_ADDRESS = "AA:BB:CC:DD:EE:FF";
36     SalPortServiceImpl salPortService;
37
38     @Override
39     public void initialization() {
40         super.initialization();
41         salPortService = new SalPortServiceImpl(mockedRequestContextStack, mockedDeviceContext);
42     }
43
44     @Test
45     public void testUpdatePort() throws Exception {
46         salPortService.updatePort(dummyUpdatePortInput());
47         verify(mockedRequestContextStack).createRequestContext();
48     }
49
50     @Test
51     public void testBuildRequest() {
52         final OfHeader ofHeader = salPortService.buildRequest(new Xid(DUMMY_XID), dummyUpdatePortInput());
53     }
54
55     private UpdatePortInput dummyUpdatePortInput(){
56         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder concretePortBuilder
57                 = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder();
58         concretePortBuilder.setConfiguration(new PortConfig(true, true, true, true));
59         concretePortBuilder.setAdvertisedFeatures(new PortFeatures(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true));
60         concretePortBuilder.setPortNumber(new PortNumberUni(DUMMY_PORT_NUMBER));
61         concretePortBuilder.setHardwareAddress(new MacAddress(DUMMY_MAC_ADDRESS));
62
63         List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port> ports
64                 = Lists.newArrayList(concretePortBuilder.build());
65         Port port = new PortBuilder().setPort(ports).build();
66         UpdatedPort updatePort = new UpdatedPortBuilder().setPort(port).build();
67         return new UpdatePortInputBuilder().setUpdatedPort(updatePort).build();
68     }
69 }