### Question:
Device { private Device(String deviceType, int deviceId) { this.deviceType = deviceType; this.deviceId = deviceId; } private  Device(String deviceType, int deviceId); static Device of(String deviceType, int deviceId); String getDeviceType(); int getDeviceId(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static Device cpu(); static Device gpu(); static Device gpu(int deviceId); static Device[] getDevices(int maxGpus); static int getGpuCount(); static int getGpuCount(String engineName); static Device defaultDevice(); static Device defaultIfNull(Device device); static Device defaultIfNull(Device device, Device def);  }### Answer:
@Test public void testDevice() { Assert.assertEquals(Device.cpu(), Device.of("cpu", -1)); if (Device.getGpuCount() > 0) { Assert.assertEquals(Device.gpu(), Device.defaultDevice()); } else { Assert.assertEquals(Device.cpu(), Device.defaultDevice()); } Assert.assertEquals(Device.gpu(), Device.of("gpu", 0)); Assert.assertEquals(Device.gpu(3), Device.of("gpu", 3)); Assert.assertNotEquals(Device.cpu(), Device.gpu()); Device dev = Device.of("myDevice", 1); Assert.assertEquals(dev.getDeviceType(), "myDevice"); }