blob: 5cd339f968ba3c9475355d88471eb9f9b35dc082 [file] [log] [blame]
Ray Milkey9098b422017-08-22 09:23:49 -07001/*
2 * Copyright 2017-present Open Networking Foundation
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.net.behaviour;
18
19import org.junit.Test;
20import org.onosproject.net.DefaultAnnotations;
21import org.onosproject.net.SparseAnnotations;
22
23import com.google.common.testing.EqualsTester;
24
25import static org.hamcrest.Matchers.is;
26import static org.junit.Assert.assertThat;
27import static org.junit.Assert.assertTrue;
28
29
30public class DefaultTunnelDescriptionTest {
31
32 private static final String DID_1 = "device1";
33 private static final String IFACE_NAME_1 = "eth1";
34 private static final TunnelKey<Long> KEY_1 = new TunnelKey<>(1L);
35 private static final TunnelEndPoint<Long> LOCAL_1 =
36 new TunnelEndPoint<>(11L);
37 private static final TunnelEndPoint<Long> REMOTE_1 =
38 new TunnelEndPoint<>(12L);
39 private static final SparseAnnotations ANNOTATIONS_1 =
40 DefaultAnnotations.builder()
41 .set("AAA", "AAA")
42 .build();
43
44 private TunnelDescription tunnelDescription1 =
45 DefaultTunnelDescription.builder()
46 .deviceId(DID_1)
47 .ifaceName(IFACE_NAME_1)
48 .key(KEY_1)
49 .type(TunnelDescription.Type.GRE)
50 .local(LOCAL_1)
51 .remote(REMOTE_1)
52 .otherConfigs(ANNOTATIONS_1)
53 .build();
54
55 private TunnelDescription tunnelDescription2 =
56 DefaultTunnelDescription.builder()
57 .deviceId(DID_1)
58 .ifaceName(IFACE_NAME_1)
59 .key(KEY_1)
60 .type(TunnelDescription.Type.GRE)
61 .remote(LOCAL_1)
62 .local(REMOTE_1)
63 .build();
64
65 @Test
66 public void testConstruction() {
67 assertTrue(tunnelDescription1.deviceId().isPresent());
68 assertThat(tunnelDescription1.deviceId().get(), is(DID_1));
69 assertThat(tunnelDescription1.ifaceName(), is(IFACE_NAME_1));
70 assertTrue(tunnelDescription1.key().isPresent());
71 assertThat(tunnelDescription1.key().get(), is(KEY_1));
72 assertThat(tunnelDescription1.type(), is(TunnelDescription.Type.GRE));
73 assertTrue(tunnelDescription1.local().isPresent());
74 assertThat(tunnelDescription1.local().get(), is(LOCAL_1));
75 assertTrue(tunnelDescription1.remote().isPresent());
76 assertThat(tunnelDescription1.remote().get(), is(REMOTE_1));
77 }
78
79 @Test
80 public void testEquals() {
81 new EqualsTester()
82 .addEqualityGroup(tunnelDescription1)
83 .addEqualityGroup(tunnelDescription2)
84 .testEquals();
85 }
86}