@Test
public void testIncrementHttpRequest() {

    CollectorRegistry registry = new CollectorRegistry();
    ConcurrentHashMap<String, Collector> namesToCollectors = new ConcurrentHashMap<>();
    String namespace = "metric_test";
    // 1. no labels (default)
    PrometheusMetric metric_1 = new PrometheusMetric(registry, namesToCollectors, null, namespace);
    String metricName_1 = "test_counter_1";
    String fullMetricName_1 = namespace + "_" + metricName_1 + "_" + PrometheusMetric.COUNTER_SUFFIX;
    String requestDomainName_1 = "request_domain_1";
    String principalDomainName_1 = "principal_domain_1";
    String httpMethodName_1 = "http_method_1";
    String httpStatusName_1 = "200";
    int httpStatus_1 = 200;
    String apiName_1 = "http_name_1";
    // assertions
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{"", "", "", "", ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{requestDomainName_1, "", "", "", ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{"", principalDomainName_1, "", httpStatusName_1, ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{requestDomainName_1, principalDomainName_1, httpMethodName_1, httpStatusName_1, ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{null, null, httpMethodName_1, httpStatusName_1, apiName_1}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{requestDomainName_1, principalDomainName_1, httpMethodName_1, httpStatusName_1, apiName_1}));
    metric_1.increment(metricName_1, null, null, null, 0, null);
    metric_1.increment(metricName_1, requestDomainName_1, null, null, 0, null);
    metric_1.increment(metricName_1, null, principalDomainName_1, null, 200, null);
    metric_1.increment(metricName_1, requestDomainName_1, principalDomainName_1, httpMethodName_1, httpStatus_1, null);
    metric_1.increment(metricName_1, null, null, httpMethodName_1, httpStatus_1, apiName_1);
    metric_1.increment(metricName_1, requestDomainName_1, principalDomainName_1, httpMethodName_1, httpStatus_1, apiName_1);
    Assert.assertEquals(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{"", "", "", "", ""}), 6d, 0.1d);
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{requestDomainName_1, "", "", "", ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{"", principalDomainName_1, "", httpStatusName_1, ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{requestDomainName_1, principalDomainName_1, httpMethodName_1, httpStatusName_1, ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{"", "", httpMethodName_1, httpStatusName_1, apiName_1}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_1, this.labelNames, new String[]{requestDomainName_1, principalDomainName_1, httpMethodName_1, httpStatusName_1, apiName_1}));
    // 2. only principal domain and httpStatus
    PrometheusMetric metric_2 = new PrometheusMetric(registry, namesToCollectors, null, namespace, false, true, false, true, false);
    String metricName_2 = "test_counter_2";
    String fullMetricName_2 = namespace + "_" + metricName_2 + "_" + PrometheusMetric.COUNTER_SUFFIX;
    String requestDomainName_2 = "request_domain_2";
    String principalDomainName_2 = "principal_domain_2";
    String httpMethodName_2 = "http_method_2";
    String httpStatusName_2 = "200";
    int httpStatus_2 = 200;
    String apiName_2 = "http_name_2";
    // assertions
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{"", "", "", "", ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{requestDomainName_2, "", "", "", ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{"", principalDomainName_2, "", httpStatusName_2, ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{requestDomainName_2, principalDomainName_2, httpMethodName_2, httpStatusName_2, ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{null, null, httpMethodName_2, httpStatusName_2, apiName_2}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{requestDomainName_2, principalDomainName_2, httpMethodName_2, httpStatusName_2, apiName_2}));
    metric_2.increment(metricName_2, null, null, null, 0, null);
    metric_2.increment(metricName_2, requestDomainName_2, null, null, 0, null);
    metric_2.increment(metricName_2, null, principalDomainName_2, null, 200, null);
    metric_2.increment(metricName_2, requestDomainName_2, principalDomainName_2, httpMethodName_2, httpStatus_2, null);
    metric_2.increment(metricName_2, null, null, httpMethodName_2, httpStatus_2, apiName_2);
    metric_2.increment(metricName_2, requestDomainName_2, principalDomainName_2, httpMethodName_2, httpStatus_2, apiName_2);
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{"", "", "", "", ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{requestDomainName_2, "", "", "", ""}));
    Assert.assertEquals(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{"", principalDomainName_2, "", httpStatusName_2, ""}), 3d, 0.1d);
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{requestDomainName_2, principalDomainName_2, httpMethodName_2, httpStatusName_2, ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{"", "", httpMethodName_2, httpStatusName_2, apiName_2}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_2, this.labelNames, new String[]{requestDomainName_2, principalDomainName_2, httpMethodName_2, httpStatusName_2, apiName_2}));
    // 3. All
    PrometheusMetric metric_3 = new PrometheusMetric(registry, namesToCollectors, null, namespace, true, true, true, true, true);
    String metricName_3 = "test_counter_3";
    String fullMetricName_3 = namespace + "_" + metricName_3 + "_" + PrometheusMetric.COUNTER_SUFFIX;
    String requestDomainName_3 = "request_domain_3";
    String principalDomainName_3 = "principal_domain_3";
    String httpMethodName_3 = "http_method_3";
    String httpStatusName_3 = "200";
    int httpStatus_3 = 200;
    String apiName_3 = "http_name_3";
    // assertions
    Assert.assertNull(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{"", "", "", "", ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{requestDomainName_3, "", "", "", ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{"", principalDomainName_3, "", httpStatusName_3, ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{requestDomainName_3, principalDomainName_3, httpMethodName_3, httpStatusName_3, ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{null, null, httpMethodName_3, httpStatusName_3, apiName_3}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{requestDomainName_3, principalDomainName_3, httpMethodName_3, httpStatusName_3, apiName_3}));
    metric_3.increment(metricName_3, null, null, null, 0, null);
    metric_3.increment(metricName_3, requestDomainName_3, null, null, 0, null);
    metric_3.increment(metricName_3, null, principalDomainName_3, null, 200, null);
    metric_3.increment(metricName_3, requestDomainName_3, principalDomainName_3, httpMethodName_3, httpStatus_3, null);
    metric_3.increment(metricName_3, null, null, httpMethodName_3, httpStatus_3, apiName_3);
    metric_3.increment(metricName_3, requestDomainName_3, principalDomainName_3, httpMethodName_3, httpStatus_3, apiName_3);
    Assert.assertNull(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{"", "", "", "", ""}));
    Assert.assertNull(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{requestDomainName_3, "", "", "", ""}));
    Assert.assertEquals(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{"", principalDomainName_3, "", httpStatusName_3, ""}), 1d, 0.1d);
    Assert.assertEquals(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{requestDomainName_3, principalDomainName_3, httpMethodName_3, httpStatusName_3, ""}), 1d, 0.1d);
    Assert.assertEquals(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{"", "", httpMethodName_3, httpStatusName_3, apiName_3}), 1d, 0.1d);
    Assert.assertEquals(registry.getSampleValue(fullMetricName_3, this.labelNames, new String[]{requestDomainName_3, principalDomainName_3, httpMethodName_3, httpStatusName_3, apiName_3}), 1d, 0.1d);
}