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