3 * Copyright (C) 2009-2022 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.issue.index;
22 import java.util.ArrayList;
23 import org.junit.Test;
25 import static java.util.OptionalInt.empty;
26 import static org.assertj.core.api.Assertions.assertThat;
28 public class SecurityStandardCategoryStatisticsTest {
31 public void hasMoreRules_default_false() {
32 SecurityStandardCategoryStatistics standardCategoryStatistics = new SecurityStandardCategoryStatistics(
36 assertThat(standardCategoryStatistics.hasMoreRules()).isFalse();
40 public void hasMoreRules_is_updatable() {
41 SecurityStandardCategoryStatistics standardCategoryStatistics = new SecurityStandardCategoryStatistics(
45 standardCategoryStatistics.setHasMoreRules(true);
46 assertThat(standardCategoryStatistics.hasMoreRules()).isTrue();
50 public void test_getters() {
51 SecurityStandardCategoryStatistics standardCategoryStatistics = new SecurityStandardCategoryStatistics(
53 0, 5, new ArrayList<>(), "version"
56 standardCategoryStatistics.setActiveRules(3);
57 standardCategoryStatistics.setTotalRules(3);
59 assertThat(standardCategoryStatistics.getCategory()).isEqualTo("cat");
60 assertThat(standardCategoryStatistics.getVulnerabilities()).isEqualTo(1);
61 assertThat(standardCategoryStatistics.getVulnerabilityRating()).isEmpty();
62 assertThat(standardCategoryStatistics.getToReviewSecurityHotspots()).isZero();
63 assertThat(standardCategoryStatistics.getReviewedSecurityHotspots()).isZero();
64 assertThat(standardCategoryStatistics.getSecurityReviewRating()).isEqualTo(5);
65 assertThat(standardCategoryStatistics.getChildren()).isEmpty();
66 assertThat(standardCategoryStatistics.getActiveRules()).isEqualTo(3);
67 assertThat(standardCategoryStatistics.getTotalRules()).isEqualTo(3);
68 assertThat(standardCategoryStatistics.getVersion()).isPresent();
69 assertThat(standardCategoryStatistics.getVersion().get()).contains("version");
70 assertThat(standardCategoryStatistics.hasMoreRules()).isFalse();