2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
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
8 package org.opendaylight.nemo.intent.algorithm;
10 import junit.framework.TestCase;
12 import org.junit.Assert;
13 import org.junit.Before;
14 import org.junit.Test;
17 * Created by zhangmeng on 2015/11/5.
19 public class EdgeTest extends TestCase {
25 private long bandwidth;
28 public void setUp() throws Exception {
34 //edge = new Edge(id,src,dest,metric,bandwidth);
38 public void testGetId() throws Exception {
39 edge = new Edge(id,src,dest,metric,bandwidth);
40 Assert.assertEquals(null,edge.getId());
42 edge = new Edge(id,src,dest,metric,bandwidth);
43 Assert.assertEquals(new String("test"),edge.getId());
47 public void testGetSrc() throws Exception {
48 edge = new Edge(id,src,dest,metric,bandwidth);
49 Assert.assertEquals(null,edge.getSrc());
51 edge = new Edge(id,src,dest,metric,bandwidth);
52 Assert.assertEquals(new String("test"),edge.getSrc());
56 public void testGetDest() throws Exception {
57 edge = new Edge(id,src,dest,metric,bandwidth);
58 Assert.assertEquals(null,edge.getDest());
60 edge = new Edge(id,src,dest,metric,bandwidth);
61 Assert.assertEquals(new String("test"),edge.getDest());
65 public void testGetMetric() throws Exception {
66 edge = new Edge(id,src,dest,metric,bandwidth);
67 Assert.assertEquals(0,edge.getMetric());
69 edge = new Edge(id,src,dest,metric,bandwidth);
70 Assert.assertEquals(1,edge.getMetric());
74 public void testGetBandwidth() throws Exception {
75 edge = new Edge(id,src,dest,metric,bandwidth);
76 Assert.assertEquals(0,edge.getBandwidth());
78 edge = new Edge(id,src,dest,metric,bandwidth);
79 Assert.assertEquals(1,edge.getBandwidth());
83 public void testSetMetric() throws Exception {
84 edge = new Edge(id,src,dest,metric,bandwidth);
85 Assert.assertEquals(0,edge.getMetric());
87 edge.setMetric(metric);
88 Assert.assertEquals(metric,edge.getMetric());
92 public void testSetBandwidth() throws Exception {
93 edge = new Edge(id,src,dest,metric,bandwidth);
94 Assert.assertEquals(0,edge.getBandwidth());
97 Assert.assertEquals(bandwidth,edge.getBandwidth());
101 public void testEquals() throws Exception {
102 String s = new String("tests");
103 Edge obj = new Edge(s,s,s,1,1);
106 metric = bandwidth = 1;
107 edge = new Edge(id,src,dest,metric,bandwidth);
109 Edge edge1= new Edge("test1","test1","test1",1,1);
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));
121 public void testToString() throws Exception {
122 edge = new Edge(id,src,dest,metric,bandwidth);
123 Assert.assertNotNull(edge.toString());