blob: 7f06e9ca588a21ed95d440ba9b6080ce75b079d2 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.device;
tom3065d122014-09-03 21:56:43 -070017
18import org.junit.Test;
alshabib7911a052014-10-16 17:49:37 -070019import org.onlab.packet.ChassisId;
Pavel Likin9d49f542015-12-13 15:04:55 +030020import org.onosproject.net.DefaultAnnotations;
tom3065d122014-09-03 21:56:43 -070021
22import java.net.URI;
23
24import static org.junit.Assert.assertEquals;
25import static org.junit.Assert.assertTrue;
Brian O'Connorabafb502014-12-02 22:26:20 -080026import static org.onosproject.net.Device.Type.SWITCH;
tom3065d122014-09-03 21:56:43 -070027
28/**
29 * Test of the default device description.
30 */
31public class DefaultDeviceDescriptionTest {
32
33 private static final URI DURI = URI.create("of:foo");
34 private static final String MFR = "whitebox";
35 private static final String HW = "1.1.x";
36 private static final String SW = "3.9.1";
37 private static final String SN = "43311-12345";
alshabib7911a052014-10-16 17:49:37 -070038 private static final ChassisId CID = new ChassisId();
Pavel Likin9d49f542015-12-13 15:04:55 +030039 private static final DefaultAnnotations DA =
40 DefaultAnnotations.builder().set("Key", "Value").build();
tom3065d122014-09-03 21:56:43 -070041
42 @Test
43 public void basics() {
44 DeviceDescription device =
Pavel Likin9d49f542015-12-13 15:04:55 +030045 new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN, CID, DA);
Jonathan Hartd9df7bd2015-11-10 17:10:25 -080046 assertEquals("incorrect uri", DURI, device.deviceUri());
tom3065d122014-09-03 21:56:43 -070047 assertEquals("incorrect type", SWITCH, device.type());
48 assertEquals("incorrect manufacturer", MFR, device.manufacturer());
49 assertEquals("incorrect hw", HW, device.hwVersion());
50 assertEquals("incorrect sw", SW, device.swVersion());
51 assertEquals("incorrect serial", SN, device.serialNumber());
52 assertTrue("incorrect toString", device.toString().contains("uri=of:foo"));
alshabib7911a052014-10-16 17:49:37 -070053 assertTrue("Incorrect chassis", device.chassisId().value() == 0);
Pavel Likin9d49f542015-12-13 15:04:55 +030054 assertTrue("incorrect annotatios", device.toString().contains("Key=Value"));
tom3065d122014-09-03 21:56:43 -070055 }
56
57}