@Test public void writeRegistryWithSmallRegistry() throws IOException { TestableStackdriverWriter spy = spy(new TestableStackdriverWriter(writerConfig.build())); Monitoring.Projects.TimeSeries.Create mockCreateMethod = Mockito.mock(Monitoring.Projects.TimeSeries.Create.class); DefaultRegistry registry = new DefaultRegistry(clock); Counter counterA = registry.counter(idAXY); Counter counterB = registry.counter(idBXY); counterA.increment(4); counterB.increment(10); when(timeseriesApi.create(eq("projects/test-project"), any(CreateTimeSeriesRequest.class))) .thenReturn(mockCreateMethod); when(mockCreateMethod.execute()).thenReturn(null); spy.writeRegistry(registry); verify(mockCreateMethod, times(1)).execute(); ArgumentCaptor<CreateTimeSeriesRequest> captor = ArgumentCaptor.forClass(CreateTimeSeriesRequest.class); verify(timeseriesApi, times(1)).create(eq("projects/test-project"), captor.capture()); Assert.assertEquals(4, captor.getValue().getTimeSeries().size()); }
public void writeRegistry(Registry registry) { Id writeId = registry.createId(WRITE_TIMER_NAME); registry .timer(writeId) .record( new Runnable() { public void run() { writeRegistryHelper(registry); } }); }
StackdriverWriter { public void writeRegistry(Registry registry) { Id writeId = registry.createId(WRITE_TIMER_NAME); registry .timer(writeId) .record( new Runnable() { public void run() { writeRegistryHelper(registry); } }); } }
StackdriverWriter { public void writeRegistry(Registry registry) { Id writeId = registry.createId(WRITE_TIMER_NAME); registry .timer(writeId) .record( new Runnable() { public void run() { writeRegistryHelper(registry); } }); } @SuppressWarnings("PMD.BooleanInversion")  StackdriverWriter(ConfigParams configParams); }
StackdriverWriter { public void writeRegistry(Registry registry) { Id writeId = registry.createId(WRITE_TIMER_NAME); registry .timer(writeId) .record( new Runnable() { public void run() { writeRegistryHelper(registry); } }); } @SuppressWarnings("PMD.BooleanInversion")  StackdriverWriter(ConfigParams configParams); MetricDescriptorCache getDescriptorCache(); TimeSeries measurementToTimeSeries(
      String descriptorType, Registry registry, Meter meter, Measurement measurement); List<TimeSeries> registryToTimeSeries(Registry registry); void writeRegistry(Registry registry); }
StackdriverWriter { public void writeRegistry(Registry registry) { Id writeId = registry.createId(WRITE_TIMER_NAME); registry .timer(writeId) .record( new Runnable() { public void run() { writeRegistryHelper(registry); } }); } @SuppressWarnings("PMD.BooleanInversion")  StackdriverWriter(ConfigParams configParams); MetricDescriptorCache getDescriptorCache(); TimeSeries measurementToTimeSeries(
      String descriptorType, Registry registry, Meter meter, Measurement measurement); List<TimeSeries> registryToTimeSeries(Registry registry); void writeRegistry(Registry registry); static final String WRITE_TIMER_NAME; }