blob: aeb950d6a642f8eaf033feb462ef19d7b30cb25e [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.packet.VlanId;
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 DiscreteResourceId.
29 */
30public class DiscreteResourceIdTest {
31
32 private static final DeviceId D1 = DeviceId.deviceId("of:001");
33 private static final DeviceId D2 = DeviceId.deviceId("of:002");
34 private static final PortNumber P1 = PortNumber.portNumber(1);
35 private static final VlanId VLAN1 = VlanId.vlanId((short) 100);
36
37 @Test
38 public void testEquality() {
39 DiscreteResourceId id1 = Resources.discrete(D1, P1, VLAN1).id();
40 DiscreteResourceId sameAsId1 = Resources.discrete(D1, P1, VLAN1).id();
41 DiscreteResourceId id2 = Resources.discrete(D2, P1, VLAN1).id();
42
43 new EqualsTester()
44 .addEqualityGroup(id1, sameAsId1)
45 .addEqualityGroup(id2);
46 }
Sho SHIMIZU74ac9012016-02-12 10:03:21 -080047
48 @Test
49 public void testSimpleTypeName() {
50 DiscreteResourceId id = Resources.discrete(D1, P1, VLAN1).id();
51 assertThat(id.simpleTypeName(), is("VlanId"));
52 }
53
54 @Test
55 public void testSimpleTypeNameOfRoot() {
56 assertThat(ResourceId.ROOT.simpleTypeName(), is("Root"));
57 }
Sho SHIMIZUe571d442016-02-11 19:10:52 -080058}