@Test public void sample_withRandomNumberLessThan10Percent_shouldReturnTrue() throws Exception { when(mockRandom.nextDouble()).thenReturn(0.09); boolean result = subject.sample(mockBaseEvent); assertThat(result).isTrue(); }
boolean sample(@NonNull BaseEvent baseEvent) { Preconditions.checkNotNull(baseEvent); return mRandom.nextDouble() < baseEvent.getSamplingRate(); }
EventSampler { boolean sample(@NonNull BaseEvent baseEvent) { Preconditions.checkNotNull(baseEvent); return mRandom.nextDouble() < baseEvent.getSamplingRate(); } }
EventSampler { boolean sample(@NonNull BaseEvent baseEvent) { Preconditions.checkNotNull(baseEvent); return mRandom.nextDouble() < baseEvent.getSamplingRate(); } EventSampler(); @VisibleForTesting  EventSampler(@NonNull Random random); }
EventSampler { boolean sample(@NonNull BaseEvent baseEvent) { Preconditions.checkNotNull(baseEvent); return mRandom.nextDouble() < baseEvent.getSamplingRate(); } EventSampler(); @VisibleForTesting  EventSampler(@NonNull Random random);  }
EventSampler { boolean sample(@NonNull BaseEvent baseEvent) { Preconditions.checkNotNull(baseEvent); return mRandom.nextDouble() < baseEvent.getSamplingRate(); } EventSampler(); @VisibleForTesting  EventSampler(@NonNull Random random);   }