Ray Milkey | c916699 | 2017-05-08 12:02:26 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Ray Milkey | c916699 | 2017-05-08 12:02:26 -0700 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.net.behaviour.protection; |
| 18 | |
| 19 | import org.junit.Test; |
| 20 | import org.onosproject.net.FilteredConnectPoint; |
| 21 | import org.onosproject.net.NetTestTools; |
| 22 | |
| 23 | import com.google.common.testing.EqualsTester; |
| 24 | |
| 25 | import static org.hamcrest.Matchers.is; |
| 26 | import static org.hamcrest.Matchers.notNullValue; |
| 27 | import static org.junit.Assert.assertThat; |
| 28 | |
| 29 | /** |
| 30 | * Unit tests for the transport endpoint description. |
| 31 | */ |
| 32 | public 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 | } |