Package org.sonar.api.measures

Examples of org.sonar.api.measures.MetricFinder


  @Before
  public void prepare() {
    activeRules = new ActiveRulesBuilder().build();
    fs = new DefaultFileSystem();
    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
    when(metricFinder.findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
    sensorContext = mock(SensorContext.class);
    settings = new Settings();
    resourcePerspectives = mock(ResourcePerspectives.class);
    ComponentDataCache componentDataCache = mock(ComponentDataCache.class);
    BlockCache blockCache = mock(BlockCache.class);
View Full Code Here


  @Test
  public void initQuery() throws ParseException {
    Project project = mock(Project.class);
    when(project.getAnalysisDate()).thenReturn(date("2009-12-25"));

    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.findAll()).thenReturn(Arrays.<Metric>asList(CoreMetrics.LINES, CoreMetrics.COVERAGE, CoreMetrics.COVERAGE_LINE_HITS_DATA));

    TendencyDecorator decorator = new TendencyDecorator(null, metricFinder);

    TimeMachineQuery query = decorator.initQuery(project);
    assertThat(query.getMetrics().size(), is(2));
View Full Code Here

    assertThat(filter.sort().period()).isNull();
  }

  @Test
  public void fallback_on_name_sort_when_metric_is_unknown() {
    MetricFinder finder = mock(MetricFinder.class);
    when(finder.findByKey(anyString())).thenReturn(null);
    MeasureFilterFactory factory = new MeasureFilterFactory(finder, system);
    Map<String, Object> props = ImmutableMap.<String, Object>of("sort", "metric:sqale_index");
    MeasureFilter filter = factory.create(props);

    assertThat(filter.sort().column()).isEqualTo("p.long_name");
View Full Code Here

    List<MeasureFilterCondition> conditions = filter.getMeasureConditions();
    assertThat(conditions).isEmpty();
  }

  private MetricFinder newMetricFinder() {
    MetricFinder finder = mock(MetricFinder.class);
    when(finder.findByKey(anyString())).thenAnswer(new Answer<Metric>() {
      public Metric answer(InvocationOnMock invocationOnMock) throws Throwable {
        String key = (String) invocationOnMock.getArguments()[0];
        return new Metric.Builder(key, key, Metric.ValueType.INT).create();
      }
    });
View Full Code Here

    snapshotCache = mock(SnapshotCache.class);
    ResourceCache resourceCache = mock(ResourceCache.class);
    when(snapshotCache.get("foo:org/foo/Bar.java")).thenReturn(fileSnapshot);
    when(resourceCache.get("foo:org/foo/Bar.java")).thenReturn(aFile);

    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.findByKey(CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn(CoreMetrics.DUPLICATIONS_DATA.setId(2));

    duplicationPersister = new DuplicationPersister(getMyBatis(), ruleFinder, snapshotCache, resourceCache, duplicationCache, metricFinder);
  }
View Full Code Here

  Project moduleB1;

  @Before
  public void createIndex() throws IOException {
    deprecatedViolations = mock(DeprecatedViolations.class);
    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.findByKey("ncloc")).thenReturn(CoreMetrics.NCLOC);
    ruleFinder = mock(RuleFinder.class);

    ProjectTree projectTree = mock(ProjectTree.class);
    index = new DefaultIndex(mock(PersistenceManager.class), projectTree, metricFinder, mock(ScanGraph.class), deprecatedViolations, mock(ResourceKeyMigration.class),
      mock(MeasureCache.class));
View Full Code Here

TOP

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

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.