blob: 1d174caedf9e07e4efa44e61f1dfc63628ba9eee [file] [log] [blame]
tom3065d122014-09-03 21:56:43 -07001package org.onlab.onos.net;
2
3import com.google.common.testing.EqualsTester;
4import org.junit.Test;
5import org.onlab.onos.net.provider.ProviderId;
6
7import java.net.URI;
8
9import static org.junit.Assert.assertEquals;
10import static org.onlab.onos.net.Device.Type.SWITCH;
11
12/**
13 * Test of the default device model entity.
14 */
15public class DefaultDeviceTest {
16
17 private static final ProviderId PID = new ProviderId("foo");
18 private static final DeviceId DID1 = new DeviceId(URI.create("of:foo"));
19 private static final DeviceId DID2 = new DeviceId(URI.create("of:bar"));
20 private static final String MFR = "whitebox";
21 private static final String HW = "1.1.x";
22 private static final String SW = "3.9.1";
23 private static final String SN1 = "43311-12345";
24 private static final String SN2 = "42346-43512";
25
26
27 @Test
28 public void testEquality() {
29 Device d1 = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1);
30 Device d2 = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1);
31 Device d3 = new DefaultDevice(PID, DID2, SWITCH, MFR, HW, SW, SN2);
32 Device d4 = new DefaultDevice(PID, DID2, SWITCH, MFR, HW, SW, SN2);
33 Device d5 = new DefaultDevice(PID, DID2, SWITCH, MFR, HW, SW, SN1);
34
35 new EqualsTester().addEqualityGroup(d1, d2)
36 .addEqualityGroup(d3, d4)
37 .addEqualityGroup(d5)
38 .testEquals();
39 }
40
41 @Test
42 public void basics() {
43 Device device = new DefaultDevice(PID, DID1, SWITCH, MFR, HW, SW, SN1);
44 assertEquals("incorrect provider", PID, device.providerId());
45 assertEquals("incorrect id", DID1, device.id());
46 assertEquals("incorrect type", SWITCH, device.type());
47 assertEquals("incorrect manufacturer", MFR, device.manufacturer());
48 assertEquals("incorrect hw", HW, device.hwVersion());
49 assertEquals("incorrect sw", SW, device.swVersion());
50 assertEquals("incorrect serial", SN1, device.serialNumber());
51 assertEquals("incorrect serial", SN1, device.serialNumber());
52 }
53
54}