### Question:
DeviceGroup extends UserDefinedEntity { public final void addDevice(final Device device) { device.setDeviceGroup(this); addDeviceProtected(device); } DeviceGroup(final String name);  DeviceGroup(final String name, final String description); protected  DeviceGroup(); static ScheduledJobInfo createDefaultScheduledJobInfo(); final Set<Device> getDevices(); final void addDevice(final Device device); final boolean removeDevice(final Device device); final boolean removeDevice(final String deviceName); final void setPeriodicReportDelayThreshold(final long milliseconds); final long getPeriodicReportDelayThreshold(); final void setEnablePeriodicReportDelayAlert(final boolean flag); final boolean isEnablePeriodicReportDelayAlert(); final void setOnDemandReportDelayThreshold(final long milliseconds); final long getOnDemandReportDelayThreshold(); final void setEnableOnDemandReportDelayAlert(final boolean flag); final boolean isEnableOnDemandReportDelayAlert(); boolean isWaitForAppraisalCompletionEnabled(); void setWaitForAppraisalCompletionEnabled(final boolean
                                                             waitForAppraisalCompletionEnabled); ScheduledJobInfo getScheduledJobInfo(); void setScheduledJobInfo(final ScheduledJobInfo scheduledJobInfo); HealthStatus getHealthStatus(); int getNumberOfDevices(); int getNumberOfTrustedDevices(); Set<Device> getAllDevices(); static final String DEFAULT_GROUP; static final long SECOND_MS_INTERVAL; static final long MINUTE_MS_INTERVAL; static final long FIVE_MINUTES_MS_INTERVAL; static final long HOUR_MS_INTERVAL; static final long DAY_MS_INTERVAL; static final long DEFAULT_REPORT_DELAY_THRESHOLD; static final long MINIMUM_PERIODIC_REPORT_INTERVAL; static final long MINIMUM_THRESHOLD_INTERVAL_MS; static final long DEFAULT_JOB_FREQUENCY_MS; }### Answer:
@Test public final void testAddDevice() throws Exception { Device device = DeviceTest.getTestDevice("TestDevice"); DeviceGroup deviceGroup = new DeviceGroup("TestDeviceGroup"); deviceGroup.addDevice(device); Set<Device> devices = deviceGroup.getDevices(); Assert.assertNotNull(devices); Assert.assertEquals(devices.size(), 1); Assert.assertEquals(deviceGroup, device.getDeviceGroup()); Assert.assertEquals(devices.iterator().next(), device); }
@Test(expectedExceptions = NullPointerException.class) public final void testAddDeviceNull() { DeviceGroup deviceGroup = new DeviceGroup("TestDeviceGroup"); deviceGroup.addDevice(null); }