PropertyStatistics { public long getHighCount(final String key) { return getReportFor(key).getSizeOf(Severity.WARNING_HIGH); } PropertyStatistics(final Report report,
            final String property, final Function<String, String> propertyFormatter); int getTotal(); String getProperty(); String getDisplayName(final String key); String getToolTip(final String key); Set<String> getKeys(); int getMax(); long getCount(final String key); long getErrorsCount(final String key); long getHighCount(final String key); long getNormalCount(final String key); long getLowCount(final String key);  }
@Test void shouldReturnHighCountOne() { Report issues = new Report(); IssueBuilder builder = new IssueBuilder(); issues.add(builder.setSeverity(Severity.WARNING_HIGH).setCategory(KEY).build()); PropertyStatistics statistics = new PropertyStatistics(issues, "category", Function.identity()); long value = statistics.getHighCount(KEY); assertThat(value).isEqualTo(1); }
@Test void shouldReturnHighCountTwo() { Report issues = new Report(); IssueBuilder builder = new IssueBuilder(); issues.add(builder.setSeverity(Severity.WARNING_HIGH).setCategory(KEY).setOrigin("A").build()); issues.add(builder.setSeverity(Severity.WARNING_HIGH).setCategory(KEY).setOrigin("B").build()); issues.add(builder.setSeverity(Severity.WARNING_LOW).setCategory(KEY).setOrigin("B").build()); issues.add(builder.setSeverity(Severity.WARNING_NORMAL).setCategory(KEY).setOrigin("B").build()); PropertyStatistics statistics = new PropertyStatistics(issues, "category", Function.identity()); long value = statistics.getHighCount(KEY); assertThat(value).isEqualTo(2); }
@Test void shouldReturnHighCountZero() { Report issues = new Report(); IssueBuilder builder = new IssueBuilder(); issues.add(builder.setSeverity(Severity.WARNING_LOW).setCategory(KEY).build()); PropertyStatistics statistics = new PropertyStatistics(issues, "category", Function.identity()); long value = statistics.getHighCount(KEY); assertThat(value).isEqualTo(0); }
@Test void shouldReturnHighCountException() { Report issues = new Report(); PropertyStatistics statistics = new PropertyStatistics(issues, "category", Function.identity()); assertThatThrownBy(() -> statistics.getHighCount(KEY)) .isInstanceOf(NoSuchElementException.class) .hasMessageContaining(KEY); }