@Test public void measure_with_annotatedFile_should_saveExpectedMeasuresThatHaveLineBreaksInAnnotations() { Mockito.when(this.inputFile.file()) .thenReturn(new File("src/test/resources/SmellMeasurerTest_5.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<Metric> metricCaptor = ArgumentCaptor.forClass(Metric.class); final ArgumentCaptor<Serializable> valueCaptor = ArgumentCaptor.forClass(Serializable.class); Mockito.verify(this.sensorContext, Mockito.times(2 + SmellType.values().length)) .newMeasure(); Mockito.verify(this.measure, Mockito.times(2 + SmellType.values().length)) .save(); Mockito.verify(this.measure, Mockito.times(2 + SmellType.values().length)) .forMetric(metricCaptor.capture()); Mockito.verify(this.measure, Mockito.times(2 + SmellType.values().length)) .withValue(valueCaptor.capture()); Mockito.verify(this.measure, Mockito.times(2 + SmellType.values().length)) .on(Mockito.any()); final List<Metric> capturedMetrics = metricCaptor.getAllValues(); final List<Serializable> capturedValues = valueCaptor.getAllValues(); int i = 0; while (i < EXPECTED_SMELL_TYPE_COUNT) { assertEquals(Integer.valueOf(1), capturedValues.get(i++)); } assertEquals(SmellMetrics.SMELL_COUNT, capturedMetrics.get(i)); assertEquals(Integer.valueOf(EXPECTED_SMELL_TYPE_COUNT), capturedValues.get(i++)); assertEquals(SmellMetrics.SMELL_DEBT, capturedMetrics.get(i)); assertEquals(Long.valueOf(EXPECTED_SMELL_TYPE_DEBT), 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);  }