diff options
65 files changed, 73 insertions, 2488 deletions
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index 291093f2b45..d767f42a1bb 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -96,7 +96,7 @@ public class ComputeEngineContainerImplTest { assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize( COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION + 23 // level 1 - + 47 // content of DaoModule + + 45 // content of DaoModule + 1 // content of EsSearchModule + 56 // content of CorePropertyDefinitions + 1 // content of CePropertyDefinitions diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/UpdateConflictResolver.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/UpdateConflictResolver.java index 3f7c2fcde48..96f98d731b8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/UpdateConflictResolver.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/UpdateConflictResolver.java @@ -47,7 +47,6 @@ public class UpdateConflictResolver { @VisibleForTesting void mergeFields(IssueDto dbIssue, DefaultIssue issue) { resolveAssignee(dbIssue, issue); - resolvePlan(dbIssue, issue); resolveSeverity(dbIssue, issue); resolveEffortToFix(dbIssue, issue); resolveResolution(dbIssue, issue); @@ -74,10 +73,6 @@ public class UpdateConflictResolver { // else keep severity as declared in quality profile } - private void resolvePlan(IssueDto dbIssue, DefaultIssue issue) { - issue.setActionPlanKey(dbIssue.getActionPlanKey()); - } - private void resolveAssignee(IssueDto dbIssue, DefaultIssue issue) { issue.setAssignee(dbIssue.getAssignee()); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ActionService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ActionService.java index db03b17d1c2..7105aa104f7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ActionService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ActionService.java @@ -66,7 +66,6 @@ public class ActionService { if (!login.equals(issue.assignee())) { availableActions.add("assign_to_me"); } - availableActions.add("plan"); String projectUuid = issue.projectUuid(); if (projectUuid != null && userSession.hasComponentUuidPermission(ISSUE_ADMIN, projectUuid)) { availableActions.add("set_severity"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java index 119d057c0f3..ec3bf7e5eda 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java @@ -30,23 +30,16 @@ import java.util.List; import java.util.Map; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.sonar.api.issue.ActionPlan; import org.sonar.api.issue.Issue; import org.sonar.api.issue.IssueComment; import org.sonar.api.server.ServerSide; import org.sonar.api.utils.SonarException; import org.sonar.api.web.UserRole; -import org.sonar.core.issue.ActionPlanStats; -import org.sonar.core.issue.DefaultActionPlan; import org.sonar.core.issue.DefaultIssueComment; -import org.sonar.db.component.ResourceDao; -import org.sonar.db.component.ResourceDto; -import org.sonar.db.component.ResourceQuery; import org.sonar.db.issue.IssueFilterDto; import org.sonar.server.es.SearchOptions; import org.sonar.server.exceptions.BadRequestException; -import org.sonar.server.issue.actionplan.ActionPlanService; import org.sonar.server.issue.filter.IssueFilterService; import org.sonar.server.issue.workflow.Transition; import org.sonar.server.search.QueryContext; @@ -68,17 +61,12 @@ public class InternalRubyIssueService { private static final String ID_PARAM = "id"; private static final String NAME_PARAM = "name"; private static final String DESCRIPTION_PARAM = "description"; - private static final String PROJECT_PARAM = "project"; private static final String USER_PARAM = "user"; - private static final String ACTION_PLANS_ERRORS_ACTION_PLAN_DOES_NOT_EXIST_MESSAGE = "action_plans.errors.action_plan_does_not_exist"; - private final IssueService issueService; private final IssueQueryService issueQueryService; private final IssueCommentService commentService; private final IssueChangelogService changelogService; - private final ActionPlanService actionPlanService; - private final ResourceDao resourceDao; private final IssueFilterService issueFilterService; private final IssueBulkChangeService issueBulkChangeService; private final ActionService actionService; @@ -88,16 +76,13 @@ public class InternalRubyIssueService { IssueService issueService, IssueQueryService issueQueryService, IssueCommentService commentService, - IssueChangelogService changelogService, ActionPlanService actionPlanService, - ResourceDao resourceDao, + IssueChangelogService changelogService, IssueFilterService issueFilterService, IssueBulkChangeService issueBulkChangeService, ActionService actionService, UserSession userSession) { this.issueService = issueService; this.issueQueryService = issueQueryService; this.commentService = commentService; this.changelogService = changelogService; - this.actionPlanService = actionPlanService; - this.resourceDao = resourceDao; this.issueFilterService = issueFilterService; this.issueBulkChangeService = issueBulkChangeService; this.actionService = actionService; @@ -164,129 +149,6 @@ public class InternalRubyIssueService { return commentService.findComment(commentKey); } - public Collection<ActionPlan> findOpenActionPlans(String projectKey) { - return actionPlanService.findOpenByProjectKey(projectKey, userSession); - } - - public ActionPlan findActionPlan(String actionPlanKey) { - return actionPlanService.findByKey(actionPlanKey, userSession); - } - - public List<ActionPlanStats> findActionPlanStats(String projectKey) { - return actionPlanService.findActionPlanStats(projectKey, userSession); - } - - public Result<ActionPlan> createActionPlan(Map<String, String> parameters) { - Result<ActionPlan> result = createActionPlanResult(parameters); - if (result.ok()) { - result.set(actionPlanService.create(result.get(), userSession)); - } - return result; - } - - public Result<ActionPlan> updateActionPlan(String key, Map<String, String> parameters) { - DefaultActionPlan existingActionPlan = (DefaultActionPlan) actionPlanService.findByKey(key, userSession); - if (existingActionPlan == null) { - Result<ActionPlan> result = Result.of(); - result.addError(Result.Message.ofL10n(ACTION_PLANS_ERRORS_ACTION_PLAN_DOES_NOT_EXIST_MESSAGE, key)); - return result; - } else { - Result<ActionPlan> result = createActionPlanResult(parameters, existingActionPlan); - if (result.ok()) { - DefaultActionPlan actionPlan = (DefaultActionPlan) result.get(); - actionPlan.setKey(existingActionPlan.key()); - actionPlan.setUserLogin(existingActionPlan.userLogin()); - result.set(actionPlanService.update(actionPlan, userSession)); - } - return result; - } - } - - public Result<ActionPlan> closeActionPlan(String actionPlanKey) { - Result<ActionPlan> result = createResultForExistingActionPlan(actionPlanKey); - if (result.ok()) { - result.set(actionPlanService.setStatus(actionPlanKey, ActionPlan.STATUS_CLOSED, userSession)); - } - return result; - } - - public Result<ActionPlan> openActionPlan(String actionPlanKey) { - Result<ActionPlan> result = createResultForExistingActionPlan(actionPlanKey); - if (result.ok()) { - result.set(actionPlanService.setStatus(actionPlanKey, ActionPlan.STATUS_OPEN, userSession)); - } - return result; - } - - public Result<ActionPlan> deleteActionPlan(String actionPlanKey) { - Result<ActionPlan> result = createResultForExistingActionPlan(actionPlanKey); - if (result.ok()) { - actionPlanService.delete(actionPlanKey, userSession); - } - return result; - } - - @VisibleForTesting - Result createActionPlanResult(Map<String, String> parameters) { - return createActionPlanResult(parameters, null); - } - - @VisibleForTesting - Result<ActionPlan> createActionPlanResult(Map<String, String> parameters, @Nullable DefaultActionPlan existingActionPlan) { - Result<ActionPlan> result = Result.of(); - - String name = parameters.get(NAME_PARAM); - String description = parameters.get(DESCRIPTION_PARAM); - String deadLineParam = parameters.get("deadLine"); - String projectParam = parameters.get(PROJECT_PARAM); - - checkMandatorySizeParameter(name, NAME_PARAM, 200, result); - checkOptionalSizeParameter(description, DESCRIPTION_PARAM, 1000, result); - - // Can only set project on creation - if (existingActionPlan == null) { - checkProject(projectParam, result); - } - Date deadLine = checkAndReturnDeadline(deadLineParam, result); - - // TODO move this check in the service, on creation and update - if (!Strings.isNullOrEmpty(projectParam) && !Strings.isNullOrEmpty(name) && isActionPlanNameAvailable(existingActionPlan, name, projectParam)) { - result.addError(Result.Message.ofL10n("action_plans.same_name_in_same_project")); - } - - if (result.ok()) { - DefaultActionPlan actionPlan = DefaultActionPlan.create(name) - .setDescription(description) - .setUserLogin(userSession.getLogin()) - .setDeadLine(deadLine); - - // Can only set project on creation - if (existingActionPlan == null) { - actionPlan.setProjectKey(projectParam); - } else { - actionPlan.setProjectKey(existingActionPlan.projectKey()); - } - - result.set(actionPlan); - } - return result; - } - - private boolean isActionPlanNameAvailable(@Nullable DefaultActionPlan existingActionPlan, String name, String projectParam) { - return (existingActionPlan == null || !name.equals(existingActionPlan.name())) && actionPlanService.isNameAlreadyUsedForProject(name, projectParam); - } - - private void checkProject(String projectParam, Result<ActionPlan> result) { - if (Strings.isNullOrEmpty(projectParam)) { - result.addError(Result.Message.ofL10n(Validation.CANT_BE_EMPTY_MESSAGE, PROJECT_PARAM)); - } else { - ResourceDto project = resourceDao.selectResource(ResourceQuery.create().setKey(projectParam)); - if (project == null) { - result.addError(Result.Message.ofL10n("action_plans.errors.project_does_not_exist", projectParam)); - } - } - } - private static Date checkAndReturnDeadline(String deadLineParam, Result<ActionPlan> result) { Date deadLine = null; if (!Strings.isNullOrEmpty(deadLineParam)) { @@ -303,14 +165,6 @@ public class InternalRubyIssueService { return deadLine; } - private Result<ActionPlan> createResultForExistingActionPlan(String actionPlanKey) { - Result<ActionPlan> result = Result.of(); - if (findActionPlan(actionPlanKey) == null) { - result.addError(Result.Message.ofL10n(ACTION_PLANS_ERRORS_ACTION_PLAN_DOES_NOT_EXIST_MESSAGE, actionPlanKey)); - } - return result; - } - public List<String> listActions(String issueKey) { return actionService.listAvailableActions(issueKey); } @@ -492,25 +346,6 @@ public class InternalRubyIssueService { return issueBulkChangeService.execute(issueBulkChangeQuery, userSession); } - private static void checkMandatoryParameter(String value, String paramName, Result result) { - if (Strings.isNullOrEmpty(value)) { - result.addError(Result.Message.ofL10n(Validation.CANT_BE_EMPTY_MESSAGE, paramName)); - } - } - - private static void checkMandatorySizeParameter(String value, String paramName, Integer size, Result result) { - checkMandatoryParameter(value, paramName, result); - if (!Strings.isNullOrEmpty(value) && value.length() > size) { - result.addError(Result.Message.ofL10n(Validation.IS_TOO_LONG_MESSAGE, paramName, size)); - } - } - - private static void checkOptionalSizeParameter(String value, String paramName, Integer size, Result result) { - if (!Strings.isNullOrEmpty(value) && value.length() > size) { - result.addError(Result.Message.ofL10n(Validation.IS_TOO_LONG_MESSAGE, paramName, size)); - } - } - private static void checkOptionalSizeParameter(String value, String paramName, Integer size) { if (!Strings.isNullOrEmpty(value) && value.length() > size) { throw new BadRequestException(Validation.IS_TOO_LONG_MESSAGE, paramName, size); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java index 2abe464e468..447f7fd50bc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java @@ -31,7 +31,6 @@ import java.util.Map; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; -import org.sonar.api.issue.ActionPlan; import org.sonar.api.issue.Issue; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; @@ -51,7 +50,6 @@ import org.sonar.db.issue.IssueDto; import org.sonar.db.protobuf.DbFileSources; import org.sonar.db.rule.RuleDto; import org.sonar.server.exceptions.BadRequestException; -import org.sonar.server.issue.actionplan.ActionPlanService; import org.sonar.server.issue.index.IssueIndex; import org.sonar.server.issue.notification.IssueChangeNotification; import org.sonar.server.issue.workflow.IssueWorkflow; @@ -72,7 +70,6 @@ public class IssueService { private final IssueUpdater issueUpdater; private final IssueStorage issueStorage; private final NotificationManager notificationService; - private final ActionPlanService actionPlanService; private final UserFinder userFinder; private final UserIndex userIndex; private final SourceService sourceService; @@ -83,7 +80,6 @@ public class IssueService { IssueStorage issueStorage, IssueUpdater issueUpdater, NotificationManager notificationService, - ActionPlanService actionPlanService, UserFinder userFinder, UserIndex userIndex, SourceService sourceService, UserSession userSession) { this.dbClient = dbClient; @@ -91,7 +87,6 @@ public class IssueService { this.workflow = workflow; this.issueStorage = issueStorage; this.issueUpdater = issueUpdater; - this.actionPlanService = actionPlanService; this.notificationService = notificationService; this.userFinder = userFinder; this.userIndex = userIndex; @@ -187,31 +182,6 @@ public class IssueService { } } - //TODO to delete - public void plan(String issueKey, @Nullable String actionPlanKey) { - userSession.checkLoggedIn(); - - DbSession session = dbClient.openSession(false); - try { - ActionPlan actionPlan = null; - if (!Strings.isNullOrEmpty(actionPlanKey)) { - actionPlan = actionPlanService.findByKey(actionPlanKey, userSession); - if (actionPlan == null) { - throw new BadRequestException("Unknown action plan: " + actionPlanKey); - } - } - DefaultIssue issue = getByKeyForUpdate(session, issueKey).toDefaultIssue(); - - IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.getLogin()); - if (issueUpdater.plan(issue, actionPlan, context)) { - saveIssue(session, issue, context, null); - } - - } finally { - session.close(); - } - } - public void setSeverity(String issueKey, String severity) { userSession.checkLoggedIn(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/ActionPlanDeadlineComparator.java b/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/ActionPlanDeadlineComparator.java deleted file mode 100644 index e2bfb1c8b56..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/ActionPlanDeadlineComparator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue.actionplan; - -import java.io.Serializable; -import java.util.Comparator; -import java.util.Date; -import org.sonar.api.issue.ActionPlan; - -/** - * Sort action plans by chronological deadlines. Plans without deadline are - * located after plans with deadline. - */ -public class ActionPlanDeadlineComparator implements Comparator<ActionPlan>, Serializable { - - @Override - public int compare(ActionPlan a1, ActionPlan a2) { - Date d1 = a1.deadLine(); - Date d2 = a2.deadLine(); - if (d1 != null && d2 != null) { - return d1.compareTo(d2); - } - if (d1 != null) { - return -1; - } - return 1; - } -} diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/ActionPlanService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/ActionPlanService.java deleted file mode 100644 index f425dd87295..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/ActionPlanService.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue.actionplan; - -import com.google.common.base.Function; -import com.google.common.collect.Iterables; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import org.sonar.api.issue.ActionPlan; -import org.sonar.api.web.UserRole; -import org.sonar.core.issue.ActionPlanStats; -import org.sonar.core.issue.DefaultActionPlan; -import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.issue.IssueChangeContext; -import org.sonar.server.issue.IssueUpdater; -import org.sonar.db.DbClient; -import org.sonar.db.DbSession; -import org.sonar.db.component.ResourceDao; -import org.sonar.db.component.ResourceDto; -import org.sonar.db.component.ResourceQuery; -import org.sonar.db.issue.ActionPlanDao; -import org.sonar.db.issue.ActionPlanDto; -import org.sonar.db.issue.ActionPlanStatsDao; -import org.sonar.db.issue.ActionPlanStatsDto; -import org.sonar.db.issue.IssueDto; -import org.sonar.server.exceptions.NotFoundException; -import org.sonar.server.issue.IssueStorage; -import org.sonar.server.user.UserSession; - -import static com.google.common.collect.Lists.newArrayList; - -public class ActionPlanService { - - private final DbClient dbClient; - - private final ActionPlanDao actionPlanDao; - private final ActionPlanStatsDao actionPlanStatsDao; - private final ResourceDao resourceDao; - private final IssueUpdater issueUpdater; - private final IssueStorage issueStorage; - - public ActionPlanService(DbClient dbClient, ActionPlanDao actionPlanDao, ActionPlanStatsDao actionPlanStatsDao, ResourceDao resourceDao, - IssueUpdater issueUpdater, IssueStorage issueStorage) { - this.dbClient = dbClient; - this.actionPlanDao = actionPlanDao; - this.actionPlanStatsDao = actionPlanStatsDao; - this.resourceDao = resourceDao; - this.issueUpdater = issueUpdater; - this.issueStorage = issueStorage; - } - - public ActionPlan create(ActionPlan actionPlan, UserSession userSession) { - ResourceDto project = findProject(actionPlan.projectKey()); - checkUserIsProjectAdministrator(project.getKey(), userSession); - actionPlanDao.save(ActionPlanDto.toActionDto(actionPlan, project.getId())); - return actionPlan; - } - - public ActionPlan update(ActionPlan actionPlan, UserSession userSession) { - ResourceDto project = findProject(actionPlan.projectKey()); - checkUserIsProjectAdministrator(project.getKey(), userSession); - actionPlanDao.update(ActionPlanDto.toActionDto(actionPlan, project.getId())); - return actionPlan; - } - - public void delete(String actionPlanKey, UserSession userSession) { - ActionPlanDto dto = findActionPlanDto(actionPlanKey); - checkUserIsProjectAdministrator(dto.getProjectKey(), userSession); - unplanIssues(dto.toActionPlan(), userSession); - actionPlanDao.delete(actionPlanKey); - } - - /** - * Unplan all issues linked to an action plan - */ - private void unplanIssues(DefaultActionPlan actionPlan, UserSession userSession) { - List<IssueDto> dtos = findIssuesByActionPlan(actionPlan.key()); - IssueChangeContext context = IssueChangeContext.createUser(new Date(), userSession.getLogin()); - List<DefaultIssue> issues = newArrayList(); - for (IssueDto issueDto : dtos) { - DefaultIssue issue = issueDto.toDefaultIssue(); - // Unplan issue - if (issueUpdater.plan(issue, null, context)) { - issues.add(issue); - } - } - // Save all issues - issueStorage.save(issues); - } - - private List<IssueDto> findIssuesByActionPlan(String actionPlanKey) { - DbSession session = dbClient.openSession(false); - try { - return dbClient.issueDao().selectByActionPlan(session, actionPlanKey); - } finally { - session.close(); - } - } - - public ActionPlan setStatus(String actionPlanKey, String status, UserSession userSession) { - ActionPlanDto actionPlanDto = findActionPlanDto(actionPlanKey); - checkUserIsProjectAdministrator(actionPlanDto.getProjectKey(), userSession); - - actionPlanDto.setStatus(status); - actionPlanDto.setCreatedAt(new Date()); - actionPlanDao.update(actionPlanDto); - return actionPlanDto.toActionPlan(); - } - - @CheckForNull - public ActionPlan findByKey(String key, UserSession userSession) { - ActionPlanDto actionPlanDto = actionPlanDao.selectByKey(key); - if (actionPlanDto == null) { - return null; - } - checkUserCanAccessProject(actionPlanDto.getProjectKey(), userSession); - return actionPlanDto.toActionPlan(); - } - - public List<ActionPlan> findByKeys(Collection<String> keys) { - List<ActionPlanDto> actionPlanDtos = actionPlanDao.selectByKeys(keys); - return toActionPlans(actionPlanDtos); - } - - public Collection<ActionPlan> findOpenByProjectKey(String projectKey, UserSession userSession) { - ResourceDto project = findProject(projectKey); - checkUserCanAccessProject(project.getKey(), userSession); - - List<ActionPlanDto> dtos = actionPlanDao.selectOpenByProjectId(project.getId()); - List<ActionPlan> plans = toActionPlans(dtos); - Collections.sort(plans, new ActionPlanDeadlineComparator()); - return plans; - } - - public List<ActionPlanStats> findActionPlanStats(String projectKey, UserSession userSession) { - ResourceDto project = findProject(projectKey); - checkUserCanAccessProject(project.getKey(), userSession); - - List<ActionPlanStatsDto> actionPlanStatsDtos = actionPlanStatsDao.selectByProjectId(project.getId()); - List<ActionPlanStats> actionPlanStats = newArrayList(Iterables.transform(actionPlanStatsDtos, ToActionPlanStats.INSTANCE)); - Collections.sort(actionPlanStats, new ActionPlanDeadlineComparator()); - return actionPlanStats; - } - - public boolean isNameAlreadyUsedForProject(String name, String projectKey) { - return !actionPlanDao.selectByNameAndProjectId(name, findProject(projectKey).getId()).isEmpty(); - } - - private static List<ActionPlan> toActionPlans(List<ActionPlanDto> actionPlanDtos) { - return newArrayList(Iterables.transform(actionPlanDtos, ToActionPlan.INSTANCE)); - } - - private ActionPlanDto findActionPlanDto(String actionPlanKey) { - ActionPlanDto actionPlanDto = actionPlanDao.selectByKey(actionPlanKey); - if (actionPlanDto == null) { - throw new NotFoundException("Action plan " + actionPlanKey + " has not been found."); - } - return actionPlanDto; - } - - private ResourceDto findProject(String projectKey) { - ResourceDto resourceDto = resourceDao.selectResource(ResourceQuery.create().setKey(projectKey)); - if (resourceDto == null) { - throw new NotFoundException("Project " + projectKey + " does not exists."); - } - return resourceDto; - } - - private static void checkUserCanAccessProject(String projectKey, UserSession userSession) { - userSession.checkComponentPermission(UserRole.USER, projectKey); - } - - private static void checkUserIsProjectAdministrator(String projectKey, UserSession userSession) { - userSession.checkComponentPermission(UserRole.ADMIN, projectKey); - } - - private enum ToActionPlanStats implements Function<ActionPlanStatsDto, ActionPlanStats> { - INSTANCE; - - @Override - public ActionPlanStats apply(@Nonnull ActionPlanStatsDto actionPlanStatsDto) { - return actionPlanStatsDto.toActionPlanStat(); - } - } - - private enum ToActionPlan implements Function<ActionPlanDto, ActionPlan> { - INSTANCE; - - @Override - public ActionPlan apply(@Nonnull ActionPlanDto actionPlanDto) { - return actionPlanDto.toActionPlan(); - } - } -} diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/package-info.java deleted file mode 100644 index d21b7c882a2..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/actionplan/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue.actionplan; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java index 71d1d9c8a59..56a3949a793 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java @@ -44,7 +44,6 @@ import org.sonarqube.ws.client.issue.IssueFilterParameters; import static com.google.common.collect.Lists.newArrayList; import static org.sonar.server.issue.ws.SearchAdditionalField.ACTIONS; -import static org.sonar.server.issue.ws.SearchAdditionalField.DEPRECATED_ACTION_PLANS; import static org.sonar.server.issue.ws.SearchAdditionalField.COMMENTS; import static org.sonar.server.issue.ws.SearchAdditionalField.RULES; import static org.sonar.server.issue.ws.SearchAdditionalField.TRANSITIONS; @@ -171,7 +170,6 @@ public class SearchResponseLoader { for (IssueDto issue : issues) { componentUuids.add(issue.getComponentUuid()); projectUuids.add(issue.getProjectUuid()); - add(DEPRECATED_ACTION_PLANS, issue.getActionPlanKey()); add(RULES, issue.getRuleKey()); add(USERS, issue.getReporter()); add(USERS, issue.getAssignee()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java b/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java index bbfa2e2777f..a8c2c2931c2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java @@ -39,7 +39,7 @@ import org.sonar.server.view.index.ViewIndexDefinition; public class BackendCleanup { private static final String[] INSPECTION_TABLES = { - "action_plans", "authors", "duplications_index", "events", "issues", "issue_changes", "manual_measures", + "authors", "duplications_index", "events", "issues", "issue_changes", "manual_measures", "notifications", "project_links", "project_measures", "projects", "resource_index", "snapshots", "file_sources" }; diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 673e1f70a24..9d4049e3817 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -111,13 +111,11 @@ import org.sonar.server.issue.IssueCommentService; import org.sonar.server.issue.IssueQueryService; import org.sonar.server.issue.IssueService; import org.sonar.server.issue.IssueUpdater; -import org.sonar.server.issue.PlanAction; import org.sonar.server.issue.RemoveTagsAction; import org.sonar.server.issue.ServerIssueStorage; import org.sonar.server.issue.SetSeverityAction; import org.sonar.server.issue.SetTypeAction; import org.sonar.server.issue.TransitionAction; -import org.sonar.server.issue.actionplan.ActionPlanService; import org.sonar.server.issue.filter.IssueFilterWsModule; import org.sonar.server.issue.index.IssueAuthorizationIndexer; import org.sonar.server.issue.index.IssueIndexDefinition; @@ -599,13 +597,9 @@ public class PlatformLevel4 extends PlatformLevel { IssueFilterWsModule.class, - // action plan - ActionPlanService.class, - // issues actions AssignAction.class, SetTypeAction.class, - PlanAction.class, SetSeverityAction.class, CommentAction.class, TransitionAction.class, diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/UpdateConflictResolverTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/UpdateConflictResolverTest.java index 1edc23c7a54..bcb05322f49 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/UpdateConflictResolverTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/UpdateConflictResolverTest.java @@ -106,7 +106,6 @@ public class UpdateConflictResolverTest { .setResolution(Issue.RESOLUTION_FALSE_POSITIVE) .setStatus(Issue.STATUS_RESOLVED) .setAssignee("arthur") - .setActionPlanKey("PLAN-2") .setSeverity(Severity.MAJOR) .setManualSeverity(false); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java index cb8825b47db..eea298e8d9f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ActionServiceTest.java @@ -77,13 +77,13 @@ public class ActionServiceTest { @Test public void return_provided_actions_without_set_severity_when_not_issue_admin() { - assertThat(underTest.listAvailableActions(issue.toDefaultIssue())).containsOnly("comment", "assign", "set_tags", "set_type", "assign_to_me", "plan"); + assertThat(underTest.listAvailableActions(issue.toDefaultIssue())).containsOnly("comment", "assign", "set_tags", "set_type", "assign_to_me"); } @Test public void return_provided_actions_with_set_severity_when_issue_admin() { userSession.addProjectUuidPermissions(ISSUE_ADMIN, PROJECT_UUID); - assertThat(underTest.listAvailableActions(issue.toDefaultIssue())).containsOnly("comment", "assign", "set_tags", "set_type", "assign_to_me", "plan", "set_severity"); + assertThat(underTest.listAvailableActions(issue.toDefaultIssue())).containsOnly("comment", "assign", "set_tags", "set_type", "assign_to_me", "set_severity"); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java index 03fa3fddcfc..0a4c0187a38 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/InternalRubyIssueServiceTest.java @@ -29,11 +29,9 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.sonar.api.issue.ActionPlan; import org.sonar.api.issue.Issue; import org.sonar.api.user.User; import org.sonar.api.web.UserRole; -import org.sonar.core.issue.DefaultActionPlan; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.FieldDiffs; import org.sonar.db.component.ResourceDao; @@ -43,7 +41,6 @@ import org.sonar.db.issue.IssueFilterDto; import org.sonar.server.es.SearchOptions; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.Message; -import org.sonar.server.issue.actionplan.ActionPlanService; import org.sonar.server.issue.filter.IssueFilterService; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.user.ThreadLocalUserSession; @@ -56,7 +53,6 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -73,8 +69,6 @@ public class InternalRubyIssueServiceTest { IssueChangelogService changelogService; - ActionPlanService actionPlanService; - ResourceDao resourceDao; IssueFilterService issueFilterService; @@ -91,7 +85,6 @@ public class InternalRubyIssueServiceTest { issueQueryService = mock(IssueQueryService.class); commentService = mock(IssueCommentService.class); changelogService = mock(IssueChangelogService.class); - actionPlanService = mock(ActionPlanService.class); resourceDao = mock(ResourceDao.class); issueFilterService = mock(IssueFilterService.class); issueBulkChangeService = mock(IssueBulkChangeService.class); @@ -100,7 +93,7 @@ public class InternalRubyIssueServiceTest { ResourceDto project = new ResourceDto().setKey("org.sonar.Sample"); when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(project); - service = new InternalRubyIssueService(issueService, issueQueryService, commentService, changelogService, actionPlanService, resourceDao, + service = new InternalRubyIssueService(issueService, issueQueryService, commentService, changelogService, issueFilterService, issueBulkChangeService, actionService, userSessionRule); } @@ -141,223 +134,6 @@ public class InternalRubyIssueServiceTest { } @Test - public void create_action_plan() { - Map<String, String> parameters = newHashMap(); - parameters.put("name", "Long term"); - parameters.put("description", "Long term issues"); - parameters.put("project", "org.sonar.Sample"); - parameters.put("deadLine", "2113-05-13"); - - Result result = service.createActionPlan(parameters); - assertThat(result.ok()).isTrue(); - - ArgumentCaptor<ActionPlan> actionPlanCaptor = ArgumentCaptor.forClass(ActionPlan.class); - verify(actionPlanService).create(actionPlanCaptor.capture(), any(ThreadLocalUserSession.class)); - ActionPlan actionPlan = actionPlanCaptor.getValue(); - - assertThat(actionPlan).isNotNull(); - assertThat(actionPlan.key()).isNotNull(); - assertThat(actionPlan.name()).isEqualTo("Long term"); - assertThat(actionPlan.description()).isEqualTo("Long term issues"); - assertThat(actionPlan.deadLine()).isNotNull(); - } - - @Test - public void update_action_plan() { - when(actionPlanService.findByKey(eq("ABCD"), any(ThreadLocalUserSession.class))).thenReturn(DefaultActionPlan.create("Long term")); - - Map<String, String> parameters = newHashMap(); - parameters.put("name", "New Long term"); - parameters.put("description", "New Long term issues"); - parameters.put("deadLine", "2113-05-13"); - parameters.put("project", "org.sonar.MultiSample"); - - Result result = service.updateActionPlan("ABCD", parameters); - assertThat(result.ok()).isTrue(); - - ArgumentCaptor<ActionPlan> actionPlanCaptor = ArgumentCaptor.forClass(ActionPlan.class); - verify(actionPlanService).update(actionPlanCaptor.capture(), any(ThreadLocalUserSession.class)); - ActionPlan actionPlan = actionPlanCaptor.getValue(); - - assertThat(actionPlan).isNotNull(); - assertThat(actionPlan.key()).isNotNull(); - assertThat(actionPlan.name()).isEqualTo("New Long term"); - assertThat(actionPlan.description()).isEqualTo("New Long term issues"); - assertThat(actionPlan.deadLine()).isNotNull(); - } - - @Test - public void update_action_plan_with_new_project() { - when(actionPlanService.findByKey(eq("ABCD"), any(ThreadLocalUserSession.class))).thenReturn(DefaultActionPlan.create("Long term").setProjectKey("org.sonar.MultiSample")); - - Map<String, String> parameters = newHashMap(); - parameters.put("name", "New Long term"); - parameters.put("description", "New Long term issues"); - parameters.put("deadLine", "2113-05-13"); - - ArgumentCaptor<ActionPlan> actionPlanCaptor = ArgumentCaptor.forClass(ActionPlan.class); - Result result = service.updateActionPlan("ABCD", parameters); - assertThat(result.ok()).isTrue(); - - verify(actionPlanService).update(actionPlanCaptor.capture(), any(ThreadLocalUserSession.class)); - ActionPlan actionPlan = actionPlanCaptor.getValue(); - - assertThat(actionPlan).isNotNull(); - assertThat(actionPlan.key()).isNotNull(); - assertThat(actionPlan.name()).isEqualTo("New Long term"); - assertThat(actionPlan.description()).isEqualTo("New Long term issues"); - assertThat(actionPlan.deadLine()).isNotNull(); - assertThat(actionPlan.projectKey()).isEqualTo("org.sonar.MultiSample"); - } - - @Test - public void not_update_action_plan_when_action_plan_is_not_found() { - when(actionPlanService.findByKey(eq("ABCD"), any(ThreadLocalUserSession.class))).thenReturn(null); - - Result result = service.updateActionPlan("ABCD", null); - assertThat(result.ok()).isFalse(); - assertThat(result.errors()).contains(Result.Message.ofL10n("action_plans.errors.action_plan_does_not_exist", "ABCD")); - } - - @Test - public void delete_action_plan() { - when(actionPlanService.findByKey(eq("ABCD"), any(ThreadLocalUserSession.class))).thenReturn(DefaultActionPlan.create("Long term")); - - Result result = service.deleteActionPlan("ABCD"); - verify(actionPlanService).delete(eq("ABCD"), any(ThreadLocalUserSession.class)); - assertThat(result.ok()).isTrue(); - } - - @Test - public void not_delete_action_plan_if_action_plan_not_found() { - when(actionPlanService.findByKey(eq("ABCD"), any(ThreadLocalUserSession.class))).thenReturn(null); - - Result result = service.deleteActionPlan("ABCD"); - verify(actionPlanService, never()).delete(eq("ABCD"), any(ThreadLocalUserSession.class)); - assertThat(result.ok()).isFalse(); - assertThat(result.errors()).contains(Result.Message.ofL10n("action_plans.errors.action_plan_does_not_exist", "ABCD")); - } - - @Test - public void close_action_plan() { - when(actionPlanService.findByKey(eq("ABCD"), any(ThreadLocalUserSession.class))).thenReturn(DefaultActionPlan.create("Long term")); - - Result result = service.closeActionPlan("ABCD"); - verify(actionPlanService).setStatus(eq("ABCD"), eq("CLOSED"), any(ThreadLocalUserSession.class)); - assertThat(result.ok()).isTrue(); - } - - @Test - public void open_action_plan() { - when(actionPlanService.findByKey(eq("ABCD"), any(ThreadLocalUserSession.class))).thenReturn(DefaultActionPlan.create("Long term")); - - Result result = service.openActionPlan("ABCD"); - verify(actionPlanService).setStatus(eq("ABCD"), eq("OPEN"), any(ThreadLocalUserSession.class)); - assertThat(result.ok()).isTrue(); - } - - @Test - public void get_error_on_action_plan_result_when_no_project() { - Map<String, String> parameters = newHashMap(); - parameters.put("name", "Long term"); - parameters.put("description", "Long term issues"); - - Result result = service.createActionPlanResult(parameters); - assertThat(result.ok()).isFalse(); - assertThat(result.errors()).contains(Result.Message.ofL10n("errors.cant_be_empty", "project")); - } - - @Test - public void get_error_on_action_plan_result_when_no_name() { - Map<String, String> parameters = newHashMap(); - parameters.put("name", null); - parameters.put("description", "Long term issues"); - parameters.put("project", "org.sonar.Sample"); - - Result result = service.createActionPlanResult(parameters); - assertThat(result.ok()).isFalse(); - assertThat(result.errors()).contains(Result.Message.ofL10n("errors.cant_be_empty", "name")); - } - - @Test - public void get_error_on_action_plan_result_when_name_is_too_long() { - Map<String, String> parameters = newHashMap(); - parameters.put("name", createLongString(201)); - parameters.put("description", "Long term issues"); - parameters.put("project", "org.sonar.Sample"); - - Result result = service.createActionPlanResult(parameters); - assertThat(result.ok()).isFalse(); - assertThat(result.errors()).contains(Result.Message.ofL10n("errors.is_too_long", "name", 200)); - } - - @Test - public void get_error_on_action_plan_result_when_description_is_too_long() { - Map<String, String> parameters = newHashMap(); - parameters.put("name", "Long term"); - parameters.put("description", createLongString(1001)); - parameters.put("project", "org.sonar.Sample"); - - Result result = service.createActionPlanResult(parameters); - assertThat(result.ok()).isFalse(); - assertThat(result.errors()).contains(Result.Message.ofL10n("errors.is_too_long", "description", 1000)); - } - - @Test - public void get_error_on_action_plan_result_when_dead_line_use_wrong_format() { - Map<String, String> parameters = newHashMap(); - parameters.put("name", "Long term"); - parameters.put("description", "Long term issues"); - parameters.put("project", "org.sonar.Sample"); - parameters.put("deadLine", "18/05/2013"); - - Result result = service.createActionPlanResult(parameters); - assertThat(result.ok()).isFalse(); - assertThat(result.errors()).contains(Result.Message.ofL10n("errors.is_not_valid", "date")); - } - - @Test - public void get_error_on_action_plan_result_when_dead_line_is_in_the_past() { - Map<String, String> parameters = newHashMap(); - parameters.put("name", "Long term"); - parameters.put("description", "Long term issues"); - parameters.put("project", "org.sonar.Sample"); - parameters.put("deadLine", "2000-01-01"); - - Result result = service.createActionPlanResult(parameters); - assertThat(result.ok()).isFalse(); - assertThat(result.errors()).contains(Result.Message.ofL10n("action_plans.date_cant_be_in_past")); - } - - @Test - public void get_error_on_action_plan_result_when_name_is_already_used_for_project() { - Map<String, String> parameters = newHashMap(); - parameters.put("name", "Long term"); - parameters.put("description", "Long term issues"); - parameters.put("project", "org.sonar.Sample"); - - when(actionPlanService.isNameAlreadyUsedForProject(anyString(), anyString())).thenReturn(true); - - Result result = service.createActionPlanResult(parameters, DefaultActionPlan.create("Short term")); - assertThat(result.ok()).isFalse(); - assertThat(result.errors()).contains(Result.Message.ofL10n("action_plans.same_name_in_same_project")); - } - - @Test - public void get_error_on_action_plan_result_when_project_not_found() { - Map<String, String> parameters = newHashMap(); - parameters.put("name", "Long term"); - parameters.put("description", "Long term issues"); - parameters.put("project", "org.sonar.Sample"); - - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(null); - - Result result = service.createActionPlanResult(parameters); - assertThat(result.ok()).isFalse(); - assertThat(result.errors()).contains(Result.Message.ofL10n("action_plans.errors.project_does_not_exist", "org.sonar.Sample")); - } - - @Test public void test_changelog_from_issue_key() throws Exception { IssueChangelog changelog = new IssueChangelog(Collections.<FieldDiffs>emptyList(), Collections.<User>emptyList()); when(changelogService.changelog(eq("ABCDE"))).thenReturn(changelog); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/actionplan/ActionPlanDeadlineComparatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/actionplan/ActionPlanDeadlineComparatorTest.java deleted file mode 100644 index 8cc09c1e9c4..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/actionplan/ActionPlanDeadlineComparatorTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue.actionplan; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import org.junit.Test; -import org.sonar.api.issue.ActionPlan; -import org.sonar.api.utils.DateUtils; -import org.sonar.core.issue.DefaultActionPlan; - -import static org.assertj.core.api.Assertions.assertThat; - -public class ActionPlanDeadlineComparatorTest { - - ActionPlan shortTerm = new DefaultActionPlan().setDeadLine(DateUtils.parseDate("2013-12-01")); - ActionPlan longTerm = new DefaultActionPlan().setDeadLine(DateUtils.parseDate("2018-05-05")); - ActionPlan noDeadline = new DefaultActionPlan().setDeadLine(null); - - @Test - public void compare_plans_with_deadlines() { - List<ActionPlan> plans = Arrays.asList(shortTerm, longTerm); - Collections.sort(plans, new ActionPlanDeadlineComparator()); - assertThat(plans).containsSequence(shortTerm, longTerm); - - plans = Arrays.asList(longTerm, shortTerm); - Collections.sort(plans, new ActionPlanDeadlineComparator()); - assertThat(plans).containsSequence(shortTerm, longTerm); - } - - @Test - public void end_with_plans_without_deadline() { - List<ActionPlan> plans = Arrays.asList(noDeadline, longTerm, shortTerm); - Collections.sort(plans, new ActionPlanDeadlineComparator()); - assertThat(plans).containsSequence(shortTerm, longTerm, noDeadline); - - plans = Arrays.asList(longTerm, noDeadline, shortTerm); - Collections.sort(plans, new ActionPlanDeadlineComparator()); - assertThat(plans).containsSequence(shortTerm, longTerm, noDeadline); - } -} diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/actionplan/ActionPlanServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/actionplan/ActionPlanServiceTest.java deleted file mode 100644 index 4f767dce4f6..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/actionplan/ActionPlanServiceTest.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue.actionplan; - -import java.util.Collection; -import java.util.Date; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.sonar.api.issue.ActionPlan; -import org.sonar.api.issue.Issue; -import org.sonar.api.rules.RuleType; -import org.sonar.api.web.UserRole; -import org.sonar.core.issue.ActionPlanStats; -import org.sonar.core.issue.DefaultActionPlan; -import org.sonar.core.issue.DefaultIssue; -import org.sonar.core.issue.IssueChangeContext; -import org.sonar.db.DbClient; -import org.sonar.db.DbSession; -import org.sonar.db.component.ResourceDao; -import org.sonar.db.component.ResourceDto; -import org.sonar.db.component.ResourceQuery; -import org.sonar.db.issue.ActionPlanDao; -import org.sonar.db.issue.ActionPlanDto; -import org.sonar.db.issue.ActionPlanStatsDao; -import org.sonar.db.issue.ActionPlanStatsDto; -import org.sonar.db.issue.IssueDao; -import org.sonar.db.issue.IssueDto; -import org.sonar.server.exceptions.ForbiddenException; -import org.sonar.server.exceptions.NotFoundException; -import org.sonar.server.issue.IssueStorage; -import org.sonar.server.issue.IssueUpdater; -import org.sonar.server.tester.MockUserSession; -import org.sonar.server.user.UserSession; - -import static com.google.common.collect.Lists.newArrayList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -@RunWith(MockitoJUnitRunner.class) -public class ActionPlanServiceTest { - - @Mock - DbClient dbClient; - - @Mock - DbSession session; - - @Mock - ActionPlanDao actionPlanDao; - - @Mock - ActionPlanStatsDao actionPlanStatsDao; - - @Mock - ResourceDao resourceDao; - - @Mock - IssueDao issueDao; - - @Mock - IssueUpdater issueUpdater; - - @Mock - IssueStorage issueStorage; - - static final String PROJECT_KEY = "org.sonar.Sample"; - static final String PROJECT_UUID = "ABCD"; - - UserSession projectAdministratorUserSession = new MockUserSession("nicolas").setName("Nicolas").addProjectPermissions(UserRole.ADMIN, PROJECT_KEY); - UserSession projectUserSession = new MockUserSession("nicolas").setName("Nicolas").addProjectPermissions(UserRole.USER, PROJECT_KEY); - UserSession unauthorizedUserSession = new MockUserSession("nicolas").setName("Nicolas"); - - private ActionPlanService actionPlanService; - - @Before - public void before() { - when(dbClient.openSession(false)).thenReturn(session); - when(dbClient.issueDao()).thenReturn(issueDao); - actionPlanService = new ActionPlanService(dbClient, actionPlanDao, actionPlanStatsDao, resourceDao, issueUpdater, issueStorage); - } - - @Test - public void create() { - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(PROJECT_KEY).setUuid(PROJECT_UUID).setId(1l)); - ActionPlan actionPlan = DefaultActionPlan.create("Long term"); - - actionPlanService.create(actionPlan, projectAdministratorUserSession); - verify(actionPlanDao).save(any(ActionPlanDto.class)); - } - - @Test - public void create_required_admin_role() { - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(PROJECT_KEY).setId(1l)); - ActionPlan actionPlan = DefaultActionPlan.create("Long term"); - - try { - actionPlanService.create(actionPlan, unauthorizedUserSession); - fail(); - } catch (Exception e) { - assertThat(e).isInstanceOf(ForbiddenException.class); - } - verifyZeroInteractions(actionPlanDao); - } - - @Test - public void set_status() { - when(actionPlanDao.selectByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(PROJECT_KEY)); - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(PROJECT_KEY).setId(1l)); - - ActionPlan result = actionPlanService.setStatus("ABCD", "CLOSED", projectAdministratorUserSession); - verify(actionPlanDao).update(any(ActionPlanDto.class)); - - assertThat(result).isNotNull(); - assertThat(result.status()).isEqualTo("CLOSED"); - } - - @Test - public void update() { - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(PROJECT_KEY).setId(1l)); - ActionPlan actionPlan = DefaultActionPlan.create("Long term"); - - actionPlanService.update(actionPlan, projectAdministratorUserSession); - verify(actionPlanDao).update(any(ActionPlanDto.class)); - } - - @Test - public void delete() { - when(actionPlanDao.selectByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(PROJECT_KEY)); - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(PROJECT_KEY).setId(1l)); - actionPlanService.delete("ABCD", projectAdministratorUserSession); - verify(actionPlanDao).delete("ABCD"); - } - - @Test - public void unplan_all_linked_issues_when_deleting_an_action_plan() { - when(actionPlanDao.selectByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(PROJECT_KEY)); - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(PROJECT_KEY).setId(1l)); - - IssueDto issueDto = new IssueDto().setId(100L).setStatus(Issue.STATUS_OPEN).setRuleKey("squid", "s100").setIssueCreationDate(new Date()).setType(RuleType.BUG); - when(issueDao.selectByActionPlan(session, "ABCD")).thenReturn(newArrayList(issueDto)); - when(issueUpdater.plan(any(DefaultIssue.class), eq((ActionPlan) null), any(IssueChangeContext.class))).thenReturn(true); - - ArgumentCaptor<DefaultIssue> captor = ArgumentCaptor.forClass(DefaultIssue.class); - actionPlanService.delete("ABCD", projectAdministratorUserSession); - verify(actionPlanDao).delete("ABCD"); - verify(issueUpdater).plan(captor.capture(), eq((ActionPlan) null), any(IssueChangeContext.class)); - verify(issueStorage).save(newArrayList(captor.getAllValues())); - } - - @Test - public void find_by_key() { - when(actionPlanDao.selectByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(PROJECT_KEY)); - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(PROJECT_KEY).setId(1l)); - - ActionPlan result = actionPlanService.findByKey("ABCD", projectUserSession); - assertThat(result).isNotNull(); - assertThat(result.key()).isEqualTo("ABCD"); - } - - @Test - public void return_null_if_no_action_plan_when_find_by_key() { - when(actionPlanDao.selectByKey("ABCD")).thenReturn(null); - assertThat(actionPlanService.findByKey("ABCD", projectUserSession)).isNull(); - } - - @Test - public void find_by_keys() { - when(actionPlanDao.selectByKeys(newArrayList("ABCD"))).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD"))); - Collection<ActionPlan> results = actionPlanService.findByKeys(newArrayList("ABCD")); - assertThat(results).hasSize(1); - assertThat(results.iterator().next().key()).isEqualTo("ABCD"); - } - - @Test - public void find_open_by_project_key() { - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(PROJECT_KEY).setId(1l)); - when(actionPlanDao.selectOpenByProjectId(1l)).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD"))); - Collection<ActionPlan> results = actionPlanService.findOpenByProjectKey(PROJECT_KEY, projectUserSession); - assertThat(results).hasSize(1); - assertThat(results.iterator().next().key()).isEqualTo("ABCD"); - } - - @Test - public void find_open_by_project_key_required_user_role() { - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(PROJECT_KEY).setId(1l)); - when(actionPlanDao.selectOpenByProjectId(1l)).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD"))); - - try { - actionPlanService.findOpenByProjectKey(PROJECT_KEY, unauthorizedUserSession); - fail(); - } catch (Exception e) { - assertThat(e).isInstanceOf(ForbiddenException.class); - } - verifyZeroInteractions(actionPlanDao); - } - - @Test(expected = NotFoundException.class) - public void throw_exception_if_project_not_found_when_find_open_by_project_key() { - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(null); - actionPlanService.findOpenByProjectKey("<Unkown>", projectUserSession); - } - - @Test - public void find_action_plan_stats() { - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setId(1L).setKey(PROJECT_KEY)); - when(actionPlanStatsDao.selectByProjectId(1L)).thenReturn(newArrayList(new ActionPlanStatsDto())); - - Collection<ActionPlanStats> results = actionPlanService.findActionPlanStats(PROJECT_KEY, projectUserSession); - assertThat(results).hasSize(1); - } - - @Test(expected = NotFoundException.class) - public void throw_exception_if_project_not_found_when_find_open_action_plan_stats() { - when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(null); - - actionPlanService.findActionPlanStats(PROJECT_KEY, projectUserSession); - } - -} diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java index 088ccde0a45..91fcecbd36d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java @@ -129,7 +129,6 @@ public class SearchActionMediumTest { .setAuthorLogin("John") .setAssignee("simon") .setReporter("fabrice") - .setActionPlanKey("AP-ABCD") .setTags(asList("bug", "owasp")) .setIssueCreationDate(DateUtils.parseDateTime("2014-09-04T00:00:00+0100")) .setIssueUpdateDate(DateUtils.parseDateTime("2017-12-04T00:00:00+0100")); diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/action_plan.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/action_plan.rb deleted file mode 100644 index 78cd2923629..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/action_plan.rb +++ /dev/null @@ -1,39 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2014 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube 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. -# -# SonarQube 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. -# - -class ActionPlan - - def self.to_hash(action_plan) - hash = {:key => action_plan.key(), :name => action_plan.name(), :status => action_plan.status()} - hash[:project] = action_plan.projectKey() if action_plan.projectKey() && !action_plan.projectKey().blank? - hash[:desc] = action_plan.description() if action_plan.description() && !action_plan.description().blank? - hash[:userLogin] = action_plan.userLogin() if action_plan.userLogin() - hash[:deadLine] = Api::Utils.format_datetime(action_plan.deadLine()) if action_plan.deadLine() - hash[:fDeadLine] = Api::Utils.format_localized_date(action_plan.deadLine()) if action_plan.deadLine() - hash[:totalIssues] = action_plan.totalIssues() if action_plan.respond_to?('totalIssues') - hash[:unresolvedIssues] = action_plan.unresolvedIssues() if action_plan.respond_to?('unresolvedIssues') - hash[:createdAt] = Api::Utils.format_datetime(action_plan.createdAt()) if action_plan.createdAt() - hash[:fCreatedAt] = Api::Utils.format_localized_date(action_plan.createdAt()) if action_plan.createdAt() - hash[:updatedAt] = Api::Utils.format_datetime(action_plan.updatedAt()) if action_plan.updatedAt() - hash[:fUpdatedAt] = Api::Utils.format_localized_date(action_plan.updatedAt()) if action_plan.updatedAt() - hash - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/issue.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/issue.rb index 9904bf4dfdc..2ecd2c7bded 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/issue.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/issue.rb @@ -39,7 +39,6 @@ class Issue hash[:reporter] = issue.reporter if issue.reporter hash[:assignee] = issue.assignee if issue.assignee hash[:author] = issue.authorLogin if issue.authorLogin - hash[:actionPlan] = issue.actionPlanKey if issue.actionPlanKey hash[:creationDate] = Api::Utils.format_datetime(issue.creationDate) if issue.creationDate hash[:updateDate] = Api::Utils.format_datetime(issue.updateDate) if issue.updateDate hash[:fUpdateAge] = Api::Utils.age_from_now(issue.updateDate) if issue.updateDate diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1121_drop_table_action_plans.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1121_drop_table_action_plans.rb new file mode 100644 index 00000000000..4d7593908e1 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1121_drop_table_action_plans.rb @@ -0,0 +1,30 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube 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. +# +# SonarQube 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. +# +# +# SonarQube 5.5 +# SONAR-7466 +class DropTableActionPlans < ActiveRecord::Migration + + def self.up + drop_table 'action_plans' + end + +end + diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1122_remove_issue_action_plan_index.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1122_remove_issue_action_plan_index.rb new file mode 100644 index 00000000000..1c415e7ce29 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1122_remove_issue_action_plan_index.rb @@ -0,0 +1,30 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube 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. +# +# SonarQube 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. +# +# +# SonarQube 5.5 +# SONAR-7466 +class RemoveIssueActionPlanIndex < ActiveRecord::Migration + + def self.up + remove_index :issues, :name => 'issues_action_plan_key' + end + +end + diff --git a/sonar-db/src/main/java/org/sonar/core/issue/ActionPlanStats.java b/sonar-db/src/main/java/org/sonar/core/issue/ActionPlanStats.java deleted file mode 100644 index 0704154c9d5..00000000000 --- a/sonar-db/src/main/java/org/sonar/core/issue/ActionPlanStats.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.core.issue; - -import java.util.Date; -import org.sonar.api.issue.ActionPlan; -import org.sonar.core.util.Uuids; - -public class ActionPlanStats extends DefaultActionPlan { - - private int totalIssues; - private int unresolvedIssues; - - private ActionPlanStats() { - - } - - public static ActionPlanStats create(String name) { - ActionPlanStats actionPlan = new ActionPlanStats(); - actionPlan.setKey(Uuids.create()); - Date now = new Date(); - actionPlan.setName(name); - actionPlan.setStatus(ActionPlan.STATUS_OPEN); - actionPlan.setCreatedAt(now).setUpdatedAt(now); - return actionPlan; - } - - public int totalIssues() { - return totalIssues; - } - - public ActionPlanStats setTotalIssues(int totalIssues) { - this.totalIssues = totalIssues; - return this; - } - - public int unresolvedIssues() { - return unresolvedIssues; - } - - public ActionPlanStats setUnresolvedIssues(int unresolvedIssues) { - this.unresolvedIssues = unresolvedIssues; - return this; - } - - public int resolvedIssues() { - return totalIssues - unresolvedIssues; - } - - public boolean isOpen() { - return ActionPlan.STATUS_OPEN.equals(status()); - } - - public boolean overDue() { - Date deadline = deadLine(); - return isOpen() && deadline != null && new Date().after(deadline); - } -} diff --git a/sonar-db/src/main/java/org/sonar/core/issue/package-info.java b/sonar-db/src/main/java/org/sonar/core/issue/package-info.java deleted file mode 100644 index 0476e218487..00000000000 --- a/sonar-db/src/main/java/org/sonar/core/issue/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.core.issue; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/sonar-db/src/main/java/org/sonar/db/DaoModule.java b/sonar-db/src/main/java/org/sonar/db/DaoModule.java index ef2eb59fdab..a3895860f78 100644 --- a/sonar-db/src/main/java/org/sonar/db/DaoModule.java +++ b/sonar-db/src/main/java/org/sonar/db/DaoModule.java @@ -37,8 +37,6 @@ import org.sonar.db.dashboard.WidgetDao; import org.sonar.db.dashboard.WidgetPropertyDao; import org.sonar.db.duplication.DuplicationDao; import org.sonar.db.event.EventDao; -import org.sonar.db.issue.ActionPlanDao; -import org.sonar.db.issue.ActionPlanStatsDao; import org.sonar.db.issue.IssueChangeDao; import org.sonar.db.issue.IssueDao; import org.sonar.db.issue.IssueFilterDao; @@ -72,8 +70,6 @@ import org.sonar.db.user.UserTokenDao; public class DaoModule extends Module { private static final List<Class<? extends Dao>> classes = ImmutableList.<Class<? extends Dao>>builder().add( - ActionPlanDao.class, - ActionPlanStatsDao.class, ActiveDashboardDao.class, ActivityDao.class, AuthorDao.class, diff --git a/sonar-db/src/main/java/org/sonar/db/DbClient.java b/sonar-db/src/main/java/org/sonar/db/DbClient.java index 1927db7cace..600e68689b8 100644 --- a/sonar-db/src/main/java/org/sonar/db/DbClient.java +++ b/sonar-db/src/main/java/org/sonar/db/DbClient.java @@ -37,8 +37,6 @@ import org.sonar.db.dashboard.WidgetDao; import org.sonar.db.dashboard.WidgetPropertyDao; import org.sonar.db.duplication.DuplicationDao; import org.sonar.db.event.EventDao; -import org.sonar.db.issue.ActionPlanDao; -import org.sonar.db.issue.ActionPlanStatsDao; import org.sonar.db.issue.IssueChangeDao; import org.sonar.db.issue.IssueDao; import org.sonar.db.issue.IssueFilterDao; @@ -97,8 +95,6 @@ public class DbClient { private final IssueFilterDao issueFilterDao; private final IssueFilterFavouriteDao issueFilterFavouriteDao; private final IssueChangeDao issueChangeDao; - private final ActionPlanDao actionPlanDao; - private final ActionPlanStatsDao actionPlanStatsDao; private final CeQueueDao ceQueueDao; private final CeActivityDao ceActivityDao; private final DashboardDao dashboardDao; @@ -153,8 +149,6 @@ public class DbClient { issueFilterDao = getDao(map, IssueFilterDao.class); issueFilterFavouriteDao = getDao(map, IssueFilterFavouriteDao.class); issueChangeDao = getDao(map, IssueChangeDao.class); - actionPlanDao = getDao(map, ActionPlanDao.class); - actionPlanStatsDao = getDao(map, ActionPlanStatsDao.class); ceQueueDao = getDao(map, CeQueueDao.class); ceActivityDao = getDao(map, CeActivityDao.class); dashboardDao = getDao(map, DashboardDao.class); @@ -289,10 +283,6 @@ public class DbClient { return permissionTemplateDao; } - public ActionPlanDao actionPlanDao() { - return actionPlanDao; - } - public CeQueueDao ceQueueDao() { return ceQueueDao; } @@ -341,10 +331,6 @@ public class DbClient { return purgeDao; } - public ActionPlanStatsDao getActionPlanStatsDao() { - return actionPlanStatsDao; - } - public QualityGateDao qualityGateDao() { return qualityGateDao; } diff --git a/sonar-db/src/main/java/org/sonar/db/MyBatis.java b/sonar-db/src/main/java/org/sonar/db/MyBatis.java index b7517208fc8..3b02b65e6ed 100644 --- a/sonar-db/src/main/java/org/sonar/db/MyBatis.java +++ b/sonar-db/src/main/java/org/sonar/db/MyBatis.java @@ -61,10 +61,6 @@ import org.sonar.db.duplication.DuplicationMapper; import org.sonar.db.duplication.DuplicationUnitDto; import org.sonar.db.event.EventDto; import org.sonar.db.event.EventMapper; -import org.sonar.db.issue.ActionPlanDto; -import org.sonar.db.issue.ActionPlanMapper; -import org.sonar.db.issue.ActionPlanStatsDto; -import org.sonar.db.issue.ActionPlanStatsMapper; import org.sonar.db.issue.IssueChangeDto; import org.sonar.db.issue.IssueChangeMapper; import org.sonar.db.issue.IssueDto; @@ -195,8 +191,6 @@ public class MyBatis { confBuilder.loadAlias("IssueChange", IssueChangeDto.class); confBuilder.loadAlias("IssueFilter", IssueFilterDto.class); confBuilder.loadAlias("IssueFilterFavourite", IssueFilterFavouriteDto.class); - confBuilder.loadAlias("ActionPlanIssue", ActionPlanDto.class); - confBuilder.loadAlias("ActionPlanStats", ActionPlanStatsDto.class); confBuilder.loadAlias("PermissionTemplate", PermissionTemplateDto.class); confBuilder.loadAlias("PermissionTemplateUser", PermissionTemplateUserDto.class); confBuilder.loadAlias("PermissionTemplateGroup", PermissionTemplateGroupDto.class); @@ -230,7 +224,7 @@ public class MyBatis { ResourceKeyUpdaterMapper.class, ResourceIndexMapper.class, RoleMapper.class, RuleMapper.class, SchemaMigrationMapper.class, WidgetMapper.class, WidgetPropertyMapper.class, UserMapper.class, GroupMapper.class, UserGroupMapper.class, UserTokenMapper.class, - FileSourceMapper.class, ActionPlanMapper.class, ActionPlanStatsMapper.class, + FileSourceMapper.class, NotificationQueueMapper.class, GroupMembershipMapper.class, QualityProfileMapper.class, ActiveRuleMapper.class, MeasureMapper.class, MetricMapper.class, CustomMeasureMapper.class, QualityGateMapper.class, QualityGateConditionMapper.class, ComponentMapper.class, SnapshotMapper.class, diff --git a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDao.java b/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDao.java deleted file mode 100644 index 928d224c3d6..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDao.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue; - -import com.google.common.base.Function; -import java.util.Collection; -import java.util.List; -import javax.annotation.Nonnull; -import org.apache.ibatis.session.SqlSession; -import org.sonar.db.Dao; -import org.sonar.db.DatabaseUtils; -import org.sonar.db.DbSession; -import org.sonar.db.MyBatis; - -public class ActionPlanDao implements Dao { - - private final MyBatis mybatis; - - public ActionPlanDao(MyBatis mybatis) { - this.mybatis = mybatis; - } - - public void save(ActionPlanDto actionPlanDto) { - SqlSession session = mybatis.openSession(false); - try { - session.getMapper(ActionPlanMapper.class).insert(actionPlanDto); - session.commit(); - } finally { - MyBatis.closeQuietly(session); - } - } - - public void update(ActionPlanDto actionPlanDto) { - SqlSession session = mybatis.openSession(false); - try { - session.getMapper(ActionPlanMapper.class).update(actionPlanDto); - session.commit(); - } finally { - MyBatis.closeQuietly(session); - } - } - - public void delete(String key) { - SqlSession session = mybatis.openSession(false); - try { - session.getMapper(ActionPlanMapper.class).delete(key); - session.commit(); - } finally { - MyBatis.closeQuietly(session); - } - } - - public ActionPlanDto selectByKey(String key) { - SqlSession session = mybatis.openSession(false); - try { - return session.getMapper(ActionPlanMapper.class).findByKey(key); - } finally { - MyBatis.closeQuietly(session); - } - } - - public List<ActionPlanDto> selectByKeys(Collection<String> keys) { - DbSession session = mybatis.openSession(false); - try { - return selectByKeys(session, keys); - } finally { - MyBatis.closeQuietly(session); - } - } - - public List<ActionPlanDto> selectByKeys(DbSession dbSession, Collection<String> keys) { - return DatabaseUtils.executeLargeInputs(keys, new SelectByKeys(dbSession.getMapper(ActionPlanMapper.class))); - } - - private static class SelectByKeys implements Function<List<String>, List<ActionPlanDto>> { - private final ActionPlanMapper mapper; - - private SelectByKeys(ActionPlanMapper mapper) { - this.mapper = mapper; - } - - @Override - public List<ActionPlanDto> apply(@Nonnull List<String> partitionOfKeys) { - return mapper.findByKeys(partitionOfKeys); - } - } - - public List<ActionPlanDto> selectOpenByProjectId(Long projectId) { - SqlSession session = mybatis.openSession(false); - try { - return session.getMapper(ActionPlanMapper.class).findOpenByProjectId(projectId); - } finally { - MyBatis.closeQuietly(session); - } - } - - public List<ActionPlanDto> selectByNameAndProjectId(String name, Long projectId) { - SqlSession session = mybatis.openSession(false); - try { - return session.getMapper(ActionPlanMapper.class).findByNameAndProjectId(name, projectId); - } finally { - MyBatis.closeQuietly(session); - } - } - -} diff --git a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDto.java b/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDto.java deleted file mode 100644 index 6d8bdec9db3..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDto.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue; - -import java.util.Date; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.sonar.api.issue.ActionPlan; -import org.sonar.core.issue.DefaultActionPlan; - -/** - * @since 3.6 - */ -public class ActionPlanDto { - - private Long id; - private String kee; - private String name; - private String description; - private String userLogin; - private Long projectId; - private String status; - private Date deadLine; - private Date createdAt; - private Date updatedAt; - - // return by joins - private String projectKey; - private String projectUuid; - - public Long getId() { - return id; - } - - public ActionPlanDto setId(Long id) { - this.id = id; - return this; - } - - public String getKey() { - return kee; - } - - public ActionPlanDto setKey(String kee) { - this.kee = kee; - return this; - } - - public String getName() { - return name; - } - - public ActionPlanDto setName(String name) { - this.name = name; - return this; - } - - @CheckForNull - public String getDescription() { - return description; - } - - public ActionPlanDto setDescription(@Nullable String description) { - this.description = description; - return this; - } - - public String getUserLogin() { - return userLogin; - } - - public ActionPlanDto setUserLogin(String userLogin) { - this.userLogin = userLogin; - return this; - } - - public Long getProjectId() { - return projectId; - } - - public ActionPlanDto setProjectId(Long projectId) { - this.projectId = projectId; - return this; - } - - public String getStatus() { - return status; - } - - public ActionPlanDto setStatus(String status) { - this.status = status; - return this; - } - - @CheckForNull - public Date getDeadLine() { - return deadLine; - } - - public ActionPlanDto setDeadLine(@Nullable Date deadLine) { - this.deadLine = deadLine; - return this; - } - - public Date getCreatedAt() { - return createdAt; - } - - public ActionPlanDto setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - return this; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public ActionPlanDto setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - public String getProjectKey() { - return projectKey; - } - - /** - * Only for unit tests - */ - public ActionPlanDto setProjectKey_unit_test_only(String projectKey) { - this.projectKey = projectKey; - return this; - } - - public String getProjectUuid() { - return projectUuid; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - ActionPlanDto actionPlanDto = (ActionPlanDto) o; - return !((id != null) ? !id.equals(actionPlanDto.id) : (actionPlanDto.id != null)); - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - public DefaultActionPlan toActionPlan() { - return new DefaultActionPlan() - .setName(name) - .setKey(kee) - .setProjectKey(projectKey) - .setDescription(description) - .setStatus(status) - .setDeadLine(deadLine) - .setUserLogin(userLogin) - .setCreatedAt(createdAt) - .setUpdatedAt(updatedAt); - } - - public static ActionPlanDto toActionDto(ActionPlan actionPlan, Long projectId) { - return new ActionPlanDto().setKey(actionPlan.key()) - .setName(actionPlan.name()) - .setProjectId(projectId) - .setDescription(actionPlan.description()) - .setStatus(actionPlan.status()) - .setDeadLine(actionPlan.deadLine()) - .setUserLogin(actionPlan.userLogin()) - .setCreatedAt(actionPlan.createdAt()) - .setUpdatedAt(actionPlan.updatedAt()); - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanMapper.java b/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanMapper.java deleted file mode 100644 index f68c5bfe86c..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanMapper.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue; - -import java.util.List; -import org.apache.ibatis.annotations.Param; - -/** - * @since 3.6 - */ -public interface ActionPlanMapper { - - void insert(ActionPlanDto actionPlanDto); - - void update(ActionPlanDto actionPlanDto); - - void delete(@Param("key") String key); - - List<ActionPlanDto> findByKeys(@Param("keys") List<String> keys); - - ActionPlanDto findByKey(@Param("key") String key); - - List<ActionPlanDto> findOpenByProjectId(@Param("projectId") Long projectId); - - List<ActionPlanDto> findByNameAndProjectId(@Param("name") String name, @Param("projectId") Long projectId); -} diff --git a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsDao.java b/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsDao.java deleted file mode 100644 index d69fea41906..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsDao.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue; - -import java.util.List; -import org.apache.ibatis.session.SqlSession; -import org.sonar.api.utils.System2; -import org.sonar.db.AbstractDao; -import org.sonar.db.MyBatis; - -public class ActionPlanStatsDao extends AbstractDao { - - public ActionPlanStatsDao(MyBatis myBatis, System2 system2) { - super(myBatis, system2); - } - - public List<ActionPlanStatsDto> selectByProjectId(Long projectId) { - SqlSession session = myBatis().openSession(false); - try { - return session.getMapper(ActionPlanStatsMapper.class).findByProjectId(projectId); - } finally { - MyBatis.closeQuietly(session); - } - } - -} diff --git a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsDto.java b/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsDto.java deleted file mode 100644 index 1b84a6cee4c..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsDto.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue; - -import java.util.Date; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; -import org.sonar.core.issue.ActionPlanStats; - -/** - * @since 3.6 - */ -public class ActionPlanStatsDto { - - private Integer id; - private String kee; - private String name; - private String description; - private String userLogin; - private Integer projectId; - private String status; - private Date deadLine; - private Date createdAt; - private Date updatedAt; - private int totalIssues; - private int unresolvedIssues; - // return by joins - private String projectKey; - private String projectUuid; - - public Integer getId() { - return id; - } - - public ActionPlanStatsDto setId(Integer id) { - this.id = id; - return this; - } - - public String getKee() { - return kee; - } - - public ActionPlanStatsDto setKee(String kee) { - this.kee = kee; - return this; - } - - public String getName() { - return name; - } - - public ActionPlanStatsDto setName(String name) { - this.name = name; - return this; - } - - public String getDescription() { - return description; - } - - public ActionPlanStatsDto setDescription(String description) { - this.description = description; - return this; - } - - public String getUserLogin() { - return userLogin; - } - - public ActionPlanStatsDto setUserLogin(String userLogin) { - this.userLogin = userLogin; - return this; - } - - public Integer getProjectId() { - return projectId; - } - - public ActionPlanStatsDto setProjectId(Integer projectId) { - this.projectId = projectId; - return this; - } - - public String getStatus() { - return status; - } - - public ActionPlanStatsDto setStatus(String status) { - this.status = status; - return this; - } - - public Date getDeadLine() { - return deadLine; - } - - public ActionPlanStatsDto setDeadLine(Date deadLine) { - this.deadLine = deadLine; - return this; - } - - public Date getCreatedAt() { - return createdAt; - } - - public ActionPlanStatsDto setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - return this; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public ActionPlanStatsDto setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - public int getTotalIssues() { - return totalIssues; - } - - public ActionPlanStatsDto setTotalIssues(int totalIssues) { - this.totalIssues = totalIssues; - return this; - } - - public int getUnresolvedIssues() { - return unresolvedIssues; - } - - public ActionPlanStatsDto setUnresolvedIssues(int unresolvedIssues) { - this.unresolvedIssues = unresolvedIssues; - return this; - } - - public String getProjectKey() { - return projectKey; - } - - /** - * Only for unit tests - */ - public ActionPlanStatsDto setProjectKey_unit_test_only(String projectKey) { - this.projectKey = projectKey; - return this; - } - - public String getProjectUuid() { - return projectUuid; - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } - - public ActionPlanStats toActionPlanStat() { - return ((ActionPlanStats) ActionPlanStats.create(name) - .setKey(kee) - .setProjectKey(projectKey) - .setDescription(description) - .setStatus(status) - .setDeadLine(deadLine) - .setUserLogin(userLogin) - .setCreatedAt(createdAt) - .setUpdatedAt(updatedAt)) - .setTotalIssues(totalIssues) - .setUnresolvedIssues(unresolvedIssues); - } - -} diff --git a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsMapper.java b/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsMapper.java deleted file mode 100644 index b8baa64ce9a..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue; - -import java.util.List; -import org.apache.ibatis.annotations.Param; - -/** - * @since 3.6 - */ -public interface ActionPlanStatsMapper { - - /** - * @since3.6 - */ - List<ActionPlanStatsDto> findByProjectId(@Param("projectId") Long projectId); -} diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java index 6e0f9665589..0f111cc9400 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java @@ -69,10 +69,6 @@ public class IssueDao implements Dao { return issue.get(); } - public List<IssueDto> selectByActionPlan(DbSession session, String actionPlan) { - return mapper(session).selectByActionPlan(actionPlan); - } - /** * Gets a list issues by their keys. The result does NOT contain {@code null} values for issues not found, so * the size of result may be less than the number of keys. A single issue is returned diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java index 0fe823de213..56d267a6b6b 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java @@ -72,7 +72,6 @@ public final class IssueDto implements Serializable { private String reporter; private String assignee; private String authorLogin; - private String actionPlanKey; private String issueAttributes; private byte[] locations; private long createdAt; @@ -128,7 +127,6 @@ public final class IssueDto implements Serializable { .setComponentUuid(issue.componentUuid()) .setProjectUuid(issue.projectUuid()) .setProjectKey(issue.projectKey()) - .setActionPlanKey(issue.actionPlanKey()) .setIssueAttributes(KeyValueFormat.format(issue.attributes())) .setAuthorLogin(issue.authorLogin()) .setIssueCreationDate(issue.creationDate()) @@ -167,7 +165,6 @@ public final class IssueDto implements Serializable { .setManualSeverity(issue.manualSeverity()) .setReporter(issue.reporter()) .setAssignee(issue.assignee()) - .setActionPlanKey(issue.actionPlanKey()) .setIssueAttributes(KeyValueFormat.format(issue.attributes())) .setAuthorLogin(issue.authorLogin()) .setRuleKey(issue.ruleKey().repository(), issue.ruleKey().rule()) @@ -243,14 +240,8 @@ public final class IssueDto implements Serializable { return this; } - @CheckForNull - public String getActionPlanKey() { - return actionPlanKey; - } - public IssueDto setActionPlanKey(@Nullable String s) { checkArgument(s == null || s.length() <= 50, "Value is too long for issue action plan: %s", s); - this.actionPlanKey = s; return this; } @@ -744,7 +735,6 @@ public final class IssueDto implements Serializable { issue.setRuleKey(getRuleKey()); issue.setTags(getTags()); issue.setLanguage(language); - issue.setActionPlanKey(actionPlanKey); issue.setAuthorLogin(authorLogin); issue.setNew(false); issue.setCreationDate(longToDate(issueCreationDate)); diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueMapper.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueMapper.java index d801ed634cc..a5e84d9e77b 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueMapper.java @@ -34,8 +34,6 @@ public interface IssueMapper { List<IssueDto> selectByKeys(List<String> keys); - List<IssueDto> selectByActionPlan(String actionPlan); - void insert(IssueDto issue); int update(IssueDto issue); diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java index 806703ebf6a..7e62eabfc55 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java @@ -132,13 +132,6 @@ class PurgeCommands { session.commit(); profiler.stop(); - profiler.start("deleteResourceActionPlans (action_plans)"); - for (List<Long> partResourceIds : componentIdPartitions) { - purgeMapper.deleteResourceActionPlans(partResourceIds); - } - session.commit(); - profiler.stop(); - profiler.start("deleteComponentEvents (events)"); for (List<String> componentUuidPartition : componentUuidsPartitions) { purgeMapper.deleteComponentEvents(componentUuidPartition); diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java index 0bf335d1bb9..f8c3149c64a 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java @@ -72,8 +72,6 @@ public interface PurgeMapper { void deleteComponentEvents(@Param("componentUuids") List<String> componentUuids); - void deleteResourceActionPlans(@Param("resourceIds") List<Long> resourceIds); - void deleteAuthors(@Param("resourceIds") List<Long> resourceIds); List<PurgeableSnapshotDto> selectPurgeableSnapshotsWithEvents(long resourceId); diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java index adc1dfa4d8d..d6e3e3c87f2 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java +++ b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java @@ -29,7 +29,7 @@ import org.sonar.db.MyBatis; public class DatabaseVersion { - public static final int LAST_VERSION = 1120; + public static final int LAST_VERSION = 1122; /** * The minimum supported version which can be upgraded. Lower @@ -44,7 +44,6 @@ public class DatabaseVersion { * for all the supported databases, particularly due to Oracle results. */ public static final List<String> TABLES = ImmutableList.of( - "action_plans", "active_dashboards", "active_rules", "active_rule_parameters", diff --git a/sonar-db/src/main/resources/org/sonar/db/issue/ActionPlanMapper.xml b/sonar-db/src/main/resources/org/sonar/db/issue/ActionPlanMapper.xml deleted file mode 100644 index c9054f54e1e..00000000000 --- a/sonar-db/src/main/resources/org/sonar/db/issue/ActionPlanMapper.xml +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mappei.dtd"> - -<mapper namespace="org.sonar.db.issue.ActionPlanMapper"> - - <sql id="actionPlanColumns"> - ap.id, - ap.kee as kee, - ap.name as name, - ap.description as description, - ap.user_login as userLogin, - ap.project_id as projectId, - ap.status as status, - ap.deadline as deadLine, - ap.created_at as createdAt, - ap.updated_at as updatedAt, - p.kee as projectKey, - p.uuid as projectUuid - </sql> - - <insert id="insert" parameterType="ActionPlanIssue" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> - INSERT INTO action_plans (kee, name, description, user_login, project_id, status, deadline, created_at, updated_at) - VALUES (#{kee}, #{name}, #{description}, #{userLogin}, #{projectId}, #{status}, #{deadLine}, #{createdAt}, - #{updatedAt}) - </insert> - - <update id="update" parameterType="ActionPlanIssue"> - update action_plans set - name=#{name}, - description=#{description}, - user_login=#{userLogin}, - project_id=#{projectId}, - status=#{status}, - deadline=#{deadLine}, - updated_at=current_timestamp - where kee = #{kee} - </update> - - <delete id="delete" parameterType="String"> - delete from action_plans where kee=#{key} - </delete> - - <select id="findByKey" parameterType="long" resultType="ActionPlanIssue"> - select - <include refid="actionPlanColumns"/> - from action_plans ap, projects p - <where> - and ap.kee=#{key} - and ap.project_id=p.id - </where> - </select> - - <select id="findByKeys" parameterType="long" resultType="ActionPlanIssue"> - select - <include refid="actionPlanColumns"/> - from action_plans ap, projects p - <where> - and ap.kee in - <foreach collection="keys" open="(" close=")" item="key" separator=","> - #{key} - </foreach> - and ap.project_id=p.id - </where> - </select> - - <select id="findOpenByProjectId" parameterType="long" resultType="ActionPlanIssue"> - select - <include refid="actionPlanColumns"/> - from action_plans ap, projects p - <where> - and ap.project_id=#{projectId} - and ap.status='OPEN' - and ap.project_id=p.id - </where> - </select> - - <select id="findByNameAndProjectId" parameterType="long" resultType="ActionPlanIssue"> - select - <include refid="actionPlanColumns"/> - from action_plans ap, projects p - <where> - and ap.project_id=#{projectId} - and ap.name=#{name} - and ap.project_id=p.id - </where> - </select> - -</mapper> diff --git a/sonar-db/src/main/resources/org/sonar/db/issue/ActionPlanStatsMapper.xml b/sonar-db/src/main/resources/org/sonar/db/issue/ActionPlanStatsMapper.xml deleted file mode 100644 index 30793f0de97..00000000000 --- a/sonar-db/src/main/resources/org/sonar/db/issue/ActionPlanStatsMapper.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mappei.dtd"> - -<mapper namespace="org.sonar.db.issue.ActionPlanStatsMapper"> - - <sql id="actionPlanColumns"> - ap.id as id, - ap.kee as kee, - ap.name as name, - ap.description as description, - ap.user_login as userLogin, - ap.project_id as projectId, - ap.status as status, - ap.deadline as deadLine, - ap.created_at as createdAt, - ap.updated_at as updatedAt, - p.kee as projectKey, - p.uuid as projectUuid - </sql> - - <select id="findByProjectId" parameterType="map" resultType="ActionPlanStats"> - select<include refid="actionPlanColumns"/>, count(total_issues.id) as totalIssues, count(open_issues.id) as - unresolvedIssues - from action_plans ap - left join projects p on p.id = ap.project_id - left join issues total_issues on total_issues.action_plan_key = ap.kee - left join issues open_issues on open_issues.id = total_issues.id and open_issues.resolution is null - <where> - and ap.project_id = #{projectId} - </where> - group by ap.id, ap.kee, ap.name, ap.description, ap.user_login, ap.project_id, ap.status, ap.deadline, - ap.created_at, ap.updated_at, p.kee, p.uuid - </select> - -</mapper> diff --git a/sonar-db/src/main/resources/org/sonar/db/issue/IssueMapper.xml b/sonar-db/src/main/resources/org/sonar/db/issue/IssueMapper.xml index 63b2c388781..8c13afdc31c 100644 --- a/sonar-db/src/main/resources/org/sonar/db/issue/IssueMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/issue/IssueMapper.xml @@ -8,7 +8,6 @@ i.id, i.kee as kee, i.rule_id as ruleId, - i.action_plan_key as actionPlanKey, i.severity as severity, i.manual_severity as manualSeverity, i.message as message, @@ -68,11 +67,11 @@ </sql> <insert id="insert" parameterType="Issue" useGeneratedKeys="false" keyProperty="id"> - INSERT INTO issues (kee, rule_id, action_plan_key, severity, manual_severity, + INSERT INTO issues (kee, rule_id, severity, manual_severity, message, line, locations, gap, effort, status, tags, resolution, checksum, reporter, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date, issue_close_date, created_at, updated_at, component_uuid, project_uuid, issue_type) - VALUES (#{kee,jdbcType=VARCHAR}, #{ruleId,jdbcType=INTEGER}, #{actionPlanKey,jdbcType=VARCHAR}, + VALUES (#{kee,jdbcType=VARCHAR}, #{ruleId,jdbcType=INTEGER}, #{severity,jdbcType=VARCHAR}, #{manualSeverity,jdbcType=BOOLEAN}, #{message,jdbcType=VARCHAR}, #{line,jdbcType=INTEGER}, #{locations,jdbcType=BINARY}, @@ -90,7 +89,6 @@ --> <update id="update" parameterType="Issue"> update issues set - action_plan_key=#{actionPlanKey,jdbcType=VARCHAR}, severity=#{severity,jdbcType=VARCHAR}, manual_severity=#{manualSeverity,jdbcType=BOOLEAN}, message=#{message,jdbcType=VARCHAR}, @@ -120,7 +118,6 @@ --> <update id="updateIfBeforeSelectedDate" parameterType="Issue"> update issues set - action_plan_key=#{actionPlanKey,jdbcType=VARCHAR}, severity=#{severity,jdbcType=VARCHAR}, manual_severity=#{manualSeverity,jdbcType=BOOLEAN}, message=#{message,jdbcType=VARCHAR}, @@ -174,7 +171,6 @@ i.rule_id as ruleId, i.component_uuid as componentUuid, i.project_uuid as projectUuid, - i.action_plan_key as actionPlanKey, i.severity as severity, i.manual_severity as manualSeverity, i.message as message, @@ -226,18 +222,5 @@ #{key} </foreach> </select> - - <select id="selectByActionPlan" parameterType="map" resultType="Issue"> - select - <include refid="issueColumns"/> - from issues i - inner join rules r on r.id=i.rule_id - inner join projects p on p.uuid=i.component_uuid - inner join projects root on root.uuid=i.project_uuid - <where> - and i.action_plan_key=#{action_plan} - </where> - </select> - </mapper> diff --git a/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml b/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml index 5c64bb131ec..aee39d1763a 100644 --- a/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml @@ -207,13 +207,6 @@ </foreach> </delete> - <delete id="deleteResourceActionPlans" parameterType="map"> - delete from action_plans where project_id in - <foreach collection="resourceIds" open="(" close=")" item="resourceId" separator=","> - #{resourceId} - </foreach> - </delete> - <delete id="deleteAuthors" parameterType="map"> delete from authors where person_id in <foreach collection="resourceIds" open="(" close=")" item="resourceId" separator=","> diff --git a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql index d4ca8b75db1..9b1fe44c018 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql +++ b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql @@ -398,6 +398,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1117'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1118'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1119'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1120'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1121'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1122'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, USER_LOCAL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', true, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl index eb657209f2e..1bbd3df88ce 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -355,19 +355,6 @@ CREATE TABLE "RESOURCE_INDEX" ( "QUALIFIER" VARCHAR(10) NOT NULL ); -CREATE TABLE "ACTION_PLANS" ( - "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "KEE" VARCHAR(100), - "NAME" VARCHAR(200), - "DESCRIPTION" VARCHAR(1000), - "DEADLINE" TIMESTAMP, - "USER_LOGIN" VARCHAR(255), - "PROJECT_ID" INTEGER, - "STATUS" VARCHAR(10), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - CREATE TABLE "AUTHORS" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "PERSON_ID" INTEGER, @@ -622,8 +609,6 @@ CREATE INDEX "RESOURCE_INDEX_KEY" ON "RESOURCE_INDEX" ("KEE"); CREATE INDEX "RESOURCE_INDEX_RID" ON "RESOURCE_INDEX" ("RESOURCE_ID"); -CREATE INDEX "INDEX_ACTION_PLANS_ON_PROJET_ID" ON "ACTION_PLANS" ("PROJECT_ID"); - CREATE UNIQUE INDEX "UNIQ_AUTHOR_LOGINS" ON "AUTHORS" ("LOGIN"); CREATE INDEX "MEASURE_FILTERS_NAME" ON "MEASURE_FILTERS" ("NAME"); @@ -642,8 +627,6 @@ CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES" ("RESOLUTION"); CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES" ("ASSIGNEE"); -CREATE INDEX "ISSUES_ACTION_PLAN_KEY" ON "ISSUES" ("ACTION_PLAN_KEY"); - CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES" ("ISSUE_CREATION_DATE"); CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES" ("UPDATED_AT"); diff --git a/sonar-db/src/test/java/org/sonar/core/issue/ActionPlanStatsTest.java b/sonar-db/src/test/java/org/sonar/core/issue/ActionPlanStatsTest.java deleted file mode 100644 index 1d76471a7f6..00000000000 --- a/sonar-db/src/test/java/org/sonar/core/issue/ActionPlanStatsTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.core.issue; - -import java.util.Date; -import org.apache.commons.lang.time.DateUtils; -import org.junit.Test; -import org.sonar.api.issue.ActionPlan; - -import static org.assertj.core.api.Assertions.assertThat; - -public class ActionPlanStatsTest { - - @Test - public void test_over_due() throws Exception { - Date yesterday = DateUtils.addDays(new Date(), -1); - Date tomorrow = DateUtils.addDays(new Date(), 1); - - assertThat(((ActionPlanStats) ActionPlanStats.create("Short term").setStatus(ActionPlan.STATUS_OPEN).setDeadLine(tomorrow)).overDue()).isFalse(); - assertThat(((ActionPlanStats) ActionPlanStats.create("Short term").setStatus(ActionPlan.STATUS_OPEN).setDeadLine(yesterday)).overDue()).isTrue(); - assertThat(((ActionPlanStats) ActionPlanStats.create("Short term").setStatus(ActionPlan.STATUS_CLOSED).setDeadLine(tomorrow)).overDue()).isFalse(); - assertThat(((ActionPlanStats) ActionPlanStats.create("Short term").setStatus(ActionPlan.STATUS_CLOSED).setDeadLine(yesterday)).overDue()).isFalse(); - assertThat(((ActionPlanStats) ActionPlanStats.create("Short term").setStatus(ActionPlan.STATUS_CLOSED)).overDue()).isFalse(); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java index 7e5f79e1d22..e666e3a2435 100644 --- a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java +++ b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java @@ -29,6 +29,6 @@ public class DaoModuleTest { public void verify_count_of_added_components() { ComponentContainer container = new ComponentContainer(); new DaoModule().configure(container); - assertThat(container.size()).isEqualTo(49); + assertThat(container.size()).isEqualTo(2 + 45); } } diff --git a/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanDaoTest.java b/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanDaoTest.java deleted file mode 100644 index 2d9edc4db87..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanDaoTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue; - -import java.util.Collection; -import java.util.List; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static com.google.common.collect.Lists.newArrayList; -import static org.assertj.core.api.Assertions.assertThat; - -public class ActionPlanDaoTest { - - private static final String[] EXCLUDED_COLUMNS = new String[] {"id", "created_at", "updated_at"}; - - @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); - - ActionPlanDao dao = dbTester.getDbClient().actionPlanDao(); - - @Test - public void should_insert_new_action_plan() { - dbTester.truncateTables(); - - ActionPlanDto actionPlanDto = new ActionPlanDto().setKey("ABC").setName("Long term").setDescription("Long term action plan").setStatus("OPEN") - .setProjectId(1l).setUserLogin("arthur"); - - dao.save(actionPlanDto); - - dbTester.assertDbUnit(getClass(), "should_insert_new_action_plan-result.xml", EXCLUDED_COLUMNS, "action_plans"); - } - - @Test - public void should_update_action_plan() { - dbTester.prepareDbUnit(getClass(), "should_update_action_plan.xml"); - - ActionPlanDto actionPlanDto = new ActionPlanDto().setKey("ABC").setName("Long term").setDescription("Long term action plan").setStatus("OPEN") - .setProjectId(1l).setUserLogin("arthur"); - dao.update(actionPlanDto); - - dbTester.assertDbUnit(getClass(), "should_update_action_plan-result.xml", EXCLUDED_COLUMNS, "action_plans"); - } - - @Test - public void should_delete_action_plan() { - dbTester.prepareDbUnit(getClass(), "should_delete_action_plan.xml"); - - dao.delete("BCD"); - - dbTester.assertDbUnit(getClass(), "should_delete_action_plan-result.xml", EXCLUDED_COLUMNS, "action_plans"); - } - - @Test - public void should_find_by_key() { - dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_key.xml"); - - ActionPlanDto result = dao.selectByKey("ABC"); - assertThat(result).isNotNull(); - assertThat(result.getKey()).isEqualTo("ABC"); - assertThat(result.getProjectKey()).isEqualTo("PROJECT_KEY"); - assertThat(result.getProjectUuid()).isEqualTo("PROJECT_UUID"); - } - - @Test - public void should_find_by_keys() { - dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_keys.xml"); - - Collection<ActionPlanDto> result = dao.selectByKeys(newArrayList("ABC", "ABD", "ABE")); - assertThat(result).hasSize(3); - } - - @Test - public void should_find_by_keys_on_huge_number_of_keys() { - dbTester.prepareDbUnit(getClass(), "shared.xml"); - - List<String> hugeNbOKeys = newArrayList(); - for (int i = 0; i < 4500; i++) { - hugeNbOKeys.add("ABCD" + i); - } - List<ActionPlanDto> result = dao.selectByKeys(hugeNbOKeys); - - // The goal of this test is only to check that the query do no fail, not to check the number of results - assertThat(result).isEmpty(); - } - - @Test - public void should_find_open_by_project_id() { - dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_open_by_project_id.xml"); - - Collection<ActionPlanDto> result = dao.selectOpenByProjectId(1l); - assertThat(result).hasSize(2); - } - - @Test - public void should_find_by_name_and_project_id() { - dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_name_and_project_id.xml"); - - Collection<ActionPlanDto> result = dao.selectByNameAndProjectId("SHORT_TERM", 1l); - assertThat(result).hasSize(2); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanStatsDaoTest.java b/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanStatsDaoTest.java deleted file mode 100644 index fed54670c62..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanStatsDaoTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.issue; - -import java.util.Collection; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - - -public class ActionPlanStatsDaoTest { - - @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); - - ActionPlanStatsDao dao = dbTester.getDbClient().getActionPlanStatsDao(); - - @Test - public void should_find_by_project() { - dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_project.xml"); - - Collection<ActionPlanStatsDto> result = dao.selectByProjectId(1l); - assertThat(result).isNotEmpty(); - - ActionPlanStatsDto actionPlanStatsDto = result.iterator().next(); - assertThat(actionPlanStatsDto.getProjectKey()).isEqualTo("PROJECT_KEY"); - assertThat(actionPlanStatsDto.getProjectUuid()).isEqualTo("PROJECT_UUID"); - assertThat(actionPlanStatsDto.getTotalIssues()).isEqualTo(3); - assertThat(actionPlanStatsDto.getUnresolvedIssues()).isEqualTo(1); - } - -} diff --git a/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java b/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java index 26cfaecff55..9f2290ad1e9 100644 --- a/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java @@ -26,7 +26,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.System2; -import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.RowNotFoundException; import org.sonar.db.component.ComponentDto; @@ -169,43 +168,6 @@ public class IssueDaoTest { assertThat(issues).extracting("key").containsExactly("I2", "I1"); } - @Test - public void selectByActionPlan() { - dbTester.prepareDbUnit(getClass(), "shared.xml", "find_by_action_plan.xml"); - - List<IssueDto> issues = underTest.selectByActionPlan(dbTester.getSession(), "AP-1"); - assertThat(issues).hasSize(1); - - IssueDto issue = issues.get(0); - assertThat(issue.getKee()).isEqualTo("ABCDE"); - assertThat(issue.getActionPlanKey()).isEqualTo("AP-1"); - assertThat(issue.getComponentUuid()).isEqualTo("CDEF"); - assertThat(issue.getProjectUuid()).isEqualTo("ABCD"); - assertThat(issue.getRuleId()).isEqualTo(500); - assertThat(issue.getLanguage()).isEqualTo("java"); - assertThat(issue.getSeverity()).isEqualTo("BLOCKER"); - assertThat(issue.isManualSeverity()).isFalse(); - assertThat(issue.getMessage()).isNull(); - assertThat(issue.getLine()).isEqualTo(200); - assertThat(issue.getGap()).isEqualTo(4.2); - assertThat(issue.getStatus()).isEqualTo("OPEN"); - assertThat(issue.getResolution()).isEqualTo("FIXED"); - assertThat(issue.getChecksum()).isEqualTo("XXX"); - assertThat(issue.getAuthorLogin()).isEqualTo("karadoc"); - assertThat(issue.getReporter()).isEqualTo("arthur"); - assertThat(issue.getAssignee()).isEqualTo("perceval"); - assertThat(issue.getIssueAttributes()).isEqualTo("JIRA=FOO-1234"); - assertThat(issue.getIssueCreationDate()).isNotNull(); - assertThat(issue.getIssueUpdateDate()).isNotNull(); - assertThat(issue.getIssueCloseDate()).isNotNull(); - assertThat(issue.getCreatedAt()).isNotNull(); - assertThat(issue.getUpdatedAt()).isNotNull(); - assertThat(issue.getRuleRepo()).isEqualTo("squid"); - assertThat(issue.getRule()).isEqualTo("AvoidCycle"); - assertThat(issue.getComponentKey()).isEqualTo("Action.java"); - assertThat(issue.getProjectKey()).isEqualTo("struts"); - } - private static IssueDto newIssueDto(String key) { IssueDto dto = new IssueDto(); dto.setComponent(new ComponentDto().setKey("struts:Action").setId(123L).setUuid("component-uuid")); @@ -222,7 +184,6 @@ public class IssueDaoTest { dto.setReporter("emmerik"); dto.setAuthorLogin("morgan"); dto.setAssignee("karadoc"); - dto.setActionPlanKey("current_sprint"); dto.setIssueAttributes("JIRA=FOO-1234"); dto.setChecksum("123456789"); dto.setMessage("the message"); diff --git a/sonar-db/src/test/java/org/sonar/db/issue/IssueMapperTest.java b/sonar-db/src/test/java/org/sonar/db/issue/IssueMapperTest.java index 2bf9d9cb891..0091675d756 100644 --- a/sonar-db/src/test/java/org/sonar/db/issue/IssueMapperTest.java +++ b/sonar-db/src/test/java/org/sonar/db/issue/IssueMapperTest.java @@ -77,7 +77,6 @@ public class IssueMapperTest { assertThat(result.getReporter()).isEqualTo("emmerik"); assertThat(result.getAuthorLogin()).isEqualTo("morgan"); assertThat(result.getAssignee()).isEqualTo("karadoc"); - assertThat(result.getActionPlanKey()).isEqualTo("current_sprint"); assertThat(result.getIssueAttributes()).isEqualTo("JIRA=FOO-1234"); assertThat(result.getChecksum()).isEqualTo("123456789"); assertThat(result.getMessage()).isEqualTo("the message"); @@ -109,7 +108,6 @@ public class IssueMapperTest { update.setReporter("emmerik"); update.setAuthorLogin("morgan"); update.setAssignee("karadoc"); - update.setActionPlanKey("current_sprint"); update.setIssueAttributes("JIRA=FOO-1234"); update.setChecksum("123456789"); update.setMessage("the message"); @@ -141,7 +139,6 @@ public class IssueMapperTest { assertThat(result.getReporter()).isEqualTo("emmerik"); assertThat(result.getAuthorLogin()).isEqualTo("morgan"); assertThat(result.getAssignee()).isEqualTo("karadoc"); - assertThat(result.getActionPlanKey()).isEqualTo("current_sprint"); assertThat(result.getIssueAttributes()).isEqualTo("JIRA=FOO-1234"); assertThat(result.getChecksum()).isEqualTo("123456789"); assertThat(result.getMessage()).isEqualTo("the message"); @@ -227,7 +224,6 @@ public class IssueMapperTest { .setReporter("emmerik") .setAuthorLogin("morgan") .setAssignee("karadoc") - .setActionPlanKey("current_sprint") .setIssueAttributes("JIRA=FOO-1234") .setChecksum("123456789") .setMessage("the message") diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java index 9f4099b8ea1..e44fa62511e 100644 --- a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java @@ -117,7 +117,6 @@ public class PurgeDaoTest { dbSession.commit(); assertThat(dbTester.countRowsOfTable("projects")).isZero(); assertThat(dbTester.countRowsOfTable("snapshots")).isZero(); - assertThat(dbTester.countRowsOfTable("action_plans")).isZero(); assertThat(dbTester.countRowsOfTable("issues")).isZero(); assertThat(dbTester.countRowsOfTable("issue_changes")).isZero(); assertThat(dbTester.countRowsOfTable("file_sources")).isZero(); diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/shared.xml deleted file mode 100644 index dfac83a8e2d..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/shared.xml +++ /dev/null @@ -1,5 +0,0 @@ -<dataset> - - <projects id="1" uuid="PROJECT_UUID" kee="PROJECT_KEY" root_id="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_delete_action_plan-result.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_delete_action_plan-result.xml deleted file mode 100644 index 2b855c97f05..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_delete_action_plan-result.xml +++ /dev/null @@ -1,6 +0,0 @@ -<dataset> - - <action_plans id="1" kee="ABC" project_id="1" name="Long term" description="Long term action plan" deadline="[null]" - user_login="arthur" status="OPEN" created_at="[null]" updated_at="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_delete_action_plan.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_delete_action_plan.xml deleted file mode 100644 index eaa959cccf9..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_delete_action_plan.xml +++ /dev/null @@ -1,9 +0,0 @@ -<dataset> - - <action_plans id="1" kee="ABC" project_id="1" name="Long term" description="Long term action plan" deadline="[null]" - user_login="arthur" status="OPEN" created_at="[null]" updated_at="[null]"/> - - <action_plans id="2" kee="BCD" project_id="1" name="Short term" description="Short term action plan" deadline="[null]" - user_login="arthur" status="CLOSED" created_at="[null]" updated_at="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_by_key.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_by_key.xml deleted file mode 100644 index c21cd9325e4..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_by_key.xml +++ /dev/null @@ -1,6 +0,0 @@ -<dataset> - - <action_plans id="1" kee="ABC" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="[null]" created_at="[null]" updated_at="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_by_keys.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_by_keys.xml deleted file mode 100644 index a682d59fd17..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_by_keys.xml +++ /dev/null @@ -1,12 +0,0 @@ -<dataset> - - <action_plans id="1" kee="ABC" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="[null]" created_at="[null]" updated_at="[null]"/> - - <action_plans id="2" kee="ABD" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="[null]" created_at="[null]" updated_at="[null]"/> - - <action_plans id="3" kee="ABE" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="[null]" created_at="[null]" updated_at="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_by_name_and_project_id.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_by_name_and_project_id.xml deleted file mode 100644 index e99d5b3eb3a..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_by_name_and_project_id.xml +++ /dev/null @@ -1,12 +0,0 @@ -<dataset> - - <action_plans id="1" kee="ABC" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="OPEN" created_at="[null]" updated_at="[null]"/> - - <action_plans id="2" kee="ABD" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="OPEN" created_at="[null]" updated_at="[null]"/> - - <action_plans id="3" kee="ABE" project_id="2" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="OPEN" created_at="[null]" updated_at="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_open_by_project_id.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_open_by_project_id.xml deleted file mode 100644 index e15d4d0bbec..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_find_open_by_project_id.xml +++ /dev/null @@ -1,12 +0,0 @@ -<dataset> - - <action_plans id="1" kee="ABC" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="OPEN" created_at="[null]" updated_at="[null]"/> - - <action_plans id="2" kee="ABD" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="OPEN" created_at="[null]" updated_at="[null]"/> - - <action_plans id="3" kee="ABE" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="CLOSED" created_at="[null]" updated_at="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_insert_new_action_plan-result.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_insert_new_action_plan-result.xml deleted file mode 100644 index 2b855c97f05..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_insert_new_action_plan-result.xml +++ /dev/null @@ -1,6 +0,0 @@ -<dataset> - - <action_plans id="1" kee="ABC" project_id="1" name="Long term" description="Long term action plan" deadline="[null]" - user_login="arthur" status="OPEN" created_at="[null]" updated_at="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_update_action_plan-result.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_update_action_plan-result.xml deleted file mode 100644 index 2b855c97f05..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_update_action_plan-result.xml +++ /dev/null @@ -1,6 +0,0 @@ -<dataset> - - <action_plans id="1" kee="ABC" project_id="1" name="Long term" description="Long term action plan" deadline="[null]" - user_login="arthur" status="OPEN" created_at="[null]" updated_at="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_update_action_plan.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_update_action_plan.xml deleted file mode 100644 index 3da5c2083b5..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanDaoTest/should_update_action_plan.xml +++ /dev/null @@ -1,6 +0,0 @@ -<dataset> - - <action_plans id="1" kee="ABC" project_id="1" name="Old name" description="Old desc" deadline="[null]" - user_login="[null]" status="CLOSED" created_at="[null]" updated_at="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanStatsDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanStatsDaoTest/shared.xml deleted file mode 100644 index dfac83a8e2d..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanStatsDaoTest/shared.xml +++ /dev/null @@ -1,5 +0,0 @@ -<dataset> - - <projects id="1" uuid="PROJECT_UUID" kee="PROJECT_KEY" root_id="[null]"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanStatsDaoTest/should_find_by_project.xml b/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanStatsDaoTest/should_find_by_project.xml deleted file mode 100644 index 4db99c6f324..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/ActionPlanStatsDaoTest/should_find_by_project.xml +++ /dev/null @@ -1,84 +0,0 @@ -<dataset> - - <action_plans id="1" kee="ABC" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="OPEN" created_at="[null]" updated_at="[null]"/> - - <issues - id="100" - kee="ABCDE" - component_uuid="uuid-400" - project_uuid="uuid-400" - rule_id="500" - severity="BLOCKER" - manual_severity="[false]" - message="[null]" - line="200" - status="OPEN" - resolution="[null]" - checksum="XXX" - reporter="arthur" - assignee="perceval" - author_login="[null]" - issue_attributes="JIRA=FOO-1234" - action_plan_key="ABC" - issue_creation_date="1366063200000" - issue_update_date="1366063200000" - issue_close_date="1366063200000" - created_at="1400000000000" - updated_at="1400000000000" - locations="[null]" - /> - - <issues - id="101" - kee="ABCDF" - component_uuid="uuid-400" - project_uuid="uuid-400" - rule_id="500" - severity="BLOCKER" - manual_severity="[false]" - message="[null]" - line="200" - status="CLOSED" - resolution="FIXED" - checksum="XXX" - reporter="arthur" - assignee="perceval" - author_login="[null]" - issue_attributes="JIRA=FOO-1234" - action_plan_key="ABC" - issue_creation_date="1366063200000" - issue_update_date="1366063200000" - issue_close_date="1366063200000" - created_at="1400000000000" - updated_at="1400000000000" - locations="[null]" - /> - - <issues - id="102" - kee="ABCDG" - component_uuid="uuid-400" - project_uuid="uuid-400" - rule_id="500" - severity="BLOCKER" - manual_severity="[false]" - message="[null]" - line="200" - status="CLOSED" - resolution="FIXED" - checksum="XXX" - reporter="arthur" - assignee="perceval" - author_login="[null]" - issue_attributes="JIRA=FOO-1234" - action_plan_key="ABC" - issue_creation_date="1366063200000" - issue_update_date="1366063200000" - issue_close_date="1366063200000" - created_at="1400000000000" - updated_at="1400000000000" - locations="[null]" - /> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/issue/IssueDaoTest/find_by_action_plan.xml b/sonar-db/src/test/resources/org/sonar/db/issue/IssueDaoTest/find_by_action_plan.xml deleted file mode 100644 index 7a280fa52b6..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/issue/IssueDaoTest/find_by_action_plan.xml +++ /dev/null @@ -1,30 +0,0 @@ -<dataset> - - <issues - id="100" - kee="ABCDE" - component_uuid="CDEF" - project_uuid="ABCD" - rule_id="500" - severity="BLOCKER" - manual_severity="[false]" - message="[null]" - line="200" - gap="4.2" - status="OPEN" - resolution="FIXED" - checksum="XXX" - reporter="arthur" - assignee="perceval" - action_plan_key="AP-1" - author_login="karadoc" - issue_attributes="JIRA=FOO-1234" - issue_creation_date="1366063200000" - issue_update_date="1366063200000" - issue_close_date="1366063200000" - created_at="1400000000000" - updated_at="1400000000000" - locations="[null]" - /> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml index f1948def485..0649f12708c 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml @@ -18,9 +18,6 @@ build_date="1228222680000" version="[null]" path="[null]"/> - <action_plans id="1" kee="ABCD" project_id="1" name="SHORT_TERM" description="[null]" deadline="[null]" - user_login="igor" status="[null]" created_at="[null]" updated_at="[null]"/> - <issues id="1" kee="ABCDE" component_uuid="A" project_uuid="A" status="CLOSED" resolution="[null]" line="200" severity="BLOCKER" reporter="perceval" assignee="arthur" rule_id="500" |