### Question:
RandomCutTree { static Cut randomCut(Random random, BoundingBox box) { double rangeSum = box.getRangeSum(); checkArgument(rangeSum > 0, "box.getRangeSum() must be greater than 0"); double breakPoint = random.nextDouble() * rangeSum; for (int i = 0; i < box.getDimensions(); i++) { double range = box.getRange(i); if (breakPoint <= range) { double cutValue = box.getMinValue(i) + breakPoint; if ((cutValue == box.getMaxValue(i)) && (box.getMinValue(i) < box.getMaxValue(i))) { cutValue = Math.nextAfter(box.getMaxValue(i), box.getMinValue(i)); } return new Cut(i, cutValue); } breakPoint -= range; } throw new IllegalStateException("The break point did not lie inside the expected range"); } 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 testRandomCut() { BoundingBox box = new BoundingBox(new double[] { 0.0, 0.0, 0.0 }) .getMergedBox(new double[] { 10.0, 0.0, 30.0 }); when(rng.nextDouble()).thenReturn(0.0); Cut cut = RandomCutTree.randomCut(rng, box); assertThat(cut.getDimension(), is(0)); assertThat(cut.getValue(), is(0.0)); when(rng.nextDouble()).thenReturn(0.1); cut = RandomCutTree.randomCut(rng, box); assertThat(cut.getDimension(), is(0)); assertThat(cut.getValue(), closeTo(10.0 * 0.1 / 0.25, EPSILON)); when(rng.nextDouble()).thenReturn(0.25); cut = RandomCutTree.randomCut(rng, box); assertThat(cut.getDimension(), is(0)); assertThat(cut.getValue(), closeTo(10.0, EPSILON)); when(rng.nextDouble()).thenReturn(0.4); cut = RandomCutTree.randomCut(rng, box); assertThat(cut.getDimension(), is(2)); assertThat(cut.getValue(), closeTo(30.0 * (0.4 - 0.25) / 0.75, EPSILON)); when(rng.nextDouble()).thenReturn(0.99); cut = RandomCutTree.randomCut(rng, box); assertThat(cut.getDimension(), is(2)); assertThat(cut.getValue(), closeTo(30.0 * (0.99 - 0.25) / 0.75, EPSILON)); when(rng.nextDouble()).thenReturn(1.0); cut = RandomCutTree.randomCut(rng, box); assertThat(cut.getDimension(), is(2)); assertThat(cut.getValue(), closeTo(30.0, EPSILON)); }