2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.openflowplugin.impl.statistics.ofpspecific;
10 import static org.junit.Assert.assertTrue;
12 import java.util.List;
13 import org.junit.Test;
14 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
16 public class MessageIntelligenceAgencyImplTest {
19 public void testMessageIntelligenceAgency() {
20 final MessageIntelligenceAgencyImpl messageIntelligenceAgency = new MessageIntelligenceAgencyImpl();
21 messageIntelligenceAgency.spyMessage(String.class, MessageSpy.StatisticsGroup.FROM_SWITCH);
22 messageIntelligenceAgency.spyMessage(Integer.class, MessageSpy.StatisticsGroup.TO_SWITCH_ENTERED);
23 final List<String> intelligence = messageIntelligenceAgency.provideIntelligence();
24 findExpectedStatistics(intelligence,
25 "FROM_SWITCH: MSG[String] -> +1 | 1", "TO_SWITCH_ENTERED: MSG[Integer] -> +1 | 1");
28 private static void findExpectedStatistics(final List<String> statisticsInfo, String ... expectedValues) {
29 for (String expectedValue : expectedValues) {
30 assertTrue("Expected value " + expectedValue + "wasn't found.",
31 findValueInStatistics(statisticsInfo, expectedValue));
35 private static boolean findValueInStatistics(List<String> statisticsInfo, String expectedValue) {
36 for (String pieceOfInfo : statisticsInfo) {
37 if (pieceOfInfo.equals(expectedValue)) {