package io.datanerd.es.metrics;

import com.google.common.collect.ImmutableList;

import org.junit.Before;
import org.junit.Test;

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

public class MetricTest {

  private Metric metric;

  @Before
  public void setUp() throws Exception {
    metric = Metric
        .builder()
        .setService(MetricTest.class)
        .setAction("test")
        .setLabels(ImmutableList.of("labela", "labelb"))
        .build();
  }

  @Test
  public void service() throws Exception {
    assertThat(metric.service()).isAssignableFrom(MetricTest.class);
  }

  @Test
  public void action() throws Exception {
    assertThat(metric.action()).isEqualTo("test");
  }

  @Test
  public void labels() throws Exception {
    assertThat(metric.labels()).isNotEmpty();
    assertThat(metric.labels().get()).contains("labela", "labelb");
  }
}
@@ -181,16 +181,68 @@
 ertThat;
+%0Aimport static org.assertj.core.api.Assertions.fail;
 %0A%0Apublic
@@ -921,10 +921,494 @@
 b%22);%0A  %7D
+%0A%0A  @Test%0A  public void optional_field() throws Exception %7B%0A    metric = Metric%0A        .builder()%0A        .setService(MetricTest.class)%0A        .setAction(%22test%22)%0A        .build();%0A    assertThat(metric.labels()).isEmpty();%0A  %7D%0A%0A  @Test(expected = IllegalStateException.class)%0A  public void mandatory_field() throws Exception %7B%0A    metric = Metric%0A        .builder()%0A        .setService(MetricTest.class)%0A        .build();%0A    fail(%22should failed as mandatory field is missing%22);%0A  %7D
 %0A%7D

add optinal and mandatory field test