// Path: exporters/metrics/src/main/java/com/google/cloud/opentelemetry/metric/MetricConfiguration.java
// @AutoValue.Builder
// public abstract static class Builder {
// 
//   Builder() {}
// 
//   abstract String getProjectId();
// 
//   abstract Duration getDeadline();
// 
//   public abstract Builder setProjectId(String projectId);
// 
//   public abstract Builder setCredentials(Credentials newCredentials);
// 
//   public abstract Builder setMetricServiceStub(MetricServiceStub newMetricServiceStub);
// 
//   public abstract Builder setDeadline(Duration deadline);
// 
//   public abstract Builder setDescriptorStrategy(MetricDescriptorStrategy strategy);
// 
//   abstract MetricConfiguration autoBuild();
// 
//   /**
//    * Builds a {@link MetricConfiguration}.
//    *
//    * @return a {@code MetricsConfiguration}.
//    */
//   public MetricConfiguration build() {
//     Preconditions.checkArgument(
//         !Strings.isNullOrEmpty(getProjectId()),
//         "Cannot find a project ID from either configurations or application default.");
//     Preconditions.checkArgument(getDeadline().compareTo(ZERO) > 0, "Deadline must be positive.");
//     return autoBuild();
//   }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import com.google.auth.Credentials;
import com.google.auth.oauth2.AccessToken;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.ServiceOptions;
import com.google.cloud.opentelemetry.metric.MetricConfiguration.Builder;
import java.util.Date;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
 * Copyright 2022 Google
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.cloud.opentelemetry.metric;



@RunWith(JUnit4.class)
public class MetricConfigurationTest {

  private static final Credentials FAKE_CREDENTIALS =
      GoogleCredentials.newBuilder().setAccessToken(new AccessToken("fake", new Date(100))).build();
  private static final String PROJECT_ID = "project";

  @Test
  public void testDefaultConfigurationSucceeds() {
    MetricConfiguration configuration =
        MetricConfiguration.builder().setProjectId(PROJECT_ID).build();

    assertNull(configuration.getCredentials());
    assertEquals(PROJECT_ID, configuration.getProjectId());
    assertNull(configuration.getMetricServiceStub());
  }

  @Test
  public void testSetAllConfigurationFieldsSucceeds() {
    MetricConfiguration configuration =
        MetricConfiguration.builder()
            .setProjectId(PROJECT_ID)
            .setCredentials(FAKE_CREDENTIALS)
            .build();

    assertEquals(FAKE_CREDENTIALS, configuration.getCredentials());
    assertEquals(PROJECT_ID, configuration.getProjectId());
  }

  @Test
  public void testConfigurationWithNullProjectIdFails() {
// Path: exporters/metrics/src/main/java/com/google/cloud/opentelemetry/metric/MetricConfiguration.java
// @AutoValue.Builder
// public abstract static class Builder {
// 
//   Builder() {}
// 
//   abstract String getProjectId();
// 
//   abstract Duration getDeadline();
// 
//   public abstract Builder setProjectId(String projectId);
// 
//   public abstract Builder setCredentials(Credentials newCredentials);
// 
//   public abstract Builder setMetricServiceStub(MetricServiceStub newMetricServiceStub);
// 
//   public abstract Builder setDeadline(Duration deadline);
// 
//   public abstract Builder setDescriptorStrategy(MetricDescriptorStrategy strategy);
// 
//   abstract MetricConfiguration autoBuild();
// 
//   /**
//    * Builds a {@link MetricConfiguration}.
//    *
//    * @return a {@code MetricsConfiguration}.
//    */
//   public MetricConfiguration build() {
//     Preconditions.checkArgument(
//         !Strings.isNullOrEmpty(getProjectId()),
//         "Cannot find a project ID from either configurations or application default.");
//     Preconditions.checkArgument(getDeadline().compareTo(ZERO) > 0, "Deadline must be positive.");
//     return autoBuild();
//   }
// }


// Path: exporters/metrics/src/test/java/com/google/cloud/opentelemetry/metric/MetricConfigurationTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import com.google.auth.Credentials;
import com.google.auth.oauth2.AccessToken;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.ServiceOptions;
import com.google.cloud.opentelemetry.metric.MetricConfiguration.Builder;
import java.util.Date;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/*
 * Copyright 2022 Google
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.cloud.opentelemetry.metric;



@RunWith(JUnit4.class)
public class MetricConfigurationTest {

  private static final Credentials FAKE_CREDENTIALS =
      GoogleCredentials.newBuilder().setAccessToken(new AccessToken("fake", new Date(100))).build();
  private static final String PROJECT_ID = "project";

  @Test
  public void testDefaultConfigurationSucceeds() {
    MetricConfiguration configuration =
        MetricConfiguration.builder().setProjectId(PROJECT_ID).build();

    assertNull(configuration.getCredentials());
    assertEquals(PROJECT_ID, configuration.getProjectId());
    assertNull(configuration.getMetricServiceStub());
  }

  @Test
  public void testSetAllConfigurationFieldsSucceeds() {
    MetricConfiguration configuration =
        MetricConfiguration.builder()
            .setProjectId(PROJECT_ID)
            .setCredentials(FAKE_CREDENTIALS)
            .build();

    assertEquals(FAKE_CREDENTIALS, configuration.getCredentials());
    assertEquals(PROJECT_ID, configuration.getProjectId());
  }

  @Test
  public void testConfigurationWithNullProjectIdFails() {
    Builder builder = MetricConfiguration.builder();