当前位置: 首页>>代码示例>>Java>>正文


Java MeasureComputerContext类代码示例

本文整理汇总了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);
}
 
开发者ID:lequal,项目名称:sonar-frama-c-plugin,代码行数:27,代码来源:ComputeProjectLocStatisticsTest.java

示例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);
}
 
开发者ID:lequal,项目名称:sonar-frama-c-plugin,代码行数:25,代码来源:ComputeProjectCyclomaticStatisticsTest.java

示例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);
}
 
开发者ID:lequal,项目名称:sonar-frama-c-plugin,代码行数:18,代码来源:ComputePluginErrorsTest.java

示例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;
}
 
开发者ID:willemsrb,项目名称:sonar-jdepend-plugin,代码行数:9,代码来源:ComputerUtil.java


注:本文中的org.sonar.api.ce.measure.MeasureComputer.MeasureComputerContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。