@Test void whenEndLineEqualsBeginLineThenRangeStartAndEndsAtSameLine() { final int line = 1; final RuleViolation mockedViolation = mock(RuleViolation.class); when(mockedViolation.getBeginLine()).thenReturn(line); when(mockedViolation.getEndLine()).thenReturn(line); final TextRange result = TextRangeCalculator.calculate(mockedViolation, testInput); assertThat(result).isNotNull(); assertThat(result.start()) .isNotNull() .hasFieldOrPropertyWithValue("line", line); assertThat(result.end()) .isNotNull() .hasFieldOrPropertyWithValue("line", line); }
static TextRange calculate(RuleViolation pmdViolation, InputFile inputFile) { final int startLine = calculateBeginLine(pmdViolation); final int endLine = calculateEndLine(pmdViolation); final TextPointer startPointer = inputFile.selectLine(startLine).start(); final TextPointer endPointer = inputFile.selectLine(endLine).end(); return inputFile.newRange(startPointer, endPointer); }
TextRangeCalculator { static TextRange calculate(RuleViolation pmdViolation, InputFile inputFile) { final int startLine = calculateBeginLine(pmdViolation); final int endLine = calculateEndLine(pmdViolation); final TextPointer startPointer = inputFile.selectLine(startLine).start(); final TextPointer endPointer = inputFile.selectLine(endLine).end(); return inputFile.newRange(startPointer, endPointer); } }
TextRangeCalculator { static TextRange calculate(RuleViolation pmdViolation, InputFile inputFile) { final int startLine = calculateBeginLine(pmdViolation); final int endLine = calculateEndLine(pmdViolation); final TextPointer startPointer = inputFile.selectLine(startLine).start(); final TextPointer endPointer = inputFile.selectLine(endLine).end(); return inputFile.newRange(startPointer, endPointer); }  }
TextRangeCalculator { static TextRange calculate(RuleViolation pmdViolation, InputFile inputFile) { final int startLine = calculateBeginLine(pmdViolation); final int endLine = calculateEndLine(pmdViolation); final TextPointer startPointer = inputFile.selectLine(startLine).start(); final TextPointer endPointer = inputFile.selectLine(endLine).end(); return inputFile.newRange(startPointer, endPointer); }   }
TextRangeCalculator { static TextRange calculate(RuleViolation pmdViolation, InputFile inputFile) { final int startLine = calculateBeginLine(pmdViolation); final int endLine = calculateEndLine(pmdViolation); final TextPointer startPointer = inputFile.selectLine(startLine).start(); final TextPointer endPointer = inputFile.selectLine(endLine).end(); return inputFile.newRange(startPointer, endPointer); }    }