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 org.junit.Assert;
16 import org.junit.Test;
17 import org.opendaylight.controller.sal.core.Node;
18 import org.opendaylight.controller.sal.reader.FlowOnNode;
19 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
20 import org.opendaylight.controller.sal.reader.NodeTableStatistics;
21 import org.opendaylight.controller.sal.utils.NodeCreator;
23 public class StatisticsNorthboundTest {
26 public void testFlowStatistics() {
27 List<FlowOnNode> fon = new ArrayList<FlowOnNode>();
28 Node node = NodeCreator.createOFNode(1L);
29 FlowStatistics fs = new FlowStatistics(node, fon);
30 Assert.assertTrue(fs.getNode().equals(node));
31 Assert.assertTrue(fs.getFlowStats().equals(fon));
33 Node node2 = NodeCreator.createOFNode(2L);
35 Assert.assertTrue(fs.getNode().equals(node2));
37 Assert.assertTrue(fs.getNode().equals(node2));
38 fs.setFlowStats(null);
39 Assert.assertTrue(fs.getFlowStats() == null);
43 public void testAllFlowStatistics() {
44 List<FlowStatistics> fs = new ArrayList<FlowStatistics>();
45 AllFlowStatistics afs = new AllFlowStatistics(fs);
46 Assert.assertTrue(afs.getFlowStatistics().equals(fs));
47 afs.setFlowStatistics(null);
48 Assert.assertTrue(afs.getFlowStatistics() == null);
52 public void testPortStatistics() {
53 List<NodeConnectorStatistics> ncs = new ArrayList<NodeConnectorStatistics>();
54 Node node = NodeCreator.createOFNode(1L);
55 PortStatistics ps = new PortStatistics(node, ncs);
57 Assert.assertTrue(ps.getNode().equals(node));
58 Assert.assertTrue(ps.getPortStats().equals(ncs));
59 Node node2 = NodeCreator.createOFNode(2L);
61 Assert.assertTrue(ps.getNode().equals(node2));
62 ps.setFlowStats(null);
63 Assert.assertTrue(ps.getPortStats() == null);
67 public void testAllPortStatistics() {
68 List<PortStatistics> ps = new ArrayList<PortStatistics>();
69 AllPortStatistics aps = new AllPortStatistics(ps);
70 Assert.assertTrue(aps.getPortStatistics().equals(ps));
71 aps.setPortStatistics(null);
72 Assert.assertTrue(aps.getPortStatistics() == null);
76 public void testTableStatistics() {
77 List<NodeTableStatistics> nts = new ArrayList<NodeTableStatistics>();
78 Node node = NodeCreator.createOFNode(1L);
79 TableStatistics ts = new TableStatistics(node, nts);
81 Assert.assertTrue(ts.getNode().equals(node));
82 Assert.assertTrue(ts.getTableStats().equals(nts));
83 Node node2 = NodeCreator.createOFNode(2L);
85 Assert.assertTrue(ts.getNode().equals(node2));
86 ts.setTableStats(null);
87 Assert.assertTrue(ts.getTableStats() == null);
91 public void testAllTableStatistics() {
92 List<TableStatistics> ts = new ArrayList<TableStatistics>();
93 AllTableStatistics ats = new AllTableStatistics(ts);
94 Assert.assertTrue(ats.getTableStatistics().equals(ts));
95 ats.setTableStatistics(null);
96 Assert.assertTrue(ats.getTableStatistics() == null);