ChildOrderDiff { static boolean isReordered(@NotNull PropertyState before, @NotNull PropertyState after) { Set<String> afterNames = newLinkedHashSet(after.getValue(Type.NAMES)); Set<String> beforeNames = newLinkedHashSet(before.getValue(Type.NAMES)); afterNames.retainAll(beforeNames); beforeNames.retainAll(afterNames); return !Iterables.elementsEqual(afterNames, beforeNames); } private  ChildOrderDiff();   }
@Test public void testBeforeEmptyAfterEmpty() { PropertyState before = createPropertyState(); PropertyState after = createPropertyState(); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testBeforeEmpty() { PropertyState before = createPropertyState(); PropertyState after = createPropertyState("n1", "n2"); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testAfterEmpty() { PropertyState before = createPropertyState("n1", "n2"); PropertyState after = createPropertyState(); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testAfterEqualsBefore() { PropertyState eq = createPropertyState("n1", "n2"); assertFalse(ChildOrderDiff.isReordered(eq, eq)); }
@Test public void testAppendedAtEnd() { PropertyState before = createPropertyState("n1", "n2", "n3"); PropertyState after = createPropertyState("n1", "n2", "n3", "n4"); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testInsertedAtBeginning() { PropertyState before = createPropertyState("n1", "n2", "n3"); PropertyState after = createPropertyState("n0", "n1", "n2", "n3"); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testInserted() { PropertyState before = createPropertyState("n1", "n2", "n3"); PropertyState after = createPropertyState("n1", "n11", "n2", "n3"); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testLastReplaced() { PropertyState before = createPropertyState("n1", "n2", "n3"); PropertyState after = createPropertyState("n1", "n2", "n4"); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testFirstRemoved() { PropertyState before = createPropertyState("n1", "n2", "n3"); PropertyState after = createPropertyState("n2", "n3"); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testSecondRemoved() { PropertyState before = createPropertyState("n1", "n2", "n3"); PropertyState after = createPropertyState("n1", "n3"); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testLastRemoved() { PropertyState before = createPropertyState("n1", "n2", "n3"); PropertyState after = createPropertyState("n1", "n2"); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testReorderedFirstToEnd() { PropertyState before = createPropertyState("n1", "n2", "n3"); PropertyState after = createPropertyState("n2", "n3", "n1"); assertTrue(ChildOrderDiff.isReordered(before, after)); }
@Test public void testReorderedLastBeforeSecond() { PropertyState before = createPropertyState("n1", "n2", "n3"); PropertyState after = createPropertyState("n1", "n3", "n2"); assertTrue(ChildOrderDiff.isReordered(before, after)); }
@Test public void testRemovedAndReordered() { PropertyState before = createPropertyState("n1", "n2", "n3", "n4"); PropertyState after = createPropertyState("n1", "n4", "n3"); assertTrue(ChildOrderDiff.isReordered(before, after)); }
@Test public void testInsertedRemovedAndReordered() { PropertyState before = createPropertyState("n1", "n2", "n3", "n4"); PropertyState after = createPropertyState("n1", "n11", "n4", "n3"); assertTrue(ChildOrderDiff.isReordered(before, after)); }
@Test public void testRemovedAndReorderedAppended() { PropertyState before = createPropertyState("n1", "n2", "n3", "n4"); PropertyState after = createPropertyState("n1", "n4", "n3", "n33"); assertTrue(ChildOrderDiff.isReordered(before, after)); }
@Test public void testReorderedAndReplaced() { PropertyState before = createPropertyState("n1", "n2", "n3", "n4"); PropertyState after = createPropertyState("n4", "n1", "n6"); assertTrue(ChildOrderDiff.isReordered(before, after)); }
@Test public void testOnlyLastEquals() { PropertyState before = createPropertyState("n1", "n2"); PropertyState after = createPropertyState("n5", "n6", "n7", "n2"); assertFalse(ChildOrderDiff.isReordered(before, after)); }
@Test public void testAllDifferent() { PropertyState before = createPropertyState("n1", "n2", "n3", "n4"); PropertyState after = createPropertyState("n5", "n6", "n7", "n8", "n9"); assertFalse(ChildOrderDiff.isReordered(before, after)); }