Merge "Refactoring SubnetConfig: -Use NetUtils IP validation methods instead of own...
[controller.git] / opendaylight / northbound / statistics / src / test / java / org / opendaylight / controller / statistics / northbound / StatisticsNorthboundTest.java
1 package org.opendaylight.controller.statistics.northbound;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.junit.Assert;
7 import org.junit.Test;
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;
12
13 import junit.framework.TestCase;
14
15 public class StatisticsNorthboundTest extends TestCase {
16
17     @Test
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));
24
25         Node node2 = NodeCreator.createOFNode(2L);
26         fs.setNode(node2);
27         Assert.assertTrue(fs.getNode().equals(node2));
28         fs.setNode(node2);
29         Assert.assertTrue(fs.getNode().equals(node2));
30         fs.setFlowStats(null);
31         Assert.assertTrue(fs.getFlowStats() == null);
32     }
33
34     @Test
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);
41     }
42
43     @Test
44     public void testPortStatistics() {
45         List<NodeConnectorStatistics> ncs = new ArrayList<NodeConnectorStatistics>();
46         Node node = NodeCreator.createOFNode(1L);
47         PortStatistics ps = new PortStatistics(node, ncs);
48
49         Assert.assertTrue(ps.getNode().equals(node));
50         Assert.assertTrue(ps.getPortStats().equals(ncs));
51         Node node2 = NodeCreator.createOFNode(2L);
52         ps.setNode(node2);
53         Assert.assertTrue(ps.getNode().equals(node2));
54         ps.setFlowStats(null);
55         Assert.assertTrue(ps.getPortStats() == null);
56     }
57
58     @Test
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);
65     }
66
67 }