Bug 1029: Remove dead code: samples/clustersession
[controller.git] / opendaylight / adsal / northbound / statistics / src / test / java / org / opendaylight / controller / statistics / northbound / StatisticsNorthboundTest.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 package org.opendaylight.controller.statistics.northbound;
11
12 import java.util.ArrayList;
13 import java.util.List;
14
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;
22
23 public class StatisticsNorthboundTest {
24
25     @Test
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));
32
33         Node node2 = NodeCreator.createOFNode(2L);
34         fs.setNode(node2);
35         Assert.assertTrue(fs.getNode().equals(node2));
36         fs.setNode(node2);
37         Assert.assertTrue(fs.getNode().equals(node2));
38         fs.setFlowStats(null);
39         Assert.assertTrue(fs.getFlowStats() == null);
40     }
41
42     @Test
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);
49     }
50
51     @Test
52     public void testPortStatistics() {
53         List<NodeConnectorStatistics> ncs = new ArrayList<NodeConnectorStatistics>();
54         Node node = NodeCreator.createOFNode(1L);
55         PortStatistics ps = new PortStatistics(node, ncs);
56
57         Assert.assertTrue(ps.getNode().equals(node));
58         Assert.assertTrue(ps.getPortStats().equals(ncs));
59         Node node2 = NodeCreator.createOFNode(2L);
60         ps.setNode(node2);
61         Assert.assertTrue(ps.getNode().equals(node2));
62         ps.setFlowStats(null);
63         Assert.assertTrue(ps.getPortStats() == null);
64     }
65
66     @Test
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);
73     }
74
75     @Test
76     public void testTableStatistics() {
77         List<NodeTableStatistics> nts = new ArrayList<NodeTableStatistics>();
78         Node node = NodeCreator.createOFNode(1L);
79         TableStatistics ts = new TableStatistics(node, nts);
80
81         Assert.assertTrue(ts.getNode().equals(node));
82         Assert.assertTrue(ts.getTableStats().equals(nts));
83         Node node2 = NodeCreator.createOFNode(2L);
84         ts.setNode(node2);
85         Assert.assertTrue(ts.getNode().equals(node2));
86         ts.setTableStats(null);
87         Assert.assertTrue(ts.getTableStats() == null);
88     }
89
90     @Test
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);
97     }
98
99 }