@Test public void cantAddSelf() throws Exception { dotProduct1.setParent(crossProduct1); try { dotProduct1.insert(dotProduct1); fail("Didn't throw IllegalArgumentException"); } catch (IllegalArgumentException ex) { // Make sure we didn't loose our old parent and // ended up in a funny state assertEquals(crossProduct1, dotProduct1.getParent()); assertEquals(dotProduct1, crossProduct1.getChildAt(0)); } }
@Test public void cantAddSelf() throws Exception { dotProduct1.setParent(crossProduct1); try { dotProduct1.insert(dotProduct1); fail("Didn't throw IllegalArgumentException"); } catch (IllegalArgumentException ex) { // Make sure we didn't loose our old parent and // ended up in a funny state assertEquals(crossProduct1, dotProduct1.getParent()); assertEquals(dotProduct1, crossProduct1.getChildAt(0)); } }
@Test public void cantSetSelfParent() throws Exception { crossProduct1.insert(dotProduct1); try { dotProduct1.setParent(dotProduct1); fail("Didn't throw IllegalArgumentException"); } catch (IllegalArgumentException ex) { // Make sure we didn't loose our old parent and // ended up in a funny state assertEquals(crossProduct1, dotProduct1.getParent()); assertEquals(dotProduct1, crossProduct1.getChildAt(0)); } }
@Test public void cantSetSelfParent() throws Exception { crossProduct1.insert(dotProduct1); try { dotProduct1.setParent(dotProduct1); fail("Didn't throw IllegalArgumentException"); } catch (IllegalArgumentException ex) { // Make sure we didn't loose our old parent and // ended up in a funny state assertEquals(crossProduct1, dotProduct1.getParent()); assertEquals(dotProduct1, crossProduct1.getChildAt(0)); } }
@Test public void addCrossProduct() throws Exception { assertNull(crossProduct1.getParent()); crossProduct1.setParent(root); assertEquals(root, crossProduct1.getParent()); assertEquals(1, root.getChildCount()); assertEquals(crossProduct1, root.getChildAt(0)); assertEquals(Arrays.asList(crossProduct1), root.getChildren()); assertEquals(0, crossProduct1.getChildCount()); crossProduct1.insert(input1); assertEquals(input1, crossProduct1.getChildAt(0)); crossProduct1.insert(input2, 0); assertEquals(input2, crossProduct1.getChildAt(0)); assertEquals(input1, crossProduct1.getChildAt(1)); assertEquals(2, crossProduct1.getChildCount()); assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren()); // A re-insert should move it crossProduct1.insert(input2, 2); assertEquals(2, crossProduct1.getChildCount()); assertEquals(Arrays.asList(input1, input2), crossProduct1.getChildren()); crossProduct1.insert(input2, 0); assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren()); crossProduct1.insert(input1, 1); assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren()); }
@Test public void addCrossProduct() throws Exception { assertNull(crossProduct1.getParent()); crossProduct1.setParent(root); assertEquals(root, crossProduct1.getParent()); assertEquals(1, root.getChildCount()); assertEquals(crossProduct1, root.getChildAt(0)); assertEquals(Arrays.asList(crossProduct1), root.getChildren()); assertEquals(0, crossProduct1.getChildCount()); crossProduct1.insert(input1); assertEquals(input1, crossProduct1.getChildAt(0)); crossProduct1.insert(input2, 0); assertEquals(input2, crossProduct1.getChildAt(0)); assertEquals(input1, crossProduct1.getChildAt(1)); assertEquals(2, crossProduct1.getChildCount()); assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren()); // A re-insert should move it crossProduct1.insert(input2, 2); assertEquals(2, crossProduct1.getChildCount()); assertEquals(Arrays.asList(input1, input2), crossProduct1.getChildren()); crossProduct1.insert(input2, 0); assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren()); crossProduct1.insert(input1, 1); assertEquals(Arrays.asList(input2, input1), crossProduct1.getChildren()); }