### Question:
IMADeviceState extends DeviceState { public final void setIndex(final int index) throws IllegalArgumentException { if (index < 0) { throw new IllegalArgumentException("index < 0"); } this.index = index; } IMADeviceState(final Device device); protected  IMADeviceState(); final Long getId(); final void resetState(); final Device getDevice(); final String getBootcycleId(); final void setBootcycleId(final String bootcycleId); final int getIndex(); final void setIndex(final int index); final Date getMostRecentFullReportDate(); final void setMostRecentFullReportDate(final Date date); @Override Criterion getDeviceTrustAlertCriterion(); final byte[] getPcrState(); final void setPcrState(final byte[] pcrState); @Override final int hashCode(); @Override final boolean equals(final Object obj); @Override final String toString();  }### Answer:
@Test public void testSetIndex() { final Device device = new Device("Test Device"); final IMADeviceState state = new IMADeviceState(device); final int[] indices = new int[] {0, 100}; for (int i = 0; i < indices.length; ++i) { final int index = indices[i]; state.setIndex(index); Assert.assertEquals(state.getIndex(), index); } }
@Test(expectedExceptions = IllegalArgumentException.class) public void testSetIndexToInvalidValue() { final Device device = new Device("Test Device"); final IMADeviceState state = new IMADeviceState(device); final int invalidIndex = -1; state.setIndex(invalidIndex); }