Added the copyright marks
[nemo.git] / nemo-impl / src / test / java / org / opendaylight / nemo / intent / algorithm / EdgeTest.java
1 /*
2  * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.nemo.intent.algorithm;
9
10 import junit.framework.TestCase;
11
12 import org.junit.Assert;
13 import org.junit.Before;
14 import org.junit.Test;
15
16 /**
17  * Created by zhangmeng on 2015/11/5.
18  */
19 public class EdgeTest extends TestCase {
20
21     private String id;
22     private String src;
23     private String dest;
24     private long metric;
25     private long bandwidth;
26     private Edge edge;
27     @Before
28     public void setUp() throws Exception {
29         id = null;
30         src = null;
31         dest = null;
32         //metric = 0;
33         //bandwidth = 0;
34         //edge = new Edge(id,src,dest,metric,bandwidth);
35     }
36
37     @Test
38     public void testGetId() throws Exception {
39         edge = new Edge(id,src,dest,metric,bandwidth);
40         Assert.assertEquals(null,edge.getId());
41         id = "test";
42         edge = new Edge(id,src,dest,metric,bandwidth);
43         Assert.assertEquals(new String("test"),edge.getId());
44     }
45
46     @Test
47     public void testGetSrc() throws Exception {
48         edge = new Edge(id,src,dest,metric,bandwidth);
49         Assert.assertEquals(null,edge.getSrc());
50         src = "test";
51         edge = new Edge(id,src,dest,metric,bandwidth);
52         Assert.assertEquals(new String("test"),edge.getSrc());
53     }
54
55     @Test
56     public void testGetDest() throws Exception {
57         edge = new Edge(id,src,dest,metric,bandwidth);
58         Assert.assertEquals(null,edge.getDest());
59         dest = "test";
60         edge = new Edge(id,src,dest,metric,bandwidth);
61         Assert.assertEquals(new String("test"),edge.getDest());
62     }
63
64     @Test
65     public void testGetMetric() throws Exception {
66         edge = new Edge(id,src,dest,metric,bandwidth);
67         Assert.assertEquals(0,edge.getMetric());
68         metric = 1;
69         edge = new Edge(id,src,dest,metric,bandwidth);
70         Assert.assertEquals(1,edge.getMetric());
71     }
72
73     @Test
74     public void testGetBandwidth() throws Exception {
75         edge = new Edge(id,src,dest,metric,bandwidth);
76         Assert.assertEquals(0,edge.getBandwidth());
77         bandwidth = 1;
78         edge = new Edge(id,src,dest,metric,bandwidth);
79         Assert.assertEquals(1,edge.getBandwidth());
80     }
81
82     @Test
83     public void testSetMetric() throws Exception {
84         edge = new Edge(id,src,dest,metric,bandwidth);
85         Assert.assertEquals(0,edge.getMetric());
86         metric = 1;
87         edge.setMetric(metric);
88         Assert.assertEquals(metric,edge.getMetric());
89     }
90
91     @Test
92     public void testSetBandwidth() throws Exception {
93         edge = new Edge(id,src,dest,metric,bandwidth);
94         Assert.assertEquals(0,edge.getBandwidth());
95         bandwidth = 1;
96         edge.setBandwidth(1);
97         Assert.assertEquals(bandwidth,edge.getBandwidth());
98     }
99
100     @Test
101     public void testEquals() throws Exception {
102         String s = new String("tests");
103         Edge obj = new Edge(s,s,s,1,1);
104
105         id = src = dest = s;
106         metric = bandwidth = 1;
107         edge = new Edge(id,src,dest,metric,bandwidth);
108
109         Edge edge1= new Edge("test1","test1","test1",1,1);
110
111         Assert.assertTrue(obj.getId().equals(edge.getId()));
112         Assert.assertTrue(obj.getSrc().equals(edge.getSrc()));
113         Assert.assertTrue(obj.getDest().equals(edge.getDest()));
114         Assert.assertTrue(obj.equals(obj));
115         Assert.assertTrue(!obj.equals(edge1));
116
117
118     }
119
120     @Test
121     public void testToString() throws Exception {
122         edge = new Edge(id,src,dest,metric,bandwidth);
123         Assert.assertNotNull(edge.toString());
124
125     }
126 }