@Test
public void testCreateOrGetCollector() throws NoSuchMethodException, SecurityException, IllegalAccessException,
        IllegalArgumentException, InvocationTargetException {

    CollectorRegistry registry = new CollectorRegistry();
    ConcurrentHashMap<String, Collector> namesToCollectors = new ConcurrentHashMap<>();
    PrometheusMetric metric = new PrometheusMetric(registry, namesToCollectors, null, "");
    Method createOrGetCollector = metric.getClass().getDeclaredMethod("createOrGetCollector", String.class, SimpleCollector.Builder.class);
    createOrGetCollector.setAccessible(true);
    // test create
    String metricName = "metric_test";
    Counter.Builder builder = Counter.build();
    double countValue = 110.110d;
    Counter counter = (Counter) createOrGetCollector.invoke(metric, metricName, builder);
    counter.labels("", "", "", "", "").inc(countValue);
    // assertions
    Assert.assertSame(counter, namesToCollectors.get(metricName));
    Assert.assertEquals(registry.getSampleValue(metricName, this.labelNames, new String[]{"", "", "", "", ""}), countValue);
    // test get
    Counter counter_2 = (Counter) createOrGetCollector.invoke(metric, metricName, builder);
    // assertions
    Assert.assertSame(counter_2, namesToCollectors.get(metricName));
    Assert.assertSame(counter_2, counter);
}