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;
17 public class MessageIntelligenceAgencyImplTest {
20 public void testMessageIntelligenceAgency() {
21 final MessageIntelligenceAgencyImpl messageIntelligenceAgency = new MessageIntelligenceAgencyImpl();
22 messageIntelligenceAgency.spyMessage(String.class, MessageSpy.StatisticsGroup.FROM_SWITCH);
23 messageIntelligenceAgency.spyMessage(Integer.class, MessageSpy.StatisticsGroup.TO_SWITCH_ENTERED);
24 final List<String> intelligence = messageIntelligenceAgency.provideIntelligence();
25 findExpectedStatistics(intelligence, "FROM_SWITCH: MSG[String] -> +1 | 1", "TO_SWITCH_ENTERED: MSG[Integer] -> +1 | 1");
28 private void findExpectedStatistics(final List<String> statisticsInfo, String ... expectedValues) {
29 for (String expectedValue : expectedValues) {
30 assertTrue("Expected value " + expectedValue + "wasn't found.", findValueInStatistics(statisticsInfo, expectedValue));
34 private boolean findValueInStatistics(List<String> statisticsInfo, String expectedValue) {
35 for (String pieceOfInfo : statisticsInfo) {
36 if (pieceOfInfo.equals(expectedValue)) {