// Path: cm-schema/src/main/java/com/cloudera/csd/tools/codahale/CodahaleMetricTypes.java
// public enum CodahaleMetricType {
//   GAUGE,
//   COUNTER,
//   HISTOGRAM,
//   TIMER,
//   METER
// }


import com.cloudera.csd.tools.JsonUtil;
import com.cloudera.csd.tools.JsonUtil.JsonRuntimeException;
import com.cloudera.csd.tools.codahale.CodahaleMetricTypes.CodahaleMetricType;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
  public void testEmptyFixture() {
    InputStream in = null;
    try {
      in = this.getClass().getResourceAsStream(
          "/com/cloudera/csd/tools/codahale/empty_but_valid.json");
      CodahaleMetricDefinitionFixture fixture = JsonUtil.valueFromStream(
          CodahaleMetricDefinitionFixture.class,
          in);
      assertNotNull(fixture.getServiceName());
    } finally {
      IOUtils.closeQuietly(in);
    }
  }

  @Test
  public void testValidFixture() {
    InputStream in = null;
    try {
      in = this.getClass().getResourceAsStream(
          "/com/cloudera/csd/tools/codahale/valid.json");
      CodahaleMetricDefinitionFixture fixture = JsonUtil.valueFromStream(
          CodahaleMetricDefinitionFixture.class,
          in);
      assertEquals("test_service", fixture.getServiceName());
      assertEquals(1, fixture.getServiceMetrics().size());
      assertEquals(2, fixture.getRolesMetrics().size());
      assertEquals(2,
                   fixture.getRolesMetrics().get("test_role1_metrics").size());
      CodahaleMetric metric =
          fixture.getRolesMetrics().get("test_role1_metrics").get(1);
// Path: cm-schema/src/main/java/com/cloudera/csd/tools/codahale/CodahaleMetricTypes.java
// public enum CodahaleMetricType {
//   GAUGE,
//   COUNTER,
//   HISTOGRAM,
//   TIMER,
//   METER
// }


// Path: cm-schema/src/test/java/com/cloudera/csd/tools/codahale/CodahaleMetricDefinitionFixtureTest.java
import com.cloudera.csd.tools.JsonUtil;
import com.cloudera.csd.tools.JsonUtil.JsonRuntimeException;
import com.cloudera.csd.tools.codahale.CodahaleMetricTypes.CodahaleMetricType;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;

  public void testEmptyFixture() {
    InputStream in = null;
    try {
      in = this.getClass().getResourceAsStream(
          "/com/cloudera/csd/tools/codahale/empty_but_valid.json");
      CodahaleMetricDefinitionFixture fixture = JsonUtil.valueFromStream(
          CodahaleMetricDefinitionFixture.class,
          in);
      assertNotNull(fixture.getServiceName());
    } finally {
      IOUtils.closeQuietly(in);
    }
  }

  @Test
  public void testValidFixture() {
    InputStream in = null;
    try {
      in = this.getClass().getResourceAsStream(
          "/com/cloudera/csd/tools/codahale/valid.json");
      CodahaleMetricDefinitionFixture fixture = JsonUtil.valueFromStream(
          CodahaleMetricDefinitionFixture.class,
          in);
      assertEquals("test_service", fixture.getServiceName());
      assertEquals(1, fixture.getServiceMetrics().size());
      assertEquals(2, fixture.getRolesMetrics().size());
      assertEquals(2,
                   fixture.getRolesMetrics().get("test_role1_metrics").size());
      CodahaleMetric metric =
          fixture.getRolesMetrics().get("test_role1_metrics").get(1);
      validateMetric(metric, "test_role1_metric2", CodahaleMetricType.GAUGE);