1 package org.opendaylight.controller.statistics.northbound;
3 import java.util.ArrayList;
6 import org.junit.Assert;
8 import org.opendaylight.controller.sal.core.Node;
9 import org.opendaylight.controller.sal.reader.FlowOnNode;
10 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
11 import org.opendaylight.controller.sal.utils.NodeCreator;
13 import junit.framework.TestCase;
15 public class StatisticsNorthboundTest extends TestCase {
18 public void testFlowStatistics() {
19 List<FlowOnNode> fon = new ArrayList<FlowOnNode>();
20 Node node = NodeCreator.createOFNode(1L);
21 FlowStatistics fs = new FlowStatistics(node, fon);
22 Assert.assertTrue(fs.getNode().equals(node));
23 Assert.assertTrue(fs.getFlowStats().equals(fon));
25 Node node2 = NodeCreator.createOFNode(2L);
27 Assert.assertTrue(fs.getNode().equals(node2));
29 Assert.assertTrue(fs.getNode().equals(node2));
30 fs.setFlowStats(null);
31 Assert.assertTrue(fs.getFlowStats() == null);
35 public void testAllFlowStatistics() {
36 List<FlowStatistics> fs = new ArrayList<FlowStatistics>();
37 AllFlowStatistics afs = new AllFlowStatistics(fs);
38 Assert.assertTrue(afs.getFlowStatistics().equals(fs));
39 afs.setFlowStatistics(null);
40 Assert.assertTrue(afs.getFlowStatistics() == null);
44 public void testPortStatistics() {
45 List<NodeConnectorStatistics> ncs = new ArrayList<NodeConnectorStatistics>();
46 Node node = NodeCreator.createOFNode(1L);
47 PortStatistics ps = new PortStatistics(node, ncs);
49 Assert.assertTrue(ps.getNode().equals(node));
50 Assert.assertTrue(ps.getPortStats().equals(ncs));
51 Node node2 = NodeCreator.createOFNode(2L);
53 Assert.assertTrue(ps.getNode().equals(node2));
54 ps.setFlowStats(null);
55 Assert.assertTrue(ps.getPortStats() == null);
59 public void testAllPortStatistics() {
60 List<PortStatistics> ps = new ArrayList<PortStatistics>();
61 AllPortStatistics aps = new AllPortStatistics(ps);
62 Assert.assertTrue(aps.getPortStatistics().equals(ps));
63 aps.setPortStatistics(null);
64 Assert.assertTrue(aps.getPortStatistics() == null);