Package org.sonar.api.batch.sensor.measure.internal

Examples of org.sonar.api.batch.sensor.measure.internal.DefaultMeasure


    when(context.fileSystem()).thenReturn(fileSystem);
    storage = mock(SensorStorage.class);
    when(context.newMeasure()).then(new Answer<DefaultMeasure>() {
      @Override
      public DefaultMeasure answer(InvocationOnMock invocation) throws Throwable {
        return new DefaultMeasure(storage);
      }
    });
  }
View Full Code Here


    when(metricFinder.findByKey("sqale_index")).thenReturn(CoreMetrics.TECHNICAL_DEBT);
    when(metricFinder.findByKey("bool")).thenReturn(booleanMetric);

    sensor.execute(context);

    verify(storage).store(new DefaultMeasure().forMetric(CoreMetrics.NCLOC).onFile(inputFile).withValue(12));
    verify(storage).store(new DefaultMeasure().forMetric(CoreMetrics.BRANCH_COVERAGE).onFile(inputFile).withValue(5.3));
    verify(storage).store(new DefaultMeasure().forMetric(CoreMetrics.TECHNICAL_DEBT).onFile(inputFile).withValue(300L));
    verify(storage).store(new DefaultMeasure().forMetric(booleanMetric).onFile(inputFile).withValue(true));
  }
View Full Code Here

    this.inputPathCache = inputPathCache;
  }

  @Override
  public void put(Value value, Object object, CoderContext context) {
    DefaultMeasure m = (DefaultMeasure) object;
    DefaultInputFile inputFile = (DefaultInputFile) m.inputFile();
    if (inputFile != null) {
      value.putString(inputFile.moduleKey());
      value.putString(inputFile.relativePath());
    } else {
      value.putNull();
    }
    value.putString(m.metric().key());
    value.put(m.value());
  }
View Full Code Here

    value.put(m.value());
  }

  @Override
  public Object get(Value value, Class clazz, CoderContext context) {
    DefaultMeasure newMeasure = new DefaultMeasure(null);
    String moduleKey = value.getString();
    if (moduleKey != null) {
      String relativePath = value.getString();
      InputFile f = inputPathCache.getFile(moduleKey, relativePath);
      newMeasure.onFile(f);
    } else {
      newMeasure.onProject();
    }
    Metric m = metricFinder.findByKey(value.getString());
    newMeasure.forMetric(m);
    newMeasure.withValue((Serializable) value.get());
    return newMeasure;
  }
View Full Code Here

    return activeRules;
  }

  @Override
  public <G extends Serializable> Measure<G> newMeasure() {
    return (Measure<G>) new DefaultMeasure(this);
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.batch.sensor.measure.internal.DefaultMeasure

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.