### Question:
AnalysisReportScreen implements IsWidget { public void showReport(final AnalysisReport report) { LOGGER.finest("Received report for: " + report.getPlace().getPath()); if (!report.getPlace().equals(currentPlace)) { return; } view.showStatusComplete(); final List<Issue> issues = getIssues(report); final boolean isIllegalState = issues.stream() .filter(issue -> Objects.equals(issue.getCheckType(), CheckType.ILLEGAL_VERIFIER_STATE)) .count() > 0; if (isIllegalState) { view.hideProgressStatus(); } dataProvider.setList(issues); if (dataProvider.getList().isEmpty()) { fireIssueSelectedEvent(Issue.EMPTY); view.clearIssue(); } else { final Issue issue = dataProvider.getList().get(0); onSelect(issue); } } AnalysisReportScreen(); @Inject  AnalysisReportScreen(final AnalysisReportScreenView view,
                                final Event<IssueSelectedEvent> issueSelectedEvent); void showReport(final AnalysisReport report); void setCurrentPlace(final PlaceRequest place); @Override Widget asWidget(); void onSelect(final Issue issue); void showStatus(final Status status);  }### Answer:
@Test public void testShowReport() throws Exception { Issue issue1 = new Issue(Severity.WARNING, CheckType.DEFICIENT_ROW, Collections.emptySet()); screen.showReport(getAnalysis(issue1)); assertEquals(1, dataProvider.getList() .size()); assertTrue(dataProvider.getList() .contains(issue1)); Issue issue2 = new Issue(Severity.ERROR, CheckType.CONFLICTING_ROWS, Collections.emptySet()); Issue issue3 = new Issue(Severity.WARNING, CheckType.SINGLE_HIT_LOST, Collections.emptySet()); screen.showReport(getAnalysis(issue2, issue3)); verify(view).showIssue(issue1); assertEquals(2, dataProvider.getList() .size()); assertFalse(dataProvider.getList() .contains(issue1)); assertTrue(dataProvider.getList() .contains(issue2)); assertTrue(dataProvider.getList() .contains(issue3)); }
@Test public void testShowReportIllegalState() { final Issue illegalStateIssue = new Issue(Severity.ERROR, CheckType.ILLEGAL_VERIFIER_STATE, Collections.emptySet()); screen.showReport(getAnalysis(illegalStateIssue)); assertEquals(1, dataProvider.getList().size()); assertTrue(dataProvider.getList().contains(illegalStateIssue)); verify(view).hideProgressStatus(); }
@Test public void testDoNotShowIfThereAreNoIssues() throws Exception { screen.showReport(getAnalysis()); assertEquals(0, dataProvider.getList() .size()); verify(view, never()).showIssue(any(Issue.class)); }
@Test public void testShowEverythingOnce() throws Exception { Issue issue2 = new Issue(Severity.WARNING, CheckType.REDUNDANT_ROWS, Collections.emptySet()); Issue issue3 = new Issue(Severity.WARNING, CheckType.REDUNDANT_ROWS, Collections.emptySet()); Issue issue4 = new Issue(Severity.WARNING, CheckType.REDUNDANT_ROWS, new HashSet<>(Arrays.asList(1, 2, 3))); Issue issue5 = new Issue(Severity.WARNING, CheckType.REDUNDANT_ROWS, new HashSet<>(Arrays.asList(1, 2, 3))); screen.showReport(getAnalysis(issue2, issue3, issue4, issue5)); assertEquals(2, dataProvider.getList() .size()); }
@Test public void testThePlaceInReportIsNotActive() throws Exception { screen.showReport(getAnalysis(PlaceRequest.NOWHERE)); verify(view, never()).showStatusComplete(); }
@Test public void testNoIssuesShowNothing() throws Exception { screen.showReport(getAnalysis()); verify(view, never()).showIssue(any(Issue.class)); verify(view).clearIssue(); verify(issueSelectedEvent, times(1)).fire(issueSelectedEventCaptor.capture()); assertEquals(Issue.EMPTY, issueSelectedEventCaptor.getValue().getIssue()); }