### Question:
StackdriverWriter { public TimeSeries measurementToTimeSeries( String descriptorType, Registry registry, Meter meter, Measurement measurement) { Map<String, String> labels = cache.tagsToTimeSeriesLabels(descriptorType, measurement.id().tags()); long millis = measurement.timestamp(); double value = measurement.value(); TimeInterval timeInterval = new TimeInterval(); Date date = new Date(millis); timeInterval.setEndTime(rfc3339.format(date)); String descriptorKind = cache.descriptorTypeToKind(descriptorType, registry, meter); if (descriptorKind == "CUMULATIVE") { timeInterval.setStartTime(counterStartTimeRfc3339); } TypedValue typedValue = new TypedValue(); typedValue.setDoubleValue(value); Point point = new Point(); point.setValue(typedValue); point.setInterval(timeInterval); Metric metric = new Metric(); metric.setType(descriptorType); metric.setLabels(labels); TimeSeries ts = new TimeSeries(); ts.setResource(monitoredResource); ts.setMetric(metric); ts.setMetricKind(descriptorKind); ts.setValueType("DOUBLE"); ts.setPoints(Lists.<Point>newArrayList(point)); return ts; } @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; }### Answer:
@Test public void testAddMeasurementsToTimeSeries() { DefaultRegistry testRegistry = new DefaultRegistry(clock); long millisA = TimeUnit.MILLISECONDS.convert(1472394975L, TimeUnit.SECONDS); long millisB = millisA + 987; String timeA = "2016-08-28T14:36:15.000000000Z"; String timeB = "2016-08-28T14:36:15.987000000Z"; Meter timerA = testRegistry.timer(idAXY); Meter timerB = testRegistry.timer(idBXY); Measurement measureAXY = new Measurement(idAXY, millisA, 1); Measurement measureBXY = new Measurement(idBXY, millisB, 20.1); descriptorRegistrySpy.addExtraTimeSeriesLabel( MetricDescriptorCache.INSTANCE_LABEL, INSTANCE_ID); Assert.assertEquals( makeTimeSeries(descriptorA, idAXY, 1, timeA), writer.measurementToTimeSeries(descriptorA.getType(), testRegistry, timerA, measureAXY)); Assert.assertEquals( makeTimeSeries(descriptorB, idBXY, 20.1, timeB), writer.measurementToTimeSeries(descriptorB.getType(), testRegistry, timerB, measureBXY)); }