### Question:
TreeUpdater { public void update(double[] point, long sequenceIndex) { WeightedPoint candidate = sampler.sample(point, sequenceIndex); if (candidate != null) { WeightedPoint evictedPoint = sampler.getEvictedPoint(); if (evictedPoint != null) { tree.deletePoint(evictedPoint); } tree.addPoint(candidate); } } TreeUpdater(SimpleStreamSampler sampler, RandomCutTree tree); SimpleStreamSampler getSampler(); RandomCutTree getTree(); void update(double[] point, long sequenceIndex);  }### Answer:
@Test public void testUpdateRejected() { when(sampler.sample(any(), anyInt())).thenReturn(null); updater.update(new double[] { 4.2, 8.4 }, 1111L); verify(tree, never()).addPoint(any()); verify(tree, never()).deletePoint(any()); }
@Test public void testUpdateRejectedWithoutEvictedPoint() { double[] point = new double[] { 4.2, 8.4 }; long sequenceIndex = 1111L; WeightedPoint sampledPoint = new WeightedPoint(point, sequenceIndex, 0.001); when(sampler.sample(any(), anyInt())).thenReturn(sampledPoint); when(sampler.getEvictedPoint()).thenReturn(null); updater.update(point, sequenceIndex); verify(tree, times(1)).addPoint(sampledPoint); verify(tree, never()).deletePoint(any()); }
@Test public void testUpdateRejectedWithEvictedPoint() { double[] point = new double[] { 4.2, 8.4 }; long sequenceIndex = 1111L; WeightedPoint sampledPoint = new WeightedPoint(point, sequenceIndex, 0.001); WeightedPoint evictedPoint = new WeightedPoint(new double[] { -0.5, 2.222 }, 1110L, 0.123); when(sampler.sample(any(), anyInt())).thenReturn(sampledPoint); when(sampler.getEvictedPoint()).thenReturn(evictedPoint); updater.update(point, sequenceIndex); verify(tree, times(1)).addPoint(sampledPoint); verify(tree, times(1)).deletePoint(evictedPoint); }