Add missing license headers
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / statistics / ofpspecific / MessageIntelligenceAgencyImplTest.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.statistics.ofpspecific;
9
10 import static org.junit.Assert.assertTrue;
11
12 import java.util.List;
13 import org.junit.Test;
14 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
15
16
17 public class MessageIntelligenceAgencyImplTest {
18
19     @Test
20     public void testMessageIntelligenceAgency() {
21         final MessageIntelligenceAgencyImpl messageIntelligenceAgency = new MessageIntelligenceAgencyImpl();
22         messageIntelligenceAgency.spyMessage(String.class, MessageSpy.STATISTIC_GROUP.FROM_SWITCH);
23         messageIntelligenceAgency.spyMessage(Integer.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_ENTERED);
24         final List<String> intelligence = messageIntelligenceAgency.provideIntelligence();
25         findExpectedStatistics(intelligence, "FROM_SWITCH: MSG[String] -> +1 | 1", "TO_SWITCH_ENTERED: MSG[Integer] -> +1 | 1");
26     }
27
28     private void findExpectedStatistics(final List<String> statisticsInfo, String ... expectedValues) {
29         for (String expectedValue : expectedValues) {
30             assertTrue("Expected value " + expectedValue + "wasn't found.", findValueInStatistics(statisticsInfo, expectedValue));
31         }
32     }
33
34     private boolean findValueInStatistics(List<String> statisticsInfo, String expectedValue) {
35         for (String pieceOfInfo : statisticsInfo) {
36             if (pieceOfInfo.equals(expectedValue)) {
37                 return true;
38             }
39         }
40         return false;
41     }
42
43
44 }