2 * Copyright (c) 2015 Cisco Systems, Inc. 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
9 package org.opendaylight.openflowplugin.impl.statistics.services;
11 import java.util.concurrent.atomic.AtomicLong;
12 import org.junit.Assert;
13 import org.junit.Test;
14 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder;
20 import org.opendaylight.yangtools.yang.common.Uint32;
23 * Test of {@link PortStatsService}.
25 public class PortStatsServiceTest extends AbstractStatsServiceTest {
27 private PortStatsService portStatsService;
31 portStatsService = new PortStatsService(rqContextStack, deviceContext,
36 public void testBuildRequest() {
37 Xid xid = new Xid(Uint32.valueOf(42L));
38 GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder()
39 .setNodeConnectorId(new NodeConnectorId("junitProto:11:12"))
40 .setNode(createNodeRef("junitProto:11"));
42 final OfHeader request = portStatsService.buildRequest(xid, input.build());
44 Assert.assertTrue(request instanceof MultipartRequestInput);
45 final MultipartRequestInput mpRequest = (MultipartRequestInput) request;
46 Assert.assertTrue(mpRequest.getMultipartRequestBody() instanceof MultipartRequestPortStatsCase);
47 final MultipartRequestPortStatsCase mpRequestBody =
48 (MultipartRequestPortStatsCase) mpRequest.getMultipartRequestBody();
49 Assert.assertEquals(12L, mpRequestBody.getMultipartRequestPortStats().getPortNo().longValue());