### Question:
StackdriverWriter implements MetricWriter { @VisibleForTesting static ImmutableList<LabelDescriptor> encodeLabelDescriptors( ImmutableSet<com.google.monitoring.metrics.LabelDescriptor> labelDescriptors) { List<LabelDescriptor> stackDriverLabelDescriptors = new ArrayList<>(labelDescriptors.size()); for (com.google.monitoring.metrics.LabelDescriptor labelDescriptor : labelDescriptors) { stackDriverLabelDescriptors.add( new LabelDescriptor() .setKey(labelDescriptor.name()) .setDescription(labelDescriptor.description()) .setValueType(LABEL_VALUE_TYPE)); } return ImmutableList.copyOf(stackDriverLabelDescriptors); } 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 encodeLabelDescriptors_simpleLabels_encodes() { ImmutableSet<LabelDescriptor> descriptors = ImmutableSet.of( LabelDescriptor.create("label1", "description1"), LabelDescriptor.create("label2", "description2")); ImmutableList<com.google.api.services.monitoring.v3.model.LabelDescriptor> encodedDescritors = StackdriverWriter.encodeLabelDescriptors(descriptors); assertThat(encodedDescritors) .containsExactly( new com.google.api.services.monitoring.v3.model.LabelDescriptor() .setValueType("STRING") .setKey("label1") .setDescription("description1"), new com.google.api.services.monitoring.v3.model.LabelDescriptor() .setValueType("STRING") .setKey("label2") .setDescription("description2")); }