import org.sonar.db.component.ApplicationProjectsMapper;
import org.sonar.db.component.BranchMapper;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.component.ComponentDtoWithSnapshotId;
import org.sonar.db.component.ComponentKeyUpdaterMapper;
import org.sonar.db.component.ComponentMapper;
import org.sonar.db.component.ComponentWithModuleUuidDto;
confBuilder.loadAlias("CeTaskCharacteristic", CeTaskCharacteristicDto.class);
confBuilder.loadAlias("Component", ComponentDto.class);
confBuilder.loadAlias("ComponentWithModuleUuid", ComponentWithModuleUuidDto.class);
- confBuilder.loadAlias("ComponentWithSnapshot", ComponentDtoWithSnapshotId.class);
confBuilder.loadAlias("DuplicationUnit", DuplicationUnitDto.class);
confBuilder.loadAlias("Event", EventDto.class);
confBuilder.loadAlias("FilePathWithHash", FilePathWithHashDto.class);
void insert(@Param("dto") AuditDto auditDto);
- void delete(@Param("uuids") List<String> uuids);
-
List<AuditDto> selectByPeriodPaginated(@Param("start")long start, @Param("end") long end, @Param("pagination") Pagination pagination);
List<AuditDto> selectOlderThan(@Param("beforeTimestamp") long beforeTimestamp);
return session.getMapper(ApplicationProjectsMapper.class);
}
- public void updateApplicationBranchName(DbSession dbSession, String applicationBranchUuid, String newName) {
- getMapper(dbSession).updateApplicationBranchName(applicationBranchUuid, newName);
- }
-
public void removeAllProjectBranchesOfAppBranch(DbSession dbSession, String applicationBranchUuid) {
getMapper(dbSession).removeAllProjectBranchesOfAppBranch(applicationBranchUuid);
}
int countApplicationProjects(@Param("applicationUuid") String applicationUuid);
- void updateApplicationBranchName(@Param("uuid") String uuid, @Param("newName") String newName);
-
Set<ProjectDto> selectApplicationsFromProjectBranch(@Param("projectUuid") String projectUuid, @Param("branchKey") String branchKey);
Set<ProjectDto> selectApplicationsFromProjects(@Param("projectUuids") Collection<String> projectUuids);
return mapper(dbSession).updateNeedIssueSync(branchUuid, needIssueSync, now);
}
- public void deleteBranch(DbSession dbSession, String projectUuid, String branchKey) {
- mapper(dbSession).deleteBranch(projectUuid, branchKey);
- }
-
public boolean doAnyOfComponentsNeedIssueSync(DbSession session, List<String> components) {
if (!components.isEmpty()) {
List<Boolean> result = new LinkedList<>();
int updateMainBranchName(@Param("projectUuid") String projectUuid, @Param("newBranchName") String newBranchName, @Param("now") long now);
- int updateManualBaseline(@Param("uuid") String uuid, @Nullable @Param("analysisUuid") String analysisUuid, @Param("now") long now);
-
int updateExcludeFromPurge(@Param("uuid") String uuid, @Param("excludeFromPurge") boolean excludeFromPurge,
@Param("now") long now);
short doAnyOfComponentsNeedIssueSync(@Param("componentKeys") List<String> components);
- void deleteBranch(@Param("projectUuid") String projectUuid, @Param("branchKey") String branchKey);
}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.component;
-
-public class ComponentDtoWithSnapshotId extends ComponentDto {
- private Long snapshotId;
-
- public Long getSnapshotId() {
- return snapshotId;
- }
-
- public ComponentDtoWithSnapshotId setSnapshotId(Long snapshotId) {
- this.snapshotId = snapshotId;
- return this;
- }
-}
void setPrivateForRootComponentUuid(@Param("branchUuid") String branchUuid, @Param("isPrivate") boolean isPrivate);
- void delete(String componentUuid);
-
List<KeyWithUuidDto> selectComponentsFromPullRequestsTargetingCurrentBranchThatHaveOpenIssues(@Param("referenceBranchUuid") String referenceBranchUuid,
@Param("currentBranchUuid") String currentBranchUuid);
languages, Pagination.forPage(page).andSize(BIG_PAGE_SIZE));
}
- public Set<String> selectIssueKeysByComponentUuidAndChangedSinceDate(DbSession session, String componentUuid, long changedSince, int page) {
- return selectIssueKeysByComponentUuidAndChangedSinceDate(session, componentUuid, changedSince, emptyList(), emptyList(),
- emptyList(), page);
- }
-
public Set<String> selectIssueKeysByComponentUuidAndChangedSinceDate(DbSession session, String componentUuid, long changedSince,
List<String> includingRepositories, List<String> excludingRepositories,
List<String> languages, int page) {
return executeLargeInputs(componentUuids, mapper(dbSession)::selectOpenByComponentUuids);
}
- public Collection<HotspotGroupDto> selectBranchHotspotsCount(DbSession dbSession, String branchUuid, long leakPeriodBeginningDate) {
- return mapper(dbSession).selectBranchHotspotsCount(branchUuid, leakPeriodBeginningDate);
- }
-
public Collection<IssueGroupDto> selectIssueGroupsByComponent(DbSession dbSession, ComponentDto component, long leakPeriodBeginningDate) {
return mapper(dbSession).selectIssueGroupsByComponent(component, leakPeriodBeginningDate);
}
List<IssueDto> selectNonClosedByModuleOrProject(@Param("projectUuid") String projectUuid, @Param("likeModuleUuidPath") String likeModuleUuidPath);
- Collection<HotspotGroupDto> selectBranchHotspotsCount(@Param("rootUuid") String rootUuid, @Param("leakPeriodBeginningDate") long leakPeriodBeginningDate);
-
Collection<IssueGroupDto> selectIssueGroupsByComponent(@Param("component") ComponentDto component, @Param("leakPeriodBeginningDate") long leakPeriodBeginningDate);
List<IssueDto> selectByBranch(@Param("keys") Set<String> keys, @Nullable @Param("changedSince") Long changedSince);
mapper(dbSession).insert(dto, Uuids.create(), system2.now());
}
- public void update(DbSession dbSession, LiveMeasureDto dto) {
- mapper(dbSession).update(dto, system2.now());
- }
-
public void insertOrUpdate(DbSession dbSession, LiveMeasureDto dto) {
LiveMeasureMapper mapper = mapper(dbSession);
long now = system2.now();
return ofNullable(mapper(dbSession).selectByBranch(projectUuid, branchUuid));
}
- public NewCodePeriodDto selectBestMatchForBranch(DbSession dbSession, String projectUuid, String branchUuid) {
- return selectByBranch(dbSession, projectUuid, branchUuid)
- .or(() -> selectByProject(dbSession, projectUuid)
- .or(() -> selectGlobal(dbSession)))
- .orElse(NewCodePeriodDto.defaultInstance());
- }
-
public Set<String> selectBranchesReferencing(DbSession dbSession, String projectUuid, String referenceBranchName) {
return mapper(dbSession).selectBranchesReferencing(projectUuid, referenceBranchName);
}
// static only
}
- public static LocalDate parseDate(String value) {
- return LocalDate.parse(value);
- }
-
public static int parseDays(String value) {
return Integer.parseInt(value);
}
int deleteByUuid(String templateUuid);
- void deleteByUuids(@Param("templateUuids") List<String> templateUuids);
-
void deleteUserPermissionsByTemplateUuid(String templateUuid);
- void deleteUserPermissionsByTemplateUuids(@Param("templateUuids") List<String> templateUuids);
-
int deleteUserPermissionsByUserUuid(@Param("userUuid") String userUuid);
int deleteUserPermission(PermissionTemplateUserDto permissionTemplateUser);
void deleteGroupPermissionsByTemplateUuid(String templateUuid);
- void deleteGroupPermissionsByTemplateUuids(@Param("templateUuids") List<String> templateUuids);
-
int deleteGroupPermission(PermissionTemplateGroupDto permissionTemplateGroup);
PermissionTemplateDto selectByUuid(String templateUuid);
int countGroupsWithPermission(@Param("templateUuid") String templateUuid, @Param("permission") String permission, @Nullable @Param("groupUuid") String groupUuid);
- List<String> selectTemplateUuids();
-
List<PermissionTemplateGroupDto> selectAllGroupPermissionTemplatesByGroupUuid(@Param("groupUuid") String groupUuid);
}
void update(PluginDto dto);
- void delete(@Param("uuid") String uuid);
}
List<ProjectDto> selectAll();
- void updateKey(@Param("uuid") String uuid, @Param("newKey") String newKey, @Param("updatedAt") long updatedAt);
-
void updateTags(ProjectDto project);
void update(ProjectDto project);
List<PropertyDto> selectGlobalProperties();
- List<PropertyDto> selectProjectProperties(String resourceKey);
-
PropertyDto selectByKey(PropertyDto key);
List<PropertyDto> selectByKeys(@Param("keys") List<String> keys);
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.qualitygate;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-public class ProjectQgateAssociation {
-
- private Long id;
- private String name;
- private boolean isMember;
-
- public Long id() {
- return id;
- }
-
- public ProjectQgateAssociation setId(Long id) {
- this.id = id;
- return this;
- }
-
- public String name() {
- return name;
- }
-
- public ProjectQgateAssociation setName(String name) {
- this.name = name;
- return this;
- }
-
- public boolean isMember() {
- return isMember;
- }
-
- public ProjectQgateAssociation setMember(boolean isMember) {
- this.isMember = isMember;
- return this;
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- ProjectQgateAssociation that = (ProjectQgateAssociation) o;
- return name.equals(that.name);
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
-}
@CheckForNull
ActiveRuleDto selectByKey(@Param("ruleProfileUuid") String ruleProfileUuid, @Param("repository") String repository, @Param("rule") String rule);
- List<ActiveRuleDto> selectByKeys(@Param("keys") List<ActiveRuleKey> keys);
-
List<OrgActiveRuleDto> selectOrgByRuleUuid(@Param("ruleUuid") String ruleUuid);
List<ActiveRuleDto> selectByRuleUuid(String ruleUuid);
void scrollByRuleProfileUuidForIndexing(@Param("ruleProfileUuid") String ruleProfileUuid, ResultHandler<IndexedActiveRuleDto> handler);
- List<OrgActiveRuleDto> selectByQualityProfileUuid(@Param("qualityProfileUuid") String qualityProfileUuid);
}
List<RuleRepositoryDto> selectByQueryAndLanguage(@Param("query") String query,@Param("language") @Nullable String language);
- @CheckForNull
- RuleRepositoryDto selectByKey(@Param("key") String key);
-
void insert(@Param("repository") RuleRepositoryDto repository, @Param("now") long now);
void update(@Param("repository") RuleRepositoryDto repository);
return result;
}
- public Map<String, Integer> countGroupsByUsers(DbSession dbSession, List<String> logins) {
- List<LoginGroupCount> loginGroupCount = mapper(dbSession).countGroupsByUsers(logins);
- Map<String, Integer> map = new HashMap<>();
- for (LoginGroupCount l : loginGroupCount) {
- map.put(l.login(), l.groupCount());
- }
- return map;
- }
-
public List<String> selectGroupUuidsByUserUuid(DbSession dbSession, String userUuid) {
return mapper(dbSession).selectGroupUuidsByUserUuid(userUuid);
}
List<GroupUserCount> countUsersByGroup(@Param("groupUuids") List<String> groupUuids);
- List<LoginGroupCount> countGroupsByUsers(@Param("logins") List<String> logins);
-
List<LoginGroup> selectGroupsByLogins(@Param("logins") List<String> logins);
List<String> selectGroupUuidsByUserUuid(@Param("userUuid") String userUuid);
where uuid in (select a.uuid from audits a where a.created_at < #{threshold,jdbcType=BIGINT}
order by a.created_at fetch first 100000 rows only)
</delete>
-
- <delete id="deleteByUuids" parameterType="string">
- delete
- from audits
- where
- uuid in
- <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
- #{uuid,jdbcType=VARCHAR}
- </foreach>
- </delete>
-
</mapper>
ap.application_uuid = #{applicationUuid,jdbcType=VARCHAR}
</select>
- <update id="updateApplicationBranchName" parameterType="String">
- UPDATE
- project_branches
- SET
- kee = #{newName,jdbcType=VARCHAR}
- WHERE
- uuid = #{uuid,jdbcType=VARCHAR}
- </update>
-
<select id="selectApplicationsFromProjectBranch" parameterType="String" resultType="Project">
SELECT
<include refid="projectColumns"/>
uuid = #{projectUuid, jdbcType=VARCHAR}
</update>
- <delete id="deleteBranch" parameterType="string">
- delete from project_branches
- where
- project_uuid = #{projectUuid, jdbcType=VARCHAR},
- kee = #{branchKey, jdbcType=VARCHAR}
- </delete>
-
<update id="updateExcludeFromPurge">
update project_branches
set
and private <> #{isPrivate,jdbcType=BOOLEAN}
</update>
- <delete id="delete" parameterType="String">
- DELETE FROM components WHERE uuid=#{componentUuid,jdbcType=VARCHAR}
- </delete>
-
<select id="selectComponentsFromPullRequestsTargetingCurrentBranchThatHaveOpenIssues" resultType="KeyWithUuid">
SELECT DISTINCT p.kee as kee, p.uuid as uuid FROM components p
JOIN issues i
i.issue_type <> 4
</select>
- <select id="selectBranchHotspotsCount" resultType="org.sonar.db.issue.HotspotGroupDto" parameterType="map">
- select i.status as status, count(i.status) as "count",
- <if test="leakPeriodBeginningDate >= 0">
- (i.issue_creation_date > #{leakPeriodBeginningDate,jdbcType=BIGINT}) as inLeak
- </if>
- <if test="leakPeriodBeginningDate < 0">
- CASE WHEN n.uuid is null THEN false ELSE true END as inLeak
- </if>
- from issues i
- <if test="leakPeriodBeginningDate < 0">
- left join new_code_reference_issues n on n.issue_key = i.kee
- </if>
- where i.project_uuid = #{rootUuid,jdbcType=VARCHAR}
- and i.status !='CLOSED'
- and i.issue_type = 4
- group by i.status, inLeak
- </select>
-
- <select id="selectBranchHotspotsCount" resultType="org.sonar.db.issue.HotspotGroupDto" parameterType="map" databaseId="oracle">
- select i2.status as status, count(i2.status) as "count", i2.inLeak as inLeak
- from (
- select i.status,
- <if test="leakPeriodBeginningDate >= 0">
- case when i.issue_creation_date > #{leakPeriodBeginningDate,jdbcType=BIGINT} then 1 else 0 end as inLeak
- </if>
- <if test="leakPeriodBeginningDate < 0">
- case when n.uuid is null then 0 else 1 end as inLeak
- </if>
- from issues i
- <if test="leakPeriodBeginningDate < 0">
- left join new_code_reference_issues n on n.issue_key = i.kee
- </if>
- where i.project_uuid = #{rootUuid,jdbcType=VARCHAR}
- and i.status !='CLOSED'
- and i.issue_type = 4
- ) i2
- group by i2.status, i2.inLeak
- </select>
-
- <select id="selectBranchHotspotsCount" resultType="org.sonar.db.issue.HotspotGroupDto" parameterType="map" databaseId="mssql">
- select i2.status as status, count(i2.status) as "count", i2.inLeak as inLeak
- from (
- select i.status,
- <if test="leakPeriodBeginningDate >= 0">
- case when i.issue_creation_date > #{leakPeriodBeginningDate,jdbcType=BIGINT} then 1 else 0 end as inLeak
- </if>
- <if test="leakPeriodBeginningDate < 0">
- case when n.uuid is null then 0 else 1 end as inLeak
- </if>
- from issues i
- <if test="leakPeriodBeginningDate < 0">
- left join new_code_reference_issues n on n.issue_key = i.kee
- </if>
- where i.project_uuid = #{rootUuid,jdbcType=VARCHAR}
- and i.status !='CLOSED'
- and i.issue_type = 4
- ) i2
- group by i2.status, i2.inLeak
- </select>
-
<select id="selectIssueGroupsByComponent" resultType="org.sonar.db.issue.IssueGroupDto" parameterType="map">
select i.issue_type as ruleType, i.severity as severity, i.resolution as resolution, i.status as status, sum(i.effort) as effort, count(i.issue_type) as "count",
<if test="leakPeriodBeginningDate >= 0">
WHERE uuid = #{uuid}
</delete>
- <delete id="deleteByUuids" parameterType="String">
- delete from
- permission_templates
- where
- uuid in <foreach collection="templateUuids" open="(" close=")" item="uuid" separator=",">
- #{uuid,jdbcType=BIGINT}
- </foreach>
- </delete>
-
<delete id="deleteUserPermissionsByTemplateUuid" parameterType="string">
delete from
perm_templates_users
template_uuid = #{templateUuid,jdbcType=VARCHAR}
</delete>
- <delete id="deleteUserPermissionsByTemplateUuids">
- delete from
- perm_templates_users
- where
- template_uuid in <foreach collection="templateUuids" open="(" close=")" item="templateUuid" separator=",">
- #{templateUuid,jdbcType=BIGINT}
- </foreach>
- </delete>
-
<delete id="deleteUserPermission" parameterType="PermissionTemplateUser">
DELETE FROM perm_templates_users
WHERE template_uuid = #{templateUuid}
template_uuid = #{templateUuid,jdbcType=VARCHAR}
</delete>
- <delete id="deleteGroupPermissionsByTemplateUuids">
- delete from
- perm_templates_groups
- where
- template_uuid in <foreach collection="templateUuids" open="(" close=")" item="templateUuid" separator=",">
- #{templateUuid,jdbcType=VARCHAR}
- </foreach>
- </delete>
-
<delete id="deleteGroupPermission" parameterType="PermissionTemplateGroup">
DELETE FROM perm_templates_groups
WHERE template_uuid = #{templateUuid}
</if>
</select>
- <select id="selectTemplateUuidsn" resultType="String">
- select
- uuid
- from
- permission_templates
- </select>
-
<select id="selectAllGroupPermissionTemplatesByGroupUuid" parameterType="string" resultType="PermissionTemplateGroup">
SELECT
ptg.uuid,
uuid = #{uuid,jdbcType=VARCHAR}
</update>
- <update id="updateKey">
- update projects set
- kee = #{newKey,jdbcType=VARCHAR},
- updated_at = #{updatedAt,jdbcType=BIGINT}
- where
- uuid = #{uuid,jdbcType=VARCHAR}
- </update>
-
- <update id="updateVisibility">
+ <update id="updateVisibility">
update projects set
private = #{isPrivate,jdbcType=BOOLEAN},
updated_at = #{updatedAt,jdbcType=BIGINT}
and p.user_uuid is null
</select>
- <select id="selectProjectProperties" parameterType="String" resultType="ScrapProperty">
- select
- <include refid="columnsToScrapPropertyDto"/>
- from
- properties p,
- components r
- where
- p.component_uuid=r.uuid
- and p.user_uuid is null
- and r.kee=#{resourceKey,jdbcType=VARCHAR}
- </select>
-
<select id="selectByKey" parameterType="map" resultType="ScrapProperty">
select
<include refid="columnsToScrapPropertyDto"/>
and r.plugin_name = #{repository, jdbcType=VARCHAR}
</select>
- <select id="selectByKeys" parameterType="map" resultType="ActiveRule">
- select
- <include refid="activeRuleColumns"/>
- from active_rules a
- <include refid="activeRuleKeyJoin"/>
- where
- <foreach collection="keys" item="key" open="(" separator=" or " close=")">
- (rp.uuid = #{key.ruleProfileUuid, jdbcType=VARCHAR}
- AND r.plugin_rule_key = #{key.ruleKey.rule, jdbcType=VARCHAR}
- AND r.plugin_name = #{key.ruleKey.repository, jdbcType=VARCHAR}
- )
- </foreach>
- </select>
-
<select id="selectByProfileUuid" parameterType="string" resultType="org.sonar.db.qualityprofile.OrgActiveRuleDto">
select
<include refid="orgActiveRuleColumns"/>
assertThat(issues).containsOnly("I1", "I3");
}
- @Test
- public void selectIssueKeysByComponentUuidAndChangedSince() {
- long t1 = 1_340_000_000_000L;
- long t2 = 1_400_000_000_000L;
- // contains I1 and I2
- prepareTables();
- // Insert I3, I4, where t1 < t2
- IntStream.range(3, 5).forEach(i -> underTest.insert(db.getSession(), newIssueDto("I" + i).setUpdatedAt(t1)));
-
- Set<String> issues = underTest.selectIssueKeysByComponentUuidAndChangedSinceDate(db.getSession(), PROJECT_UUID, t2, 1);
-
- assertThat(issues).contains("I1");
- }
-
@Test
public void selectIssueKeysByComponentUuidAndChangedSinceFiltersAccordingly() {
long t1 = 1_340_000_000_000L;
assertThat(groups).isEmpty();
}
- @Test
- public void test_selectBranchHotspotsCount_on_component_without_issues() {
- ComponentDto project = db.components().insertPublicProject();
- ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
-
- Collection<HotspotGroupDto> groups = underTest.selectBranchHotspotsCount(db.getSession(), project.uuid(), 1_000L);
-
- assertThat(groups).isEmpty();
- }
-
@Test
public void selectByKey_givenOneIssueWithQuickFix_selectOneIssueWithQuickFix() {
prepareIssuesComponent();
assertThat(result.stream().filter(g -> !g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isOne();
}
- @Test
- public void selectBranchHotspotsCount_on_project() {
- ComponentDto project = db.components().insertPublicProject();
- ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
- RuleDto rule = db.rules().insert();
- IssueDto i1 = db.issues().insert(rule, project, file,
- i -> i.setStatus("REVIEWED").setResolution("SAFE").setSeverity("CRITICAL").setType(RuleType.SECURITY_HOTSPOT).setIssueCreationTime(1_500L));
- IssueDto i2 = db.issues().insert(rule, project, file,
- i -> i.setStatus("TO_REVIEW").setResolution(null).setSeverity("CRITICAL").setType(RuleType.SECURITY_HOTSPOT).setIssueCreationTime(1_600L));
- IssueDto i3 = db.issues().insert(rule, project, file,
- i -> i.setStatus("TO_REVIEW").setResolution(null).setSeverity("CRITICAL").setType(RuleType.SECURITY_HOTSPOT).setIssueCreationTime(1_700L));
-
- // closed issues or other types are ignored
- IssueDto closed = db.issues().insert(rule, project, file,
- i -> i.setStatus("CLOSED").setResolution("REMOVED").setSeverity("CRITICAL").setType(RuleType.BUG).setIssueCreationTime(1_700L));
- IssueDto bug = db.issues().insert(rule, project, file,
- i -> i.setStatus("OPEN").setResolution(null).setSeverity("CRITICAL").setType(RuleType.BUG).setIssueCreationTime(1_700L));
-
- Collection<HotspotGroupDto> result = underTest.selectBranchHotspotsCount(db.getSession(), project.uuid(), 1_000L);
-
- assertThat(result.stream().mapToLong(HotspotGroupDto::getCount).sum()).isEqualTo(3);
-
- assertThat(result.stream().filter(g -> g.getStatus().equals("TO_REVIEW")).mapToLong(HotspotGroupDto::getCount).sum()).isEqualTo(2);
- assertThat(result.stream().filter(g -> g.getStatus().equals("REVIEWED")).mapToLong(HotspotGroupDto::getCount).sum()).isOne();
- assertThat(result.stream().filter(g -> g.getStatus().equals("CLOSED")).mapToLong(HotspotGroupDto::getCount).sum()).isZero();
-
- assertThat(result.stream().filter(HotspotGroupDto::isInLeak).mapToLong(HotspotGroupDto::getCount).sum()).isEqualTo(3);
- assertThat(result.stream().filter(g -> !g.isInLeak()).mapToLong(HotspotGroupDto::getCount).sum()).isZero();
-
- // test leak
- result = underTest.selectBranchHotspotsCount(db.getSession(), project.uuid(), 999_999_999L);
- assertThat(result.stream().filter(HotspotGroupDto::isInLeak).mapToLong(HotspotGroupDto::getCount).sum()).isZero();
- assertThat(result.stream().filter(g -> !g.isInLeak()).mapToLong(HotspotGroupDto::getCount).sum()).isEqualTo(3);
- }
-
- @Test
- public void selectBranchHotspotsCount_on_project_with_reference_branch() {
- ComponentDto project = db.components().insertPublicProject();
- ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
- RuleDto rule = db.rules().insert();
- IssueDto i1 = db.issues().insert(rule, project, file,
- i -> i.setStatus("REVIEWED").setResolution("SAFE").setSeverity("CRITICAL").setType(RuleType.SECURITY_HOTSPOT).setIssueCreationTime(1_500L));
- IssueDto i2 = db.issues().insert(rule, project, file,
- i -> i.setStatus("TO_REVIEW").setResolution(null).setSeverity("CRITICAL").setType(RuleType.SECURITY_HOTSPOT).setIssueCreationTime(1_600L));
- IssueDto i3 = db.issues().insert(rule, project, file,
- i -> i.setStatus("TO_REVIEW").setResolution(null).setSeverity("CRITICAL").setType(RuleType.SECURITY_HOTSPOT).setIssueCreationTime(1_700L));
-
- // closed issues or other types are ignored
- IssueDto closed = db.issues().insert(rule, project, file,
- i -> i.setStatus("CLOSED").setResolution("REMOVED").setSeverity("CRITICAL").setType(RuleType.BUG).setIssueCreationTime(1_700L));
- IssueDto bug = db.issues().insert(rule, project, file,
- i -> i.setStatus("OPEN").setResolution(null).setSeverity("CRITICAL").setType(RuleType.BUG).setIssueCreationTime(1_700L));
-
- db.issues().insertNewCodeReferenceIssue(i1);
- db.issues().insertNewCodeReferenceIssue(bug);
-
- Collection<HotspotGroupDto> result = underTest.selectBranchHotspotsCount(db.getSession(), project.uuid(), -1);
-
- assertThat(result.stream().mapToLong(HotspotGroupDto::getCount).sum()).isEqualTo(3);
-
- assertThat(result.stream().filter(g -> g.getStatus().equals("TO_REVIEW")).mapToLong(HotspotGroupDto::getCount).sum()).isEqualTo(2);
- assertThat(result.stream().filter(g -> g.getStatus().equals("REVIEWED")).mapToLong(HotspotGroupDto::getCount).sum()).isOne();
- assertThat(result.stream().filter(g -> g.getStatus().equals("CLOSED")).mapToLong(HotspotGroupDto::getCount).sum()).isZero();
-
- assertThat(result.stream().filter(HotspotGroupDto::isInLeak).mapToLong(HotspotGroupDto::getCount).sum()).isEqualTo(1);
- assertThat(result.stream().filter(g -> !g.isInLeak()).mapToLong(HotspotGroupDto::getCount).sum()).isEqualTo(2);
- }
-
@Test
public void selectModuleAndDirComponentUuidsOfOpenIssuesForProjectUuid() {
assertThat(underTest.selectModuleAndDirComponentUuidsOfOpenIssuesForProjectUuid(db.getSession(), randomAlphabetic(12)))
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.authentication.exception;
-
-public abstract class RedirectionException extends RuntimeException {
-
- public abstract String getPath(String contextPath);
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.server.authentication.exception;
-
-import javax.annotation.ParametersAreNonnullByDefault;