private void assertDuplicate(Duplicate d, int otherFileRef, int rangeStartLine, int rangeEndLine) { assertThat(d.getOtherFileRef()).isEqualTo(otherFileRef); assertThat(d.getRange().getStartLine()).isEqualTo(rangeStartLine); assertThat(d.getRange().getEndLine()).isEqualTo(rangeEndLine); }
private void assertDuplication(Duplication d, int originStartLine, int originEndLine, @Nullable Integer otherFileRef, int rangeStartLine, int rangeEndLine) { assertThat(d.getOriginPosition().getStartLine()).isEqualTo(originStartLine); assertThat(d.getOriginPosition().getEndLine()).isEqualTo(originEndLine); assertThat(d.getDuplicateList()).hasSize(1); if (otherFileRef != null) { assertThat(d.getDuplicate(0).getOtherFileRef()).isEqualTo(otherFileRef); } else { assertThat(d.getDuplicate(0).getOtherFileRef()).isEqualTo(0); } assertThat(d.getDuplicate(0).getRange().getStartLine()).isEqualTo(rangeStartLine); assertThat(d.getDuplicate(0).getRange().getEndLine()).isEqualTo(rangeEndLine); }
assertThat(cloneGroupFile1.getOriginPosition().getEndLine()).isEqualTo(17); assertThat(cloneGroupFile1.getDuplicateList()).hasSize(1); assertThat(cloneGroupFile1.getDuplicate(0).getOtherFileRef()).isEqualTo(result.getReportComponent(inputFile2).getRef()); assertThat(cloneGroupFile2.getOriginPosition().getEndLine()).isEqualTo(17); assertThat(cloneGroupFile2.getDuplicateList()).hasSize(1); assertThat(cloneGroupFile2.getDuplicate(0).getOtherFileRef()).isEqualTo(result.getReportComponent(inputFile1).getRef());
@Override @Nonnull public Duplicate apply(@Nonnull ScannerReport.Duplicate input) { if (input.getOtherFileRef() != 0) { checkArgument(input.getOtherFileRef() != file.getReportAttributes().getRef(), "file and otherFile references can not be the same"); return new InProjectDuplicate( treeRootHolder.getComponentByRef(input.getOtherFileRef()), convert(input.getRange())); } return new InnerDuplicate(convert(input.getRange())); } }
assertThat(cloneGroupFile1.getOriginPosition().getEndLine()).isEqualTo(17); assertThat(cloneGroupFile1.getDuplicateList()).hasSize(1); assertThat(cloneGroupFile1.getDuplicate(0).getOtherFileRef()).isEqualTo(result.getReportComponent(inputFile2).getRef()); assertThat(cloneGroupFile2.getOriginPosition().getEndLine()).isEqualTo(17); assertThat(cloneGroupFile2.getDuplicateList()).hasSize(1); assertThat(cloneGroupFile2.getDuplicate(0).getOtherFileRef()).isEqualTo(result.getReportComponent(inputFile1).getRef());
@Override @Nonnull public Duplicate apply(@Nonnull ScannerReport.Duplicate input) { if (input.getOtherFileRef() != 0) { checkArgument(input.getOtherFileRef() != file.getReportAttributes().getRef(), "file and otherFile references can not be the same"); Component otherComponent = treeRootHolder.getReportTreeComponentByRef(input.getOtherFileRef()); if ((analysisMetadataHolder.isShortLivingBranch() || analysisMetadataHolder.isPullRequest()) && otherComponent.getStatus() == Component.Status.SAME) { return new InExtendedProjectDuplicate(otherComponent, convert(input.getRange())); } else { return new InProjectDuplicate(otherComponent, convert(input.getRange())); } } return new InnerDuplicate(convert(input.getRange())); }