### Question:
StackdriverWriter implements MetricWriter { @Override public <V> void write(com.google.monitoring.metrics.MetricPoint<V> point) throws IOException { checkNotNull(point); TimeSeries timeSeries = getEncodedTimeSeries(point); timeSeriesBuffer.add(timeSeries); logger.fine(String.format("Enqueued metric %s for writing", timeSeries.getMetric().getType())); if (timeSeriesBuffer.size() == maxPointsPerRequest) { flush(); } } 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 testWrite_invalidMetricType_throwsException() throws Exception { when(metric.getValueClass()).thenAnswer((Answer<Class<?>>) invocation -> Object.class); StackdriverWriter writer = new StackdriverWriter(client, PROJECT, MONITORED_RESOURCE, MAX_QPS, MAX_POINTS_PER_REQUEST); for (MetricPoint<?> point : metric.getTimestampedValues()) { assertThrows(IOException.class, () -> writer.write(point)); } }