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