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