### Question:
TLVList implements Serializable, Loggeable { public TLVMsg index(int index) throws IndexOutOfBoundsException { return tags.get(index); } TLVList(); void unpack(byte[] buf); List<TLVMsg> getTags(); Enumeration<TLVMsg> elements(); void unpack(byte[] buf, int offset); void append(TLVMsg tlv); TLVList append(int tag, byte[] value); TLVList append(int tag, String value); void deleteByIndex(int index); void deleteByTag(int tag); TLVMsg find(int tag); int findIndex(int tag); TLVMsg findNextTLV(); TLVMsg index(int index); byte[] pack(); String getString(int tag); byte[] getValue(int tag); boolean hasTag(int tag); @Override void dump(PrintStream p, String indent);  }### Answer:
@Test public void testIndex() { TLVMsg expected = instance.createTLVMsg(TEST_TAG1, null); instance.append(expected); TLVMsg result = instance.index(0); assertSame(expected, result); }
@Test public void testIndexThrowsIndexOutOfBounds() { assertThrows(IndexOutOfBoundsException.class, () -> { instance.index(TEST_TAG1); }); }