@Override public void accept(DefaultIssue issue, ScmInfo scmInfo) { when(issue.getLocations()).thenReturn(DbIssues.Locations.newBuilder().setTextRange(range(2, 3)).build()); setDateOfChangetsetAtLine(scmInfo, 2, 1200L); setDateOfChangetsetAtLine(scmInfo, 3, 1300L); } }
@Override public void accept(DefaultIssue issue, ScmInfo scmInfo) { Builder locations = DbIssues.Locations.newBuilder() .setTextRange(range(2, 3)) .addFlow(newFlow(newLocation(4, 5))) .addFlow(newFlow(newLocation(6, 7, COMPONENT_UUID), newLocation(8, 9, COMPONENT_UUID))); when(issue.getLocations()).thenReturn(locations.build()); setDateOfChangetsetAtLine(scmInfo, 2, 1200L); setDateOfChangetsetAtLine(scmInfo, 3, 1300L); setDateOfChangetsetAtLine(scmInfo, 4, 1400L); setDateOfChangetsetAtLine(scmInfo, 5, 1500L); // some lines missing should be ok setDateOfChangetsetAtLine(scmInfo, 9, 1900L); } }
@Override public void accept(DefaultIssue issue, ScmInfo scmInfo) { Builder locations = DbIssues.Locations.newBuilder() .setTextRange(range(2, 3)) .addFlow(newFlow(newLocation(4, 5))) .addFlow(newFlow(newLocation(6, 7, COMPONENT_UUID), newLocation(8, 9, "another"))); when(issue.getLocations()).thenReturn(locations.build()); setDateOfChangetsetAtLine(scmInfo, 2, 1200L); setDateOfChangetsetAtLine(scmInfo, 3, 1300L); setDateOfChangetsetAtLine(scmInfo, 4, 1400L); setDateOfChangetsetAtLine(scmInfo, 5, 1500L); setDateOfChangetsetAtLine(scmInfo, 6, 1600L); setDateOfChangetsetAtLine(scmInfo, 7, 1700L); setDateOfChangetsetAtLine(scmInfo, 8, 1800L); setDateOfChangetsetAtLine(scmInfo, 9, 1900L); } }
DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); if (reportIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange()));
issue.setGap(reportIssue.getGap()); DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); if (reportIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange()));
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
.setCloseDate(parseDate("2015-10-03")); DbIssues.Locations issueLocations = DbIssues.Locations.newBuilder() .setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(10)
.setCloseDate(parseDate("2015-10-03")); DbIssues.Locations issueLocations = DbIssues.Locations.newBuilder() .setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(10)
.setCloseDate(parseDate("2015-10-03")); DbIssues.Locations issueLocations = DbIssues.Locations.newBuilder() .setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(10)
ComponentDto file = db.components().insertComponent(newFileDto(project)); ComponentDto anotherFile = db.components().insertComponent(newFileDto(project)); DbIssues.Locations.Builder locations = DbIssues.Locations.newBuilder().addFlow(DbIssues.Flow.newBuilder().addAllLocation(Arrays.asList( DbIssues.Location.newBuilder() .setComponentId(file.uuid())
DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); if (reportExternalIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportExternalIssue.getTextRange()));
issue.setGap(reportIssue.getGap()); DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); if (reportIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange()));
@Test public void allLinesFor_traverses_all_flows() { DbIssues.Locations.Builder locations = DbIssues.Locations.newBuilder(); locations.addFlowBuilder() .addLocation(newLocation("file1", 5, 5)) .addLocation(newLocation("file2", 10, 11)) .build(); locations.addFlowBuilder() .addLocation(newLocation("file1", 7, 9)) .addLocation(newLocation("file2", 12, 12)) .build(); DefaultIssue issue = new DefaultIssue().setLocations(locations.build()); assertThat(IssueLocations.allLinesFor(issue, "file1")).containsExactlyInAnyOrder(5, 7, 8, 9); assertThat(IssueLocations.allLinesFor(issue, "file2")).containsExactlyInAnyOrder(10, 11, 12); }
@Test public void allLinesFor_filters_lines_for_specified_component() { DbIssues.Locations.Builder locations = DbIssues.Locations.newBuilder(); locations.addFlowBuilder() .addLocation(newLocation("file1", 5, 5)) .addLocation(newLocation("file1", 10, 12)) .addLocation(newLocation("file1", 15, 15)) .addLocation(newLocation("file2", 10, 11)) .build(); DefaultIssue issue = new DefaultIssue().setLocations(locations.build()); assertThat(IssueLocations.allLinesFor(issue, "file1")).containsExactlyInAnyOrder(5, 10, 11, 12, 15); assertThat(IssueLocations.allLinesFor(issue, "file2")).containsExactlyInAnyOrder(10, 11); assertThat(IssueLocations.allLinesFor(issue, "file3")).isEmpty(); }
@Test public void allLinesFor_default_component_of_location_is_the_issue_component() { DbIssues.Locations.Builder locations = DbIssues.Locations.newBuilder(); locations.addFlowBuilder() .addLocation(newLocation("", 5, 5)) .addLocation(newLocation(null, 7, 7)) .addLocation(newLocation("file2", 9, 9)) .build(); DefaultIssue issue = new DefaultIssue() .setComponentUuid("file1") .setLocations(locations.build()); assertThat(IssueLocations.allLinesFor(issue, "file1")).containsExactlyInAnyOrder(5, 7); assertThat(IssueLocations.allLinesFor(issue, "file2")).containsExactlyInAnyOrder(9); assertThat(IssueLocations.allLinesFor(issue, "file3")).isEmpty(); }
@Test public void allLinesFor_keeps_duplicated_lines() { DbIssues.Locations.Builder locations = DbIssues.Locations.newBuilder(); locations.addFlowBuilder() .addLocation(newLocation("file1", 5, 5)) .addLocation(newLocation("file1", 4, 6)) .build(); DefaultIssue issue = new DefaultIssue().setLocations(locations.build()); assertThat(IssueLocations.allLinesFor(issue, "file1")).containsExactlyInAnyOrder(4, 5, 5, 6); }
private static DefaultIssue newIssueOnLines(int... lines) { DefaultIssue issue = new DefaultIssue(); issue.setComponentUuid(FILE.getUuid()); DbIssues.Locations.Builder locations = DbIssues.Locations.newBuilder(); DbIssues.Flow.Builder flow = DbIssues.Flow.newBuilder(); Arrays.stream(lines).forEach(line -> flow.addLocation(newLocation(line))); locations.addFlow(flow.build()); issue.setLocations(locations.build()); return issue; }