本文整理汇总了Java中org.sonar.api.ce.measure.MeasureComputer.MeasureComputerContext类的典型用法代码示例。如果您正苦于以下问题:Java MeasureComputerContext类的具体用法?Java MeasureComputerContext怎么用?Java MeasureComputerContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MeasureComputerContext类属于org.sonar.api.ce.measure.MeasureComputer包,在下文中一共展示了MeasureComputerContext类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: given_context_when_compute_then_newComputedMeasures
import org.sonar.api.ce.measure.MeasureComputer.MeasureComputerContext; //导入依赖的package包/类
@Test
public void given_context_when_compute_then_newComputedMeasures(){
org.sonar.api.ce.measure.Component componentFile = Mockito.mock(org.sonar.api.ce.measure.Component.class);
Mockito.when(componentFile.getType()).thenReturn(Component.Type.DIRECTORY);
MeasureComputerContext context = Mockito.mock(MeasureComputerContext.class);
Mockito.when(context.getComponent()).thenReturn(componentFile);
ArrayList<Measure> childsMeasures = new ArrayList<Measure>();
Measure aMeasureMin = Mockito.mock(Measure.class);
Mockito.when(aMeasureMin.getIntValue()).thenReturn(1);
Mockito.when(aMeasureMin.getDoubleValue()).thenReturn(1.);
Measure aMeasureMax = Mockito.mock(Measure.class);
Mockito.when(aMeasureMax.getIntValue()).thenReturn(5);
Mockito.when(aMeasureMax.getDoubleValue()).thenReturn(5.);
childsMeasures.add(aMeasureMin);
childsMeasures.add(aMeasureMax);
Mockito.when(context.getChildrenMeasures(CyclomaticMetrics.SLOC.key())).thenReturn(childsMeasures);
Mockito.when(context.getChildrenMeasures(CyclomaticMetrics.SLOC_MEAN.key())).thenReturn(childsMeasures);
Mockito.when(context.getChildrenMeasures(CyclomaticMetrics.SLOC_MIN.key())).thenReturn(childsMeasures);
Mockito.when(context.getChildrenMeasures(CyclomaticMetrics.SLOC_MAX.key())).thenReturn(childsMeasures);
ComputeProjectLocStatistics computeProjectLocStatistics = new ComputeProjectLocStatistics();
computeProjectLocStatistics.compute(context);
Mockito.verify(context).addMeasure(CyclomaticMetrics.SLOC.key(), 6);
Mockito.verify(context).addMeasure(CyclomaticMetrics.SLOC_MEAN.key(), 3.0);
Mockito.verify(context).addMeasure(CyclomaticMetrics.SLOC_MIN.key(), 1);
Mockito.verify(context).addMeasure(CyclomaticMetrics.SLOC_MAX.key(), 5);
}
示例2: given_context_when_compute_then_newComputedMeasures
import org.sonar.api.ce.measure.MeasureComputer.MeasureComputerContext; //导入依赖的package包/类
@Test
public void given_context_when_compute_then_newComputedMeasures(){
org.sonar.api.ce.measure.Component componentFile = Mockito.mock(org.sonar.api.ce.measure.Component.class);
Mockito.when(componentFile.getType()).thenReturn(Component.Type.DIRECTORY);
MeasureComputerContext context = Mockito.mock(MeasureComputerContext.class);
Mockito.when(context.getComponent()).thenReturn(componentFile);
ArrayList<Measure> childsMeasures = new ArrayList<Measure>();
Measure aMeasureMin = Mockito.mock(Measure.class);
Mockito.when(aMeasureMin.getIntValue()).thenReturn(1);
Mockito.when(aMeasureMin.getDoubleValue()).thenReturn(1.);
Measure aMeasureMax = Mockito.mock(Measure.class);
Mockito.when(aMeasureMax.getIntValue()).thenReturn(5);
Mockito.when(aMeasureMax.getDoubleValue()).thenReturn(5.);
childsMeasures.add(aMeasureMin);
childsMeasures.add(aMeasureMax);
Mockito.when(context.getChildrenMeasures(CyclomaticMetrics.CYCLOMATIC_MEAN.key())).thenReturn(childsMeasures);
Mockito.when(context.getChildrenMeasures(CyclomaticMetrics.CYCLOMATIC_MIN.key())).thenReturn(childsMeasures);
Mockito.when(context.getChildrenMeasures(CyclomaticMetrics.CYCLOMATIC_MAX.key())).thenReturn(childsMeasures);
ComputeProjectCyclomaticStatistics computeProjectCyclomaticStatistics = new ComputeProjectCyclomaticStatistics();
computeProjectCyclomaticStatistics.compute(context);
Mockito.verify(context).addMeasure(CyclomaticMetrics.CYCLOMATIC_MEAN.key(), 3.0);
Mockito.verify(context).addMeasure(CyclomaticMetrics.CYCLOMATIC_MIN.key(), 1);
Mockito.verify(context).addMeasure(CyclomaticMetrics.CYCLOMATIC_MAX.key(), 5);
}
示例3: given_context_when_compute_then_newComputedMeasures
import org.sonar.api.ce.measure.MeasureComputer.MeasureComputerContext; //导入依赖的package包/类
@Test
public void given_context_when_compute_then_newComputedMeasures(){
org.sonar.api.ce.measure.Component componentFile = Mockito.mock(org.sonar.api.ce.measure.Component.class);
Mockito.when(componentFile.getType()).thenReturn(Component.Type.DIRECTORY);
MeasureComputerContext context = Mockito.mock(MeasureComputerContext.class);
Mockito.when(context.getComponent()).thenReturn(componentFile);
ArrayList<Measure> childsMeasures = new ArrayList<Measure>();
Measure aMeasure = Mockito.mock(Measure.class);
Mockito.when(aMeasure.getIntValue()).thenReturn(1);
childsMeasures.add(aMeasure);
Mockito.when(context.getChildrenMeasures(FramaCMetrics.NUMBER_OF_ERRORS.key())).thenReturn(childsMeasures);
Mockito.when(context.getChildrenMeasures(FramaCMetrics.REPORT_FILES_ERROR.key())).thenReturn(childsMeasures);
ComputePluginErrors computePluginErrors = new ComputePluginErrors();
computePluginErrors.compute(context);
Mockito.verify(context).addMeasure(FramaCMetrics.NUMBER_OF_ERRORS.key(), 1);
Mockito.verify(context).addMeasure(FramaCMetrics.REPORT_FILES_ERROR.key(), ComputePluginErrors.SEE_REPORT_FILES_ERROR_MESSAGES);
}
示例4: countFromChildren
import org.sonar.api.ce.measure.MeasureComputer.MeasureComputerContext; //导入依赖的package包/类
public static int countFromChildren(final MeasureComputerContext context, final String key) {
int result = 0;
for (final Measure measure : context.getChildrenMeasures(key)) {
result += measure.getIntValue();
}
return result;
}