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