### Question:
DenominatorValidator extends AbstractMonitoringValidator<MetricDescriptor> { @Override public <T> List<ConstraintViolation<T>> validate( MonitoringValidationContext context, MetricDescriptor metricDescriptor, DescriptorPathImpl path) { Preconditions.checkNotNull(context); Preconditions.checkNotNull(metricDescriptor); Preconditions.checkNotNull(path); path = constructPathFromProperty(metricDescriptor, "name", path); String metricName = metricDescriptor.getName(); String denominatorUnit = metricDescriptor.getDenominatorUnit(); if (!MonitoringConventions.isValidDenominatorForMetricWithRateEnding( metricName, denominatorUnit)) { String msg = String.format( "Non-counter metric '%s' ends with " + MonitoringConventions.RATE_SUFFIX + " but has no denominator", metricDescriptor.getName()); return forViolation(msg, metricDescriptor, metricName, path); } if (metricDescriptor.isCounter() && !MonitoringConventions.isValidDenominatorForCounterMetric( denominatorUnit)) { String msg = String.format( "Counter metric '%s' has a denominator and should not", metricDescriptor.getName()); return forViolation(msg, metricDescriptor, metricName, path); } return noViolations(); }  @Override String getDescription(); @Override List<ConstraintViolation<T>> validate(
      MonitoringValidationContext context,
      MetricDescriptor metricDescriptor,
      DescriptorPathImpl path);  }### Answer:
@Test public void testNotEndingWithRateWithDenominator() { setName("bytes_read"); setDenominator("seconds"); assertTrue(validator.validate(context, metric, root).isEmpty()); }
@Test public void testNotEndingWithRateWithoutDenominator() { setName("bytes_read"); setDenominator(null); assertTrue(validator.validate(context, metric, root).isEmpty()); }
@Test public void testCounterNotEndingWithRateWithDenominator() { setName("bytes_read"); setIsCounter(true); setDenominator("seconds"); assertFalse(validator.validate(context, metric, root).isEmpty()); }
@Test public void testCounterNotEndingWithRateWithoutDenominator() { setName("bytes_read"); setIsCounter(true); setDenominator(null); assertTrue(validator.validate(context, metric, root).isEmpty()); }
@Test public void testEndingWithRateWithDenominator() { setName("bytes_read_rate"); setDenominator("seconds"); assertTrue(validator.validate(context, metric, root).isEmpty()); }
@Test public void testEndingWithRateWithoutDenominator() { setName("bytes_read_rate"); setDenominator(null); assertFalse(validator.validate(context, metric, root).isEmpty()); }
@Test public void testCounterEndingWithRateWithDenominator() { setName("bytes_read_rate"); setIsCounter(true); setDenominator("seconds"); assertFalse(validator.validate(context, metric, root).isEmpty()); }
@Test public void testCounterEndingWithRateWithoutDenominator() { setName("bytes_read_rate"); setIsCounter(true); setDenominator(null); assertFalse(validator.validate(context, metric, root).isEmpty()); }