blob: cf6e0e81cd6a91354265ba544a1867a8b9a4d4d0 [file] [log] [blame]
Sho SHIMIZUe571d442016-02-11 19:10:52 -08001/*
2 * Copyright 2016 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 */
16package org.onosproject.net.newresource;
17
18import com.google.common.testing.EqualsTester;
19import org.junit.Test;
20import org.onlab.util.Bandwidth;
21import org.onosproject.net.DeviceId;
22import org.onosproject.net.PortNumber;
23
24/**
25 * Unit test for ContinuousResourceId.
26 */
27public class ContinuousResourceIdTest {
28
29 private static final DeviceId D1 = DeviceId.deviceId("of:001");
30 private static final PortNumber P1 = PortNumber.portNumber(1);
31 private static final Bandwidth BW1 = Bandwidth.gbps(2);
32 private static final Bandwidth BW2 = Bandwidth.gbps(1);
33
34 @Test
35 public void testEquality() {
36 ContinuousResourceId id1 = Resources.continuous(D1, P1, Bandwidth.class)
37 .resource(BW1.bps()).id();
38 // intentionally set a different value
39 ContinuousResourceId sameAsId1 = Resources.continuous(D1, P1, Bandwidth.class)
40 .resource(BW2.bps()).id();
41
42 new EqualsTester()
43 .addEqualityGroup(id1, sameAsId1);
44 }
45}