FileData implements Serializable { public int getContentAsCounterValue(int numCounter) { Assert.getInstance().greaterOrEqual(numCounter, 1, "numCounter"); byte[] rec1 = records.get(1); if (rec1 == null) { throw new NoSuchElementException("Record #1 is not set."); } int counterIndex = (numCounter - 1) * 3; if (counterIndex >= rec1.length) { throw new NoSuchElementException( "Counter #" + numCounter + " is not set (nb of actual counters = " + (rec1.length / 3) + ")."); } if (counterIndex + 3 > rec1.length) { throw new IndexOutOfBoundsException( "Counter #" + numCounter + " has a truncated value (nb of actual counters = " + (rec1.length / 3) + ")."); } return ByteArrayUtil.threeBytesToInt(rec1, counterIndex); } FileData();   FileData(FileData source); SortedMap<Integer, byte[]> getAllRecordsContent(); byte[] getContent(); byte[] getContent(int numRecord); byte[] getContent(int numRecord, int dataOffset, int dataLength); int getContentAsCounterValue(int numCounter); SortedMap<Integer, Integer> getAllCountersValue(); @Override String toString();  }
@Test(expected = IllegalArgumentException.class) public void getContentAsCounterValue_whenNumRecordLt1_shouldThrowIAE() { file.getContentAsCounterValue(0); }
@Test(expected = NoSuchElementException.class) public void getContentAsCounterValue_whenRecordIsNotSet_shouldThrowNSEE() { file.getContentAsCounterValue(1); }