@Test
public void testAllocationSamplingRateCorrectlyInitialized() {

  // If the sampling mode is already available from the memory service, make sure the memory stage is correctly initialized to that value.
  if (myUnifiedPipeline) {
    myTransportService.addEventToStream(
      FAKE_DEVICE_ID, ProfilersTestData.generateMemoryAllocSamplingData(FAKE_PROCESS.getPid(), 0, 1).build());
  }
  else {
    AllocationSamplingRateEvent fullTrackingMode = AllocationSamplingRateEvent.newBuilder()
      .setSamplingRate(MemoryAllocSamplingData.newBuilder().setSamplingNumInterval(1))
      .build();
    myService
      .setMemoryData(MemoryData.newBuilder().addAllocSamplingRateEvents(fullTrackingMode).build());
  }
  MemoryProfilerStage stage = new MemoryProfilerStage(myProfilers, myMockLoader);
  assertThat(stage.getLiveAllocationSamplingMode()).isEqualTo(MemoryProfilerStage.LiveAllocationSamplingMode.FULL);
}