From: Jozef Gloncak Date: Mon, 27 Jul 2015 09:11:45 +0000 (+0200) Subject: Coverage - MessageIntelligenceAgencyImpl. X-Git-Tag: release/beryllium~148 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=ef80e14220ad2bb41987a4a8bd80ae3aa8fa824b;p=openflowplugin.git Coverage - MessageIntelligenceAgencyImpl. Increase code coverage for MessageIntelligenceAgencyImpl. Change-Id: I16000bb415f1b58e0b94113f5dc9b27c6e0fb1c1 Signed-off-by: Jozef Gloncak --- 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 index 0000000000..d599b860b4 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/MessageIntelligenceAgencyImplTest.java @@ -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 intelligence = messageIntelligenceAgency.provideIntelligence(); + findExpectedStatistics(intelligence, "FROM_SWITCH: MSG[String] -> +1 | 1", "TO_SWITCH_ENTERED: MSG[Integer] -> +1 | 1"); + } + + private void findExpectedStatistics(final List statisticsInfo, String ... expectedValues) { + for (String expectedValue : expectedValues) { + assertTrue("Expected value " + expectedValue + "wasn't found.", findValueInStatistics(statisticsInfo, expectedValue)); + } + } + + private boolean findValueInStatistics(List statisticsInfo, String expectedValue) { + for (String pieceOfInfo : statisticsInfo) { + if (pieceOfInfo.equals(expectedValue)) { + return true; + } + } + return false; + } + + +} \ No newline at end of file