All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.sdk.testing.assertj.DoubleGaugeAssert Maven / Gradle / Ivy

/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.sdk.testing.assertj;

import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.sdk.metrics.data.DoublePointData;
import io.opentelemetry.sdk.metrics.data.GaugeData;
import java.util.Arrays;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import org.assertj.core.api.AbstractAssert;

/**
 * Assertions for an exported double {@link GaugeData}.
 *
 * @since 1.14.0
 */
public final class DoubleGaugeAssert
    extends AbstractAssert> {

  DoubleGaugeAssert(@Nullable GaugeData actual) {
    super(actual, DoubleGaugeAssert.class);
  }

  /**
   * Asserts the gauge has points matching all of the given assertions and no more, in any order.
   */
  @SafeVarargs
  @SuppressWarnings("varargs")
  public final DoubleGaugeAssert hasPointsSatisfying(Consumer... assertions) {
    return hasPointsSatisfying(Arrays.asList(assertions));
  }

  /**
   * Asserts the gauge has points matching all of the given assertions and no more, in any order.
   */
  public DoubleGaugeAssert hasPointsSatisfying(
      Iterable> assertions) {
    isNotNull();
    assertThat(actual.getPoints())
        .satisfiesExactlyInAnyOrder(AssertUtil.toConsumers(assertions, DoublePointAssert::new));
    return this;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy