EepData { public void update(byte[] eepData) { if(eepData == null) { throw new IllegalArgumentException("null EEP data"); } if(this.data.length != eepData.length) { throw new IllegalArgumentException( "Invalid EEP data length, expected " + this.data.length + ", got " + eepData.length); } this.data = eepData.clone(); for(EepDataListener listener : listeners) { try { listener.didUpdateData(this); } catch (EepOutOfRangeException e) { } } } EepData(EepType type, int length, Set<EepDataListener> dataListeners);  EepData(EepType type, int length, EepDataListener...dataListeners); @Override String toString(); int length(); void setValue(int index, int value); int getValue(int index); byte[] asByteArray(); String dataAsString(); void update(byte[] eepData);  }
@Test (expected = IllegalArgumentException.class) public void testNullUpdateData() throws Exception { EepData data = new EepData(EepType.EEP_TYPE_A50205, 2, dataListeners); data.update(null); }
@Test public void testUpdateWithInvalidDataLength() throws Exception { EepData data = new EepData(EepType.EEP_TYPE_A50205, 2, dataListeners); try { data.update(new byte[1]); Assert.fail(); } catch (IllegalArgumentException e) { } try { data.update(new byte[3]); Assert.fail(); } catch (IllegalArgumentException e) { } }