@Test public void measure_with_annotatedFile_should_saveExpectedMeasuresAfterHavingRegroupedThemBySmellType() { Mockito.when(this.inputFile.file()) .thenReturn(new File("src/test/resources/SmellMeasurerTest_3.java")); Mockito.when(this.sensorContext.newMeasure()) .thenReturn(this.measure); Mockito.when(this.measure.forMetric(Mockito.any())) .thenReturn(this.measure); Mockito.when(this.measure.withValue(Mockito.any())) .thenReturn(this.measure); Mockito.when(this.measure.on(Mockito.any())) .thenReturn(this.measure); final SmellMeasurer sut = new SmellMeasurer(this.sensorContext); sut.measure(this.inputFile); final ArgumentCaptor<Serializable> valueCaptor = ArgumentCaptor.forClass(Serializable.class); Mockito.verify(this.sensorContext, Mockito.times(3)) .newMeasure(); Mockito.verify(this.measure, Mockito.times(3)) .save(); Mockito.verify(this.measure, Mockito.times(3)) .forMetric(Mockito.any()); Mockito.verify(this.measure, Mockito.times(3)) .withValue(valueCaptor.capture()); Mockito.verify(this.measure, Mockito.times(3)) .on(Mockito.any()); final List<Serializable> capturedValues = valueCaptor.getAllValues(); int i = 0; assertEquals(Integer.valueOf(3), capturedValues.get(i++)); assertEquals(Integer.valueOf(3), capturedValues.get(i++)); assertEquals(Long.valueOf(30), capturedValues.get(i++)); Mockito.verifyNoMoreInteractions(this.sensorContext); }
public void measure(final InputFile inputFile) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Measuring code smells for file '{}'", inputFile.absolutePath()); } final String fileContent = getFileAsString(inputFile.file(), Charsets.UTF_8); measureSmellTypes(inputFile, fileContent); measureSmellDebt(inputFile, fileContent); }
SmellMeasurer { public void measure(final InputFile inputFile) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Measuring code smells for file '{}'", inputFile.absolutePath()); } final String fileContent = getFileAsString(inputFile.file(), Charsets.UTF_8); measureSmellTypes(inputFile, fileContent); measureSmellDebt(inputFile, fileContent); } }
SmellMeasurer { public void measure(final InputFile inputFile) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Measuring code smells for file '{}'", inputFile.absolutePath()); } final String fileContent = getFileAsString(inputFile.file(), Charsets.UTF_8); measureSmellTypes(inputFile, fileContent); measureSmellDebt(inputFile, fileContent); } SmellMeasurer(final SensorContext context); }
SmellMeasurer { public void measure(final InputFile inputFile) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Measuring code smells for file '{}'", inputFile.absolutePath()); } final String fileContent = getFileAsString(inputFile.file(), Charsets.UTF_8); measureSmellTypes(inputFile, fileContent); measureSmellDebt(inputFile, fileContent); } SmellMeasurer(final SensorContext context); void measure(final InputFile inputFile); }
SmellMeasurer { public void measure(final InputFile inputFile) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Measuring code smells for file '{}'", inputFile.absolutePath()); } final String fileContent = getFileAsString(inputFile.file(), Charsets.UTF_8); measureSmellTypes(inputFile, fileContent); measureSmellDebt(inputFile, fileContent); } SmellMeasurer(final SensorContext context); void measure(final InputFile inputFile);  }