Package org.sonar.api.measures

Examples of org.sonar.api.measures.Metric


    assertThat(PastMeasuresLoader.getValue(pastMeasure), is(80.0));
  }

  @Test
  public void shouldKeepOnlyNumericalMetrics() {
    Metric ncloc = new Metric("ncloc", Metric.ValueType.INT);
    ncloc.setId(1);
    Metric complexity = new Metric("complexity", Metric.ValueType.INT);
    complexity.setId(2);
    Metric data = new Metric("data", Metric.ValueType.DATA);
    data.setId(3);
    List<Metric> metrics = Arrays.asList(ncloc, complexity, data);

    PastMeasuresLoader loader = new PastMeasuresLoader(getSession(), metrics);

    assertThat(loader.getMetrics().size(), is(2));
View Full Code Here


    verify(context).saveMeasure(argThat(matchesMetric(CoreMetrics.ALERT_STATUS, Metric.Level.ERROR, "Classes < 10000, Coverages < 50.0")));
  }

  @Test
  public void alertLabelUsesL10nMetricName() {
    Metric metric = new Metric.Builder("rating", "Rating", Metric.ValueType.INT).create();

    // metric name is declared in l10n bundle
    when(i18n.message(any(Locale.class), eq("metric.rating.name"), anyString())).thenReturn("THE RATING");

    when(context.getMeasure(metric)).thenReturn(new Measure(metric, 4d));
View Full Code Here

    verify(context).saveMeasure(argThat(hasLevel(measureClasses, Metric.Level.OK)));
  }

  @Test
  public void shouldVariationPeriodValueCouldBeUsedForRatingMetric() {
    Metric ratingMetric = new Metric.Builder("key_rating_metric", "Rating metric", Metric.ValueType.RATING).create();
    Measure measureRatingMetric = new Measure(ratingMetric, 150d);
    measureRatingMetric.setVariation1(50d);
    when(context.getMeasure(ratingMetric)).thenReturn(measureRatingMetric);

    ArrayList<ResolvedCondition> conditions = Lists.newArrayList(
View Full Code Here

    verify(context).saveMeasure(argThat(matchesMetric(CoreMetrics.ALERT_STATUS, Metric.Level.WARN, "Classes variation > 30 since someday")));
  }

  @Test
  public void shouldLabelAlertForNewMetricDoNotContainsVariationWord() {
    Metric newMetric = new Metric.Builder("new_metric_key", "New Metric", Metric.ValueType.INT).create();
    Measure measure = new Measure(newMetric, 15d);
    measure.setVariation1(50d);
    when(context.getMeasure(newMetric)).thenReturn(measure);
    measureClasses.setVariation1(40d);
View Full Code Here

    verify(context).saveMeasure(argThat(matchesMetric(CoreMetrics.ALERT_STATUS, Metric.Level.WARN, "New Measure > 30 since someday")));
  }

  @Test
  public void alert_on_work_duration() {
    Metric metric = new Metric.Builder("tech_debt", "Debt", Metric.ValueType.WORK_DUR).create();

    // metric name is declared in l10n bundle
    when(i18n.message(any(Locale.class), eq("metric.tech_debt.name"), anyString())).thenReturn("The Debt");
    when(durations.format(any(Locale.class), eq(Duration.create(3600L)), eq(Durations.DurationFormat.SHORT))).thenReturn("1h");
View Full Code Here

TOP

Related Classes of org.sonar.api.measures.Metric

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.