Bump mdsal to 5.0.2
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / statistics / services / dedicated / StatisticsGatheringServiceTest.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
9 package org.opendaylight.openflowplugin.impl.statistics.services.dedicated;
10
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.mockito.Mockito;
14 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
15 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
16 import org.opendaylight.openflowplugin.impl.services.ServiceMocking;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
20 import org.opendaylight.yangtools.yang.common.Uint32;
21
22 /**
23  * Test for {@link StatisticsGatheringService}.
24  */
25 public class StatisticsGatheringServiceTest extends ServiceMocking {
26
27     private StatisticsGatheringService statisticsGatheringService;
28
29     @Override
30     protected void setup() {
31         statisticsGatheringService = new StatisticsGatheringService(mockedRequestContextStack, mockedDeviceContext);
32
33     }
34
35     @Test
36     public void testGetStatisticsOfType() {
37         final EventIdentifier eventIdentifier = new EventIdentifier("ut-event", "ut-device-id:1");
38         for (MultipartType mpType : MultipartType.values()) {
39             statisticsGatheringService.getStatisticsOfType(eventIdentifier, mpType);
40         }
41
42         Mockito.verify(mockedRequestContextStack, Mockito.times(15)).createRequestContext();
43     }
44
45     @Test
46     public void testBuildRequest() {
47         final long xidValue = 21L;
48         Xid xid = new Xid(Uint32.valueOf(xidValue));
49         for (MultipartType mpType : MultipartType.values()) {
50             final OfHeader request = statisticsGatheringService.buildRequest(xid, mpType);
51             Assert.assertEquals(MultipartRequestInput.class, request.implementedInterface());
52             Assert.assertEquals(xidValue, request.getXid().longValue());
53             Assert.assertNotNull(request);
54         }
55     }
56 }