### Question:
RandomCutTree { static Node getSibling(Node node) { checkNotNull(node.getParent(), "node parent must not be null"); Node parent = node.getParent(); if (parent.getLeftChild() == node) { return parent.getRightChild(); } else if (parent.getRightChild() == node) { return parent.getLeftChild(); } else { throw new IllegalArgumentException("node parent does not link back to node"); } } protected  RandomCutTree(Builder<?> builder); static Builder builder(); static RandomCutTree defaultTree(long randomSeed); static RandomCutTree defaultTree(); boolean centerOfMassEnabled(); boolean storeSequenceIndexesEnabled(); void deletePoint(WeightedPoint weightedPoint); void addPoint(WeightedPoint weightedPoint); R traverseTree(double[] point, Visitor<R> visitor); R traverseTreeMulti(double[] point, MultiVisitor<R> visitor); Node getRoot(); static final boolean DEFAULT_STORE_SEQUENCE_INDEXES_ENABLED; static final boolean DEFAULT_CENTER_OF_MASS_ENABLED; }### Answer:
@Test public void testGetSibling() { Node left = new Node(new double[] { 0.0, 0.0 }); Node right = new Node(new double[] { 1.0, 1.0 }); BoundingBox parentBox = new BoundingBox(left.getLeafPoint()).getMergedBox(right.getLeafPoint()); Node parent = new Node(left, right, new Cut(0, 0.5), parentBox); left.setParent(parent); right.setParent(parent); assertThat(RandomCutTree.getSibling(left), sameInstance(right)); assertThat(RandomCutTree.getSibling(right), sameInstance(left)); }
@Test public void testGetSiblingNullParent() { Node node = new Node(new double[] { 0.0, 0.0 }); assertThrows(NullPointerException.class, () -> RandomCutTree.getSibling(node)); }
@Test public void testGetSiblingMalformedTree() { Node left = new Node(new double[] { 0.0, 0.0 }); Node right = new Node(new double[] { 1.0, 1.0 }); BoundingBox parentBox = new BoundingBox(left.getLeafPoint()).getMergedBox(right.getLeafPoint()); Node parent = new Node(null, right, new Cut(0, 0.5), parentBox); left.setParent(parent); right.setParent(parent); assertThrows(IllegalArgumentException.class, () -> RandomCutTree.getSibling(left)); }