### Question:
SimpleStreamSampler { public WeightedPoint sample(double[] newPoint, long sequenceIndex) { evictedPoint = null; WeightedPoint candidate = null; double weight = computeWeight(sequenceIndex); ++entriesSeen; if (entriesSeen <= sampleSize || weight < weightedSamples.element().getWeight()) { if (isFull()) { evictedPoint = weightedSamples.poll(); } candidate = new WeightedPoint(newPoint, sequenceIndex, weight); weightedSamples.add(candidate); checkState(weightedSamples.size() <= sampleSize, "The number of points in the sampler is greater than the sample size"); } return candidate; } SimpleStreamSampler(final int sampleSize, final double lambda, long seed); protected  SimpleStreamSampler(final int sampleSize, final double lambda, Random random); static SimpleStreamSampler uniformSampler(int sampleSize, long seed); WeightedPoint sample(double[] newPoint, long sequenceIndex); WeightedPoint getEvictedPoint(); List<double[]> getSamples(); List<WeightedPoint> getWeightedSamples(); boolean isReady(); boolean isFull(); long getCapacity(); long getSize(); double getLambda();  }### Answer:
@Test public void testSample() { int entriesSeen; for (entriesSeen = 0; entriesSeen < 2 * sampleSize; entriesSeen++) { sampler.sample(new double[] { Math.random() }, entriesSeen); } assertEquals(entriesSeen, 2 * sampleSize); assertTrue(sampler.isFull()); double maxWeight = sampler.getWeightedSamples().stream().mapToDouble(WeightedPoint::getWeight).max() .orElseThrow(IllegalStateException::new); double u = 10e-100; when(random.nextDouble()).thenReturn(u); WeightedPoint sampledPoint = sampler.sample(new double[] { Math.random() }, ++entriesSeen); assertNull(sampledPoint); assertNull(sampler.getEvictedPoint()); double maxWeight2 = sampler.getWeightedSamples().stream().mapToDouble(WeightedPoint::getWeight).max() .orElseThrow(IllegalStateException::new); assertEquals(maxWeight, maxWeight2); u = 1 - 10e-100; when(random.nextDouble()).thenReturn(u); double point = Math.random(); sampledPoint = sampler.sample(new double[] { point }, ++entriesSeen); assertNotNull(sampledPoint); assertArrayEquals(new double[] { point }, sampledPoint.getPoint()); assertEquals(entriesSeen, sampledPoint.getSequenceIndex()); assertTrue(sampledPoint.getWeight() < sampler.getEvictedPoint().getWeight()); assertNotNull(sampler.getEvictedPoint()); assertEquals(maxWeight, sampler.getEvictedPoint().getWeight(), EPSILON); maxWeight2 = sampler.getWeightedSamples().stream().mapToDouble(WeightedPoint::getWeight).max() .orElseThrow(IllegalStateException::new); assertTrue(maxWeight2 < maxWeight); assertTrue(sampler.getSamples().stream().anyMatch(array -> array[0] == point)); }