Fix Eclipse compilation errors and warnings
[nemo.git] / nemo-impl / src / test / java / org / opendaylight / nemo / intent / algorithm / EdgeTest.java
1 package org.opendaylight.nemo.intent.algorithm;
2
3 import junit.framework.TestCase;
4
5 import org.junit.Assert;
6 import org.junit.Before;
7 import org.junit.Test;
8
9 /**
10  * Created by zhangmeng on 2015/11/5.
11  */
12 public class EdgeTest extends TestCase {
13
14     private String id;
15     private String src;
16     private String dest;
17     private long metric;
18     private long bandwidth;
19     private Edge edge;
20     @Before
21     public void setUp() throws Exception {
22         id = null;
23         src = null;
24         dest = null;
25         //metric = 0;
26         //bandwidth = 0;
27         //edge = new Edge(id,src,dest,metric,bandwidth);
28     }
29
30     @Test
31     public void testGetId() throws Exception {
32         edge = new Edge(id,src,dest,metric,bandwidth);
33         Assert.assertEquals(null,edge.getId());
34         id = "test";
35         edge = new Edge(id,src,dest,metric,bandwidth);
36         Assert.assertEquals(new String("test"),edge.getId());
37     }
38
39     @Test
40     public void testGetSrc() throws Exception {
41         edge = new Edge(id,src,dest,metric,bandwidth);
42         Assert.assertEquals(null,edge.getSrc());
43         src = "test";
44         edge = new Edge(id,src,dest,metric,bandwidth);
45         Assert.assertEquals(new String("test"),edge.getSrc());
46     }
47
48     @Test
49     public void testGetDest() throws Exception {
50         edge = new Edge(id,src,dest,metric,bandwidth);
51         Assert.assertEquals(null,edge.getDest());
52         dest = "test";
53         edge = new Edge(id,src,dest,metric,bandwidth);
54         Assert.assertEquals(new String("test"),edge.getDest());
55     }
56
57     @Test
58     public void testGetMetric() throws Exception {
59         edge = new Edge(id,src,dest,metric,bandwidth);
60         Assert.assertEquals(0,edge.getMetric());
61         metric = 1;
62         edge = new Edge(id,src,dest,metric,bandwidth);
63         Assert.assertEquals(1,edge.getMetric());
64     }
65
66     @Test
67     public void testGetBandwidth() throws Exception {
68         edge = new Edge(id,src,dest,metric,bandwidth);
69         Assert.assertEquals(0,edge.getBandwidth());
70         bandwidth = 1;
71         edge = new Edge(id,src,dest,metric,bandwidth);
72         Assert.assertEquals(1,edge.getBandwidth());
73     }
74
75     @Test
76     public void testSetMetric() throws Exception {
77         edge = new Edge(id,src,dest,metric,bandwidth);
78         Assert.assertEquals(0,edge.getMetric());
79         metric = 1;
80         edge.setMetric(metric);
81         Assert.assertEquals(metric,edge.getMetric());
82     }
83
84     @Test
85     public void testSetBandwidth() throws Exception {
86         edge = new Edge(id,src,dest,metric,bandwidth);
87         Assert.assertEquals(0,edge.getBandwidth());
88         bandwidth = 1;
89         edge.setBandwidth(1);
90         Assert.assertEquals(bandwidth,edge.getBandwidth());
91     }
92
93     @Test
94     public void testEquals() throws Exception {
95         String s = new String("tests");
96         Edge obj = new Edge(s,s,s,1,1);
97
98         id = src = dest = s;
99         metric = bandwidth = 1;
100         edge = new Edge(id,src,dest,metric,bandwidth);
101
102         Assert.assertTrue(obj.getId().equals(edge.getId()));
103         Assert.assertTrue(obj.getSrc().equals(edge.getSrc()));
104         Assert.assertTrue(obj.getDest().equals(edge.getDest()));
105     }
106
107     @Test
108     public void testToString() throws Exception {
109         edge = new Edge(id,src,dest,metric,bandwidth);
110         Assert.assertNotNull(edge.toString());
111
112     }
113 }