Program: 32475
Project: 32475
Buggy source:
/** 
 * Tests that elements are properly moved when value changes require that if sort order is not enforced on the list.
 */
public void testSimpleMovesSortNotEnforced(){
  unsortedList=new BasicEventList<Comparable>();
  sortedList=SortedList.create(unsortedList);
  sortedList.setMode(SortedList.AVOID_MOVING_ELEMENTS);
  ListConsistencyListener.install(sortedList);
  unsortedList.addAll(GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  unsortedList.set(3,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(3,unsortedList.indexOf("String_Node_Str"));
  assertEquals(3,sortedList.indexOf("String_Node_Str"));
  unsortedList.addAll(3,GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(10,unsortedList.indexOf("String_Node_Str"));
  assertEquals(3,sortedList.indexOf("String_Node_Str"));
  unsortedList.removeAll(GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(7,unsortedList.indexOf("String_Node_Str"));
  assertEquals(2,sortedList.indexOf("String_Node_Str"));
  unsortedList.addAll(8,GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(7,unsortedList.indexOf("String_Node_Str"));
  assertEquals(4,sortedList.indexOf("String_Node_Str"));
  unsortedList.set(0,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(7,unsortedList.indexOf("String_Node_Str"));
  assertEquals(4,sortedList.indexOf("String_Node_Str"));
  assertEquals(0,unsortedList.indexOf("String_Node_Str"));
  assertEquals(1,sortedList.indexOf("String_Node_Str"));
  unsortedList.set(7,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(-1,unsortedList.indexOf("String_Node_Str"));
  assertEquals(-1,sortedList.indexOf("String_Node_Str"));
  assertEquals(7,unsortedList.indexOf("String_Node_Str"));
  assertEquals(4,sortedList.indexOf("String_Node_Str"));
  unsortedList.addAll(0,GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  unsortedList.addAll(5,GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  sortedList.set(1,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(4,unsortedList.indexOf("String_Node_Str"));
  assertEquals(1,sortedList.indexOf("String_Node_Str"));
  sortedList.clear();
  assertEquals(Collections.EMPTY_LIST,unsortedList);
  assertEquals(Collections.EMPTY_LIST,sortedList);
  sortedList.addAll(GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  sortedList.set(0,"String_Node_Str");
  sortedList.set(2,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  sortedList.add("String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(2,unsortedList.indexOf("String_Node_Str"));
  assertEquals(0,unsortedList.indexOf("String_Node_Str"));
  assertEquals(0,sortedList.indexOf("String_Node_Str"));
  assertEquals(1,sortedList.indexOf("String_Node_Str"));
  sortedList.add("String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
}

Fixed version (ground truth):
/** 
 * Tests that elements are properly moved when value changes require that if sort order is not enforced on the list.
 */
public void testSimpleMovesSortNotEnforced(){
  unsortedList=new BasicEventList<Comparable>();
  sortedList=SortedList.create(unsortedList);
  sortedList.setMode(SortedList.AVOID_MOVING_ELEMENTS);
  ListConsistencyListener.install(sortedList);
  unsortedList.addAll(GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  unsortedList.set(3,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(3,unsortedList.indexOf("String_Node_Str"));
  assertEquals(3,sortedList.indexOf("String_Node_Str"));
  unsortedList.addAll(3,GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(10,unsortedList.indexOf("String_Node_Str"));
  assertEquals(3,sortedList.indexOf("String_Node_Str"));
  assertEquals(12,unsortedList.lastIndexOf("String_Node_Str"));
  assertEquals(5,sortedList.lastIndexOf("String_Node_Str"));
  unsortedList.removeAll(GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(7,unsortedList.indexOf("String_Node_Str"));
  assertEquals(2,sortedList.indexOf("String_Node_Str"));
  assertEquals(8,unsortedList.lastIndexOf("String_Node_Str"));
  assertEquals(3,sortedList.lastIndexOf("String_Node_Str"));
  unsortedList.addAll(8,GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(7,unsortedList.indexOf("String_Node_Str"));
  assertEquals(4,sortedList.indexOf("String_Node_Str"));
  unsortedList.set(0,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(7,unsortedList.indexOf("String_Node_Str"));
  assertEquals(4,sortedList.indexOf("String_Node_Str"));
  assertEquals(0,unsortedList.indexOf("String_Node_Str"));
  assertEquals(1,sortedList.indexOf("String_Node_Str"));
  unsortedList.set(7,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(-1,unsortedList.indexOf("String_Node_Str"));
  assertEquals(-1,sortedList.indexOf("String_Node_Str"));
  assertEquals(7,unsortedList.indexOf("String_Node_Str"));
  assertEquals(4,sortedList.indexOf("String_Node_Str"));
  assertEquals(12,unsortedList.lastIndexOf("String_Node_Str"));
  assertEquals(5,sortedList.lastIndexOf("String_Node_Str"));
  unsortedList.addAll(0,GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(2,unsortedList.indexOf("String_Node_Str"));
  assertEquals(6,sortedList.indexOf("String_Node_Str"));
  assertEquals(16,unsortedList.lastIndexOf("String_Node_Str"));
  assertEquals(9,sortedList.lastIndexOf("String_Node_Str"));
  unsortedList.addAll(5,GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  sortedList.set(1,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(4,unsortedList.indexOf("String_Node_Str"));
  assertEquals(1,sortedList.indexOf("String_Node_Str"));
  sortedList.clear();
  assertEquals(Collections.EMPTY_LIST,unsortedList);
  assertEquals(Collections.EMPTY_LIST,sortedList);
  sortedList.addAll(GlazedListsTests.stringToList("String_Node_Str"));
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  sortedList.set(0,"String_Node_Str");
  sortedList.set(2,"String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  sortedList.add("String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
  assertEquals(2,unsortedList.indexOf("String_Node_Str"));
  assertEquals(0,unsortedList.indexOf("String_Node_Str"));
  assertEquals(0,sortedList.indexOf("String_Node_Str"));
  assertEquals(1,sortedList.indexOf("String_Node_Str"));
  sortedList.add("String_Node_Str");
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),unsortedList);
  assertEquals(GlazedListsTests.stringToList("String_Node_Str"),sortedList);
}