Package org.sonar.api.measures

Examples of org.sonar.api.measures.Metrics


    for (Metric metric : metrics.getMetrics()) {
      String metricKey = metric.getKey();
      if (CoreMetrics.getMetrics().contains(metric)) {
        throw new IllegalStateException("The following metric is already defined in sonar: " + metricKey);
      }
      Metrics anotherRepository = metricsByRepository.get(metricKey);
      if (anotherRepository != null) {
        throw new IllegalStateException("The metric '" + metricKey + "' is already defined in the extension: " + anotherRepository);
      }
      metricsByRepository.put(metricKey, metrics);
    }
View Full Code Here


    checkTables("shouldUpdateIfAlreadyExists", "metrics");
  }

  @Test
  public void shouldAddUserManagesMetric() {
    Metrics metrics = mock(Metrics.class);
    when(metrics.getMetrics()).thenReturn(Lists.<Metric>newArrayList(new Metric.Builder("key", "new short name", Metric.ValueType.FLOAT)
      .setDescription("new description")
      .setDirection(-1)
      .setQualitative(true)
      .setDomain("new domain")
      .setUserManaged(true)
View Full Code Here

  @Test
  public void shouldNotUpdateUserManagesMetricIfAlreadyExists() {
    setupData("shouldNotUpdateUserManagesMetricIfAlreadyExists");

    Metrics metrics = mock(Metrics.class);
    when(metrics.getMetrics()).thenReturn(Lists.<Metric>newArrayList(new Metric.Builder("key", "new short name", Metric.ValueType.FLOAT)
      .setDescription("new description")
      .setDirection(-1)
      .setQualitative(true)
      .setDomain("new domain")
      .setUserManaged(true)
View Full Code Here

    assertThat(metrics).onProperty("key").contains("ncloc");
  }

  @Test
  public void should_provide_plugin_metrics() {
    Metrics factory = new Metrics() {
      public List<Metric> getMetrics() {
        return Arrays.<Metric>asList(new Metric.Builder("custom", "Custom", Metric.ValueType.FLOAT).create());
      }
    };
    MetricProvider provider = new MetricProvider(new Metrics[] {factory});
View Full Code Here

TOP

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

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.