blob: 8b91bbdd503cff50a7b71cf0e76393e2b7d82f05 [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 */
Sho SHIMIZUe18cb122016-02-22 21:04:56 -080016package org.onosproject.net.resource;
Sho SHIMIZUe571d442016-02-11 19:10:52 -080017
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
Sho SHIMIZU74ac9012016-02-12 10:03:21 -080024import static org.hamcrest.Matchers.is;
25import static org.junit.Assert.assertThat;
26
Sho SHIMIZUe571d442016-02-11 19:10:52 -080027/**
28 * Unit test for ContinuousResourceId.
29 */
30public class ContinuousResourceIdTest {
31
32 private static final DeviceId D1 = DeviceId.deviceId("of:001");
33 private static final PortNumber P1 = PortNumber.portNumber(1);
34 private static final Bandwidth BW1 = Bandwidth.gbps(2);
35 private static final Bandwidth BW2 = Bandwidth.gbps(1);
36
37 @Test
38 public void testEquality() {
39 ContinuousResourceId id1 = Resources.continuous(D1, P1, Bandwidth.class)
40 .resource(BW1.bps()).id();
41 // intentionally set a different value
42 ContinuousResourceId sameAsId1 = Resources.continuous(D1, P1, Bandwidth.class)
43 .resource(BW2.bps()).id();
44
45 new EqualsTester()
46 .addEqualityGroup(id1, sameAsId1);
47 }
Sho SHIMIZU74ac9012016-02-12 10:03:21 -080048
49 @Test
50 public void testSimpleTypeName() {
51 ContinuousResourceId id1 = Resources.continuous(D1, P1, Bandwidth.class).resource(BW1.bps()).id();
52
53 assertThat(id1.simpleTypeName(), is("Bandwidth"));
54 }
Sho SHIMIZUe571d442016-02-11 19:10:52 -080055}