### Question:
IndexPropertyList extends AbstractList implements ValueHolder { @Override public void add(int index, Object element) { if (dirty) { sort(); } list.add(index, element); if (element != null) { int indexValue = calculateIndexValue(index); setIndexValue(element, indexValue); shift(index + 1, indexValue); } } IndexPropertyList(String indexProperty);  IndexPropertyList(String indexProperty, List objects, boolean sortNeeded); boolean isFault(); Object setValueDirectly(Object value); Object setValue(Object value); Object getValue(); Object getValueDirectly(); void invalidate(); void touch(); @Override Object get(int index); @Override int size(); @Override Object set(int index, Object element); @Override void add(int index, Object element); @Override Object remove(int index);  }### Answer:
@Test public void testAppend() { IndexedObject o1 = new IndexedObject(1); IndexedObject o2 = new IndexedObject(2); IndexedObject o3 = new IndexedObject(3); IndexedObject o4 = new IndexedObject(4); List list1 = new ArrayList(Arrays.asList(o2, o4, o3, o1)); IndexPropertyList indexedList = new IndexPropertyList("order", list1, true); IndexedObject o5 = new IndexedObject(-1); indexedList.add(o5); assertEquals(4, o4.getOrder()); assertTrue(o4.getOrder() < o5.getOrder()); }
@Test public void testInsert() { IndexedObject o1 = new IndexedObject(1); IndexedObject o2 = new IndexedObject(2); IndexedObject o3 = new IndexedObject(3); IndexedObject o4 = new IndexedObject(4); List list1 = new ArrayList(Arrays.asList(o2, o4, o3, o1)); IndexPropertyList indexedList = new IndexPropertyList("order", list1, true); IndexedObject o5 = new IndexedObject(-1); indexedList.add(1, o5); assertEquals(1, o1.getOrder()); assertTrue(o1.getOrder() < o5.getOrder()); assertTrue(o5.getOrder() < o2.getOrder()); assertTrue(o2.getOrder() < o3.getOrder()); assertTrue(o3.getOrder() < o4.getOrder()); }