alshabib | ab98466 | 2014-12-04 18:56:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.store.link.impl; |
Yuta HIGUCHI | 34a01f2 | 2014-11-04 15:58:20 -0800 | [diff] [blame] | 17 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 18 | import static org.onosproject.net.DeviceId.deviceId; |
Yuta HIGUCHI | 34a01f2 | 2014-11-04 15:58:20 -0800 | [diff] [blame] | 19 | |
| 20 | import org.junit.Test; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 21 | import org.onosproject.net.ConnectPoint; |
| 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.LinkKey; |
| 24 | import org.onosproject.net.PortNumber; |
| 25 | import org.onosproject.net.provider.ProviderId; |
Yuta HIGUCHI | 34a01f2 | 2014-11-04 15:58:20 -0800 | [diff] [blame] | 26 | import com.google.common.testing.EqualsTester; |
| 27 | |
| 28 | public class LinkFragmentIdTest { |
| 29 | |
| 30 | private static final ProviderId PID = new ProviderId("of", "foo"); |
| 31 | private static final ProviderId PIDA = new ProviderId("of", "bar", true); |
| 32 | |
| 33 | private static final DeviceId DID1 = deviceId("of:foo"); |
| 34 | private static final DeviceId DID2 = deviceId("of:bar"); |
| 35 | |
| 36 | private static final PortNumber P1 = PortNumber.portNumber(1); |
| 37 | private static final PortNumber P2 = PortNumber.portNumber(2); |
| 38 | private static final PortNumber P3 = PortNumber.portNumber(3); |
| 39 | |
| 40 | private static final ConnectPoint CP1 = new ConnectPoint(DID1, P1); |
| 41 | private static final ConnectPoint CP2 = new ConnectPoint(DID2, P2); |
| 42 | |
| 43 | private static final ConnectPoint CP3 = new ConnectPoint(DID1, P2); |
| 44 | private static final ConnectPoint CP4 = new ConnectPoint(DID2, P3); |
| 45 | |
| 46 | private static final LinkKey L1 = LinkKey.linkKey(CP1, CP2); |
| 47 | private static final LinkKey L2 = LinkKey.linkKey(CP3, CP4); |
| 48 | |
| 49 | @Test |
| 50 | public void testEquals() { |
| 51 | new EqualsTester() |
| 52 | .addEqualityGroup(new LinkFragmentId(L1, PID), |
| 53 | new LinkFragmentId(L1, PID)) |
| 54 | .addEqualityGroup(new LinkFragmentId(L2, PID), |
| 55 | new LinkFragmentId(L2, PID)) |
| 56 | .addEqualityGroup(new LinkFragmentId(L1, PIDA), |
| 57 | new LinkFragmentId(L1, PIDA)) |
| 58 | .addEqualityGroup(new LinkFragmentId(L2, PIDA), |
| 59 | new LinkFragmentId(L2, PIDA)) |
| 60 | .testEquals(); |
| 61 | } |
| 62 | |
| 63 | } |