AbstractSmellMeasureComputer implements MeasureComputer { @Override public void compute(final MeasureComputerContext context) { final Component component = context.getComponent(); if (component.getType() != Type.FILE) { compute(component, context); } } AbstractSmellMeasureComputer(final List<String> inputMetricsKeys, final List<String> outputMetricsKeys); List<String> getOutputMetricsKeys(); List<String> getInputMetricsKeys(); @Override MeasureComputerDefinition define(final MeasureComputerDefinitionContext definitionContext); @Override void compute(final MeasureComputerContext context); @Override String toString();  }
@Test @Parameters public void decorate_shouldNot_saveMeasures_when_resourceIsNotAProject(final Type scope) { Mockito.when(this.context.getComponent()) .thenReturn(this.component); Mockito.when(this.component.getType()) .thenReturn(scope); Mockito.when(this.context.getChildrenMeasures(Matchers.any(String.class))) .thenReturn(DUMMY_INT_METRIC_COLLECTION); final AbstractSmellMeasureComputer sut = sut(); sut.compute(this.context); Mockito.verify(this.context, Mockito.times(1)) .getComponent(); Mockito.verify(this.component, Mockito.times(1)) .getType(); Mockito.verifyNoMoreInteractions(this.component, this.context); }
@Test public void decorate_should_saveExpectedMeasureTotal() { Mockito.when(this.context.getComponent()) .thenReturn(this.component); Mockito.when(this.component.getType()) .thenReturn(Type.PROJECT); Mockito.when(this.context.getChildrenMeasures(Matchers.any(String.class))) .thenReturn(dummyMeasures(metricValueType())); final AbstractSmellMeasureComputer sut = sut(); sut.compute(this.context); Mockito.verify(this.context, Mockito.times(1)) .getComponent(); Mockito.verify(this.context, Mockito.times(expectedGetChildrenMeasuresCount())) .getChildrenMeasures(Matchers.any(String.class)); switch (metricValueType()) { case INT: Mockito.verify(this.context, Mockito.times(expectedSavedMeasuresCount())) .addMeasure(Matchers.any(String.class), Matchers.eq(expectedSavedMeasureIntValue())); break; case WORK_DUR: Mockito.verify(this.context, Mockito.times(expectedSavedMeasuresCount())) .addMeasure(Matchers.any(String.class), Matchers.eq(expectedSavedMeasureLongValue())); break; default: break; } Mockito.verifyNoMoreInteractions(this.context); }