unifying statistics manager api packages
[openflowplugin.git] / openflowplugin / src / test / java / org / opendaylight / openflowplugin / statistics / MessageSpyCounterImplTest.java
1 /*
2  * Copyright (c) 2014 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.statistics;
10
11 import static org.junit.Assert.assertEquals;
12
13 import java.util.List;
14 import org.junit.Test;
15 import org.opendaylight.openflowplugin.api.openflow.statistics.MessageSpy;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action;
17 import org.opendaylight.yangtools.yang.binding.DataContainer;
18
19 /**
20  * Created by Martin Bobak mbobak@cisco.com on 9/10/14.
21  */
22 public class MessageSpyCounterImplTest {
23
24     private static final MessageSpyCounterImpl messageSpyCounter = new MessageSpyCounterImpl();
25     private static final int EXPECTED_MSG_COUNT = 10;
26
27     @Test
28     public void testDumpMessageCounts() {
29         DataContainer msg = new MockDataContainer();
30         List<String> messageCounts = messageSpyCounter.dumpMessageCounts();
31         assertEquals(EXPECTED_MSG_COUNT,messageCounts.size());
32
33         assertEquals("FROM_SWITCH_ENQUEUED: no activity detected", messageCounts.get(0));
34         messageSpyCounter.spyMessage(msg, MessageSpy.STATISTIC_GROUP.FROM_SWITCH_ENQUEUED);
35         messageCounts = messageSpyCounter.dumpMessageCounts();
36         assertEquals("FROM_SWITCH_ENQUEUED: MSG[Action] -> +1 | 1", messageCounts.get(0));
37
38     }
39
40
41     private static class MockDataContainer implements DataContainer {
42
43         @Override
44         public Class<? extends DataContainer> getImplementedInterface() {
45             return Action.class;
46         }
47     }
48 }