blob: 4d9e2b9b84f66900cb5b38bcf49135bccbe249bf [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
Ray Milkey3f038c42017-09-26 11:31:54 -070019import com.google.common.testing.EqualsTester;
Ray Milkey9098b422017-08-22 09:23:49 -070020import org.junit.Test;
21import org.onosproject.net.DefaultAnnotations;
22import org.onosproject.net.SparseAnnotations;
23
Ray Milkey3f038c42017-09-26 11:31:54 -070024import static com.spotify.hamcrest.optional.OptionalMatchers.optionalWithValue;
Ray Milkey9098b422017-08-22 09:23:49 -070025import static org.hamcrest.Matchers.is;
26import static org.junit.Assert.assertThat;
Ray Milkey9098b422017-08-22 09:23:49 -070027
28
29public class DefaultTunnelDescriptionTest {
30
31 private static final String DID_1 = "device1";
32 private static final String IFACE_NAME_1 = "eth1";
33 private static final TunnelKey<Long> KEY_1 = new TunnelKey<>(1L);
34 private static final TunnelEndPoint<Long> LOCAL_1 =
35 new TunnelEndPoint<>(11L);
36 private static final TunnelEndPoint<Long> REMOTE_1 =
37 new TunnelEndPoint<>(12L);
38 private static final SparseAnnotations ANNOTATIONS_1 =
39 DefaultAnnotations.builder()
40 .set("AAA", "AAA")
41 .build();
42
43 private TunnelDescription tunnelDescription1 =
44 DefaultTunnelDescription.builder()
45 .deviceId(DID_1)
46 .ifaceName(IFACE_NAME_1)
47 .key(KEY_1)
48 .type(TunnelDescription.Type.GRE)
49 .local(LOCAL_1)
50 .remote(REMOTE_1)
51 .otherConfigs(ANNOTATIONS_1)
52 .build();
53
54 private TunnelDescription tunnelDescription2 =
55 DefaultTunnelDescription.builder()
56 .deviceId(DID_1)
57 .ifaceName(IFACE_NAME_1)
58 .key(KEY_1)
59 .type(TunnelDescription.Type.GRE)
60 .remote(LOCAL_1)
61 .local(REMOTE_1)
62 .build();
63
64 @Test
65 public void testConstruction() {
Ray Milkey3f038c42017-09-26 11:31:54 -070066 assertThat(tunnelDescription1.deviceId(), optionalWithValue(is(DID_1)));
Ray Milkey9098b422017-08-22 09:23:49 -070067 assertThat(tunnelDescription1.ifaceName(), is(IFACE_NAME_1));
Ray Milkey3f038c42017-09-26 11:31:54 -070068 assertThat(tunnelDescription1.key(), optionalWithValue(is(KEY_1)));
Ray Milkey9098b422017-08-22 09:23:49 -070069 assertThat(tunnelDescription1.type(), is(TunnelDescription.Type.GRE));
Ray Milkey3f038c42017-09-26 11:31:54 -070070 assertThat(tunnelDescription1.local(), optionalWithValue(is(LOCAL_1)));
71 assertThat(tunnelDescription1.remote(), optionalWithValue(is(REMOTE_1)));
Ray Milkey9098b422017-08-22 09:23:49 -070072 }
73
74 @Test
75 public void testEquals() {
76 new EqualsTester()
77 .addEqualityGroup(tunnelDescription1)
78 .addEqualityGroup(tunnelDescription2)
79 .testEquals();
80 }
81}