BlamesModel extends DetailsTableModel { @Override protected BlamesRow getRow(final Issue issue) { return new BlamesRow(getAgeBuilder(), getFileNameRenderer(), getDescriptionProvider(), issue, getJenkinsFacade(), new Blame(issue, blames)); } BlamesModel(final Report report, final Blames blames, final FileNameRenderer fileNameRenderer,
            final AgeBuilder ageBuilder, final DescriptionProvider labelProvider); @VisibleForTesting  BlamesModel(final Report report, final Blames blames, final FileNameRenderer fileNameRenderer,
            final AgeBuilder ageBuilder, final DescriptionProvider labelProvider, final JenkinsFacade jenkinsFacade); @Override String getId(); @Override List<TableColumn> getColumns();  }
@Test void shouldShowIssueWithBlames() { Report report = new Report(); Issue issue = createIssue(1); report.add(issue); FileBlame blameRequest = mock(FileBlame.class); when(blameRequest.getCommit(issue.getLineStart())).thenReturn(COMMIT); when(blameRequest.getEmail(issue.getLineStart())).thenReturn(EMAIL); when(blameRequest.getName(issue.getLineStart())).thenReturn(NAME); when(blameRequest.getTime(issue.getLineStart())).thenReturn(TIME); Blames blames = mock(Blames.class); when(blames.contains(issue.getFileName())).thenReturn(true); when(blames.getBlame(issue.getFileName())).thenReturn(blameRequest); BlamesModel model = createModel(report, blames); BlamesRow actualRow = model.getRow(issue); assertThat(actualRow).hasDescription(EXPECTED_DESCRIPTION) .hasAge("1") .hasCommit(COMMIT) .hasAuthor(NAME) .hasEmail(EMAIL) .hasAddedAt(TIME); assertThatDetailedColumnContains(actualRow.getFileName(), createExpectedFileName(issue), "/path/to/file-1:0000015"); }
@Test void shouldShowIssueWithoutBlames() { Report report = new Report(); Issue issue = createIssue(1); report.add(issue); Blames blames = mock(Blames.class); BlamesModel model = createModel(report, blames); BlamesRow actualRow = model.getRow(issue); assertThat(actualRow).hasDescription(EXPECTED_DESCRIPTION) .hasAge("1") .hasCommit(BlamesModel.UNDEFINED) .hasAuthor(BlamesModel.UNDEFINED) .hasEmail(BlamesModel.UNDEFINED); assertThatDetailedColumnContains(actualRow.getFileName(), createExpectedFileName(issue), "/path/to/file-1:0000015"); }