blob: 2f5347dd086f9be4b80fd298f19cb247780610e5 [file] [log] [blame]
Mahesh Poojary Sd7a36922016-04-01 16:11:14 +05301/*
2 * Copyright 2016 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.pce.pceservice;
18
19import org.junit.Test;
20
21import static org.hamcrest.MatcherAssert.assertThat;
22import static org.hamcrest.Matchers.is;
23
24import org.onosproject.incubator.net.tunnel.TunnelId;
25
26/**
27 * Unit tests for DefaultPcePath class.
28 */
29public class DefaultPcePathTest {
30 /**
31 * Checks the operation of equals() methods.
32 */
33 @Test
34 public void testEquals() {
35 // create same two pce-path objects.
36 final String cost1 = "1";
37 final String bandwidth1 = "200";
38 final String src1 = "foo";
39 final String dst1 = "bee";
40 final String type1 = "1";
41 final String name1 = "pcc";
42
43 PcePath path1 = DefaultPcePath.builder()
44 .source(src1)
45 .destination(dst1)
46 .lspType(type1)
47 .name(name1)
48 .costConstraint(cost1)
49 .bandwidthConstraint(bandwidth1)
50 .build();
51 path1.id(TunnelId.valueOf("1"));
52
53 // create same as above object
54 PcePath samePath1 = DefaultPcePath.builder()
55 .source(src1)
56 .destination(dst1)
57 .lspType(type1)
58 .name(name1)
59 .costConstraint(cost1)
60 .bandwidthConstraint(bandwidth1)
61 .build();
62 samePath1.id(TunnelId.valueOf("1"));
63
64 // Create different pce-path object.
65 final String cost2 = "1";
66 final String bandwidth2 = "200";
67 final String src2 = "google";
68 final String dst2 = "yahoo";
69 final String type2 = "2";
70 final String name2 = "pcc2";
71
72 PcePath path2 = DefaultPcePath.builder()
73 .source(src2)
74 .destination(dst2)
75 .lspType(type2)
76 .name(name2)
77 .costConstraint(cost2)
78 .bandwidthConstraint(bandwidth2)
79 .build();
80 path2.id(TunnelId.valueOf("2"));
81 //TODO: will be uncommented below line once CostConstraint and LocalBandwidthConstraint classes are ready
82 //new EqualsTester().addEqualityGroup(path1, samePath1).addEqualityGroup(path2).testEquals();
83 }
84
85 /**
86 * Checks the construction of a DefaultPcePath object.
87 */
88 @Test
89 public void testConstruction() {
90 final String cost = "1";
91 final String bandwidth = "600";
92 final String src = "indiatimes";
93 final String dst = "deccan";
94 final String type = "3";
95 final String name = "pcc4";
96
97 PcePath path = DefaultPcePath.builder()
98 .source(src)
99 .destination(dst)
100 .lspType(type)
101 .name(name)
102 .costConstraint(cost)
103 .bandwidthConstraint(bandwidth)
104 .build();
105
106 assertThat(src, is(path.source()));
107 assertThat(dst, is(path.destination()));
108 assertThat(LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR, is(path.lspType()));
109 assertThat(name, is(path.name()));
110 //TODO: will be uncommented below lines once CostConstraint and LocalBandwidthConstraint classes are ready
111 //assertThat(cost, is(path.costConstraint().toString()));
112 //assertThat(bandwidth, is(path.bandwidthConstraint().toString()));
113 }
114}