3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.statistics.northbound;
12 import java.util.ArrayList;
13 import java.util.List;
15 import junit.framework.TestCase;
17 import org.junit.Assert;
18 import org.junit.Test;
19 import org.opendaylight.controller.sal.core.Node;
20 import org.opendaylight.controller.sal.reader.FlowOnNode;
21 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
22 import org.opendaylight.controller.sal.reader.NodeTableStatistics;
23 import org.opendaylight.controller.sal.utils.NodeCreator;
25 public class StatisticsNorthboundTest extends TestCase {
28 public void testFlowStatistics() {
29 List<FlowOnNode> fon = new ArrayList<FlowOnNode>();
30 Node node = NodeCreator.createOFNode(1L);
31 FlowStatistics fs = new FlowStatistics(node, fon);
32 Assert.assertTrue(fs.getNode().equals(node));
33 Assert.assertTrue(fs.getFlowStats().equals(fon));
35 Node node2 = NodeCreator.createOFNode(2L);
37 Assert.assertTrue(fs.getNode().equals(node2));
39 Assert.assertTrue(fs.getNode().equals(node2));
40 fs.setFlowStats(null);
41 Assert.assertTrue(fs.getFlowStats() == null);
45 public void testAllFlowStatistics() {
46 List<FlowStatistics> fs = new ArrayList<FlowStatistics>();
47 AllFlowStatistics afs = new AllFlowStatistics(fs);
48 Assert.assertTrue(afs.getFlowStatistics().equals(fs));
49 afs.setFlowStatistics(null);
50 Assert.assertTrue(afs.getFlowStatistics() == null);
54 public void testPortStatistics() {
55 List<NodeConnectorStatistics> ncs = new ArrayList<NodeConnectorStatistics>();
56 Node node = NodeCreator.createOFNode(1L);
57 PortStatistics ps = new PortStatistics(node, ncs);
59 Assert.assertTrue(ps.getNode().equals(node));
60 Assert.assertTrue(ps.getPortStats().equals(ncs));
61 Node node2 = NodeCreator.createOFNode(2L);
63 Assert.assertTrue(ps.getNode().equals(node2));
64 ps.setFlowStats(null);
65 Assert.assertTrue(ps.getPortStats() == null);
69 public void testAllPortStatistics() {
70 List<PortStatistics> ps = new ArrayList<PortStatistics>();
71 AllPortStatistics aps = new AllPortStatistics(ps);
72 Assert.assertTrue(aps.getPortStatistics().equals(ps));
73 aps.setPortStatistics(null);
74 Assert.assertTrue(aps.getPortStatistics() == null);
78 public void testTableStatistics() {
79 List<NodeTableStatistics> nts = new ArrayList<NodeTableStatistics>();
80 Node node = NodeCreator.createOFNode(1L);
81 TableStatistics ts = new TableStatistics(node, nts);
83 Assert.assertTrue(ts.getNode().equals(node));
84 Assert.assertTrue(ts.getTableStats().equals(nts));
85 Node node2 = NodeCreator.createOFNode(2L);
87 Assert.assertTrue(ts.getNode().equals(node2));
88 ts.setTableStats(null);
89 Assert.assertTrue(ts.getTableStats() == null);
93 public void testAllTableStatistics() {
94 List<TableStatistics> ts = new ArrayList<TableStatistics>();
95 AllTableStatistics ats = new AllTableStatistics(ts);
96 Assert.assertTrue(ats.getTableStatistics().equals(ts));
97 ats.setTableStatistics(null);
98 Assert.assertTrue(ats.getTableStatistics() == null);