### Question:
StackdriverWriter implements MetricWriter { @VisibleForTesting static MetricDescriptor encodeMetricDescriptor(com.google.monitoring.metrics.Metric<?> metric) { return new MetricDescriptor() .setType(METRIC_DOMAIN + metric.getMetricSchema().name()) .setDescription(metric.getMetricSchema().description()) .setDisplayName(metric.getMetricSchema().valueDisplayName()) .setValueType(ENCODED_METRIC_TYPES.get(metric.getValueClass())) .setLabels(encodeLabelDescriptors(metric.getMetricSchema().labels())) .setMetricKind(ENCODED_METRIC_KINDS.get(metric.getMetricSchema().kind().name())); } StackdriverWriter(
      Monitoring monitoringClient,
      String project,
      MonitoredResource monitoredResource,
      int maxQps,
      int maxPointsPerRequest); @Override void write(com.google.monitoring.metrics.MetricPoint<V> point); @Override void flush();  }### Answer:
@Test public void encodeMetricDescriptor_simpleMetric_encodes() { MetricDescriptor descriptor = StackdriverWriter.encodeMetricDescriptor(metric); assertThat(descriptor.getType()).isEqualTo("custom.googleapis.com/name"); assertThat(descriptor.getValueType()).isEqualTo("INT64"); assertThat(descriptor.getDescription()).isEqualTo("desc"); assertThat(descriptor.getDisplayName()).isEqualTo("vdn"); assertThat(descriptor.getLabels()) .containsExactly( new com.google.api.services.monitoring.v3.model.LabelDescriptor() .setValueType("STRING") .setKey("label1") .setDescription("desc1")); }