### Question:
MetricRegistryHolder { @SuppressWarnings("unchecked") public <T> SimpleSensor<T> getOrCreateSimpleSensor(String metricName) { final Gauge sensor = metrics.gauge(metricName, SimpleSensor::new); if (sensor instanceof SimpleSensor) { return (SimpleSensor<T>) sensor; } throw new IllegalArgumentException(metricName + " is already used for a different type of metric"); } private  MetricRegistryHolder(); static MetricRegistryHolder getInstance(); MetricRegistry getMetrics(); void setMetrics(MetricRegistry metricRegistry); @SuppressWarnings("unchecked") SimpleSensor<T> getOrCreateSimpleSensor(String metricName); Histogram getOrCreateHistogram(String metricName);  }### Answer:
@Test public void testGetOrCreateSimpleSensor() { try { MetricRegistryHolder holder = MetricRegistryHolder.getInstance(); assertEquals(holder.getOrCreateSimpleSensor("Sensor"), holder.getOrCreateSimpleSensor("Sensor")); } catch (Exception e) { fail("Exception should not have been thrwon!"); } }