blob: c98216b6cf3e2d9e79c9ad1151028005500d62e6 [file] [log] [blame]
Ray Milkeyc9166992017-05-08 12:02:26 -07001/*
2 * Copyright 2017-present 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.net.behaviour.protection;
18
19import org.junit.Test;
20import org.onosproject.net.FilteredConnectPoint;
21import org.onosproject.net.NetTestTools;
22
23import com.google.common.testing.EqualsTester;
24
25import static org.hamcrest.Matchers.is;
26import static org.hamcrest.Matchers.notNullValue;
27import static org.junit.Assert.assertThat;
28
29/**
30 * Unit tests for the transport endpoint description.
31 */
32public class TransportEndpointDescriptionTest {
33
34 @Test
35 public void testConstruction() {
36 FilteredConnectPoint output =
37 new FilteredConnectPoint(NetTestTools.connectPoint("xxx", 1));
38 TransportEndpointDescription ted =
39 TransportEndpointDescription
40 .builder()
41 .withEnabled(true)
42 .withOutput(output)
43 .build();
44
45 assertThat(ted, notNullValue());
46 assertThat(ted.isEnabled(), is(true));
47 assertThat(ted.output(), is(output));
48 }
49
50 @Test
51 public void testCopyConstruction() {
52 FilteredConnectPoint output =
53 new FilteredConnectPoint(NetTestTools.connectPoint("xxx", 1));
54 TransportEndpointDescription originalTed =
55 TransportEndpointDescription
56 .builder()
57 .withEnabled(true)
58 .withOutput(output)
59 .build();
60 TransportEndpointDescription ted =
61 TransportEndpointDescription
62 .builder()
63 .copyFrom(originalTed)
64 .build();
65
66 assertThat(ted, notNullValue());
67 assertThat(ted.isEnabled(), is(true));
68 assertThat(ted.output(), is(output));
69 }
70
71 @Test
72 public void testEquals() {
73 FilteredConnectPoint cp =
74 new FilteredConnectPoint(NetTestTools.connectPoint("d", 1));
75
76 TransportEndpointDescription ted1 =
77 TransportEndpointDescription
78 .builder()
79 .withEnabled(true)
80 .withOutput(cp)
81 .build();
82
83 TransportEndpointDescription ted2 =
84 TransportEndpointDescription
85 .builder()
86 .withEnabled(true)
87 .withOutput(cp)
88 .build();
89
90 new EqualsTester()
91 .addEqualityGroup(ted1)
92 .addEqualityGroup(ted2)
93 .testEquals();
94 }
95}