Coverage - MessageIntelligenceAgencyImpl. 66/24566/3
authorJozef Gloncak <jgloncak@cisco.com>
Mon, 27 Jul 2015 09:11:45 +0000 (11:11 +0200)
committerJozef Gloncak <jgloncak@cisco.com>
Wed, 29 Jul 2015 12:14:17 +0000 (14:14 +0200)
Increase code coverage for MessageIntelligenceAgencyImpl.

Change-Id: I16000bb415f1b58e0b94113f5dc9b27c6e0fb1c1
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/MessageIntelligenceAgencyImplTest.java [new file with mode: 0644]

diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/MessageIntelligenceAgencyImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/MessageIntelligenceAgencyImplTest.java
new file mode 100644 (file)
index 0000000..d599b86
--- /dev/null
@@ -0,0 +1,39 @@
+package org.opendaylight.openflowplugin.impl.statistics.ofpspecific;
+
+import junit.framework.TestCase;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class MessageIntelligenceAgencyImplTest {
+
+    @Test
+    public void testMessageIntelligenceAgency() {
+        final MessageIntelligenceAgencyImpl messageIntelligenceAgency = new MessageIntelligenceAgencyImpl();
+        messageIntelligenceAgency.spyMessage(String.class, MessageSpy.STATISTIC_GROUP.FROM_SWITCH);
+        messageIntelligenceAgency.spyMessage(Integer.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_ENTERED);
+        final List<String> intelligence = messageIntelligenceAgency.provideIntelligence();
+        findExpectedStatistics(intelligence, "FROM_SWITCH: MSG[String] -> +1 | 1", "TO_SWITCH_ENTERED: MSG[Integer] -> +1 | 1");
+    }
+
+    private void findExpectedStatistics(final List<String> statisticsInfo, String ... expectedValues) {
+        for (String expectedValue : expectedValues) {
+            assertTrue("Expected value " + expectedValue + "wasn't found.", findValueInStatistics(statisticsInfo, expectedValue));
+        }
+    }
+
+    private boolean findValueInStatistics(List<String> statisticsInfo, String expectedValue) {
+        for (String pieceOfInfo : statisticsInfo) {
+            if (pieceOfInfo.equals(expectedValue)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+}
\ No newline at end of file