diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-07-23 14:06:44 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-07-23 14:06:44 +0200 |
commit | 2890a151e4fd3034ad13601b9d79120e248d6cdd (patch) | |
tree | 0261c3ea1438427b70ee7ca938aeb94ff11124c4 | |
parent | 056b4bdc63c2ef126d9f9d2e0526f60be930cb81 (diff) | |
download | sonarqube-2890a151e4fd3034ad13601b9d79120e248d6cdd.tar.gz sonarqube-2890a151e4fd3034ad13601b9d79120e248d6cdd.zip |
Rename methods in DAO layer to follow conventions
173 files changed, 997 insertions, 1001 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/IssuesAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/IssuesAction.java index c6c5328a91c..64d7e0a7e0e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/IssuesAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/IssuesAction.java @@ -147,7 +147,7 @@ public class IssuesAction implements BatchWsAction { if (moduleUuid == null) { throw new IllegalArgumentException(String.format("The component '%s' has no module uuid", component.uuid())); } - ComponentDto module = dbClient.componentDao().selectNonNullByUuid(session, moduleUuid); + ComponentDto module = dbClient.componentDao().selectOrFailByUuid(session, moduleUuid); keysByUUid.put(module.uuid(), module.key()); } return keysByUUid; diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryLoader.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryLoader.java index 63fce32ee8e..63d8ad433f9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryLoader.java @@ -140,7 +140,7 @@ public class ProjectRepositoryLoader { private ComponentDto getProject(ComponentDto module, DbSession session) { if (!module.isRootProject()) { - return dbClient.componentDao().selectNonNullByUuid(session, module.projectUuid()); + return dbClient.componentDao().selectOrFailByUuid(session, module.projectUuid()); } else { return module; } @@ -161,7 +161,7 @@ public class ProjectRepositoryLoader { private void aggregateParentModules(ComponentDto component, List<ComponentDto> parents, DbSession session) { String moduleUuid = component.moduleUuid(); if (moduleUuid != null) { - ComponentDto parent = dbClient.componentDao().selectNonNullByUuid(session, moduleUuid); + ComponentDto parent = dbClient.componentDao().selectOrFailByUuid(session, moduleUuid); if (parent != null) { parents.add(parent); aggregateParentModules(parent, parents, session); diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java index 085898cb64e..1fda279305e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java @@ -91,7 +91,7 @@ public class ComponentService { public ComponentDto getNonNullByUuid(String uuid) { DbSession session = dbClient.openSession(false); try { - return dbClient.componentDao().selectNonNullByUuid(session, uuid); + return dbClient.componentDao().selectOrFailByUuid(session, uuid); } finally { session.close(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java b/server/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java index d5696b708f8..f572b30164e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/DefaultRubyComponentService.java @@ -52,7 +52,7 @@ public class DefaultRubyComponentService implements RubyComponentService { @Override @CheckForNull public Component findByKey(String key) { - return resourceDao.findByKey(key); + return resourceDao.selectByKey(key); } @CheckForNull @@ -74,7 +74,7 @@ public class DefaultRubyComponentService implements RubyComponentService { // Sub view should not be created with provisioning. Will be fixed by http://jira.sonarsource.com/browse/VIEWS-296 if (!Qualifiers.SUBVIEW.equals(qualifier)) { String createdKey = componentService.create(NewComponent.create(key, name).setQualifier(qualifier).setBranch(branch)); - ComponentDto component = (ComponentDto) resourceDao.findByKey(createdKey); + ComponentDto component = (ComponentDto) resourceDao.selectByKey(createdKey); if (component == null) { throw new BadRequestException(String.format("Component not created: %s", createdKey)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java index 0f05e3f568c..d81a4411113 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/AppAction.java @@ -134,7 +134,7 @@ public class AppAction implements RequestHandler { json.prop("q", component.qualifier()); ComponentDto parentProject = nullableComponentById(component.parentProjectId(), session); - ComponentDto project = dbClient.componentDao().selectNonNullByUuid(session, component.projectUuid()); + ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, component.projectUuid()); // Do not display parent project if parent project and project are the same boolean displayParentProject = parentProject != null && !parentProject.getId().equals(project.getId()); @@ -181,7 +181,7 @@ public class AppAction implements RequestHandler { private Map<String, MeasureDto> measuresByMetricKey(ComponentDto component, DbSession session) { Map<String, MeasureDto> measuresByMetricKey = newHashMap(); String fileKey = component.getKey(); - for (MeasureDto measureDto : dbClient.measureDao().findByComponentKeyAndMetricKeys(session, fileKey, METRIC_KEYS)) { + for (MeasureDto measureDto : dbClient.measureDao().selectByComponentKeyAndMetricKeys(session, fileKey, METRIC_KEYS)) { measuresByMetricKey.put(measureDto.getMetricKey(), measureDto); } return measuresByMetricKey; @@ -190,7 +190,7 @@ public class AppAction implements RequestHandler { @CheckForNull private ComponentDto nullableComponentById(@Nullable Long componentId, DbSession session) { if (componentId != null) { - return dbClient.componentDao().selectNonNullById(session, componentId); + return dbClient.componentDao().selectOrFailById(session, componentId); } return null; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java index 383b19df02b..e1041e58fea 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java @@ -70,7 +70,7 @@ public class MeasureRepositoryImpl implements MeasureRepository { requireNonNull(metric); try (DbSession dbSession = dbClient.openSession(false)) { - MeasureDto measureDto = dbClient.measureDao().findByComponentKeyAndMetricKey(dbSession, component.getKey(), metric.getKey()); + MeasureDto measureDto = dbClient.measureDao().selectByComponentKeyAndMetricKey(dbSession, component.getKey(), metric.getKey()); return measureDtoToMeasure.toMeasure(measureDto, metric); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java index c8766aa5116..7788935dff9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java @@ -59,7 +59,7 @@ public class PersistDuplicationsStep implements ComputationStep { public void execute() { DbSession session = dbClient.openSession(true); try { - MetricDto duplicationMetric = dbClient.metricDao().selectByKey(session, CoreMetrics.DUPLICATIONS_DATA_KEY); + MetricDto duplicationMetric = dbClient.metricDao().selectOrFailByKey(session, CoreMetrics.DUPLICATIONS_DATA_KEY); new DuplicationVisitor(session, duplicationMetric).visit(treeRootHolder.getRoot()); session.commit(); } finally { diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/SwitchSnapshotStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/SwitchSnapshotStep.java index 2152a24ff9a..8a566bcee38 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/SwitchSnapshotStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/SwitchSnapshotStep.java @@ -75,7 +75,7 @@ public class SwitchSnapshotStep implements ComputationStep { private void enableCurrentSnapshot(DbSession session, long reportSnapshotId) { SnapshotDao dao = dbClient.snapshotDao(); - SnapshotDto snapshot = dao.selectById(session, reportSnapshotId); + SnapshotDto snapshot = dao.selectOrFailById(session, reportSnapshotId); SnapshotDto previousLastSnapshot = dao.selectLastSnapshotByComponentId(session, snapshot.getComponentId()); boolean isLast = isLast(snapshot, previousLastSnapshot); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java index 5e4e5a21cf0..ba1dfc6acec 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ValidateProjectStep.java @@ -137,7 +137,7 @@ public class ValidateProjectStep implements ComputationStep { private void validateProjectKey(Optional<ComponentDto> baseProject, String rawProjectKey) { if (baseProject.isPresent() && !baseProject.get().projectUuid().equals(baseProject.get().uuid())) { // Project key is already used as a module of another project - ComponentDto anotherBaseProject = componentDao.selectNonNullByUuid(session, baseProject.get().projectUuid()); + ComponentDto anotherBaseProject = componentDao.selectOrFailByUuid(session, baseProject.get().projectUuid()); validationMessages.add(String.format("The project \"%s\" is already defined in SonarQube but as a module of project \"%s\". " + "If you really want to stop directly analysing project \"%s\", please first delete it from SonarQube and then relaunch the analysis of project \"%s\".", rawProjectKey, anotherBaseProject.key(), anotherBaseProject.key(), rawProjectKey)); @@ -182,7 +182,7 @@ public class ValidateProjectStep implements ComputationStep { private void validateModuleKeyIsNotAlreadyUsedInAnotherProject(ComponentDto baseModule, String rawModuleKey) { if (!baseModule.projectUuid().equals(baseModule.uuid()) && !baseModule.projectUuid().equals(rawProject.getUuid())) { - ComponentDto projectModule = componentDao.selectNonNullByUuid(session, baseModule.projectUuid()); + ComponentDto projectModule = componentDao.selectOrFailByUuid(session, baseModule.projectUuid()); validationMessages.add(String.format("Module \"%s\" is already part of project \"%s\"", rawModuleKey, projectModule.key())); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java index cd167f79481..b11c6fd7f2c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/GlobalDefaultDashboard.java @@ -88,6 +88,6 @@ public final class GlobalDefaultDashboard extends DashboardTemplate { } private MeasureFilterDto findSystemFilter(String name) { - return filterDao.findSystemFilterByName(name); + return filterDao.selectSystemFilterByName(name); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java index 52339a34334..0e68a12e43d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/ShowAction.java @@ -63,7 +63,7 @@ public class ShowAction implements DashboardsWsAction { DbSession dbSession = dbClient.openSession(false); try { Integer userId = userSession.getUserId(); - DashboardDto dashboard = dbClient.dashboardDao().getAllowedByKey(dbSession, request.mandatoryParamAsLong(PARAM_KEY), + DashboardDto dashboard = dbClient.dashboardDao().selectAllowedByKey(dbSession, request.mandatoryParamAsLong(PARAM_KEY), userId != null ? userId.longValue() : null); if (dashboard == null) { throw new NotFoundException(); @@ -78,7 +78,7 @@ public class ShowAction implements DashboardsWsAction { json.prop("global", dashboard.getGlobal()); json.prop("shared", dashboard.getShared()); if (dashboard.getUserId() != null) { - UserDto user = dbClient.userDao().getUser(dashboard.getUserId()); + UserDto user = dbClient.userDao().selectUserById(dashboard.getUserId()); if (user != null) { json.name("owner").beginObject(); // TODO to be shared and extracted from here @@ -91,7 +91,7 @@ public class ShowAction implements DashboardsWsAction { json.name("widgets").beginArray(); Collection<WidgetDto> widgets = dbClient.widgetDao().findByDashboard(dbSession, dashboard.getKey()); ListMultimap<Long, WidgetPropertyDto> propertiesByWidget = WidgetPropertyDto.groupByWidgetId( - dbClient.widgetPropertyDao().findByDashboard(dbSession, dashboard.getKey())); + dbClient.widgetPropertyDao().selectByDashboard(dbSession, dashboard.getKey())); for (WidgetDto widget : widgets) { json.beginObject(); json.prop("id", widget.getId()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java index 32c3a44580d..22c88c4f80b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java @@ -137,7 +137,7 @@ public class DebtModelBackup { DbSession session = dbClient.openSession(false); try { // Restore characteristics - List<CharacteristicDto> allCharacteristicDtos = restoreCharacteristics(loadModelFromPlugin(DebtModelPluginRepository.DEFAULT_MODEL), updateDate, session); + List<CharacteristicDto> allCharacteristicDtos = restoreCharacteristics(session, loadModelFromPlugin(DebtModelPluginRepository.DEFAULT_MODEL), updateDate); // Restore rules List<RuleDto> ruleDtos = dbClient.ruleDao().selectEnabledAndNonManual(session); @@ -215,7 +215,7 @@ public class DebtModelBackup { Date updateDate = new Date(system2.now()); DbSession session = dbClient.openSession(false); try { - List<CharacteristicDto> allCharacteristicDtos = restoreCharacteristics(characteristicsXMLImporter.importXML(xml), updateDate, session); + List<CharacteristicDto> allCharacteristicDtos = restoreCharacteristics(session, characteristicsXMLImporter.importXML(xml), updateDate); restoreRules(allCharacteristicDtos, rules(languageKey, session), rulesXMLImporter.importXML(xml, validationMessages), validationMessages, updateDate, session); session.commit(); @@ -248,7 +248,7 @@ public class DebtModelBackup { } @VisibleForTesting - List<CharacteristicDto> restoreCharacteristics(DebtModel targetModel, Date updateDate, DbSession session) { + List<CharacteristicDto> restoreCharacteristics(DbSession session, DebtModel targetModel, Date updateDate) { List<CharacteristicDto> sourceCharacteristics = dbClient.debtCharacteristicDao().selectEnabledCharacteristics(session); List<CharacteristicDto> result = newArrayList(); @@ -275,7 +275,7 @@ public class DebtModelBackup { CharacteristicDto sourceCharacteristic = characteristicByKey(targetCharacteristic.key(), sourceCharacteristics, false); if (sourceCharacteristic == null) { CharacteristicDto newCharacteristic = toDto(targetCharacteristic, parentId).setCreatedAt(updateDate); - dbClient.debtCharacteristicDao().insert(newCharacteristic, session); + dbClient.debtCharacteristicDao().insert(session, newCharacteristic); return newCharacteristic; } else { // Update only if modifications diff --git a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java index 77513d7c15e..9839d2cf71d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java +++ b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java @@ -79,7 +79,7 @@ public class DebtModelOperations { // New root characteristic newCharacteristic.setOrder(dbClient.debtCharacteristicDao().selectMaxCharacteristicOrder(session) + 1); } - dbClient.debtCharacteristicDao().insert(newCharacteristic, session); + dbClient.debtCharacteristicDao().insert(session, newCharacteristic); session.commit(); return toCharacteristic(newCharacteristic); } finally { @@ -207,7 +207,7 @@ public class DebtModelOperations { private void disableSubCharacteristic(CharacteristicDto subCharacteristic, Date updateDate, DbSession session) { // Disable debt on all rules (even REMOVED ones, in order to have no issue if they are reactivated) linked to the sub characteristic - disableRulesDebt(dbClient.ruleDao().findRulesByDebtSubCharacteristicId(session, subCharacteristic.getId()), subCharacteristic.getId(), updateDate, session); + disableRulesDebt(dbClient.ruleDao().selectRulesByDebtSubCharacteristicId(session, subCharacteristic.getId()), subCharacteristic.getId(), updateDate, session); disableCharacteristic(subCharacteristic, updateDate, session); } @@ -237,7 +237,7 @@ public class DebtModelOperations { } private CharacteristicDto findCharacteristic(Integer id, SqlSession session) { - CharacteristicDto dto = dbClient.debtCharacteristicDao().selectById(id, session); + CharacteristicDto dto = dbClient.debtCharacteristicDao().selectById(session, id); if (dto == null) { throw new NotFoundException(String.format("Characteristic with id %s does not exists.", id)); } @@ -245,7 +245,7 @@ public class DebtModelOperations { } private void checkNotAlreadyExists(String name, SqlSession session) { - if (dbClient.debtCharacteristicDao().selectByName(name, session) != null) { + if (dbClient.debtCharacteristicDao().selectByName(session, name) != null) { throw new BadRequestException(Validation.IS_ALREADY_USED_MESSAGE, name); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java index 0eac871bb7a..3c064d0150b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java @@ -100,7 +100,7 @@ public class ShowAction implements RequestHandler { @CheckForNull private String findDataFromComponent(String fileKey, String metricKey, DbSession session) { - MeasureDto measure = measureDao.findByComponentKeyAndMetricKey(session, fileKey, metricKey); + MeasureDto measure = measureDao.selectByComponentKeyAndMetricKey(session, fileKey, metricKey); if (measure != null) { return measure.getData(); } 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 7da35289923..bca049f9b71 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 @@ -407,7 +407,7 @@ public class InternalRubyIssueService { if (Strings.isNullOrEmpty(projectParam)) { result.addError(Result.Message.ofL10n(Validation.CANT_BE_EMPTY_MESSAGE, PROJECT_PARAM)); } else { - ResourceDto project = resourceDao.getResource(ResourceQuery.create().setKey(projectParam)); + ResourceDto project = resourceDao.selectResource(ResourceQuery.create().setKey(projectParam)); if (project == null) { result.addError(Result.Message.ofL10n("action_plans.errors.project_does_not_exist", projectParam)); } 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 7badf04fb8d..8af900a154b 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 @@ -249,7 +249,7 @@ public class IssueService { throw new NotFoundException(String.format("Component with key '%s' not found", componentKey)); } ComponentDto component = componentOptional.get(); - ComponentDto project = dbClient.componentDao().selectNonNullByUuid(session, component.projectUuid()); + ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, component.projectUuid()); userSession.checkProjectPermission(UserRole.USER, project.getKey()); if (!ruleKey.isManual()) { 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 index be321bda86b..99a2ff07088 100644 --- 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 @@ -131,7 +131,7 @@ public class ActionPlanService { @CheckForNull public ActionPlan findByKey(String key, UserSession userSession) { - ActionPlanDto actionPlanDto = actionPlanDao.findByKey(key); + ActionPlanDto actionPlanDto = actionPlanDao.selectByKey(key); if (actionPlanDto == null) { return null; } @@ -140,7 +140,7 @@ public class ActionPlanService { } public List<ActionPlan> findByKeys(Collection<String> keys) { - List<ActionPlanDto> actionPlanDtos = actionPlanDao.findByKeys(keys); + List<ActionPlanDto> actionPlanDtos = actionPlanDao.selectByKeys(keys); return toActionPlans(actionPlanDtos); } @@ -148,7 +148,7 @@ public class ActionPlanService { ResourceDto project = findProject(projectKey); checkUserCanAccessProject(project.getKey(), userSession); - List<ActionPlanDto> dtos = actionPlanDao.findOpenByProjectId(project.getId()); + List<ActionPlanDto> dtos = actionPlanDao.selectOpenByProjectId(project.getId()); List<ActionPlan> plans = toActionPlans(dtos); Collections.sort(plans, new ActionPlanDeadlineComparator()); return plans; @@ -158,14 +158,14 @@ public class ActionPlanService { ResourceDto project = findProject(projectKey); checkUserCanAccessProject(project.getKey(), userSession); - List<ActionPlanStatsDto> actionPlanStatsDtos = actionPlanStatsDao.findByProjectId(project.getId()); + 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.findByNameAndProjectId(name, findProject(projectKey).getId()).isEmpty(); + return !actionPlanDao.selectByNameAndProjectId(name, findProject(projectKey).getId()).isEmpty(); } private List<ActionPlan> toActionPlans(List<ActionPlanDto> actionPlanDtos) { @@ -173,7 +173,7 @@ public class ActionPlanService { } private ActionPlanDto findActionPlanDto(String actionPlanKey) { - ActionPlanDto actionPlanDto = actionPlanDao.findByKey(actionPlanKey); + ActionPlanDto actionPlanDto = actionPlanDao.selectByKey(actionPlanKey); if (actionPlanDto == null) { throw new NotFoundException("Action plan " + actionPlanKey + " has not been found."); } @@ -181,7 +181,7 @@ public class ActionPlanService { } private ResourceDto findProject(String projectKey) { - ResourceDto resourceDto = resourceDao.getResource(ResourceQuery.create().setKey(projectKey)); + ResourceDto resourceDto = resourceDao.selectResource(ResourceQuery.create().setKey(projectKey)); if (resourceDto == null) { throw new NotFoundException("Project " + projectKey + " does not exists."); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/NewIssuesNotification.java b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/NewIssuesNotification.java index e09bc32f4ff..2c550dbee84 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/notification/NewIssuesNotification.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/notification/NewIssuesNotification.java @@ -112,7 +112,7 @@ public class NewIssuesNotification extends Notification { try { for (int i = 0; i < 5 && i < componentStats.size(); i++) { String uuid = componentStats.get(i).getElement(); - String componentName = dbClient.componentDao().selectNonNullByUuid(dbSession, uuid).name(); + String componentName = dbClient.componentDao().selectOrFailByUuid(dbSession, uuid).name(); setFieldValue(metric + DOT + (i + 1) + LABEL, componentName); setFieldValue(metric + DOT + (i + 1) + COUNT, String.valueOf(componentStats.get(i).getCount())); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/ShowAction.java index 373c4db14c8..5487d2ee999 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/ShowAction.java @@ -169,10 +169,10 @@ public class ShowAction implements IssuesWsAction { } private void addComponents(DbSession session, Issue issue, JsonWriter json) { - ComponentDto component = dbClient.componentDao().selectNonNullByUuid(session, issue.componentUuid()); + ComponentDto component = dbClient.componentDao().selectOrFailByUuid(session, issue.componentUuid()); Long parentProjectId = component.parentProjectId(); Optional<ComponentDto> parentProject = parentProjectId != null ? dbClient.componentDao().selectById(session, parentProjectId) : Optional.<ComponentDto>absent(); - ComponentDto project = dbClient.componentDao().selectNonNullByUuid(session, component.projectUuid()); + ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, component.projectUuid()); String projectName = project.longName() != null ? project.longName() : project.name(); // Do not display sub project long name if sub project and project are the same diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java index 8d88085c834..7fb1fc44f99 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java @@ -162,6 +162,6 @@ public class CreateAction implements CustomMeasuresWsAction { return dbClient.metricDao().selectById(dbSession, metricId); } - return dbClient.metricDao().selectByKey(dbSession, metricKey); + return dbClient.metricDao().selectOrFailByKey(dbSession, metricKey); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/DeleteAction.java index f4f2dd10eb7..237495bcba5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/DeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/DeleteAction.java @@ -65,7 +65,7 @@ public class DeleteAction implements CustomMeasuresWsAction { DbSession dbSession = dbClient.openSession(false); try { - CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectById(dbSession, id); + CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectOrFail(dbSession, id); checkPermissions(dbSession, customMeasure); dbClient.customMeasureDao().delete(dbSession, id); dbSession.commit(); @@ -81,7 +81,7 @@ public class DeleteAction implements CustomMeasuresWsAction { return; } - ComponentDto component = dbClient.componentDao().selectNonNullByUuid(dbSession, customMeasure.getComponentUuid()); + ComponentDto component = dbClient.componentDao().selectOrFailByUuid(dbSession, customMeasure.getComponentUuid()); userSession.checkLoggedIn().checkProjectUuidPermission(UserRole.ADMIN, component.projectUuid()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/UpdateAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/UpdateAction.java index e1db533b5f6..b9c15ea2f09 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/UpdateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/UpdateAction.java @@ -93,9 +93,9 @@ public class UpdateAction implements CustomMeasuresWsAction { DbSession dbSession = dbClient.openSession(true); try { - CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectById(dbSession, id); + CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectOrFail(dbSession, id); MetricDto metric = dbClient.metricDao().selectById(dbSession, customMeasure.getMetricId()); - ComponentDto component = dbClient.componentDao().selectNonNullByUuid(dbSession, customMeasure.getComponentUuid()); + ComponentDto component = dbClient.componentDao().selectOrFailByUuid(dbSession, customMeasure.getComponentUuid()); checkPermissions(userSession, component); User user = userIndex.getByLogin(userSession.getLogin()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/DefaultMetricFinder.java b/server/sonar-server/src/main/java/org/sonar/server/metric/DefaultMetricFinder.java index fea0509d71b..e6eb24eb131 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/metric/DefaultMetricFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/metric/DefaultMetricFinder.java @@ -60,7 +60,7 @@ public class DefaultMetricFinder implements MetricFinder { public Metric findByKey(String key) { DbSession session = dbClient.openSession(false); try { - MetricDto dto = dbClient.metricDao().selectNullableByKey(session, key); + MetricDto dto = dbClient.metricDao().selectByKey(session, key); if (dto != null && dto.isEnabled()) { return ToMetric.INSTANCE.apply(dto); } @@ -74,7 +74,7 @@ public class DefaultMetricFinder implements MetricFinder { public Collection<Metric> findAll(List<String> metricKeys) { DbSession session = dbClient.openSession(false); try { - List<MetricDto> dtos = dbClient.metricDao().selectNullableByKeys(session, metricKeys); + List<MetricDto> dtos = dbClient.metricDao().selectByKeys(session, metricKeys); return from(dtos).filter(IsEnabled.INSTANCE).transform(ToMetric.INSTANCE).toList(); } finally { MyBatis.closeQuietly(session); diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/CreateAction.java b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/CreateAction.java index 2f65f8ebeb0..708309d14db 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/CreateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/CreateAction.java @@ -105,7 +105,7 @@ public class CreateAction implements MetricsWsAction { DbSession dbSession = dbClient.openSession(false); try { MetricDto metricTemplate = newMetricTemplate(request); - MetricDto metricInDb = dbClient.metricDao().selectNullableByKey(dbSession, key); + MetricDto metricInDb = dbClient.metricDao().selectByKey(dbSession, key); checkMetricInDbAndTemplate(dbSession, metricInDb, metricTemplate); if (metricIsNotInDb(metricInDb)) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/DeleteAction.java index 4da369d1e0c..f46b50bb8fb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/DeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/DeleteAction.java @@ -93,7 +93,7 @@ public class DeleteAction implements MetricsWsAction { if (idsAsStrings != null) { ids = Lists.transform(idsAsStrings, new StringToIntegerFunction()); } else if (keys != null) { - ids = Lists.transform(dbClient.metricDao().selectNullableByKeys(dbSession, keys), new MetricDtoToIdFunction()); + ids = Lists.transform(dbClient.metricDao().selectByKeys(dbSession, keys), new MetricDtoToIdFunction()); } return ids; diff --git a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/UpdateAction.java b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/UpdateAction.java index 1e1f0cf01d8..ce27a51a3b2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/metric/ws/UpdateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/metric/ws/UpdateAction.java @@ -191,7 +191,7 @@ public class UpdateAction implements MetricsWsAction { private void checkNoOtherMetricWithTargetKey(DbSession dbSession, MetricDto metricInDb, MetricDto template) { String targetKey = template.getKey(); - MetricDto metricWithTargetKey = dbClient.metricDao().selectNullableByKey(dbSession, targetKey); + MetricDto metricWithTargetKey = dbClient.metricDao().selectByKey(dbSession, targetKey); if (isMetricFoundInDb(metricWithTargetKey) && !metricInDb.getId().equals(metricWithTargetKey.getId())) { throw new BadRequestException(String.format("The key '%s' is already used by an existing metric.", targetKey)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java b/server/sonar-server/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java index c30fed67119..9dd264dc5f0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java +++ b/server/sonar-server/src/main/java/org/sonar/server/notification/DefaultNotificationManager.java @@ -91,7 +91,7 @@ public class DefaultNotificationManager implements NotificationManager { */ public Notification getFromQueue() { int batchSize = 1; - List<NotificationQueueDto> notificationDtos = notificationQueueDao.findOldest(batchSize); + List<NotificationQueueDto> notificationDtos = notificationQueueDao.selectOldest(batchSize); if (notificationDtos.isEmpty()) { return null; } @@ -141,11 +141,11 @@ public class DefaultNotificationManager implements NotificationManager { String channelKey = channel.getKey(); // Find users subscribed globally to the dispatcher (i.e. not on a specific project) - addUsersToRecipientListForChannel(propertiesDao.findUsersForNotification(dispatcherKey, channelKey, null), recipients, channel); + addUsersToRecipientListForChannel(propertiesDao.selectUsersForNotification(dispatcherKey, channelKey, null), recipients, channel); if (projectUuid != null) { // Find users subscribed to the dispatcher specifically for the project - addUsersToRecipientListForChannel(propertiesDao.findUsersForNotification(dispatcherKey, channelKey, projectUuid), recipients, channel); + addUsersToRecipientListForChannel(propertiesDao.selectUsersForNotification(dispatcherKey, channelKey, projectUuid), recipients, channel); } } @@ -158,7 +158,7 @@ public class DefaultNotificationManager implements NotificationManager { SetMultimap<String, NotificationChannel> recipients = HashMultimap.create(); for (NotificationChannel channel : notificationChannels) { - addUsersToRecipientListForChannel(propertiesDao.findNotificationSubscribers(dispatcherKey, channel.getKey(), componentKey), recipients, channel); + addUsersToRecipientListForChannel(propertiesDao.selectNotificationSubscribers(dispatcherKey, channel.getKey(), componentKey), recipients, channel); } return recipients; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java b/server/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java index ae89013e22d..0373abeac4a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java @@ -97,7 +97,7 @@ public class InternalPermissionTemplateService { PermissionTemplateUpdater.checkSystemAdminUser(userSession); validateTemplateName(null, name); validateKeyPattern(keyPattern); - PermissionTemplateDto permissionTemplateDto = permissionTemplateDao.createPermissionTemplate(name, description, keyPattern); + PermissionTemplateDto permissionTemplateDto = permissionTemplateDao.insertPermissionTemplate(name, description, keyPattern); return PermissionTemplate.create(permissionTemplateDto); } @@ -118,7 +118,7 @@ public class InternalPermissionTemplateService { @Override protected void doExecute(Long templateId, String permission) { Long userId = getUserId(); - permissionTemplateDao.addUserPermission(templateId, userId, permission); + permissionTemplateDao.insertUserPermission(templateId, userId, permission); } }; updater.executeUpdate(); @@ -129,7 +129,7 @@ public class InternalPermissionTemplateService { @Override protected void doExecute(Long templateId, String permission) { Long userId = getUserId(); - permissionTemplateDao.removeUserPermission(templateId, userId, permission); + permissionTemplateDao.deleteUserPermission(templateId, userId, permission); } }; updater.executeUpdate(); @@ -140,7 +140,7 @@ public class InternalPermissionTemplateService { @Override protected void doExecute(Long templateId, String permission) { Long groupId = getGroupId(); - permissionTemplateDao.addGroupPermission(templateId, groupId, permission); + permissionTemplateDao.insertGroupPermission(templateId, groupId, permission); } }; updater.executeUpdate(); @@ -151,7 +151,7 @@ public class InternalPermissionTemplateService { @Override protected void doExecute(Long templateId, String permission) { Long groupId = getGroupId(); - permissionTemplateDao.removeGroupPermission(templateId, groupId, permission); + permissionTemplateDao.deleteGroupPermission(templateId, groupId, permission); } }; updater.executeUpdate(); @@ -165,7 +165,7 @@ public class InternalPermissionTemplateService { if (group == null) { throw new NotFoundException("Group does not exists : " + groupName); } - permissionTemplateDao.removeByGroup(group.getId(), session); + permissionTemplateDao.deleteByGroup(session, group.getId()); session.commit(); } finally { MyBatis.closeQuietly(session); diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionFinder.java b/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionFinder.java index c9f5a22ee1a..026c6adff65 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/PermissionFinder.java @@ -109,7 +109,7 @@ public class PermissionFinder { if (componentKey == null) { return null; } else { - ResourceDto resourceDto = resourceDao.getResource(ResourceQuery.create().setKey(componentKey)); + ResourceDto resourceDto = resourceDao.selectResource(ResourceQuery.create().setKey(componentKey)); if (resourceDto == null) { throw new NotFoundException(String.format("Component '%s' does not exist", componentKey)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/PersistentSettings.java b/server/sonar-server/src/main/java/org/sonar/server/platform/PersistentSettings.java index 480cd19f894..de83e58f4f7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/PersistentSettings.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/PersistentSettings.java @@ -57,7 +57,7 @@ public class PersistentSettings implements Startable { public PersistentSettings saveProperty(String key, @Nullable String value) { settings.setProperty(key, value); - propertiesDao.setProperty(new PropertyDto().setKey(key).setValue(value)); + propertiesDao.insertProperty(new PropertyDto().setKey(key).setValue(value)); return this; } @@ -75,7 +75,7 @@ public class PersistentSettings implements Startable { public PersistentSettings saveProperties(Map<String, String> properties) { settings.addProperties(properties); - propertiesDao.saveGlobalProperties(properties); + propertiesDao.insertGlobalProperties(properties); return this; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java index ea308eb7b36..10ffe2417cc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java @@ -156,7 +156,7 @@ public class QualityGates { settings.removeProperty(SONAR_QUALITYGATE_PROPERTY); } else { QualityGateDto newDefault = getNonNullQgate(idToUseAsDefault); - propertiesDao.setProperty(new PropertyDto().setKey(SONAR_QUALITYGATE_PROPERTY).setValue(newDefault.getId().toString())); + propertiesDao.insertProperty(new PropertyDto().setKey(SONAR_QUALITYGATE_PROPERTY).setValue(newDefault.getId().toString())); settings.setProperty(SONAR_QUALITYGATE_PROPERTY, idToUseAsDefault); } } @@ -218,7 +218,7 @@ public class QualityGates { try { getNonNullQgate(qGateId); checkPermission(projectId, session); - propertiesDao.setProperty(new PropertyDto().setKey(SONAR_QUALITYGATE_PROPERTY).setResourceId(projectId).setValue(qGateId.toString())); + propertiesDao.insertProperty(new PropertyDto().setKey(SONAR_QUALITYGATE_PROPERTY).setResourceId(projectId).setValue(qGateId.toString())); } finally { MyBatis.closeQuietly(session); } @@ -365,7 +365,7 @@ public class QualityGates { } private void checkPermission(Long projectId, DbSession session) { - ComponentDto project = componentDao.selectNonNullById(session, projectId); + ComponentDto project = componentDao.selectOrFailById(session, projectId); if (!userSession.hasGlobalPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN) && !userSession.hasProjectPermission(UserRole.ADMIN, project.key())) { throw new ForbiddenException("Insufficient privileges"); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java index afad30cfaab..6681e3e7ddc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java @@ -68,7 +68,7 @@ public class QProfileBackuper { QualityProfileDto profile; DbSession dbSession = db.openSession(false); try { - profile = db.qualityProfileDao().getNonNullByKey(dbSession, key); + profile = db.qualityProfileDao().selectOrFailByKey(dbSession, key); } finally { dbSession.close(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java index 9fc6a666628..3e19cdd5b44 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java @@ -61,9 +61,9 @@ public class QProfileComparison { } private void compare(String leftKey, String rightKey, DbSession session, QProfileComparisonResult result) { - result.left = dbClient.qualityProfileDao().getByKey(session, leftKey); + result.left = dbClient.qualityProfileDao().selectByKey(session, leftKey); Preconditions.checkArgument(result.left != null, String.format("Could not find left profile '%s'", leftKey)); - result.right = dbClient.qualityProfileDao().getByKey(session, rightKey); + result.right = dbClient.qualityProfileDao().selectByKey(session, rightKey); Preconditions.checkArgument(result.right != null, String.format("Could not find right profile '%s'", leftKey)); Map<RuleKey, ActiveRule> leftActiveRulesByRuleKey = loadActiveRules(leftKey); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileCopier.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileCopier.java index 22685e1414f..49924afdadb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileCopier.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileCopier.java @@ -66,10 +66,10 @@ public class QProfileCopier { private QualityProfileDto prepareTarget(String fromProfileKey, String toName) { DbSession dbSession = db.openSession(false); try { - QualityProfileDto fromProfile = db.qualityProfileDao().getNonNullByKey(dbSession, fromProfileKey); + QualityProfileDto fromProfile = db.qualityProfileDao().selectOrFailByKey(dbSession, fromProfileKey); QProfileName toProfileName = new QProfileName(fromProfile.getLanguage(), toName); verify(fromProfile, toProfileName); - QualityProfileDto toProfile = db.qualityProfileDao().getByNameAndLanguage(toProfileName.getName(), toProfileName.getLanguage(), dbSession); + QualityProfileDto toProfile = db.qualityProfileDao().selectByNameAndLanguage(toProfileName.getName(), toProfileName.getLanguage(), dbSession); if (toProfile == null) { // Do not delegate creation to QProfileBackuper because we need to keep // the parent-child association, if exists. diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java index f90be5b0e86..036e62723d5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileFactory.java @@ -46,7 +46,7 @@ public class QProfileFactory { // ------------- CREATION QualityProfileDto getOrCreate(DbSession dbSession, QProfileName name) { - QualityProfileDto profile = db.qualityProfileDao().getByNameAndLanguage(name.getName(), name.getLanguage(), dbSession); + QualityProfileDto profile = db.qualityProfileDao().selectByNameAndLanguage(name.getName(), name.getLanguage(), dbSession); if (profile == null) { profile = doCreate(dbSession, name); } @@ -54,7 +54,7 @@ public class QProfileFactory { } public QualityProfileDto create(DbSession dbSession, QProfileName name) { - QualityProfileDto dto = db.qualityProfileDao().getByNameAndLanguage(name.getName(), name.getLanguage(), dbSession); + QualityProfileDto dto = db.qualityProfileDao().selectByNameAndLanguage(name.getName(), name.getLanguage(), dbSession); if (dto != null) { throw new BadRequestException("Quality profile already exists: " + name); } @@ -72,7 +72,7 @@ public class QProfileFactory { .setName(name.getName()) .setLanguage(name.getLanguage()) .setRulesUpdatedAtAsDate(now); - if (db.qualityProfileDao().getByKey(dbSession, dto.getKey()) == null) { + if (db.qualityProfileDao().selectByKey(dbSession, dto.getKey()) == null) { db.qualityProfileDao().insert(dbSession, dto); return dto; } @@ -98,8 +98,8 @@ public class QProfileFactory { * except if the parameter <code>force</code> is true. */ public void delete(DbSession session, String key, boolean force) { - QualityProfileDto profile = db.qualityProfileDao().getNonNullByKey(session, key); - List<QualityProfileDto> descendants = db.qualityProfileDao().findDescendants(session, key); + QualityProfileDto profile = db.qualityProfileDao().selectOrFailByKey(session, key); + List<QualityProfileDto> descendants = db.qualityProfileDao().selectDescendants(session, key); if (!force) { checkNotDefault(profile); for (QualityProfileDto descendant : descendants) { @@ -133,7 +133,7 @@ public class QProfileFactory { @CheckForNull public QualityProfileDto getDefault(DbSession session, String language) { - return db.qualityProfileDao().getDefaultProfile(language, session); + return db.qualityProfileDao().selectDefaultProfile(session, language); } public void setDefault(String profileKey) { @@ -147,13 +147,13 @@ public class QProfileFactory { void setDefault(DbSession dbSession, String profileKey) { Verifications.check(StringUtils.isNotBlank(profileKey), "Profile key must be set"); - QualityProfileDto profile = db.qualityProfileDao().getNonNullByKey(dbSession, profileKey); + QualityProfileDto profile = db.qualityProfileDao().selectOrFailByKey(dbSession, profileKey); setDefault(dbSession, profile); dbSession.commit(); } private void setDefault(DbSession session, QualityProfileDto profile) { - QualityProfileDto previousDefault = db.qualityProfileDao().getDefaultProfile(profile.getLanguage(), session); + QualityProfileDto previousDefault = db.qualityProfileDao().selectDefaultProfile(session, profile.getLanguage()); if (previousDefault != null) { db.qualityProfileDao().update(session, previousDefault.setDefault(false)); } @@ -171,7 +171,7 @@ public class QProfileFactory { @CheckForNull public QualityProfileDto getByProjectAndLanguage(DbSession session, String projectKey, String language) { - return db.qualityProfileDao().getByProjectAndLanguage(projectKey, language, session); + return db.qualityProfileDao().selectByProjectAndLanguage(session, projectKey, language); } QualityProfileDto getByNameAndLanguage(String name, String language) { @@ -185,7 +185,7 @@ public class QProfileFactory { @CheckForNull public QualityProfileDto getByNameAndLanguage(DbSession session, String name, String language) { - return db.qualityProfileDao().getByNameAndLanguage(name, language, session); + return db.qualityProfileDao().selectByNameAndLanguage(name, language, session); } private void checkNotDefault(QualityProfileDto p) { @@ -201,9 +201,9 @@ public class QProfileFactory { Verifications.check(newName.length() < 100, String.format("Name is too long (>%d characters)", 100)); DbSession dbSession = db.openSession(false); try { - QualityProfileDto profile = db.qualityProfileDao().getNonNullByKey(dbSession, key); + QualityProfileDto profile = db.qualityProfileDao().selectOrFailByKey(dbSession, key); if (!StringUtils.equals(newName, profile.getName())) { - if (db.qualityProfileDao().getByNameAndLanguage(newName, profile.getLanguage(), dbSession) != null) { + if (db.qualityProfileDao().selectByNameAndLanguage(newName, profile.getLanguage(), dbSession) != null) { throw new BadRequestException("Quality profile already exists: " + newName); } profile.setName(newName); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java index 50ae9a3b777..d4d49177118 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java @@ -63,7 +63,7 @@ public class QProfileLoader { public List<QualityProfileDto> findAll() { DbSession dbSession = db.openSession(false); try { - return db.qualityProfileDao().findAll(dbSession); + return db.qualityProfileDao().selectAll(dbSession); } finally { dbSession.close(); } @@ -73,7 +73,7 @@ public class QProfileLoader { public QualityProfileDto getByKey(String key) { DbSession dbSession = db.openSession(false); try { - return db.qualityProfileDao().getByKey(dbSession, key); + return db.qualityProfileDao().selectByKey(dbSession, key); } finally { dbSession.close(); } @@ -83,7 +83,7 @@ public class QProfileLoader { public QualityProfileDto getByLangAndName(String lang, String name) { DbSession dbSession = db.openSession(false); try { - return db.qualityProfileDao().getByNameAndLanguage(name, lang, dbSession); + return db.qualityProfileDao().selectByNameAndLanguage(name, lang, dbSession); } finally { dbSession.close(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java index 5c0ad9b44dd..8dd068570c2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java @@ -42,11 +42,11 @@ public class QProfileLookup { } public List<QProfile> allProfiles() { - return toQProfiles(db.qualityProfileDao().findAll()); + return toQProfiles(db.qualityProfileDao().selectAll()); } public List<QProfile> profiles(String language) { - return toQProfiles(db.qualityProfileDao().findByLanguage(language)); + return toQProfiles(db.qualityProfileDao().selectByLanguage(language)); } @CheckForNull @@ -113,7 +113,7 @@ public class QProfileLookup { } public List<QProfile> children(QProfile profile, DbSession session) { - return toQProfiles(db.qualityProfileDao().findChildren(session, profile.key())); + return toQProfiles(db.qualityProfileDao().selectChildren(session, profile.key())); } public List<QProfile> ancestors(QualityProfileDto profile, DbSession session) { @@ -135,7 +135,7 @@ public class QProfileLookup { private void incrementAncestors(QProfile profile, List<QProfile> ancestors, DbSession session) { if (profile.parent() != null) { - QualityProfileDto parentDto = db.qualityProfileDao().getParentById(profile.id(), session); + QualityProfileDto parentDto = db.qualityProfileDao().selectParentById(session, profile.id()); if (parentDto == null) { throw new IllegalStateException("Cannot find parent of profile : " + profile.id()); } @@ -151,12 +151,12 @@ public class QProfileLookup { @CheckForNull private QualityProfileDto findQualityProfile(int id, DbSession session) { - return db.qualityProfileDao().getById(id, session); + return db.qualityProfileDao().selectById(session, id); } @CheckForNull private QualityProfileDto findQualityProfile(String name, String language, DbSession session) { - return db.qualityProfileDao().getByNameAndLanguage(name, language, session); + return db.qualityProfileDao().selectByNameAndLanguage(name, language, session); } private enum ToQProfile implements Function<QualityProfileDto, QProfile> { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java index 76100b1d996..41f18501e3e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java @@ -52,7 +52,7 @@ public class QProfileProjectLookup { public List<Component> projects(int profileId) { DbSession session = db.openSession(false); try { - QualityProfileDto qualityProfile = db.qualityProfileDao().getById(profileId, session); + QualityProfileDto qualityProfile = db.qualityProfileDao().selectById(session, profileId); QProfileValidations.checkProfileIsNotNull(qualityProfile); Map<String, Component> componentsByKeys = Maps.newHashMap(); for (Component component : db.qualityProfileDao().selectProjects(qualityProfile.getName(), qualityProfile.getLanguage(), session)) { @@ -79,7 +79,7 @@ public class QProfileProjectLookup { @CheckForNull public QProfile findProfileByProjectAndLanguage(long projectId, String language) { - QualityProfileDto dto = db.qualityProfileDao().getByProjectAndLanguage(projectId, language); + QualityProfileDto dto = db.qualityProfileDao().selectByProjectAndLanguage(projectId, language); if (dto != null) { return QProfile.from(dto); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java index 0a301efea93..2547ba1c5a9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java @@ -55,11 +55,11 @@ public class QProfileProjectOperations { } void addProject(String profileKey, String projectUuid, UserSession userSession, DbSession session) { - ComponentDto project = db.componentDao().selectNonNullByUuid(session, projectUuid); + ComponentDto project = db.componentDao().selectOrFailByUuid(session, projectUuid); checkPermission(userSession, project.key()); QualityProfileDto qualityProfile = findNotNull(profileKey, session); - QualityProfileDto currentProfile = db.qualityProfileDao().getByProjectAndLanguage(project.key(), qualityProfile.getLanguage(), session); + QualityProfileDto currentProfile = db.qualityProfileDao().selectByProjectAndLanguage(session, project.key(), qualityProfile.getLanguage()); boolean updated = false; if (currentProfile == null) { @@ -77,7 +77,7 @@ public class QProfileProjectOperations { public void removeProject(String profileKey, String projectUuid, UserSession userSession) { DbSession session = db.openSession(false); try { - ComponentDto project = db.componentDao().selectNonNullByUuid(session, projectUuid); + ComponentDto project = db.componentDao().selectOrFailByUuid(session, projectUuid); checkPermission(userSession, project.key()); QualityProfileDto qualityProfile = findNotNull(profileKey, session); @@ -91,10 +91,10 @@ public class QProfileProjectOperations { public void removeProject(String language, long projectId, UserSession userSession) { DbSession session = db.openSession(false); try { - ComponentDto project = db.componentDao().selectNonNullById(session, projectId); + ComponentDto project = db.componentDao().selectOrFailById(session, projectId); checkPermission(userSession, project.key()); - QualityProfileDto associatedProfile = db.qualityProfileDao().getByProjectAndLanguage(project.getKey(), language, session); + QualityProfileDto associatedProfile = db.qualityProfileDao().selectByProjectAndLanguage(session, project.getKey(), language); if (associatedProfile != null) { db.qualityProfileDao().deleteProjectProfileAssociation(project.uuid(), associatedProfile.getKey(), session); session.commit(); @@ -117,7 +117,7 @@ public class QProfileProjectOperations { } private QualityProfileDto findNotNull(String key, DbSession session) { - QualityProfileDto qualityProfile = db.qualityProfileDao().getByKey(session, key); + QualityProfileDto qualityProfile = db.qualityProfileDao().selectByKey(session, key); QProfileValidations.checkProfileIsNotNull(qualityProfile); return qualityProfile; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileReset.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileReset.java index e3ac5e2fc51..5db1b1b1b3e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileReset.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileReset.java @@ -90,7 +90,7 @@ public class QProfileReset { activation.setParameter(param.getParamKey(), param.getValue()); } } else { - for (RuleParamDto param : db.ruleDao().findRuleParamsByRuleKey(dbSession, activeRule.getRule().ruleKey())) { + for (RuleParamDto param : db.ruleDao().selectRuleParamsByRuleKey(dbSession, activeRule.getRule().ruleKey())) { activation.setParameter(param.getName(), param.getDefaultValue()); } } @@ -129,7 +129,7 @@ public class QProfileReset { BulkChangeResult result = new BulkChangeResult(profile); Set<RuleKey> ruleToBeDeactivated = Sets.newHashSet(); // Keep reference to all the activated rules before backup restore - for (ActiveRuleDto activeRuleDto : db.activeRuleDao().findByProfileKey(dbSession, profile.getKee())) { + for (ActiveRuleDto activeRuleDto : db.activeRuleDao().selectByProfileKey(dbSession, profile.getKee())) { if (activeRuleDto.getInheritance() == null) { // inherited rules can't be deactivated ruleToBeDeactivated.add(activeRuleDto.getKey().ruleKey()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java index 01d8a08ead5..53b140af21c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java @@ -135,7 +135,7 @@ public class RegisterQualityProfiles { private void register(QProfileName name, Collection<RulesProfile> profiles, DbSession session) { LOGGER.info("Register profile " + name); - QualityProfileDto profileDto = dbClient.qualityProfileDao().getByNameAndLanguage(name.getName(), name.getLanguage(), session); + QualityProfileDto profileDto = dbClient.qualityProfileDao().selectByNameAndLanguage(name.getName(), name.getLanguage(), session); if (profileDto != null) { profileFactory.delete(session, profileDto.getKey(), true); } @@ -158,12 +158,12 @@ public class RegisterQualityProfiles { } private void setDefault(String language, List<RulesProfile> profileDefs, DbSession session) { - QualityProfileDto currentDefault = dbClient.qualityProfileDao().getDefaultProfile(language, session); + QualityProfileDto currentDefault = dbClient.qualityProfileDao().selectDefaultProfile(session, language); if (currentDefault == null) { String defaultProfileName = nameOfDefaultProfile(profileDefs); LOGGER.info("Set default " + language + " profile: " + defaultProfileName); - QualityProfileDto newDefaultProfile = dbClient.qualityProfileDao().getByNameAndLanguage(defaultProfileName, language, session); + QualityProfileDto newDefaultProfile = dbClient.qualityProfileDao().selectByNameAndLanguage(defaultProfileName, language, session); if (newDefaultProfile == null) { // Must not happen, we just registered it throw new IllegalStateException("Could not find declared default profile '%s' for language '%s'"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java index 3926fbf095e..98e18064415 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java @@ -221,7 +221,7 @@ public class RuleActivator { List<ActiveRuleChange> changes = Lists.newArrayList(); // get all inherited profiles - List<QualityProfileDto> children = db.qualityProfileDao().findChildren(session, profileKey); + List<QualityProfileDto> children = db.qualityProfileDao().selectChildren(session, profileKey); for (QualityProfileDto child : children) { RuleActivation childActivation = new RuleActivation(activation).setCascade(true); changes.addAll(activate(session, childActivation, child.getKey())); @@ -262,7 +262,7 @@ public class RuleActivator { if (param.getValue() != null) { ActiveRuleParamDto paramDto = ActiveRuleParamDto.createFor(context.ruleParamsByKeys().get(param.getKey())); paramDto.setValue(param.getValue()); - dao.addParam(dbSession, activeRule, paramDto); + dao.insertParam(dbSession, activeRule, paramDto); } } return activeRule; @@ -289,7 +289,7 @@ public class RuleActivator { if (param.getValue() != null) { activeRuleParamDto = ActiveRuleParamDto.createFor(context.ruleParamsByKeys().get(param.getKey())); activeRuleParamDto.setValue(param.getValue()); - dao.addParam(dbSession, activeRule, activeRuleParamDto); + dao.insertParam(dbSession, activeRule, activeRuleParamDto); } } else { if (param.getValue() != null) { @@ -331,7 +331,7 @@ public class RuleActivator { */ public List<ActiveRuleChange> deactivate(DbSession dbSession, RuleDto ruleDto) { List<ActiveRuleChange> changes = Lists.newArrayList(); - List<ActiveRuleDto> activeRules = db.activeRuleDao().findByRule(dbSession, ruleDto); + List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByRule(dbSession, ruleDto); for (ActiveRuleDto activeRule : activeRules) { changes.addAll(deactivate(dbSession, activeRule.getKey(), true)); } @@ -361,7 +361,7 @@ public class RuleActivator { persist(change, context, dbSession); // get all inherited profiles - List<QualityProfileDto> profiles = db.qualityProfileDao().findChildren(dbSession, key.qProfile()); + List<QualityProfileDto> profiles = db.qualityProfileDao().selectChildren(dbSession, key.qProfile()); for (QualityProfileDto profile : profiles) { ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), key.ruleKey()); @@ -463,13 +463,13 @@ public class RuleActivator { } void setParent(DbSession dbSession, String profileKey, @Nullable String parentKey) { - QualityProfileDto profile = db.qualityProfileDao().getNonNullByKey(dbSession, profileKey); + QualityProfileDto profile = db.qualityProfileDao().selectOrFailByKey(dbSession, profileKey); if (parentKey == null) { // unset if parent is defined, else nothing to do removeParent(dbSession, profile); } else if (profile.getParentKee() == null || !parentKey.equals(profile.getParentKee())) { - QualityProfileDto parentProfile = db.qualityProfileDao().getNonNullByKey(dbSession, parentKey); + QualityProfileDto parentProfile = db.qualityProfileDao().selectOrFailByKey(dbSession, parentKey); if (isDescendant(dbSession, profile, parentProfile)) { throw new BadRequestException(String.format("Descendant profile '%s' can not be selected as parent of '%s'", parentKey, profileKey)); } @@ -478,7 +478,7 @@ public class RuleActivator { // set new parent profile.setParentKee(parentKey); db.qualityProfileDao().update(dbSession, profile); - for (ActiveRuleDto parentActiveRule : db.activeRuleDao().findByProfileKey(dbSession, parentKey)) { + for (ActiveRuleDto parentActiveRule : db.activeRuleDao().selectByProfileKey(dbSession, parentKey)) { try { RuleActivation activation = new RuleActivation(parentActiveRule.getKey().ruleKey()); activate(dbSession, activation, profileKey); @@ -497,7 +497,7 @@ public class RuleActivator { if (profileDto.getParentKee() != null) { profileDto.setParentKee(null); db.qualityProfileDao().update(dbSession, profileDto); - for (ActiveRuleDto activeRule : db.activeRuleDao().findByProfileKey(dbSession, profileDto.getKey())) { + for (ActiveRuleDto activeRule : db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKey())) { if (ActiveRuleDto.INHERITED.equals(activeRule.getInheritance())) { deactivate(dbSession, activeRule.getKey(), true); } else if (ActiveRuleDto.OVERRIDES.equals(activeRule.getInheritance())) { @@ -516,7 +516,7 @@ public class RuleActivator { } String parentKey = currentParent.getParentKee(); if (parentKey != null) { - currentParent = db.qualityProfileDao().getByKey(dbSession, parentKey); + currentParent = db.qualityProfileDao().selectByKey(dbSession, parentKey); } else { currentParent = null; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java index 8f7bf9df30b..580b7b7f59e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java @@ -43,7 +43,7 @@ public class RuleActivatorContextFactory { RuleActivatorContext create(String profileKey, RuleKey ruleKey, DbSession session) { RuleActivatorContext context = new RuleActivatorContext(); - QualityProfileDto profile = db.qualityProfileDao().getByKey(session, profileKey); + QualityProfileDto profile = db.qualityProfileDao().selectByKey(session, profileKey); if (profile == null) { throw new BadRequestException("Quality profile not found: " + profileKey); } @@ -53,7 +53,7 @@ public class RuleActivatorContextFactory { RuleActivatorContext create(QProfileName profileName, RuleKey ruleKey, DbSession session) { RuleActivatorContext context = new RuleActivatorContext(); - QualityProfileDto profile = db.qualityProfileDao().getByNameAndLanguage(profileName.getName(), profileName.getLanguage(), session); + QualityProfileDto profile = db.qualityProfileDao().selectByNameAndLanguage(profileName.getName(), profileName.getLanguage(), session); if (profile == null) { throw new BadRequestException("Quality profile not found: " + profileName); } @@ -81,7 +81,7 @@ public class RuleActivatorContextFactory { throw new BadRequestException("Rule not found: " + ruleKey); } context.setRule(rule); - context.setRuleParams(db.ruleDao().findRuleParamsByRuleKey(dbSession, rule.getKey())); + context.setRuleParams(db.ruleDao().selectRuleParamsByRuleKey(dbSession, rule.getKey())); return rule; } @@ -90,7 +90,7 @@ public class RuleActivatorContextFactory { ActiveRuleDto activeRule = db.activeRuleDao().getNullableByKey(session, key); Collection<ActiveRuleParamDto> activeRuleParams = null; if (activeRule != null) { - activeRuleParams = db.activeRuleDao().findParamsByActiveRuleKey(session, key); + activeRuleParams = db.activeRuleDao().selectParamsByActiveRuleKey(session, key); } if (parent) { context.setParentActiveRule(activeRule); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java index d62aafcbaaf..bde8446bc1f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/db/ActiveRuleDao.java @@ -65,11 +65,11 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti */ @CheckForNull @Deprecated - public ActiveRuleDto getById(DbSession session, int activeRuleId) { + public ActiveRuleDto selectById(DbSession session, int activeRuleId) { ActiveRuleDto activeRule = mapper(session).selectById(activeRuleId); if (activeRule != null) { - QualityProfileDto profile = profileDao.getById(activeRule.getProfileId(), session); - RuleDto rule = ruleDao.getById(session, activeRule.getRuleId()); + QualityProfileDto profile = profileDao.selectById(session, activeRule.getProfileId()); + RuleDto rule = ruleDao.selectById(session, activeRule.getRuleId()); if (profile != null && rule != null) { activeRule.setKey(ActiveRuleKey.of(profile.getKey(), rule.getKey())); return activeRule; @@ -114,16 +114,16 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti * Finder methods for Rules */ - public List<ActiveRuleDto> findByRule(DbSession dbSession, RuleDto rule) { + public List<ActiveRuleDto> selectByRule(DbSession dbSession, RuleDto rule) { Preconditions.checkNotNull(rule.getId(), RULE_IS_NOT_PERSISTED); return mapper(dbSession).selectByRuleId(rule.getId()); } - public List<ActiveRuleDto> findAll(DbSession dbSession) { + public List<ActiveRuleDto> selectAll(DbSession dbSession) { return mapper(dbSession).selectAll(); } - public List<ActiveRuleParamDto> findAllParams(DbSession dbSession) { + public List<ActiveRuleParamDto> selectAllParams(DbSession dbSession) { return mapper(dbSession).selectAllParams(); } @@ -131,7 +131,7 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti * Nested DTO ActiveRuleParams */ - public ActiveRuleParamDto addParam(DbSession session, ActiveRuleDto activeRule, ActiveRuleParamDto activeRuleParam) { + public ActiveRuleParamDto insertParam(DbSession session, ActiveRuleDto activeRule, ActiveRuleParamDto activeRuleParam) { Preconditions.checkArgument(activeRule.getId() != null, ACTIVE_RULE_IS_NOT_PERSISTED); Preconditions.checkArgument(activeRuleParam.getId() == null, ACTIVE_RULE_PARAM_IS_ALREADY_PERSISTED); Preconditions.checkNotNull(activeRuleParam.getRulesParameterId(), RULE_PARAM_IS_NOT_PERSISTED); @@ -142,7 +142,7 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti return activeRuleParam; } - public void removeParamByKeyAndName(DbSession session, ActiveRuleKey key, String param) { + public void deleteParamByKeyAndName(DbSession session, ActiveRuleKey key, String param) { // TODO SQL rewrite to delete by key ActiveRuleDto activeRule = getNullableByKey(session, key); if (activeRule != null) { @@ -169,12 +169,12 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti public void deleteByProfileKey(DbSession session, String profileKey) { /** Functional cascade for params */ - for (ActiveRuleDto activeRule : findByProfileKey(session, profileKey)) { + for (ActiveRuleDto activeRule : selectByProfileKey(session, profileKey)) { delete(session, activeRule); } } - public List<ActiveRuleDto> findByProfileKey(DbSession session, String profileKey) { + public List<ActiveRuleDto> selectByProfileKey(DbSession session, String profileKey) { return mapper(session).selectByProfileKey(profileKey); } @@ -182,14 +182,14 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti * Finder methods for ActiveRuleParams */ - public List<ActiveRuleParamDto> findParamsByActiveRuleKey(DbSession session, ActiveRuleKey key) { + public List<ActiveRuleParamDto> selectParamsByActiveRuleKey(DbSession session, ActiveRuleKey key) { Preconditions.checkNotNull(key, ACTIVE_RULE_KEY_CANNOT_BE_NULL); ActiveRuleDto activeRule = this.getByKey(session, key); return mapper(session).selectParamsByActiveRuleId(activeRule.getId()); } @CheckForNull - public ActiveRuleParamDto getParamByKeyAndName(ActiveRuleKey key, String name, DbSession session) { + public ActiveRuleParamDto selectParamByKeyAndName(ActiveRuleKey key, String name, DbSession session) { Preconditions.checkNotNull(key, ACTIVE_RULE_KEY_CANNOT_BE_NULL); Preconditions.checkNotNull(name, PARAMETER_NAME_CANNOT_BE_NULL); ActiveRuleDto activeRule = getNullableByKey(session, key); @@ -200,9 +200,9 @@ public class ActiveRuleDao extends BaseDao<ActiveRuleMapper, ActiveRuleDto, Acti } public void deleteParamsByRuleParam(DbSession dbSession, RuleDto rule, String paramKey) { - List<ActiveRuleDto> activeRules = findByRule(dbSession, rule); + List<ActiveRuleDto> activeRules = selectByRule(dbSession, rule); for (ActiveRuleDto activeRule : activeRules) { - for (ActiveRuleParamDto activeParam : findParamsByActiveRuleKey(dbSession, activeRule.getKey())) { + for (ActiveRuleParamDto activeParam : selectParamsByActiveRuleKey(dbSession, activeRule.getKey())) { if (activeParam.getKey().equals(paramKey)) { deleteParam(dbSession, activeRule, activeParam); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java index a40c9e09b09..29f282aff75 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java @@ -96,7 +96,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu DbSession session = db.openSession(false); try { // TODO because DTO uses legacy ID pattern - QualityProfileDto profile = db.qualityProfileDao().getById(activeRuleDto.getProfileId(), session); + QualityProfileDto profile = db.qualityProfileDao().selectById(session, activeRuleDto.getProfileId()); if (profile == null) { throw new IllegalStateException("Profile is null : " + activeRuleDto.getProfileId()); } @@ -106,7 +106,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu String parentKey = null; Integer parentId = activeRuleDto.getParentId(); if (parentId != null) { - ActiveRuleDto parentDto = db.activeRuleDao().getById(session, parentId); + ActiveRuleDto parentDto = db.activeRuleDao().selectById(session, parentId); if (parentDto != null) { parentKey = parentDto.getKey().toString(); } @@ -122,7 +122,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu .upsert(getUpsertFor(ActiveRuleField.ALL_FIELDS, newRule))); // Get the RuleParameters - for (ActiveRuleParamDto param : db.activeRuleDao().findParamsByActiveRuleKey(session, key)) { + for (ActiveRuleParamDto param : db.activeRuleDao().selectParamsByActiveRuleKey(session, key)) { requests.addAll(normalizeNested(param, key)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java index 80d1dba461a..39c451edace 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java @@ -89,7 +89,7 @@ public class ChangelogAction implements QProfileWsAction { DbSession session = dbClient.openSession(false); try { String profileKey = QProfileIdentificationParamUtils.getProfileKeyFromParameters(request, profileFactory, session); - if (dbClient.qualityProfileDao().getByKey(session, profileKey) == null) { + if (dbClient.qualityProfileDao().selectByKey(session, profileKey) == null) { throw new NotFoundException(String.format("Could not find a profile with key '%s'", profileKey)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java index 19ce4a83a37..ee4fbb89441 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java @@ -79,13 +79,13 @@ public class InheritanceAction implements QProfileWsAction { DbSession session = dbClient.openSession(false); try { String profileKey = QProfileIdentificationParamUtils.getProfileKeyFromParameters(request, profileFactory, session); - QualityProfileDto profile = dbClient.qualityProfileDao().getByKey(session, profileKey); + QualityProfileDto profile = dbClient.qualityProfileDao().selectByKey(session, profileKey); if (profile == null) { throw new NotFoundException(String.format("Could not find a quality profile with key %s", profileKey)); } List<QProfile> ancestors = profileLookup.ancestors(profile, session); - List<QualityProfileDto> children = dbClient.qualityProfileDao().findChildren(session, profileKey); + List<QualityProfileDto> children = dbClient.qualityProfileDao().selectChildren(session, profileKey); Map<String, Multimap<String, FacetValue>> profileStats = profileLoader.getAllProfileStats(); writeResponse(response.newJsonWriter(), profile, ancestors, children, profileStats); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java index 534b9654772..e5582ef0e14 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java @@ -139,7 +139,7 @@ public class ProjectsAction implements QProfileWsAction { } private void checkProfileExists(String profileKey, DbSession session) { - if (dbClient.qualityProfileDao().getByKey(session, profileKey) == null) { + if (dbClient.qualityProfileDao().selectByKey(session, profileKey) == null) { throw new NotFoundException(String.format("Could not find a quality profile with key '%s'", profileKey)); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java index 11e6746279b..09abc179429 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -148,7 +148,7 @@ public class RegisterRules implements Startable { private Map<RuleKey, RuleDto> loadRules(DbSession session) { Map<RuleKey, RuleDto> rules = new HashMap<>(); - for (RuleDto rule : dbClient.ruleDao().findByNonManual(session)) { + for (RuleDto rule : dbClient.ruleDao().selectByNonManual(session)) { rules.put(rule.getKey(), rule); } return rules; @@ -316,14 +316,14 @@ public class RegisterRules implements Startable { } private void mergeParams(RulesDefinition.Rule ruleDef, RuleDto rule, DbSession session) { - List<RuleParamDto> paramDtos = dbClient.ruleDao().findRuleParamsByRuleKey(session, rule.getKey()); + List<RuleParamDto> paramDtos = dbClient.ruleDao().selectRuleParamsByRuleKey(session, rule.getKey()); Map<String, RuleParamDto> existingParamsByName = Maps.newHashMap(); for (RuleParamDto paramDto : paramDtos) { RulesDefinition.Param paramDef = ruleDef.param(paramDto.getName()); if (paramDef == null) { dbClient.activeRuleDao().deleteParamsByRuleParam(session, rule, paramDto.getName()); - dbClient.ruleDao().removeRuleParam(session, rule, paramDto); + dbClient.ruleDao().deleteRuleParam(session, rule, paramDto); } else { if (mergeParam(paramDto, paramDef)) { dbClient.ruleDao().updateRuleParam(session, rule, paramDto); @@ -341,12 +341,12 @@ public class RegisterRules implements Startable { .setDescription(param.description()) .setDefaultValue(param.defaultValue()) .setType(param.type().toString()); - dbClient.ruleDao().addRuleParam(session, rule, paramDto); + dbClient.ruleDao().insertRuleParam(session, rule, paramDto); if (!StringUtils.isEmpty(param.defaultValue())) { // Propagate the default value to existing active rules - for (ActiveRuleDto activeRule : dbClient.activeRuleDao().findByRule(session, rule)) { + for (ActiveRuleDto activeRule : dbClient.activeRuleDao().selectByRule(session, rule)) { ActiveRuleParamDto activeParam = ActiveRuleParamDto.createFor(paramDto).setValue(param.defaultValue()); - dbClient.activeRuleDao().addParam(session, activeRule, activeParam); + dbClient.activeRuleDao().insertParam(session, activeRule, activeParam); } } } @@ -400,7 +400,7 @@ public class RegisterRules implements Startable { } for (RuleDto customRule : customRules) { - RuleDto template = dbClient.ruleDao().getTemplate(customRule, session); + RuleDto template = dbClient.ruleDao().selectTemplate(customRule, session); if (template != null && template.getStatus() != RuleStatus.REMOVED) { if (updateCustomRuleFromTemplateRule(customRule, template)) { dbClient.ruleDao().update(session, customRule); diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java index 69dd9390cd0..204e8e913ba 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java @@ -129,7 +129,7 @@ public class RuleCreator { errors.add(Message.of("coding_rules.validation.missing_status")); } - for (RuleParamDto ruleParam : dbClient.ruleDao().findRuleParamsByRuleKey(dbSession, templateKey)) { + for (RuleParamDto ruleParam : dbClient.ruleDao().selectRuleParamsByRuleKey(dbSession, templateKey)) { try { validateParam(ruleParam, newRule.parameter(ruleParam.getName())); } catch (BadRequestException validationError) { @@ -212,7 +212,7 @@ public class RuleCreator { .setSystemTags(templateRuleDto.getSystemTags()); dbClient.ruleDao().insert(dbSession, ruleDto); - for (RuleParamDto templateRuleParamDto : dbClient.ruleDao().findRuleParamsByRuleKey(dbSession, templateRuleDto.getKey())) { + for (RuleParamDto templateRuleParamDto : dbClient.ruleDao().selectRuleParamsByRuleKey(dbSession, templateRuleDto.getKey())) { String customRuleParamValue = Strings.emptyToNull(newRule.parameter(templateRuleParamDto.getName())); createCustomRuleParams(customRuleParamValue, ruleDto, templateRuleParamDto, dbSession); } @@ -225,7 +225,7 @@ public class RuleCreator { .setType(templateRuleParam.getType()) .setDescription(templateRuleParam.getDescription()) .setDefaultValue(paramValue); - dbClient.ruleDao().addRuleParam(dbSession, ruleDto, ruleParamDto); + dbClient.ruleDao().insertRuleParam(dbSession, ruleDto, ruleParamDto); } private RuleKey createManualRule(RuleKey ruleKey, NewRule newRule, DbSession dbSession) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java index 272fa006128..10fac8658e1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java @@ -266,7 +266,7 @@ public class RuleUpdater { private void updateParameters(DbSession dbSession, RuleUpdate update, Context context) { if (update.isChangeParameters() && update.isCustomRule()) { RuleDto customRule = context.rule; - RuleDto templateRule = dbClient.ruleDao().getTemplate(customRule, dbSession); + RuleDto templateRule = dbClient.ruleDao().selectTemplate(customRule, dbSession); if (templateRule == null) { throw new IllegalStateException(String.format("Template %s of rule %s does not exist", customRule.getTemplateId(), customRule.getKey())); @@ -276,9 +276,9 @@ public class RuleUpdater { // Load active rules and its parameters in cache Multimap<RuleDto, ActiveRuleDto> activeRules = ArrayListMultimap.create(); Multimap<ActiveRuleDto, ActiveRuleParamDto> activeRuleParams = ArrayListMultimap.create(); - for (ActiveRuleDto activeRuleDto : dbClient.activeRuleDao().findByRule(dbSession, customRule)) { + for (ActiveRuleDto activeRuleDto : dbClient.activeRuleDao().selectByRule(dbSession, customRule)) { activeRules.put(customRule, activeRuleDto); - for (ActiveRuleParamDto activeRuleParamDto : dbClient.activeRuleDao().findParamsByActiveRuleKey(dbSession, activeRuleDto.getKey())) { + for (ActiveRuleParamDto activeRuleParamDto : dbClient.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey())) { activeRuleParams.put(activeRuleDto, activeRuleParamDto); } } @@ -290,7 +290,7 @@ public class RuleUpdater { private void deleteOrUpdateParameters(DbSession dbSession, RuleUpdate update, RuleDto customRule, List<String> paramKeys, Multimap<RuleDto, ActiveRuleDto> activeRules, Multimap<ActiveRuleDto, ActiveRuleParamDto> activeRuleParams) { - for (RuleParamDto ruleParamDto : dbClient.ruleDao().findRuleParamsByRuleKey(dbSession, update.getRuleKey())) { + for (RuleParamDto ruleParamDto : dbClient.ruleDao().selectRuleParamsByRuleKey(dbSession, update.getRuleKey())) { String key = ruleParamDto.getName(); String value = Strings.emptyToNull(update.parameter(key)); @@ -305,7 +305,7 @@ public class RuleUpdater { if (activeRuleParamDto.getKey().equals(key)) { dbClient.activeRuleDao().updateParam(dbSession, activeRuleDto, activeRuleParamDto.setValue(value)); } else { - dbClient.activeRuleDao().addParam(dbSession, activeRuleDto, ActiveRuleParamDto.createFor(ruleParamDto).setValue(value)); + dbClient.activeRuleDao().insertParam(dbSession, activeRuleDto, ActiveRuleParamDto.createFor(ruleParamDto).setValue(value)); } } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java b/server/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java index a3dcba0ef97..83db14f57f9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/db/RuleDao.java @@ -70,12 +70,12 @@ public class RuleDao extends BaseDao<RuleMapper, RuleDto, RuleKey> { */ @CheckForNull @Deprecated - public RuleDto getById(DbSession session, int id) { + public RuleDto selectById(DbSession session, int id) { return mapper(session).selectById(id); } @CheckForNull - public RuleDto getTemplate(RuleDto rule, DbSession session) { + public RuleDto selectTemplate(RuleDto rule, DbSession session) { Preconditions.checkNotNull(rule.getTemplateId(), "Rule has no persisted template!"); return mapper(session).selectById(rule.getTemplateId()); } @@ -84,15 +84,15 @@ public class RuleDao extends BaseDao<RuleMapper, RuleDto, RuleKey> { * Finder methods for Rules */ - public List<RuleDto> findByNonManual(DbSession session) { + public List<RuleDto> selectByNonManual(DbSession session) { return mapper(session).selectNonManual(); } - public List<RuleDto> findAll(DbSession session) { + public List<RuleDto> selectAll(DbSession session) { return mapper(session).selectAll(); } - public List<RuleDto> findByEnabledAndNotManual(DbSession session) { + public List<RuleDto> selectByEnabledAndNotManual(DbSession session) { return mapper(session).selectEnablesAndNonManual(); } @@ -100,7 +100,7 @@ public class RuleDao extends BaseDao<RuleMapper, RuleDto, RuleKey> { * Nested DTO RuleParams */ - public void addRuleParam(DbSession session, RuleDto rule, RuleParamDto param) { + public void insertRuleParam(DbSession session, RuleDto rule, RuleParamDto param) { Preconditions.checkNotNull(rule.getId(), "Rule id must be set"); param.setRuleId(rule.getId()); mapper(session).insertParameter(param); @@ -116,7 +116,7 @@ public class RuleDao extends BaseDao<RuleMapper, RuleDto, RuleKey> { return param; } - public void removeRuleParam(DbSession session, RuleDto rule, RuleParamDto param) { + public void deleteRuleParam(DbSession session, RuleDto rule, RuleParamDto param) { Preconditions.checkNotNull(param.getId(), "Param is not persisted"); mapper(session).deleteParameter(param.getId()); this.enqueueDelete(param, rule.getKey(), session); @@ -126,15 +126,15 @@ public class RuleDao extends BaseDao<RuleMapper, RuleDto, RuleKey> { * Finder methods for RuleParams */ - public List<RuleParamDto> findAllRuleParams(DbSession session) { + public List<RuleParamDto> selectAllRuleParams(DbSession session) { return mapper(session).selectAllParams(); } - public List<RuleParamDto> findRuleParamsByRuleKey(DbSession session, RuleKey key) { + public List<RuleParamDto> selectRuleParamsByRuleKey(DbSession session, RuleKey key) { return mapper(session).selectParamsByRuleKey(key); } - public List<RuleDto> findRulesByDebtSubCharacteristicId(DbSession session, int id) { + public List<RuleDto> selectRulesByDebtSubCharacteristicId(DbSession session, int id) { return mapper(session).selectBySubCharacteristicId(id); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java index 3a486a50562..981c6351d8c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java @@ -182,7 +182,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { Integer templateId = rule.getTemplateId(); String templateKeyFieldValue = null; if (templateId != null) { - RuleDto templateRule = db.ruleDao().getById(session, templateId); + RuleDto templateRule = db.ruleDao().selectById(session, templateId); if (templateRule != null) { RuleKey templateKey = templateRule.getKey(); templateKeyFieldValue = templateKey != null ? templateKey.toString() : null; @@ -204,7 +204,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { Integer defaultSubCharacteristicId = rule.getDefaultSubCharacteristicId(); if (defaultSubCharacteristicId != null) { - CharacteristicDto subCharacteristic = db.debtCharacteristicDao().selectById(defaultSubCharacteristicId, session); + CharacteristicDto subCharacteristic = db.debtCharacteristicDao().selectById(session, defaultSubCharacteristicId); if (subCharacteristic != null) { Integer characteristicId = subCharacteristic.getParentId(); if (characteristicId != null) { @@ -225,7 +225,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { update.put(RuleField.CHARACTERISTIC.field(), DebtCharacteristic.NONE); update.put(RuleField.SUB_CHARACTERISTIC.field(), DebtCharacteristic.NONE); } else { - CharacteristicDto subCharacteristic = db.debtCharacteristicDao().selectById(subCharacteristicId, session); + CharacteristicDto subCharacteristic = db.debtCharacteristicDao().selectById(session, subCharacteristicId); if (subCharacteristic != null) { Integer characteristicId = subCharacteristic.getParentId(); if (characteristicId != null) { @@ -282,7 +282,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> { .doc(update) .upsert(upsert)); - for (RuleParamDto param : db.ruleDao().findRuleParamsByRuleKey(session, rule.getKey())) { + for (RuleParamDto param : db.ruleDao().selectRuleParamsByRuleKey(session, rule.getKey())) { requests.addAll(normalizeNested(param, rule.getKey())); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java b/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java index 2c96d76c5a5..b86457343e9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java +++ b/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java @@ -82,7 +82,7 @@ public final class RegisterNewMeasureFilters { @VisibleForTesting MeasureFilterDto register(String name, Filter filter) { MeasureFilterDto dto = null; - if (filterDao.findSystemFilterByName(name) == null) { + if (filterDao.selectSystemFilterByName(name) == null) { LOG.info("Register measure filter: " + name); dto = createDtoFromExtension(name, filter); filterDao.insert(dto); diff --git a/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterPermissionTemplates.java b/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterPermissionTemplates.java index 7f44a0a741b..68e91d5de68 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterPermissionTemplates.java +++ b/server/sonar-server/src/main/java/org/sonar/server/startup/RegisterPermissionTemplates.java @@ -79,7 +79,7 @@ public class RegisterPermissionTemplates { private void insertDefaultTemplate(String templateName) { PermissionTemplateDto defaultPermissionTemplate = permissionTemplateDao - .createPermissionTemplate(templateName, PermissionTemplateDto.DEFAULT.getDescription(), null); + .insertPermissionTemplate(templateName, PermissionTemplateDto.DEFAULT.getDescription(), null); addGroupPermission(defaultPermissionTemplate, UserRole.ADMIN, DefaultGroups.ADMINISTRATORS); addGroupPermission(defaultPermissionTemplate, UserRole.ISSUE_ADMIN, DefaultGroups.ADMINISTRATORS); addGroupPermission(defaultPermissionTemplate, UserRole.USER, DefaultGroups.ANYONE); @@ -98,7 +98,7 @@ public class RegisterPermissionTemplates { LOG.error("Cannot setup default permission for group: " + groupName); } } - permissionTemplateDao.addGroupPermission(template.getId(), groupId, permission); + permissionTemplateDao.insertGroupPermission(template.getId(), groupId, permission); } private void registerInitialization() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/startup/RenameIssueWidgets.java b/server/sonar-server/src/main/java/org/sonar/server/startup/RenameIssueWidgets.java index 0862b23e707..0f33446c220 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/startup/RenameIssueWidgets.java +++ b/server/sonar-server/src/main/java/org/sonar/server/startup/RenameIssueWidgets.java @@ -149,7 +149,7 @@ public class RenameIssueWidgets implements Startable { } private String getReplacementWidgetKey(DbSession session, WidgetDto widget) { - DashboardDto dashboard = dbClient.dashboardDao().getNullableByKey(session, widget.getDashboardId()); + DashboardDto dashboard = dbClient.dashboardDao().selectByKey(session, widget.getDashboardId()); if (dashboard == null) { LOGGER.warn(String.format("Widget with ID=%d is not displayed on any dashboard, updating nevertheless", widget.getId())); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/test/CoverageService.java b/server/sonar-server/src/main/java/org/sonar/server/test/CoverageService.java index 1c8d1e0b3ec..fa758777ee4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/test/CoverageService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/test/CoverageService.java @@ -91,7 +91,7 @@ public class CoverageService { private Map<Integer, Integer> findDataFromComponent(String fileKey, String metricKey) { DbSession session = myBatis.openSession(false); try { - MeasureDto data = measureDao.findByComponentKeyAndMetricKey(session, fileKey, metricKey); + MeasureDto data = measureDao.selectByComponentKeyAndMetricKey(session, fileKey, metricKey); String dataValue = data != null ? data.getData() : null; if (dataValue != null) { return KeyValueFormat.parseIntInt(dataValue); diff --git a/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java b/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java index e35469e1d89..2081e95baed 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java @@ -229,7 +229,7 @@ public class ListAction implements TestsWsAction { } private void checkComponentUuidPermission(DbSession dbSession, String componentUuid) { - ComponentDto component = dbClient.componentDao().selectNonNullByUuid(dbSession, componentUuid); + ComponentDto component = dbClient.componentDao().selectOrFailByUuid(dbSession, componentUuid); userSession.checkProjectUuidPermission(UserRole.CODEVIEWER, component.projectUuid()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java index c8a29d186a5..ca0cf295bd6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java @@ -263,8 +263,8 @@ public class ComponentNavigationAction implements NavigationWsAction { if (snapshot != null) { SnapshotDto currentSnapshot = snapshot; while (currentSnapshot.getParentId() != null) { - currentSnapshot = dbClient.snapshotDao().selectById(session, currentSnapshot.getParentId()); - componentPath.add(0, dbClient.componentDao().selectNonNullById(session, currentSnapshot.getComponentId())); + currentSnapshot = dbClient.snapshotDao().selectOrFailById(session, currentSnapshot.getParentId()); + componentPath.add(0, dbClient.componentDao().selectOrFailById(session, currentSnapshot.getComponentId())); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ServerUserSession.java b/server/sonar-server/src/main/java/org/sonar/server/user/ServerUserSession.java index 70db3b3ccb2..17d79b5154b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/ServerUserSession.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/ServerUserSession.java @@ -123,7 +123,7 @@ public class ServerUserSession extends AbstractUserSession<ServerUserSession> public boolean hasComponentUuidPermission(String permission, String componentUuid) { String projectUuid = projectUuidByComponentUuid.get(componentUuid); if (projectUuid == null) { - ResourceDto project = resourceDao.getResource(componentUuid); + ResourceDto project = resourceDao.selectResource(componentUuid); if (project == null) { return false; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java index 1bca7a4828d..fc2052306f8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java @@ -90,7 +90,7 @@ public class UserUpdater { try { UserDto userDto = createNewUserDto(dbSession, newUser); String login = userDto.getLogin(); - UserDto existingUser = dbClient.userDao().selectNullableByLogin(dbSession, login); + UserDto existingUser = dbClient.userDao().selectByLogin(dbSession, login); if (existingUser == null) { saveUser(dbSession, userDto); } else { @@ -119,7 +119,7 @@ public class UserUpdater { public void update(UpdateUser updateUser) { DbSession dbSession = dbClient.openSession(false); try { - UserDto user = dbClient.userDao().selectNullableByLogin(dbSession, updateUser.login()); + UserDto user = dbClient.userDao().selectByLogin(dbSession, updateUser.login()); if (user == null) { throw new NotFoundException(String.format("User with login '%s' has not been found", updateUser.login())); } @@ -141,7 +141,7 @@ public class UserUpdater { public void checkCurrentPassword(String login, String password) { DbSession dbSession = dbClient.openSession(false); try { - UserDto user = dbClient.userDao().selectByLogin(dbSession, login); + UserDto user = dbClient.userDao().selectOrFailByLogin(dbSession, login); String cryptedPassword = encryptPassword(password, user.getSalt()); if (!cryptedPassword.equals(user.getCryptedPassword())) { throw new IllegalArgumentException("Incorrect password"); @@ -276,7 +276,7 @@ public class UserUpdater { if (scmAccount.equals(login) || scmAccount.equals(email)) { messages.add(Message.of("user.login_or_email_used_as_scm_account")); } else { - List<UserDto> matchingUsers = dbClient.userDao().selectNullableByScmAccountOrLoginOrEmail(dbSession, scmAccount); + List<UserDto> matchingUsers = dbClient.userDao().selectByScmAccountOrLoginOrEmail(dbSession, scmAccount); List<String> matchingUsersWithoutExistingUser = newArrayList(); for (UserDto matchingUser : matchingUsers) { if (existingUser == null || !matchingUser.getId().equals(existingUser.getId())) { @@ -338,9 +338,9 @@ public class UserUpdater { if (defaultGroup == null) { throw new ServerException(HttpURLConnection.HTTP_INTERNAL_ERROR, String.format("The default group property '%s' is null", CoreProperties.CORE_DEFAULT_GROUP)); } - List<GroupDto> userGroups = dbClient.groupDao().findByUserLogin(dbSession, userDto.getLogin()); + List<GroupDto> userGroups = dbClient.groupDao().selectByUserLogin(dbSession, userDto.getLogin()); if (!Iterables.any(userGroups, new GroupDtoMatchKey(defaultGroup))) { - GroupDto groupDto = dbClient.groupDao().selectNullableByKey(dbSession, defaultGroup); + GroupDto groupDto = dbClient.groupDao().selectByKey(dbSession, defaultGroup); if (groupDto == null) { throw new ServerException(HttpURLConnection.HTTP_INTERNAL_ERROR, String.format("The default group '%s' for new users does not exist. Please update the general security settings to fix this issue.", diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ws/GroupsAction.java b/server/sonar-server/src/main/java/org/sonar/server/user/ws/GroupsAction.java index cfa985a563b..c9e56d5eddd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/user/ws/GroupsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/user/ws/GroupsAction.java @@ -94,7 +94,7 @@ public class GroupsAction implements UsersWsAction { DbSession session = dbClient.openSession(false); try { - UserDto user = dbClient.userDao().selectNullableByLogin(session, login); + UserDto user = dbClient.userDao().selectByLogin(session, login); if (user == null) { throw new NotFoundException(String.format("User with login '%s' has not been found", login)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java index 70fd56dfa1c..c6104faeca2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java @@ -76,7 +76,7 @@ public class AddUserAction implements UserGroupsWsAction { DbSession dbSession = dbClient.openSession(false); try { - GroupDto group = dbClient.groupDao().selectNullableById(dbSession, groupId); + GroupDto group = dbClient.groupDao().selectById(dbSession, groupId); UserDto user = dbClient.userDao().selectActiveUserByLogin(dbSession, login); if (group == null) { throw new NotFoundException(String.format("Could not find a user group with group id '%s'", groupId)); diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java index 9ae00ab5fe7..c7c03d292a0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java @@ -68,7 +68,7 @@ public class DeleteAction implements UserGroupsWsAction { DbSession dbSession = dbClient.openSession(false); try { - if (dbClient.groupDao().selectNullableById(dbSession, groupId) == null) { + if (dbClient.groupDao().selectById(dbSession, groupId) == null) { throw new NotFoundException(String.format("Could not find a group with id=%d", groupId)); } @@ -88,7 +88,7 @@ public class DeleteAction implements UserGroupsWsAction { private void checkNotTryingToDeleteDefaultGroup(DbSession dbSession, long groupId) { String defaultGroupName = settings.getString(CoreProperties.CORE_DEFAULT_GROUP); - GroupDto defaultGroup = dbClient.groupDao().selectByKey(dbSession, defaultGroupName); + GroupDto defaultGroup = dbClient.groupDao().selectOrFailByKey(dbSession, defaultGroupName); Preconditions.checkArgument(groupId != defaultGroup.getId(), String.format("Default group '%s' cannot be deleted", defaultGroupName)); } @@ -102,6 +102,6 @@ public class DeleteAction implements UserGroupsWsAction { } private void removeFromPermissionTemplates(long groupId, DbSession dbSession) { - dbClient.permissionTemplateDao().removeByGroup(groupId, dbSession); + dbClient.permissionTemplateDao().deleteByGroup(dbSession, groupId); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/GroupUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/GroupUpdater.java index 8bc42ffc176..ae9cbcf1c76 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/GroupUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/GroupUpdater.java @@ -65,7 +65,7 @@ public class GroupUpdater { // There is no database constraint on column groups.name // because MySQL cannot create a unique index // on a UTF-8 VARCHAR larger than 255 characters on InnoDB - if (dbClient.groupDao().selectNullableByKey(session, name) != null) { + if (dbClient.groupDao().selectByKey(session, name) != null) { throw new BadRequestException(String.format("Name '%s' is already taken", name)); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java index ebde38ba567..939bf546063 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java @@ -75,7 +75,7 @@ public class RemoveUserAction implements UserGroupsWsAction { DbSession dbSession = dbClient.openSession(false); try { - GroupDto group = dbClient.groupDao().selectNullableById(dbSession, groupId); + GroupDto group = dbClient.groupDao().selectById(dbSession, groupId); if (group == null) { throw new NotFoundException(String.format("Could not find a user group with id '%s'", groupId)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java index b253311eaf4..9aa000b9104 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java @@ -86,7 +86,7 @@ public class UpdateAction implements UserGroupsWsAction { DbSession dbSession = dbClient.openSession(false); try { groupUpdater.checkNameIsUnique(name, dbSession); - GroupDto group = dbClient.groupDao().selectNullableById(dbSession, groupId); + GroupDto group = dbClient.groupDao().selectById(dbSession, groupId); if (group == null) { throw new NotFoundException(String.format("Could not find a user group with id '%s'.", groupId)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java index a09f155476d..48baacf9fc1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java @@ -95,7 +95,7 @@ public class UsersAction implements UserGroupsWsAction { DbSession dbSession = dbClient.openSession(false); try { - GroupDto group = dbClient.groupDao().selectNullableById(dbSession, groupId); + GroupDto group = dbClient.groupDao().selectById(dbSession, groupId); if (group == null) { throw new NotFoundException(String.format("Could not find user group with id '%s'", groupId)); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryLoaderMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryLoaderMediumTest.java index 36980c84684..395b883d98e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryLoaderMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectRepositoryLoaderMediumTest.java @@ -95,12 +95,12 @@ public class ProjectRepositoryLoaderMediumTest { addDefaultProfile(); // Project properties - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()), - dbSession); - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()), - dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()) + ); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()) + ); dbSession.commit(); ProjectRepositories ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key())); @@ -119,12 +119,12 @@ public class ProjectRepositoryLoaderMediumTest { addDefaultProfile(); // Project properties - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()), - dbSession); - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()), - dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()) + ); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()) + ); dbSession.commit(); ProjectRepositories ref = loader.load(ProjectRepositoryQuery.create().setModuleKey(project.key()).setPreview(true)); @@ -142,19 +142,19 @@ public class ProjectRepositoryLoaderMediumTest { addDefaultProfile(); // Project properties - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId())); ComponentDto module = ComponentTesting.newModuleDto(project); tester.get(DbClient.class).componentDao().insert(dbSession, module); // Module properties - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER").setResourceId(module.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(module.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER").setResourceId(module.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(module.getId())); dbSession.commit(); @@ -178,10 +178,10 @@ public class ProjectRepositoryLoaderMediumTest { addDefaultProfile(); // Project properties - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId())); ComponentDto module = ComponentTesting.newModuleDto(project); tester.get(DbClient.class).componentDao().insert(dbSession, module); @@ -209,26 +209,26 @@ public class ProjectRepositoryLoaderMediumTest { addDefaultProfile(); // Project properties - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId())); ComponentDto module = ComponentTesting.newModuleDto(project); tester.get(DbClient.class).componentDao().insert(dbSession, module); // Module properties - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER").setResourceId(module.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(module.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER").setResourceId(module.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(module.getId())); ComponentDto subModule = ComponentTesting.newModuleDto(module); tester.get(DbClient.class).componentDao().insert(dbSession, subModule); // Sub module properties - tester.get(DbClient.class).propertiesDao().setProperty( - new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER-DAO").setResourceId(subModule.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty( + dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER-DAO").setResourceId(subModule.getId())); dbSession.commit(); @@ -257,23 +257,23 @@ public class ProjectRepositoryLoaderMediumTest { addDefaultProfile(); // Project properties - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId())); ComponentDto module1 = ComponentTesting.newModuleDto(project); tester.get(DbClient.class).componentDao().insert(dbSession, module1); // Module 1 properties - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER").setResourceId(module1.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER").setResourceId(module1.getId())); // This property should not be found on the other module - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(module1.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(module1.getId())); ComponentDto module2 = ComponentTesting.newModuleDto(project); tester.get(DbClient.class).componentDao().insert(dbSession, module2); // Module 2 property tester.get(DbClient.class).propertiesDao() - .setProperty(new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-APPLICATION").setResourceId(module2.getId()), dbSession); + .insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-APPLICATION").setResourceId(module2.getId())); dbSession.commit(); @@ -302,8 +302,8 @@ public class ProjectRepositoryLoaderMediumTest { addDefaultProfile(); // Project properties - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId())); dbSession.commit(); @@ -331,9 +331,9 @@ public class ProjectRepositoryLoaderMediumTest { tester.get(DbClient.class).componentDao().insert(dbSession, subModule); // Sub module properties - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(subModule.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(subModule.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(subModule.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(subModule.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(subModule.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(subModule.getId())); dbSession.commit(); @@ -354,20 +354,20 @@ public class ProjectRepositoryLoaderMediumTest { addDefaultProfile(); // Project property - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId())); ComponentDto module = ComponentTesting.newModuleDto(project); tester.get(DbClient.class).componentDao().insert(dbSession, module); // Module property - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(module.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(module.getId())); ComponentDto subModule = ComponentTesting.newModuleDto(module); userSessionRule.login("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION); tester.get(DbClient.class).componentDao().insert(dbSession, subModule); // Sub module properties - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(subModule.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(subModule.getId())); dbSession.commit(); @@ -388,9 +388,9 @@ public class ProjectRepositoryLoaderMediumTest { addDefaultProfile(); // Project properties - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(project.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR").setResourceId(project.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(project.getId())); ComponentDto module = ComponentTesting.newModuleDto(project); tester.get(DbClient.class).componentDao().insert(dbSession, module); @@ -420,14 +420,14 @@ public class ProjectRepositoryLoaderMediumTest { addDefaultProfile(); // Project properties - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId()), dbSession); - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(project.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.login.secured").setValue("john").setResourceId(project.getId())); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java").setResourceId(project.getId())); ComponentDto module = ComponentTesting.newModuleDto(project); tester.get(DbClient.class).componentDao().insert(dbSession, module); // Module property - tester.get(DbClient.class).propertiesDao().setProperty(new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER").setResourceId(module.getId()), dbSession); + tester.get(DbClient.class).propertiesDao().insertProperty(dbSession, new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER").setResourceId(module.getId())); ComponentDto subModule = ComponentTesting.newModuleDto(module); userSessionRule.login("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION); @@ -589,7 +589,7 @@ public class ProjectRepositoryLoaderMediumTest { RuleKey ruleKey = RuleKey.of("squid", "AvoidCycle"); RuleDto rule = RuleTesting.newDto(ruleKey).setName("Avoid Cycle").setConfigKey("squid-1").setLanguage(ServerTester.Xoo.KEY); tester.get(DbClient.class).ruleDao().insert(dbSession, rule); - tester.get(DbClient.class).ruleDao().addRuleParam(dbSession, rule, RuleParamDto.createFor(rule) + tester.get(DbClient.class).ruleDao().insertRuleParam(dbSession, rule, RuleParamDto.createFor(rule) .setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type())); RuleActivation activation = new RuleActivation(ruleKey); diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java index f56742e2322..b6931a46697 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/DefaultRubyComponentServiceTest.java @@ -61,7 +61,7 @@ public class DefaultRubyComponentServiceTest { @Test public void find_by_key() { Component component = mock(Component.class); - when(resourceDao.findByKey("struts")).thenReturn(component); + when(resourceDao.selectByKey("struts")).thenReturn(component); assertThat(service.findByKey("struts")).isEqualTo(component); } @@ -86,7 +86,7 @@ public class DefaultRubyComponentServiceTest { String componentKey = "new-project"; String componentName = "New Project"; String qualifier = Qualifiers.PROJECT; - when(resourceDao.findByKey(componentKey)).thenReturn(ComponentTesting.newProjectDto()); + when(resourceDao.selectByKey(componentKey)).thenReturn(ComponentTesting.newProjectDto()); when(componentService.create(any(NewComponent.class))).thenReturn(componentKey); service.createComponent(componentKey, componentName, qualifier); @@ -105,7 +105,7 @@ public class DefaultRubyComponentServiceTest { @Test public void not_create_component_on_sub_views() { - when(resourceDao.findByKey(anyString())).thenReturn(ComponentTesting.newProjectDto()); + when(resourceDao.selectByKey(anyString())).thenReturn(ComponentTesting.newProjectDto()); service.createComponent("new-project", "New Project", Qualifiers.SUBVIEW); @@ -118,7 +118,7 @@ public class DefaultRubyComponentServiceTest { String componentKey = "new-project"; String componentName = "New Project"; String qualifier = Qualifiers.PROJECT; - when(resourceDao.findByKey(componentKey)).thenReturn(null); + when(resourceDao.selectByKey(componentKey)).thenReturn(null); service.createComponent(componentKey, componentName, qualifier); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java index 480f3855a1e..40817960f07 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java @@ -106,7 +106,7 @@ public class AppActionTest { when(dbClient.propertiesDao()).thenReturn(propertiesDao); when(dbClient.measureDao()).thenReturn(measureDao); - when(measureDao.findByComponentKeyAndMetricKeys(eq(session), anyString(), anyListOf(String.class))).thenReturn(measures); + when(measureDao.selectByComponentKeyAndMetricKeys(eq(session), anyString(), anyListOf(String.class))).thenReturn(measures); tester = new WsTester(new ComponentsWs(new AppAction(dbClient, durations, i18n, userSessionRule, new ComponentFinder(dbClient)), mock(SearchAction.class))); } @@ -126,8 +126,8 @@ public class AppActionTest { .setPath("src/main/java/org/sonar/api/Plugin.java") .setParentProjectId(5L); when(componentDao.selectByUuid(session, COMPONENT_UUID)).thenReturn(Optional.of(file)); - when(componentDao.selectNonNullById(session, 5L)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); - when(componentDao.selectNonNullByUuid(session, project.uuid())).thenReturn(project); + when(componentDao.selectOrFailById(session, 5L)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); + when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); when(propertiesDao.selectByQuery(any(PropertyQuery.class), eq(session))).thenReturn(newArrayList(new PropertyDto())); WsTester.TestRequest request = tester.newGetRequest("api/components", "app").setParam("uuid", COMPONENT_UUID); @@ -152,7 +152,7 @@ public class AppActionTest { WsTester.TestRequest request = tester.newGetRequest("api/components", "app").setParam("uuid", COMPONENT_UUID); request.execute().assertJson(getClass(), "app_with_measures.json"); - verify(measureDao).findByComponentKeyAndMetricKeys(eq(session), eq(COMPONENT_KEY), measureKeysCaptor.capture()); + verify(measureDao).selectByComponentKeyAndMetricKeys(eq(session), eq(COMPONENT_KEY), measureKeysCaptor.capture()); assertThat(measureKeysCaptor.getValue()).contains(CoreMetrics.LINES_KEY, CoreMetrics.COVERAGE_KEY, CoreMetrics.DUPLICATED_LINES_DENSITY_KEY, CoreMetrics.TECHNICAL_DEBT_KEY); } @@ -230,8 +230,8 @@ public class AppActionTest { .setPath("src/main/java/org/sonar/api/Plugin.java") .setParentProjectId(5L); when(componentDao.selectByUuid(session, COMPONENT_UUID)).thenReturn(Optional.of(file)); - when(componentDao.selectNonNullById(session, 5L)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); - when(componentDao.selectNonNullByUuid(session, project.uuid())).thenReturn(project); + when(componentDao.selectOrFailById(session, 5L)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); + when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); return file; } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/component/ProjectSettingsRepositoryTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/component/ProjectSettingsRepositoryTest.java index 12f90d1dddb..eeb1fbd7fb2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/component/ProjectSettingsRepositoryTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/component/ProjectSettingsRepositoryTest.java @@ -82,7 +82,7 @@ public class ProjectSettingsRepositoryTest { public void get_project_settings_from_db() { ComponentDto project = ComponentTesting.newProjectDto().setKey(PROJECT_KEY); dbClient.componentDao().insert(session, project); - dbClient.propertiesDao().setProperty(new PropertyDto().setResourceId(project.getId()).setKey("key").setValue("value"), session); + dbClient.propertiesDao().insertProperty(session, new PropertyDto().setResourceId(project.getId()).setKey("key").setValue("value")); session.commit(); Settings settings = underTest.getProjectSettings(PROJECT_KEY); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ApplyPermissionsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ApplyPermissionsStepTest.java index 928f77e0bd4..ffc2b760acd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ApplyPermissionsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ApplyPermissionsStepTest.java @@ -105,9 +105,9 @@ public class ApplyPermissionsStepTest extends BaseStepTest { dbClient.componentDao().insert(dbSession, projectDto); // Create a permission template containing browse permission for anonymous group - PermissionTemplateDto permissionTemplateDto = dbClient.permissionTemplateDao().createPermissionTemplate("Default", null, null); + PermissionTemplateDto permissionTemplateDto = dbClient.permissionTemplateDao().insertPermissionTemplate("Default", null, null); settings.setProperty("sonar.permission.template.default", permissionTemplateDto.getKee()); - dbClient.permissionTemplateDao().addGroupPermission(permissionTemplateDto.getId(), null, UserRole.USER); + dbClient.permissionTemplateDao().insertGroupPermission(permissionTemplateDto.getId(), null, UserRole.USER); dbSession.commit(); Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).build(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/GlobalDefaultDashboardTest.java b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/GlobalDefaultDashboardTest.java index 49b97643472..65751a278f1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/GlobalDefaultDashboardTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/GlobalDefaultDashboardTest.java @@ -53,10 +53,10 @@ public class GlobalDefaultDashboardTest { @Test public void should_create_global_dashboard_with_four_widgets() { - when(dao.findSystemFilterByName(MyFavouritesFilter.NAME)).thenReturn( + when(dao.selectSystemFilterByName(MyFavouritesFilter.NAME)).thenReturn( new MeasureFilterDto().setId(100L) ); - when(dao.findSystemFilterByName(ProjectFilter.NAME)).thenReturn( + when(dao.selectSystemFilterByName(ProjectFilter.NAME)).thenReturn( new MeasureFilterDto().setId(101L) ); Dashboard dashboard = template.createDashboard(); @@ -76,8 +76,8 @@ public class GlobalDefaultDashboardTest { @Test public void should_not_fail_if_filter_widgets_not_found() { - when(dao.findSystemFilterByName(MyFavouritesFilter.NAME)).thenReturn(null); - when(dao.findSystemFilterByName(ProjectFilter.NAME)).thenReturn(null); + when(dao.selectSystemFilterByName(MyFavouritesFilter.NAME)).thenReturn(null); + when(dao.selectSystemFilterByName(ProjectFilter.NAME)).thenReturn(null); Dashboard dashboard = template.createDashboard(); List<Widget> firstColumn = dashboard.getWidgetsOfColumn(1); diff --git a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java index 472086bd4fd..514a035558f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java @@ -46,9 +46,9 @@ import org.sonar.api.utils.System2; import org.sonar.api.utils.ValidationMessages; import org.sonar.core.permission.GlobalPermissions; import org.sonar.db.DbSession; -import org.sonar.db.rule.RuleDto; import org.sonar.db.debt.CharacteristicDao; import org.sonar.db.debt.CharacteristicDto; +import org.sonar.db.rule.RuleDto; import org.sonar.server.db.DbClient; import org.sonar.server.debt.DebtModelXMLExporter.DebtModel; import org.sonar.server.debt.DebtModelXMLExporter.RuleDebt; @@ -115,7 +115,7 @@ public class DebtModelBackupTest { int currentId; - DebtModelBackup debtModelBackup; + DebtModelBackup underTest; @Before public void setUp() { @@ -128,11 +128,11 @@ public class DebtModelBackupTest { doAnswer(new Answer() { public Object answer(InvocationOnMock invocation) { Object[] args = invocation.getArguments(); - CharacteristicDto dto = (CharacteristicDto) args[0]; + CharacteristicDto dto = (CharacteristicDto) args[1]; dto.setId(currentId++); return null; } - }).when(dao).insert(any(CharacteristicDto.class), any(DbSession.class)); + }).when(dao).insert(any(DbSession.class), any(CharacteristicDto.class)); when(dbClient.openSession(false)).thenReturn(session); when(dbClient.ruleDao()).thenReturn(ruleDao); @@ -141,7 +141,7 @@ public class DebtModelBackupTest { Reader defaultModelReader = mock(Reader.class); when(debtModelPluginRepository.createReaderForXMLFile("technical-debt")).thenReturn(defaultModelReader); - debtModelBackup = new DebtModelBackup(dbClient, debtModelOperations, ruleOperations, debtModelPluginRepository, characteristicsXMLImporter, rulesXMLImporter, + underTest = new DebtModelBackup(dbClient, debtModelOperations, ruleOperations, debtModelPluginRepository, characteristicsXMLImporter, rulesXMLImporter, debtModelXMLExporter, defLoader, system2, userSessionRule); } @@ -150,21 +150,23 @@ public class DebtModelBackupTest { when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2), new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1) - )); + )); - when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( - // Rule with overridden debt values - new RuleDto().setRepositoryKey("squid").setRuleKey("UselessImportCheck") - .setSubCharacteristicId(2) - .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) - .setRemediationCoefficient("2h") - .setRemediationOffset("15min"), + when(ruleDao.selectEnabledAndNonManual(session)).thenReturn( + newArrayList( + // Rule with overridden debt values + new RuleDto().setRepositoryKey("squid").setRuleKey("UselessImportCheck") + .setSubCharacteristicId(2) + .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) + .setRemediationCoefficient("2h") + .setRemediationOffset("15min"), - // Rule with default debt values - new RuleDto().setRepositoryKey("squid").setRuleKey("AvoidNPE").setDefaultSubCharacteristicId(2).setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h") - )); + // Rule with default debt values + new RuleDto().setRepositoryKey("squid").setRuleKey("AvoidNPE").setDefaultSubCharacteristicId(2).setDefaultRemediationFunction("LINEAR") + .setDefaultRemediationCoefficient("2h") + )); - debtModelBackup.backup(); + underTest.backup(); ArgumentCaptor<DebtModel> debtModelArgument = ArgumentCaptor.forClass(DebtModel.class); verify(debtModelXMLExporter).export(debtModelArgument.capture(), ruleDebtListCaptor.capture()); @@ -196,7 +198,7 @@ public class DebtModelBackupTest { when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2), new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1) - )); + )); when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( // Debt disabled @@ -204,9 +206,9 @@ public class DebtModelBackupTest { // Not debt new RuleDto().setRepositoryKey("squid").setRuleKey("AvoidNPE") - )); + )); - debtModelBackup.backup(); + underTest.backup(); verify(debtModelXMLExporter).export(any(DebtModel.class), ruleDebtListCaptor.capture()); @@ -218,10 +220,11 @@ public class DebtModelBackupTest { when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2), new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1) - )); + )); when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( - // Rule with default debt values : default value is linear (only coefficient is set) and overridden value is constant per issue (only offset is set) + // Rule with default debt values : default value is linear (only coefficient is set) and overridden value is constant per issue (only + // offset is set) // -> Ony offset should be set new RuleDto().setRepositoryKey("squid").setRuleKey("AvoidNPE") .setDefaultSubCharacteristicId(2) @@ -230,9 +233,9 @@ public class DebtModelBackupTest { .setSubCharacteristicId(2) .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.toString()) .setRemediationOffset("15min") - )); + )); - debtModelBackup.backup(); + underTest.backup(); ArgumentCaptor<DebtModel> debtModelArgument = ArgumentCaptor.forClass(DebtModel.class); verify(debtModelXMLExporter).export(debtModelArgument.capture(), ruleDebtListCaptor.capture()); @@ -256,24 +259,24 @@ public class DebtModelBackupTest { when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2), new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1) - )); + )); when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setLanguage("java") .setSubCharacteristicId(2) .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.toString()) .setRemediationOffset("15min"), -// .setCreatedAt(oldDate).setUpdatedAt(oldDate), + // .setCreatedAt(oldDate).setUpdatedAt(oldDate), // Should be ignored new RuleDto().setId(2).setRepositoryKey("checkstyle") .setLanguage("java2") .setSubCharacteristicId(3) .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) .setRemediationCoefficient("2h") -// .setCreatedAt(oldDate).setUpdatedAt(oldDate) - )); + // .setCreatedAt(oldDate).setUpdatedAt(oldDate) + )); - debtModelBackup.backup("java"); + underTest.backup("java"); verify(debtModelXMLExporter).export(any(DebtModel.class), ruleDebtListCaptor.capture()); @@ -293,15 +296,15 @@ public class DebtModelBackupTest { public void create_characteristics_when_restoring_characteristics() { when(dao.selectEnabledCharacteristics(session)).thenReturn(Collections.<CharacteristicDto>emptyList()); - debtModelBackup.restoreCharacteristics( + underTest.restoreCharacteristics( + session, new DebtModel() .addRootCharacteristic(new DefaultDebtCharacteristic().setKey("PORTABILITY").setName("Portability").setOrder(1)) .addSubCharacteristic(new DefaultDebtCharacteristic().setKey("COMPILER").setName("Compiler"), "PORTABILITY"), - now, - session + now ); - verify(dao, times(2)).insert(characteristicCaptor.capture(), eq(session)); + verify(dao, times(2)).insert(eq(session), characteristicCaptor.capture()); CharacteristicDto dto1 = characteristicCaptor.getAllValues().get(0); assertThat(dto1.getId()).isEqualTo(10); @@ -328,14 +331,13 @@ public class DebtModelBackupTest { // Order and name have changed new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2).setCreatedAt(oldDate).setUpdatedAt(oldDate), new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1).setCreatedAt(oldDate).setUpdatedAt(oldDate) - )); + )); - debtModelBackup.restoreCharacteristics( - new DebtModel() + underTest.restoreCharacteristics( + session, new DebtModel() .addRootCharacteristic(new DefaultDebtCharacteristic().setKey("PORTABILITY").setName("Portability").setOrder(1)) .addSubCharacteristic(new DefaultDebtCharacteristic().setKey("COMPILER").setName("Compiler"), "PORTABILITY"), - now, - session + now ); verify(dao, times(2)).update(characteristicCaptor.capture(), eq(session)); @@ -365,14 +367,13 @@ public class DebtModelBackupTest { // Parent has changed new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setParentId(1).setOrder(1).setCreatedAt(oldDate).setUpdatedAt(oldDate), new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setCreatedAt(oldDate).setUpdatedAt(oldDate) - )); + )); - debtModelBackup.restoreCharacteristics( - new DebtModel() + underTest.restoreCharacteristics( + session, new DebtModel() .addRootCharacteristic(new DefaultDebtCharacteristic().setKey("PORTABILITY").setName("Portability").setOrder(1)) .addSubCharacteristic(new DefaultDebtCharacteristic().setKey("COMPILER").setName("Compiler"), "PORTABILITY"), - now, - session + now ); verify(dao, times(2)).update(characteristicCaptor.capture(), eq(session)); @@ -397,7 +398,7 @@ public class DebtModelBackupTest { when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList(dto1, dto2)); - debtModelBackup.restoreCharacteristics(new DebtModel(), now, session); + underTest.restoreCharacteristics(session, new DebtModel(), now); verify(debtModelOperations).delete(dto1, now, session); verify(debtModelOperations).delete(dto2, now, session); @@ -410,9 +411,9 @@ public class DebtModelBackupTest { .addSubCharacteristic(new DefaultDebtCharacteristic().setKey("COMPILER").setName("Compiler"), "PORTABILITY")); when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList( - new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2),//.setCreatedAt(oldDate), - new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1)//.setCreatedAt(oldDate) - )); + new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2),// .setCreatedAt(oldDate), + new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1)// .setCreatedAt(oldDate) + )); when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setRepositoryKey("squid").setRuleKey("NPE") @@ -423,7 +424,7 @@ public class DebtModelBackupTest { .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) .setRemediationCoefficient("2h") .setRemediationOffset("15min") - )); + )); RulesDefinition.Context context = new RulesDefinition.Context(); RulesDefinition.NewRepository repo = context.createRepository("squid", "java").setName("Squid"); @@ -437,7 +438,7 @@ public class DebtModelBackupTest { repo.done(); when(defLoader.load()).thenReturn(context); - debtModelBackup.reset(); + underTest.reset(); verify(dao).selectEnabledCharacteristics(session); verify(dao, times(2)).update(any(CharacteristicDto.class), eq(session)); @@ -473,7 +474,7 @@ public class DebtModelBackupTest { when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2).setCreatedAt(oldDate), new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1).setCreatedAt(oldDate) - )); + )); when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setRepositoryKey("squid").setRuleKey("NPE") @@ -484,7 +485,7 @@ public class DebtModelBackupTest { .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) .setRemediationCoefficient("2h") .setRemediationOffset("15min") - )); + )); RulesDefinition.Context context = new RulesDefinition.Context(); RulesDefinition.NewRepository repo = context.createRepository("squid", "java").setName("Squid"); @@ -496,7 +497,7 @@ public class DebtModelBackupTest { repo.done(); when(defLoader.load()).thenReturn(context); - debtModelBackup.reset(); + underTest.reset(); verify(dao).selectEnabledCharacteristics(session); verify(dao, times(2)).update(any(CharacteristicDto.class), eq(session)); @@ -525,7 +526,7 @@ public class DebtModelBackupTest { when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2).setCreatedAt(oldDate), new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1).setCreatedAt(oldDate) - )); + )); when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( // Template rule @@ -540,7 +541,7 @@ public class DebtModelBackupTest { .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) .setRemediationCoefficient("2h") .setRemediationOffset("15min") - )); + )); RulesDefinition.Context context = new RulesDefinition.Context(); // Template rule @@ -555,7 +556,7 @@ public class DebtModelBackupTest { repo.done(); when(defLoader.load()).thenReturn(context); - debtModelBackup.reset(); + underTest.reset(); verify(ruleDao).selectEnabledAndNonManual(session); verify(ruleDao, times(2)).update(eq(session), ruleCaptor.capture()); @@ -587,11 +588,11 @@ public class DebtModelBackupTest { when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2).setCreatedAt(oldDate), new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1).setCreatedAt(oldDate) - )); + )); when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(Collections.<RuleDto>emptyList()); - debtModelBackup.reset(); + underTest.reset(); verify(dao).selectEnabledCharacteristics(session); verify(dao, times(2)).update(any(CharacteristicDto.class), eq(session)); @@ -624,10 +625,10 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") .setDefaultSubCharacteristicId(3).setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h") -// .setCreatedAt(oldDate).setUpdatedAt(oldDate) - )); + // .setCreatedAt(oldDate).setUpdatedAt(oldDate) + )); - debtModelBackup.restoreFromXml("<xml/>"); + underTest.restoreFromXml("<xml/>"); verify(ruleOperations).updateRule(ruleCaptor.capture(), eq(compiler), eq("LINEAR"), eq("2h"), isNull(String.class), eq(session)); @@ -648,10 +649,10 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") .setDefaultSubCharacteristicId(2).setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationCoefficient("2h").setDefaultRemediationOffset("15min") -// .setCreatedAt(oldDate).setUpdatedAt(oldDate) - )); + // .setCreatedAt(oldDate).setUpdatedAt(oldDate) + )); - debtModelBackup.restoreFromXml("<xml/>"); + underTest.restoreFromXml("<xml/>"); verify(ruleOperations).updateRule(ruleCaptor.capture(), isNull(CharacteristicDto.class), isNull(String.class), isNull(String.class), isNull(String.class), eq(session)); @@ -683,9 +684,9 @@ public class DebtModelBackupTest { .setSubCharacteristicId(3) .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.toString()) .setRemediationCoefficient("2h") - )); + )); - debtModelBackup.restoreFromXml("<xml/>", "java"); + underTest.restoreFromXml("<xml/>", "java"); verify(ruleOperations).updateRule(ruleCaptor.capture(), eq(compiler), eq("LINEAR"), eq("2h"), isNull(String.class), eq(session)); @@ -703,7 +704,7 @@ public class DebtModelBackupTest { CharacteristicDto dto2 = new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler").setParentId(1); when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList(dto1, dto2)); - debtModelBackup.restoreFromXml("<xml/>", "java"); + underTest.restoreFromXml("<xml/>", "java"); verify(debtModelOperations).delete(dto2, now, session); verify(session).commit(); @@ -718,7 +719,7 @@ public class DebtModelBackupTest { when(dao.selectEnabledCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability updated").setOrder(2).setCreatedAt(oldDate), new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler updated").setParentId(1).setCreatedAt(oldDate) - )); + )); when(rulesXMLImporter.importXML(anyString(), any(ValidationMessages.class))).thenReturn(Collections.<RuleDebt>emptyList()); when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( @@ -729,9 +730,9 @@ public class DebtModelBackupTest { .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) .setRemediationCoefficient("2h") .setRemediationOffset("15min") - )); + )); - debtModelBackup.restoreFromXml("<xml/>", "java"); + underTest.restoreFromXml("<xml/>", "java"); verify(ruleOperations).updateRule(ruleCaptor.capture(), isNull(CharacteristicDto.class), isNull(String.class), isNull(String.class), isNull(String.class), eq(session)); @@ -754,7 +755,7 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(Collections.<RuleDto>emptyList()); - assertThat(debtModelBackup.restoreFromXml("<xml/>").getWarnings()).hasSize(1); + assertThat(underTest.restoreFromXml("<xml/>").getWarnings()).hasSize(1); verifyZeroInteractions(ruleOperations); @@ -778,12 +779,12 @@ public class DebtModelBackupTest { when(ruleDao.selectEnabledAndNonManual(session)).thenReturn(newArrayList( new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck") .setDefaultSubCharacteristicId(3).setDefaultRemediationFunction("LINEAR").setDefaultRemediationCoefficient("2h") -// .setCreatedAt(oldDate).setUpdatedAt(oldDate) - )); + // .setCreatedAt(oldDate).setUpdatedAt(oldDate) + )); when(ruleOperations.updateRule(any(RuleDto.class), any(CharacteristicDto.class), anyString(), anyString(), anyString(), eq(session))).thenThrow(IllegalArgumentException.class); - assertThat(debtModelBackup.restoreFromXml("<xml/>").getErrors()).hasSize(1); + assertThat(underTest.restoreFromXml("<xml/>").getErrors()).hasSize(1); verify(ruleDao).selectEnabledAndNonManual(session); verify(session, never()).commit(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java index bb2608a0c93..89d229ec6ba 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java @@ -122,11 +122,11 @@ public class DebtModelOperationsTest { doAnswer(new Answer() { public Object answer(InvocationOnMock invocation) { Object[] args = invocation.getArguments(); - CharacteristicDto dto = (CharacteristicDto) args[0]; + CharacteristicDto dto = (CharacteristicDto) args[1]; dto.setId(++currentId); return null; } - }).when(dao).insert(any(CharacteristicDto.class), any(SqlSession.class)); + }).when(dao).insert(any(SqlSession.class), any(CharacteristicDto.class)); when(dbClient.openSession(false)).thenReturn(session); when(dbClient.ruleDao()).thenReturn(ruleDao); @@ -136,7 +136,7 @@ public class DebtModelOperationsTest { @Test public void create_sub_characteristic() { - when(dao.selectById(1, session)).thenReturn(characteristicDto); + when(dao.selectById(session, 1)).thenReturn(characteristicDto); DefaultDebtCharacteristic result = (DefaultDebtCharacteristic) service.create("Compilation name", 1); @@ -149,7 +149,7 @@ public class DebtModelOperationsTest { @Test public void fail_to_create_sub_characteristic_when_parent_id_is_not_a_root_characteristic() { - when(dao.selectById(1, session)).thenReturn(subCharacteristicDto); + when(dao.selectById(session, 1)).thenReturn(subCharacteristicDto); try { service.create("Compilation", 1); @@ -161,7 +161,7 @@ public class DebtModelOperationsTest { @Test public void fail_to_create_sub_characteristic_when_parent_does_not_exists() { - when(dao.selectById(1, session)).thenReturn(null); + when(dao.selectById(session, 1)).thenReturn(null); try { service.create("Compilation", 1); @@ -173,8 +173,8 @@ public class DebtModelOperationsTest { @Test public void fail_to_create_sub_characteristic_when_name_already_used() { - when(dao.selectByName("Compilation", session)).thenReturn(new CharacteristicDto()); - when(dao.selectById(1, session)).thenReturn(characteristicDto); + when(dao.selectByName(session, "Compilation")).thenReturn(new CharacteristicDto()); + when(dao.selectById(session, 1)).thenReturn(characteristicDto); try { service.create("Compilation", 1); @@ -225,7 +225,7 @@ public class DebtModelOperationsTest { @Test public void rename_characteristic() { - when(dao.selectById(10, session)).thenReturn(subCharacteristicDto); + when(dao.selectById(session, 10)).thenReturn(subCharacteristicDto); DefaultDebtCharacteristic result = (DefaultDebtCharacteristic) service.rename(10, "New Efficiency"); @@ -236,7 +236,7 @@ public class DebtModelOperationsTest { @Test public void not_rename_characteristic_when_renaming_with_same_name() { - when(dao.selectById(10, session)).thenReturn(subCharacteristicDto); + when(dao.selectById(session, 10)).thenReturn(subCharacteristicDto); service.rename(10, "Efficiency"); @@ -245,7 +245,7 @@ public class DebtModelOperationsTest { @Test public void fail_to_rename_unknown_characteristic() { - when(dao.selectById(10, session)).thenReturn(null); + when(dao.selectById(session, 10)).thenReturn(null); try { service.rename(10, "New Efficiency"); @@ -257,7 +257,7 @@ public class DebtModelOperationsTest { @Test public void move_up() { - when(dao.selectById(10, session)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2)); + when(dao.selectById(session, 10)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2)); when(dao.selectEnabledRootCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(2).setKey("PORTABILITY").setOrder(1), new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2) @@ -276,7 +276,7 @@ public class DebtModelOperationsTest { @Test public void do_nothing_when_move_up_and_already_on_top() { - when(dao.selectById(10, session)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(1)); + when(dao.selectById(session, 10)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(1)); when(dao.selectEnabledRootCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(1), new CharacteristicDto().setId(2).setKey("PORTABILITY").setOrder(2) @@ -289,7 +289,7 @@ public class DebtModelOperationsTest { @Test public void move_down() { - when(dao.selectById(10, session)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2)); + when(dao.selectById(session, 10)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2)); when(dao.selectEnabledRootCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2), new CharacteristicDto().setId(2).setKey("PORTABILITY").setOrder(3) @@ -308,7 +308,7 @@ public class DebtModelOperationsTest { @Test public void do_nothing_when_move_down_and_already_on_bottom() { - when(dao.selectById(10, session)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2)); + when(dao.selectById(session, 10)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2)); when(dao.selectEnabledRootCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(2).setKey("PORTABILITY").setOrder(1), new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2) @@ -321,7 +321,7 @@ public class DebtModelOperationsTest { @Test public void fail_to_move_sub_characteristic() { - when(dao.selectById(10, session)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setParentId(1)); + when(dao.selectById(session, 10)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setParentId(1)); when(dao.selectEnabledRootCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2), new CharacteristicDto().setId(2).setKey("PORTABILITY").setOrder(3) @@ -338,7 +338,7 @@ public class DebtModelOperationsTest { @Test public void fail_to_move_characteristic_with_no_order() { - when(dao.selectById(10, session)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(null)); + when(dao.selectById(session, 10)).thenReturn(new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(null)); when(dao.selectEnabledRootCharacteristics(session)).thenReturn(newArrayList( new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2), new CharacteristicDto().setId(2).setKey("PORTABILITY").setOrder(3) @@ -359,7 +359,7 @@ public class DebtModelOperationsTest { DbSession batchSession = mock(DbSession.class); when(dbClient.openSession(true)).thenReturn(batchSession); - when(ruleDao.findRulesByDebtSubCharacteristicId(batchSession, 2)).thenReturn(newArrayList( + when(ruleDao.selectRulesByDebtSubCharacteristicId(batchSession, 2)).thenReturn(newArrayList( new RuleDto() .setSubCharacteristicId(2) .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) @@ -369,7 +369,7 @@ public class DebtModelOperationsTest { .setDefaultRemediationCoefficient("4h") .setDefaultRemediationOffset("15min") )); - when(dao.selectById(2, batchSession)).thenReturn(subCharacteristicDto); + when(dao.selectById(batchSession, 2)).thenReturn(subCharacteristicDto); service.delete(2); @@ -404,12 +404,12 @@ public class DebtModelOperationsTest { DbSession batchSession = mock(DbSession.class); when(dbClient.openSession(true)).thenReturn(batchSession); - when(ruleDao.findRulesByDebtSubCharacteristicId(batchSession, 2)).thenReturn(newArrayList( + when(ruleDao.selectRulesByDebtSubCharacteristicId(batchSession, 2)).thenReturn(newArrayList( new RuleDto() .setSubCharacteristicId(10).setRemediationFunction("LINEAR_OFFSET").setRemediationCoefficient("2h").setRemediationOffset("5min") .setDefaultSubCharacteristicId(2).setDefaultRemediationFunction("LINEAR_OFFSET").setDefaultRemediationCoefficient("4h").setDefaultRemediationOffset("15min") )); - when(dao.selectById(2, batchSession)).thenReturn(subCharacteristicDto); + when(dao.selectById(batchSession, 2)).thenReturn(subCharacteristicDto); service.delete(2); @@ -442,7 +442,7 @@ public class DebtModelOperationsTest { DbSession batchSession = mock(DbSession.class); when(dbClient.openSession(true)).thenReturn(batchSession); - when(ruleDao.findRulesByDebtSubCharacteristicId(batchSession, subCharacteristicDto.getId())).thenReturn(newArrayList( + when(ruleDao.selectRulesByDebtSubCharacteristicId(batchSession, subCharacteristicDto.getId())).thenReturn(newArrayList( new RuleDto().setSubCharacteristicId(subCharacteristicDto.getId()) .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.toString()) .setRemediationCoefficient("2h") @@ -451,7 +451,7 @@ public class DebtModelOperationsTest { when(dao.selectCharacteristicsByParentId(1, batchSession)).thenReturn(newArrayList( subCharacteristicDto )); - when(dao.selectById(1, batchSession)).thenReturn(characteristicDto); + when(dao.selectById(batchSession, 1)).thenReturn(characteristicDto); service.delete(1); @@ -477,7 +477,7 @@ public class DebtModelOperationsTest { DbSession batchSession = mock(DbSession.class); when(dbClient.openSession(true)).thenReturn(batchSession); - when(dao.selectById(1, batchSession)).thenReturn(new CharacteristicDto() + when(dao.selectById(batchSession, 1)).thenReturn(new CharacteristicDto() .setId(1) .setKey("MEMORY_EFFICIENCY") .setName("Memory use") diff --git a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java index 3b73fd88fb5..9e1bc7b9f6d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java @@ -91,7 +91,7 @@ public class ShowActionTest { when(componentDao.selectByKey(session, componentKey)).thenReturn(Optional.of(componentDto)); String data = "{duplications}"; - when(measureDao.findByComponentKeyAndMetricKey(session, componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn( + when(measureDao.selectByComponentKeyAndMetricKey(session, componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn( new MeasureDto().setComponentKey(componentKey).setMetricKey(CoreMetrics.DUPLICATIONS_DATA_KEY).setData("{duplications}") ); @@ -114,7 +114,7 @@ public class ShowActionTest { when(componentDao.selectByUuid(session, uuid)).thenReturn(Optional.of(componentDto)); String data = "{duplications}"; - when(measureDao.findByComponentKeyAndMetricKey(session, componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn( + when(measureDao.selectByComponentKeyAndMetricKey(session, componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn( new MeasureDto().setComponentKey(componentKey).setMetricKey(CoreMetrics.DUPLICATIONS_DATA_KEY).setData("{duplications}") ); @@ -135,7 +135,7 @@ public class ShowActionTest { ComponentDto componentDto = new ComponentDto().setId(10L).setKey(componentKey); when(componentDao.selectByKey(session, componentKey)).thenReturn(Optional.of(componentDto)); - when(measureDao.findByComponentKeyAndMetricKey(session, componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn(null); + when(measureDao.selectByComponentKeyAndMetricKey(session, componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn(null); WsTester.TestRequest request = tester.newGetRequest("api/duplications", "show").setParam("key", componentKey); request.execute(); 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 0e552d4bfb2..3702a79d978 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 @@ -128,7 +128,7 @@ public class InternalRubyIssueServiceTest { userWriter = mock(UserJsonWriter.class); ResourceDto project = new ResourceDto().setKey("org.sonar.Sample"); - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(project); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(project); service = new InternalRubyIssueService(issueService, issueQueryService, commentService, changelogService, actionPlanService, resourceDao, actionService, issueFilterService, issueBulkChangeService, issueWriter, issueComponentHelper, componentWriter, userIndex, dbClient, userSessionRule, userWriter); @@ -402,7 +402,7 @@ public class InternalRubyIssueServiceTest { parameters.put("description", "Long term issues"); parameters.put("project", "org.sonar.Sample"); - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(null); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(null); Result result = service.createActionPlanResult(parameters); assertThat(result.ok()).isFalse(); 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 index 084ab728dc2..e052f12cd1b 100644 --- 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 @@ -106,7 +106,7 @@ public class ActionPlanServiceTest { @Test public void create() { - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); ActionPlan actionPlan = DefaultActionPlan.create("Long term"); actionPlanService.create(actionPlan, projectAdministratorUserSession); @@ -115,7 +115,7 @@ public class ActionPlanServiceTest { @Test public void create_required_admin_role() { - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); ActionPlan actionPlan = DefaultActionPlan.create("Long term"); try { @@ -129,8 +129,8 @@ public class ActionPlanServiceTest { @Test public void set_status() { - when(actionPlanDao.findByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey)); - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); + when(actionPlanDao.selectByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey)); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); ActionPlan result = actionPlanService.setStatus("ABCD", "CLOSED", projectAdministratorUserSession); verify(actionPlanDao).update(any(ActionPlanDto.class)); @@ -141,7 +141,7 @@ public class ActionPlanServiceTest { @Test public void update() { - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); ActionPlan actionPlan = DefaultActionPlan.create("Long term"); actionPlanService.update(actionPlan, projectAdministratorUserSession); @@ -150,16 +150,16 @@ public class ActionPlanServiceTest { @Test public void delete() { - when(actionPlanDao.findByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey)); - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); + when(actionPlanDao.selectByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey)); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); actionPlanService.delete("ABCD", projectAdministratorUserSession); verify(actionPlanDao).delete("ABCD"); } @Test public void unplan_all_linked_issues_when_deleting_an_action_plan() { - when(actionPlanDao.findByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey)); - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); + when(actionPlanDao.selectByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey)); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); IssueDto issueDto = new IssueDto().setId(100L).setStatus(Issue.STATUS_OPEN).setRuleKey("squid", "s100").setIssueCreationDate(new Date()); when(issueDao.findByActionPlan(session, "ABCD")).thenReturn(newArrayList(issueDto)); @@ -174,8 +174,8 @@ public class ActionPlanServiceTest { @Test public void find_by_key() { - when(actionPlanDao.findByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey)); - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); + when(actionPlanDao.selectByKey("ABCD")).thenReturn(new ActionPlanDto().setKey("ABCD").setProjectKey_unit_test_only(projectKey)); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); ActionPlan result = actionPlanService.findByKey("ABCD", projectUserSession); assertThat(result).isNotNull(); @@ -184,13 +184,13 @@ public class ActionPlanServiceTest { @Test public void return_null_if_no_action_plan_when_find_by_key() { - when(actionPlanDao.findByKey("ABCD")).thenReturn(null); + when(actionPlanDao.selectByKey("ABCD")).thenReturn(null); assertThat(actionPlanService.findByKey("ABCD", projectUserSession)).isNull(); } @Test public void find_by_keys() { - when(actionPlanDao.findByKeys(newArrayList("ABCD"))).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD"))); + 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"); @@ -198,8 +198,8 @@ public class ActionPlanServiceTest { @Test public void find_open_by_project_key() { - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); - when(actionPlanDao.findOpenByProjectId(1l)).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD"))); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); + when(actionPlanDao.selectOpenByProjectId(1l)).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD"))); Collection<ActionPlan> results = actionPlanService.findOpenByProjectKey(projectKey, projectUserSession); assertThat(results).hasSize(1); assertThat(results.iterator().next().key()).isEqualTo("ABCD"); @@ -207,8 +207,8 @@ public class ActionPlanServiceTest { @Test public void find_open_by_project_key_required_user_role() { - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); - when(actionPlanDao.findOpenByProjectId(1l)).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD"))); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setKey(projectKey).setId(1l)); + when(actionPlanDao.selectOpenByProjectId(1l)).thenReturn(newArrayList(new ActionPlanDto().setKey("ABCD"))); try { actionPlanService.findOpenByProjectKey(projectKey, unauthorizedUserSession); @@ -221,14 +221,14 @@ public class ActionPlanServiceTest { @Test(expected = NotFoundException.class) public void throw_exception_if_project_not_found_when_find_open_by_project_key() { - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(null); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(null); actionPlanService.findOpenByProjectKey("<Unkown>", projectUserSession); } @Test public void find_action_plan_stats() { - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setId(1L).setKey(projectKey)); - when(actionPlanStatsDao.findByProjectId(1L)).thenReturn(newArrayList(new ActionPlanStatsDto())); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setId(1L).setKey(projectKey)); + when(actionPlanStatsDao.selectByProjectId(1L)).thenReturn(newArrayList(new ActionPlanStatsDto())); Collection<ActionPlanStats> results = actionPlanService.findActionPlanStats(projectKey, projectUserSession); assertThat(results).hasSize(1); @@ -236,7 +236,7 @@ public class ActionPlanServiceTest { @Test(expected = NotFoundException.class) public void throw_exception_if_project_not_found_when_find_open_action_plan_stats() { - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(null); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(null); actionPlanService.findActionPlanStats(projectKey, projectUserSession); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesNotificationTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesNotificationTest.java index ad0e289ca6c..7d13669e035 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesNotificationTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesNotificationTest.java @@ -83,8 +83,8 @@ public class NewIssuesNotificationTest { public void set_statistics() { addIssueNTimes(newIssue1(), 5); addIssueNTimes(newIssue2(), 3); - when(dbClient.componentDao().selectNonNullByUuid(any(DbSession.class), eq("file-uuid")).name()).thenReturn("file-name"); - when(dbClient.componentDao().selectNonNullByUuid(any(DbSession.class), eq("directory-uuid")).name()).thenReturn("directory-name"); + when(dbClient.componentDao().selectOrFailByUuid(any(DbSession.class), eq("file-uuid")).name()).thenReturn("file-name"); + when(dbClient.componentDao().selectOrFailByUuid(any(DbSession.class), eq("directory-uuid")).name()).thenReturn("directory-name"); when(ruleIndex.getByKey(RuleKey.of("SonarQube", "rule-the-world"))).thenReturn(newRule("Rule the World", "Java")); when(ruleIndex.getByKey(RuleKey.of("SonarQube", "rule-the-universe"))).thenReturn(newRule("Rule the Universe", "Clojure")); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ShowActionTest.java index ed30414fada..2e227df5e83 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ShowActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ShowActionTest.java @@ -164,7 +164,7 @@ public class ShowActionTest { .setKey("org.sonar.Sonar") .setLongName("SonarQube") .setName("SonarQube"); - when(componentDao.selectNonNullByUuid(session, project.uuid())).thenReturn(project); + when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); ComponentDto file = ComponentTesting.newFileDto(project) .setId(10L) @@ -173,7 +173,7 @@ public class ShowActionTest { .setName("SonarQube :: Issue Client") .setQualifier("FIL") .setParentProjectId(1L); - when(componentDao.selectNonNullByUuid(session, file.uuid())).thenReturn(file); + when(componentDao.selectOrFailByUuid(session, file.uuid())).thenReturn(file); DefaultIssue issue = new DefaultIssue() .setKey(issueKey) @@ -203,7 +203,7 @@ public class ShowActionTest { .setId(1L) .setKey("org.sonar.Sonar") .setLongName("SonarQube"); - when(componentDao.selectNonNullByUuid(session, project.uuid())).thenReturn(project); + when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); // Module ComponentDto module = ComponentTesting.newModuleDto(project) @@ -221,7 +221,7 @@ public class ShowActionTest { .setLongName("SonarQube :: Issue Client") .setQualifier("FIL") .setParentProjectId(2L); - when(componentDao.selectNonNullByUuid(session, file.uuid())).thenReturn(file); + when(componentDao.selectOrFailByUuid(session, file.uuid())).thenReturn(file); DefaultIssue issue = new DefaultIssue() .setKey(issueKey) @@ -253,7 +253,7 @@ public class ShowActionTest { .setKey("org.sonar.Sonar") .setName("SonarQube") .setLongName(null); - when(componentDao.selectNonNullByUuid(session, project.uuid())).thenReturn(project); + when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); // Module ComponentDto module = ComponentTesting.newModuleDto(project) @@ -272,7 +272,7 @@ public class ShowActionTest { .setLongName("SonarQube :: Issue Client") .setQualifier("FIL") .setParentProjectId(2L); - when(componentDao.selectNonNullByUuid(session, file.uuid())).thenReturn(file); + when(componentDao.selectOrFailByUuid(session, file.uuid())).thenReturn(file); DefaultIssue issue = new DefaultIssue() .setKey(issueKey) @@ -304,7 +304,7 @@ public class ShowActionTest { .setKey("org.sonar.Sonar") .setLongName("SonarQube") .setName("SonarQube"); - when(componentDao.selectNonNullByUuid(session, project.uuid())).thenReturn(project); + when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); ComponentDto file = ComponentTesting.newFileDto(project) .setId(10L) @@ -314,7 +314,7 @@ public class ShowActionTest { .setName("SonarQube :: Issue Client") .setQualifier("FIL") .setParentProjectId(1L); - when(componentDao.selectNonNullByUuid(session, file.uuid())).thenReturn(file); + when(componentDao.selectOrFailByUuid(session, file.uuid())).thenReturn(file); DefaultIssue issue = createIssue() .setComponentUuid(file.uuid()) @@ -504,7 +504,7 @@ public class ShowActionTest { .setKey("org.sonar.Sonar") .setLongName("SonarQube") .setName("SonarQube"); - when(componentDao.selectNonNullByUuid(session, project.uuid())).thenReturn(project); + when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); ComponentDto file = ComponentTesting.newFileDto(project) .setId(10L) @@ -513,7 +513,7 @@ public class ShowActionTest { .setName("SonarQube :: Issue Client") .setQualifier("FIL") .setParentProjectId(1L); - when(componentDao.selectNonNullByUuid(session, file.uuid())).thenReturn(file); + when(componentDao.selectOrFailByUuid(session, file.uuid())).thenReturn(file); return createIssue() .setComponentUuid(file.uuid()) diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/DeleteActionTest.java index 5d603612f14..d9eb55bbcd9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/DeleteActionTest.java @@ -37,7 +37,6 @@ import org.sonar.db.measure.custom.CustomMeasureDto; import org.sonar.server.component.ComponentTesting; import org.sonar.server.db.DbClient; import org.sonar.server.exceptions.ForbiddenException; -import org.sonar.server.exceptions.NotFoundException; import org.sonar.db.measure.custom.CustomMeasureDao; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.ws.WsTester; @@ -83,8 +82,8 @@ public class DeleteActionTest { WsTester.Result response = newRequest().setParam(PARAM_ID, String.valueOf(id)).execute(); - assertThat(dbClient.customMeasureDao().selectNullableById(dbSession, id)).isNull(); - assertThat(dbClient.customMeasureDao().selectNullableById(dbSession, anotherId)).isNotNull(); + assertThat(dbClient.customMeasureDao().selectById(dbSession, id)).isNull(); + assertThat(dbClient.customMeasureDao().selectById(dbSession, anotherId)).isNotNull(); response.assertNoContent(); } @@ -97,7 +96,7 @@ public class DeleteActionTest { newRequest().setParam(PARAM_ID, String.valueOf(id)).execute(); - assertThat(dbClient.customMeasureDao().selectNullableById(dbSession, id)).isNull(); + assertThat(dbClient.customMeasureDao().selectById(dbSession, id)).isNull(); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java index 1d6b7cf3899..a086593bcc8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java @@ -123,7 +123,7 @@ public class UpdateActionTest { .setParam(PARAM_VALUE, "new-text-measure-value") .execute(); - CustomMeasureDto updatedCustomMeasure = dbClient.customMeasureDao().selectById(dbSession, customMeasure.getId()); + CustomMeasureDto updatedCustomMeasure = dbClient.customMeasureDao().selectOrFail(dbSession, customMeasure.getId()); assertThat(updatedCustomMeasure.getTextValue()).isEqualTo("new-text-measure-value"); assertThat(updatedCustomMeasure.getDescription()).isEqualTo("new-custom-measure-description"); assertThat(updatedCustomMeasure.getUpdatedAt()).isEqualTo(123_456_789L); @@ -146,7 +146,7 @@ public class UpdateActionTest { .setParam(PARAM_VALUE, "1984") .execute(); - CustomMeasureDto updatedCustomMeasure = dbClient.customMeasureDao().selectById(dbSession, customMeasure.getId()); + CustomMeasureDto updatedCustomMeasure = dbClient.customMeasureDao().selectOrFail(dbSession, customMeasure.getId()); assertThat(updatedCustomMeasure.getValue()).isCloseTo(1984d, offset(0.01d)); assertThat(updatedCustomMeasure.getDescription()).isEqualTo("new-custom-measure-description"); assertThat(customMeasure.getCreatedAt()).isEqualTo(updatedCustomMeasure.getCreatedAt()); @@ -197,7 +197,7 @@ public class UpdateActionTest { .setParam(PARAM_DESCRIPTION, "new-custom-measure-description") .execute(); - CustomMeasureDto updatedCustomMeasure = dbClient.customMeasureDao().selectById(dbSession, customMeasure.getId()); + CustomMeasureDto updatedCustomMeasure = dbClient.customMeasureDao().selectOrFail(dbSession, customMeasure.getId()); assertThat(updatedCustomMeasure.getTextValue()).isEqualTo("text-measure-value"); assertThat(updatedCustomMeasure.getDescription()).isEqualTo("new-custom-measure-description"); assertThat(updatedCustomMeasure.getUpdatedAt()).isEqualTo(123_456_789L); @@ -223,7 +223,7 @@ public class UpdateActionTest { .setParam(PARAM_VALUE, "new-text-measure-value") .execute(); - CustomMeasureDto updatedCustomMeasure = dbClient.customMeasureDao().selectById(dbSession, customMeasure.getId()); + CustomMeasureDto updatedCustomMeasure = dbClient.customMeasureDao().selectOrFail(dbSession, customMeasure.getId()); assertThat(updatedCustomMeasure.getTextValue()).isEqualTo("new-text-measure-value"); assertThat(updatedCustomMeasure.getDescription()).isEqualTo("custom-measure-description"); assertThat(updatedCustomMeasure.getUpdatedAt()).isEqualTo(123_456_789L); diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java index bf9090c3acd..4d1d6833ff0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/CreateActionTest.java @@ -94,7 +94,7 @@ public class CreateActionTest { .setParam(PARAM_TYPE, DEFAULT_TYPE) .execute(); - MetricDto metric = dbClient.metricDao().selectNullableByKey(dbSession, DEFAULT_KEY); + MetricDto metric = dbClient.metricDao().selectByKey(dbSession, DEFAULT_KEY); assertThat(metric.getKey()).isEqualTo(DEFAULT_KEY); assertThat(metric.getShortName()).isEqualTo(DEFAULT_NAME); @@ -117,7 +117,7 @@ public class CreateActionTest { .setParam(PARAM_DESCRIPTION, DEFAULT_DESCRIPTION) .execute(); - MetricDto metric = dbClient.metricDao().selectNullableByKey(dbSession, DEFAULT_KEY); + MetricDto metric = dbClient.metricDao().selectByKey(dbSession, DEFAULT_KEY); assertThat(metric.getKey()).isEqualTo(DEFAULT_KEY); assertThat(metric.getDescription()).isEqualTo(DEFAULT_DESCRIPTION); @@ -158,7 +158,7 @@ public class CreateActionTest { result.assertJson(getClass(), "metric.json"); result.outputAsString().matches("\"id\"\\s*:\\s*\"" + metricInDb.getId() + "\""); - MetricDto metricAfterWs = dbClient.metricDao().selectNullableByKey(dbSession, DEFAULT_KEY); + MetricDto metricAfterWs = dbClient.metricDao().selectByKey(dbSession, DEFAULT_KEY); assertThat(metricAfterWs.getId()).isEqualTo(metricInDb.getId()); assertThat(metricAfterWs.getDomain()).isEqualTo(DEFAULT_DOMAIN); assertThat(metricAfterWs.getDescription()).isEqualTo(DEFAULT_DESCRIPTION); diff --git a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java index c0b49db50df..38079656bf5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java @@ -86,9 +86,9 @@ public class DeleteActionTest { newRequest().setParam("keys", "key-1, key-3").execute(); dbSession.commit(); - List<MetricDto> disabledMetrics = metricDao.selectNullableByKeys(dbSession, Arrays.asList("key-1", "key-3")); + List<MetricDto> disabledMetrics = metricDao.selectByKeys(dbSession, Arrays.asList("key-1", "key-3")); assertThat(disabledMetrics).extracting("enabled").containsOnly(false); - assertThat(metricDao.selectNullableByKey(dbSession, "key-2").isEnabled()).isTrue(); + assertThat(metricDao.selectByKey(dbSession, "key-2").isEnabled()).isTrue(); } @Test @@ -112,7 +112,7 @@ public class DeleteActionTest { newRequest().setParam("keys", "key-1").execute(); dbSession.commit(); - MetricDto metric = metricDao.selectNullableByKey(dbSession, "key-1"); + MetricDto metric = metricDao.selectByKey(dbSession, "key-1"); assertThat(metric.isEnabled()).isTrue(); } @@ -128,8 +128,8 @@ public class DeleteActionTest { newRequest().setParam("keys", "key-1").execute(); - assertThat(dbClient.customMeasureDao().selectNullableById(dbSession, customMeasure.getId())).isNull(); - assertThat(dbClient.customMeasureDao().selectNullableById(dbSession, undeletedCustomMeasure.getId())).isNotNull(); + assertThat(dbClient.customMeasureDao().selectById(dbSession, customMeasure.getId())).isNull(); + assertThat(dbClient.customMeasureDao().selectById(dbSession, undeletedCustomMeasure.getId())).isNotNull(); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/notification/DefaultNotificationManagerTest.java b/server/sonar-server/src/test/java/org/sonar/server/notification/DefaultNotificationManagerTest.java index 4e759f57ede..42452198fe6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/notification/DefaultNotificationManagerTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/notification/DefaultNotificationManagerTest.java @@ -97,12 +97,12 @@ public class DefaultNotificationManagerTest { Notification notification = new Notification("test"); NotificationQueueDto dto = NotificationQueueDto.toNotificationQueueDto(notification); List<NotificationQueueDto> dtos = Arrays.asList(dto); - when(notificationQueueDao.findOldest(1)).thenReturn(dtos); + when(notificationQueueDao.selectOldest(1)).thenReturn(dtos); assertThat(manager.getFromQueue()).isNotNull(); InOrder inOrder = inOrder(notificationQueueDao); - inOrder.verify(notificationQueueDao).findOldest(1); + inOrder.verify(notificationQueueDao).selectOldest(1); inOrder.verify(notificationQueueDao).delete(dtos); } @@ -112,7 +112,7 @@ public class DefaultNotificationManagerTest { NotificationQueueDto dto1 = mock(NotificationQueueDto.class); when(dto1.toNotification()).thenThrow(new InvalidClassException("Pouet")); List<NotificationQueueDto> dtos = Arrays.asList(dto1); - when(notificationQueueDao.findOldest(1)).thenReturn(dtos); + when(notificationQueueDao.selectOldest(1)).thenReturn(dtos); manager = spy(manager); assertThat(manager.getFromQueue()).isNull(); @@ -128,11 +128,11 @@ public class DefaultNotificationManagerTest { @Test public void shouldFindSubscribedRecipientForGivenResource() { - when(propertiesDao.findUsersForNotification("NewViolations", "Email", "uuid_45")).thenReturn(Lists.newArrayList("user1", "user2")); - when(propertiesDao.findUsersForNotification("NewViolations", "Email", null)).thenReturn(Lists.newArrayList("user1", "user3")); - when(propertiesDao.findUsersForNotification("NewViolations", "Twitter", "uuid_56")).thenReturn(Lists.newArrayList("user2")); - when(propertiesDao.findUsersForNotification("NewViolations", "Twitter", null)).thenReturn(Lists.newArrayList("user3")); - when(propertiesDao.findUsersForNotification("NewAlerts", "Twitter", null)).thenReturn(Lists.newArrayList("user4")); + when(propertiesDao.selectUsersForNotification("NewViolations", "Email", "uuid_45")).thenReturn(Lists.newArrayList("user1", "user2")); + when(propertiesDao.selectUsersForNotification("NewViolations", "Email", null)).thenReturn(Lists.newArrayList("user1", "user3")); + when(propertiesDao.selectUsersForNotification("NewViolations", "Twitter", "uuid_56")).thenReturn(Lists.newArrayList("user2")); + when(propertiesDao.selectUsersForNotification("NewViolations", "Twitter", null)).thenReturn(Lists.newArrayList("user3")); + when(propertiesDao.selectUsersForNotification("NewAlerts", "Twitter", null)).thenReturn(Lists.newArrayList("user4")); Multimap<String, NotificationChannel> multiMap = manager.findSubscribedRecipientsForDispatcher(dispatcher, "uuid_45"); assertThat(multiMap.entries()).hasSize(4); @@ -146,11 +146,11 @@ public class DefaultNotificationManagerTest { @Test public void shouldFindSubscribedRecipientForNoResource() { - when(propertiesDao.findUsersForNotification("NewViolations", "Email", "uuid_45")).thenReturn(Lists.newArrayList("user1", "user2")); - when(propertiesDao.findUsersForNotification("NewViolations", "Email", null)).thenReturn(Lists.newArrayList("user1", "user3")); - when(propertiesDao.findUsersForNotification("NewViolations", "Twitter", "uuid_56")).thenReturn(Lists.newArrayList("user2")); - when(propertiesDao.findUsersForNotification("NewViolations", "Twitter", null)).thenReturn(Lists.newArrayList("user3")); - when(propertiesDao.findUsersForNotification("NewAlerts", "Twitter", null)).thenReturn(Lists.newArrayList("user4")); + when(propertiesDao.selectUsersForNotification("NewViolations", "Email", "uuid_45")).thenReturn(Lists.newArrayList("user1", "user2")); + when(propertiesDao.selectUsersForNotification("NewViolations", "Email", null)).thenReturn(Lists.newArrayList("user1", "user3")); + when(propertiesDao.selectUsersForNotification("NewViolations", "Twitter", "uuid_56")).thenReturn(Lists.newArrayList("user2")); + when(propertiesDao.selectUsersForNotification("NewViolations", "Twitter", null)).thenReturn(Lists.newArrayList("user3")); + when(propertiesDao.selectUsersForNotification("NewAlerts", "Twitter", null)).thenReturn(Lists.newArrayList("user4")); Multimap<String, NotificationChannel> multiMap = manager.findSubscribedRecipientsForDispatcher(dispatcher, null); assertThat(multiMap.entries()).hasSize(3); @@ -164,8 +164,8 @@ public class DefaultNotificationManagerTest { @Test public void findNotificationSubscribers() { - when(propertiesDao.findNotificationSubscribers("NewViolations", "Email", "struts")).thenReturn(Lists.newArrayList("user1", "user2")); - when(propertiesDao.findNotificationSubscribers("NewViolations", "Twitter", "struts")).thenReturn(Lists.newArrayList("user2")); + when(propertiesDao.selectNotificationSubscribers("NewViolations", "Email", "struts")).thenReturn(Lists.newArrayList("user1", "user2")); + when(propertiesDao.selectNotificationSubscribers("NewViolations", "Twitter", "struts")).thenReturn(Lists.newArrayList("user2")); Multimap<String, NotificationChannel> multiMap = manager.findNotificationSubscribers(dispatcher, "struts"); assertThat(multiMap.entries()).hasSize(3); diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java index 163bd4397db..9735ab18186 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/InternalPermissionTemplateServiceTest.java @@ -118,7 +118,7 @@ public class InternalPermissionTemplateServiceTest { @Test public void should_create_permission_template() { - when(permissionTemplateDao.createPermissionTemplate(DEFAULT_KEY, DEFAULT_DESC, DEFAULT_PATTERN)).thenReturn(DEFAULT_TEMPLATE); + when(permissionTemplateDao.insertPermissionTemplate(DEFAULT_KEY, DEFAULT_DESC, DEFAULT_PATTERN)).thenReturn(DEFAULT_TEMPLATE); PermissionTemplate permissionTemplate = service.createPermissionTemplate(DEFAULT_KEY, DEFAULT_DESC, DEFAULT_PATTERN); @@ -286,7 +286,7 @@ public class InternalPermissionTemplateServiceTest { service.addUserPermission(DEFAULT_KEY, DEFAULT_PERMISSION, "user"); - verify(permissionTemplateDao, times(1)).addUserPermission(1L, 1L, DEFAULT_PERMISSION); + verify(permissionTemplateDao, times(1)).insertUserPermission(1L, 1L, DEFAULT_PERMISSION); } @Test @@ -308,7 +308,7 @@ public class InternalPermissionTemplateServiceTest { service.removeUserPermission(DEFAULT_KEY, DEFAULT_PERMISSION, "user"); - verify(permissionTemplateDao, times(1)).removeUserPermission(1L, 1L, DEFAULT_PERMISSION); + verify(permissionTemplateDao, times(1)).deleteUserPermission(1L, 1L, DEFAULT_PERMISSION); } @Test @@ -319,7 +319,7 @@ public class InternalPermissionTemplateServiceTest { service.addGroupPermission(DEFAULT_KEY, DEFAULT_PERMISSION, "group"); - verify(permissionTemplateDao, times(1)).addGroupPermission(1L, 1L, DEFAULT_PERMISSION); + verify(permissionTemplateDao, times(1)).insertGroupPermission(1L, 1L, DEFAULT_PERMISSION); } @Test @@ -341,7 +341,7 @@ public class InternalPermissionTemplateServiceTest { service.removeGroupPermission(DEFAULT_KEY, DEFAULT_PERMISSION, "group"); - verify(permissionTemplateDao, times(1)).removeGroupPermission(1L, 1L, DEFAULT_PERMISSION); + verify(permissionTemplateDao, times(1)).deleteGroupPermission(1L, 1L, DEFAULT_PERMISSION); } @Test @@ -350,7 +350,7 @@ public class InternalPermissionTemplateServiceTest { service.addGroupPermission(DEFAULT_KEY, DEFAULT_PERMISSION, "Anyone"); - verify(permissionTemplateDao).addGroupPermission(1L, null, DEFAULT_PERMISSION); + verify(permissionTemplateDao).insertGroupPermission(1L, null, DEFAULT_PERMISSION); verifyZeroInteractions(userDao); } @@ -360,7 +360,7 @@ public class InternalPermissionTemplateServiceTest { service.removeGroupPermission(DEFAULT_KEY, DEFAULT_PERMISSION, "Anyone"); - verify(permissionTemplateDao).removeGroupPermission(1L, null, DEFAULT_PERMISSION); + verify(permissionTemplateDao).deleteGroupPermission(1L, null, DEFAULT_PERMISSION); verifyZeroInteractions(userDao); } @@ -371,7 +371,7 @@ public class InternalPermissionTemplateServiceTest { service.removeGroupFromTemplates("group"); - verify(permissionTemplateDao).removeByGroup(eq(1L), eq(session)); + verify(permissionTemplateDao).deleteByGroup(eq(session), eq(1L)); } private PermissionTemplateUserDto buildUserPermission(String userName, String permission) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionFinderTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionFinderTest.java index da5793949f2..293092c9127 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionFinderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionFinderTest.java @@ -64,7 +64,7 @@ public class PermissionFinderTest { @Before public void setUp() { - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setId(100L).setName("org.sample.Sample")); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(new ResourceDto().setId(100L).setName("org.sample.Sample")); finder = new PermissionFinder(permissionDao, resourceDao, permissionTemplateDao); } @@ -81,7 +81,7 @@ public class PermissionFinderTest { @Test public void fail_to_find_users_when_component_not_found() { - when(resourceDao.getResource(any(ResourceQuery.class))).thenReturn(null); + when(resourceDao.selectResource(any(ResourceQuery.class))).thenReturn(null); try { finder.findUsersWithPermission(PermissionQuery.builder().permission("user").component("Unknown").build()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateUpdaterTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateUpdaterTest.java index 1ee16c93c51..ef4c25bbc49 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateUpdaterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/PermissionTemplateUpdaterTest.java @@ -72,12 +72,12 @@ public class PermissionTemplateUpdaterTest { new PermissionTemplateUpdater("my_template", UserRole.USER, "user", permissionTemplateDao, userDao, userSessionRule) { @Override void doExecute(Long templateId, String permission) { - permissionTemplateDao.addUserPermission(1L, 1L, UserRole.USER); + permissionTemplateDao.insertUserPermission(1L, 1L, UserRole.USER); } }; updater.executeUpdate(); - verify(permissionTemplateDao, times(1)).addUserPermission(1L, 1L, UserRole.USER); + verify(permissionTemplateDao, times(1)).insertUserPermission(1L, 1L, UserRole.USER); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java index 285f0dcd98d..2050689c660 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/PersistentSettingsTest.java @@ -69,7 +69,7 @@ public class PersistentSettingsTest { // kept in memory cache and persisted in db assertThat(settings.getString("foo")).isEqualTo("bar"); - verify(dao).setProperty(argThat(new ArgumentMatcher<PropertyDto>() { + verify(dao).insertProperty(argThat(new ArgumentMatcher<PropertyDto>() { @Override public boolean matches(Object o) { PropertyDto dto = (PropertyDto) o; @@ -121,7 +121,7 @@ public class PersistentSettingsTest { persistentSettings.saveProperties(props); assertThat(settings.getString("foo")).isEqualTo("bar"); - verify(dao).saveGlobalProperties(props); + verify(dao).insertGlobalProperties(props); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java index 3b3df23b9fb..14c1f67d00e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkDeleteActionTest.java @@ -144,11 +144,11 @@ public class BulkDeleteActionTest { dbSession.commit(); assertThat(dbClient.componentDao().selectByUuids(dbSession, Arrays.asList("project-uuid-1", "project-uuid-3", "project-uuid-4"))).isEmpty(); - assertThat(dbClient.componentDao().selectNonNullByUuid(dbSession, "project-uuid-2")).isNotNull(); - assertThat(dbClient.snapshotDao().selectNullableById(dbSession, snapshotId1)).isNull(); - assertThat(dbClient.snapshotDao().selectNullableById(dbSession, snapshotId3)).isNull(); - assertThat(dbClient.snapshotDao().selectNullableById(dbSession, snapshotId4)).isNull(); - assertThat(dbClient.snapshotDao().selectNullableById(dbSession, snapshotId2)).isNotNull(); + assertThat(dbClient.componentDao().selectOrFailByUuid(dbSession, "project-uuid-2")).isNotNull(); + assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId1)).isNull(); + assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId3)).isNull(); + assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId4)).isNull(); + assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId2)).isNotNull(); assertThat(dbClient.issueDao().selectByKeys(dbSession, Arrays.asList("issue-key-1", "issue-key-3", "issue-key-4"))).isEmpty(); assertThat(dbClient.issueDao().selectByKey(dbSession, "issue-key-2")).isNotNull(); } @@ -165,7 +165,7 @@ public class BulkDeleteActionTest { dbSession.commit(); assertThat(dbClient.componentDao().selectByUuids(dbSession, Arrays.asList("project-uuid-1", "project-uuid-3", "project-uuid-4"))).isEmpty(); - assertThat(dbClient.componentDao().selectNonNullByUuid(dbSession, "project-uuid-2")).isNotNull(); + assertThat(dbClient.componentDao().selectOrFailByUuid(dbSession, "project-uuid-2")).isNotNull(); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java index 0ed28ff6ca6..f7d51ce48c1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/DeleteActionTest.java @@ -147,9 +147,9 @@ public class DeleteActionTest { dbSession.commit(); assertThat(dbClient.componentDao().selectByUuid(dbSession, "project-uuid-1")).isAbsent(); - assertThat(dbClient.componentDao().selectNonNullByUuid(dbSession, "project-uuid-2")).isNotNull(); - assertThat(dbClient.snapshotDao().selectNullableById(dbSession, snapshotId1)).isNull(); - assertThat(dbClient.snapshotDao().selectNullableById(dbSession, snapshotId2)).isNotNull(); + assertThat(dbClient.componentDao().selectOrFailByUuid(dbSession, "project-uuid-2")).isNotNull(); + assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId1)).isNull(); + assertThat(dbClient.snapshotDao().selectById(dbSession, snapshotId2)).isNotNull(); assertThat(dbClient.issueDao().selectNullableByKey(dbSession, "issue-key-1")).isNull(); assertThat(dbClient.issueDao().selectByKey(dbSession, "issue-key-2")).isNotNull(); } @@ -164,7 +164,7 @@ public class DeleteActionTest { dbSession.commit(); assertThat(dbClient.componentDao().selectByUuid(dbSession, "project-uuid-1")).isAbsent(); - assertThat(dbClient.componentDao().selectNonNullByUuid(dbSession, "project-uuid-2")).isNotNull(); + assertThat(dbClient.componentDao().selectOrFailByUuid(dbSession, "project-uuid-2")).isNotNull(); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java index edf73b396c2..fa99eb14bac 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java @@ -111,7 +111,7 @@ public class QualityGatesTest { public void initialize() { settings.clear(); - when(componentDao.selectNonNullById(eq(session), anyLong())).thenReturn(new ComponentDto().setId(1L).setKey(PROJECT_KEY)); + when(componentDao.selectOrFailById(eq(session), anyLong())).thenReturn(new ComponentDto().setId(1L).setKey(PROJECT_KEY)); when(myBatis.openSession(false)).thenReturn(session); qGates = new QualityGates(dao, conditionDao, metricFinder, propertiesDao, componentDao, myBatis, userSessionRule, settings); @@ -236,7 +236,7 @@ public class QualityGatesTest { verify(dao).selectById(defaultId); ArgumentCaptor<PropertyDto> propertyCaptor = ArgumentCaptor.forClass(PropertyDto.class); - verify(propertiesDao).setProperty(propertyCaptor.capture()); + verify(propertiesDao).insertProperty(propertyCaptor.capture()); assertThat(propertyCaptor.getValue().getKey()).isEqualTo("sonar.qualitygate"); assertThat(propertyCaptor.getValue().getValue()).isEqualTo("42"); @@ -536,7 +536,7 @@ public class QualityGatesTest { qGates.associateProject(qGateId, projectId); verify(dao).selectById(qGateId); ArgumentCaptor<PropertyDto> propertyCaptor = ArgumentCaptor.forClass(PropertyDto.class); - verify(propertiesDao).setProperty(propertyCaptor.capture()); + verify(propertiesDao).insertProperty(propertyCaptor.capture()); PropertyDto property = propertyCaptor.getValue(); assertThat(property.getKey()).isEqualTo("sonar.qualitygate"); assertThat(property.getResourceId()).isEqualTo(projectId); @@ -553,7 +553,7 @@ public class QualityGatesTest { qGates.associateProject(qGateId, projectId); verify(dao).selectById(qGateId); ArgumentCaptor<PropertyDto> propertyCaptor = ArgumentCaptor.forClass(PropertyDto.class); - verify(propertiesDao).setProperty(propertyCaptor.capture()); + verify(propertiesDao).insertProperty(propertyCaptor.capture()); PropertyDto property = propertyCaptor.getValue(); assertThat(property.getKey()).isEqualTo("sonar.qualitygate"); assertThat(property.getResourceId()).isEqualTo(projectId); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java index 8cc6afdc0c9..ddf519bd604 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleBackendMediumTest.java @@ -138,7 +138,7 @@ public class ActiveRuleBackendMediumTest { // verify db assertThat(db.activeRuleDao().getByKey(dbSession, activeRule.getKey())).isNotNull(); - List<ActiveRuleDto> persistedDtos = db.activeRuleDao().findByRule(dbSession, ruleDto); + List<ActiveRuleDto> persistedDtos = db.activeRuleDao().selectByRule(dbSession, ruleDto); assertThat(persistedDtos).hasSize(1); // verify es @@ -162,12 +162,12 @@ public class ActiveRuleBackendMediumTest { RuleParamDto minParam = new RuleParamDto() .setName("min") .setType("STRING"); - db.ruleDao().addRuleParam(dbSession, ruleDto, minParam); + db.ruleDao().insertRuleParam(dbSession, ruleDto, minParam); RuleParamDto maxParam = new RuleParamDto() .setName("max") .setType("STRING"); - db.ruleDao().addRuleParam(dbSession, ruleDto, maxParam); + db.ruleDao().insertRuleParam(dbSession, ruleDto, maxParam); ActiveRuleDto activeRule = ActiveRuleDto.createFor(profileDto, ruleDto) .setInheritance(ActiveRule.Inheritance.INHERITED.name()) @@ -176,17 +176,17 @@ public class ActiveRuleBackendMediumTest { ActiveRuleParamDto activeRuleMinParam = ActiveRuleParamDto.createFor(minParam) .setValue("minimum"); - db.activeRuleDao().addParam(dbSession, activeRule, activeRuleMinParam); + db.activeRuleDao().insertParam(dbSession, activeRule, activeRuleMinParam); ActiveRuleParamDto activeRuleMaxParam = ActiveRuleParamDto.createFor(maxParam) .setValue("maximum"); - db.activeRuleDao().addParam(dbSession, activeRule, activeRuleMaxParam); + db.activeRuleDao().insertParam(dbSession, activeRule, activeRuleMaxParam); dbSession.commit(); // verify db List<ActiveRuleParamDto> persistedDtos = - db.activeRuleDao().findParamsByActiveRuleKey(dbSession, activeRule.getKey()); + db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRule.getKey()); assertThat(persistedDtos).hasSize(2); // verify es @@ -222,8 +222,8 @@ public class ActiveRuleBackendMediumTest { // in db dbSession.clearCache(); - assertThat(db.activeRuleDao().findByRule(dbSession, rule1)).hasSize(1); - assertThat(db.activeRuleDao().findByRule(dbSession, rule2)).hasSize(2); + assertThat(db.activeRuleDao().selectByRule(dbSession, rule1)).hasSize(1); + assertThat(db.activeRuleDao().selectByRule(dbSession, rule2)).hasSize(2); // in es List<ActiveRule> activeRules = index.get(ActiveRuleIndex.class).findByRule(RuleTesting.XOO_X1); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java index 7dd91786d01..48913ec4dfa 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java @@ -68,7 +68,7 @@ public class QProfileBackuperMediumTest { RuleDto xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR").setLanguage("xoo"); RuleDto xooRule2 = RuleTesting.newXooX2().setSeverity("MAJOR").setLanguage("xoo"); db.ruleDao().insert(dbSession, xooRule1, xooRule2); - db.ruleDao().addRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) + db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) .setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type())); dbSession.commit(); dbSession.clearCache(); @@ -128,7 +128,7 @@ public class QProfileBackuperMediumTest { Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore.xml"), StandardCharsets.UTF_8)), null); - QualityProfileDto profile = db.qualityProfileDao().getByNameAndLanguage("P1", "xoo", dbSession); + QualityProfileDto profile = db.qualityProfileDao().selectByNameAndLanguage("P1", "xoo", dbSession); assertThat(profile).isNotNull(); List<ActiveRule> activeRules = Lists.newArrayList(tester.get(QProfileLoader.class).findActiveRulesByProfile(profile.getKey())); @@ -303,7 +303,7 @@ public class QProfileBackuperMediumTest { List<ActiveRule> activeRules = Lists.newArrayList(tester.get(QProfileLoader.class).findActiveRulesByProfile(QProfileTesting.XOO_P1_KEY)); assertThat(activeRules).hasSize(0); - QualityProfileDto target = db.qualityProfileDao().getByNameAndLanguage("P3", "xoo", dbSession); + QualityProfileDto target = db.qualityProfileDao().selectByNameAndLanguage("P3", "xoo", dbSession); assertThat(target).isNotNull(); activeRules = Lists.newArrayList(tester.get(QProfileLoader.class).findActiveRulesByProfile(target.getKey())); assertThat(activeRules).hasSize(1); @@ -316,8 +316,8 @@ public class QProfileBackuperMediumTest { null); dbSession.clearCache(); - assertThat(db.activeRuleDao().findAll(dbSession)).hasSize(0); - List<QualityProfileDto> profiles = db.qualityProfileDao().findAll(dbSession); + assertThat(db.activeRuleDao().selectAll(dbSession)).hasSize(0); + List<QualityProfileDto> profiles = db.qualityProfileDao().selectAll(dbSession); assertThat(profiles).hasSize(1); assertThat(profiles.get(0).getName()).isEqualTo("P1"); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java index 0662f249453..4db018b3a9a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java @@ -71,9 +71,9 @@ public class QProfileComparisonMediumTest { xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR"); xooRule2 = RuleTesting.newXooX2().setSeverity("MAJOR"); db.ruleDao().insert(dbSession, xooRule1, xooRule2); - db.ruleDao().addRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) + db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) .setName("max").setType(RuleParamType.INTEGER.type())); - db.ruleDao().addRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) + db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) .setName("min").setType(RuleParamType.INTEGER.type())); left = QProfileTesting.newXooP1(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java index f44231a963d..d503d38166f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java @@ -71,7 +71,7 @@ public class QProfileCopierMediumTest { RuleDto xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR"); RuleDto xooRule2 = RuleTesting.newXooX2().setSeverity("MAJOR"); db.ruleDao().insert(dbSession, xooRule1, xooRule2); - db.ruleDao().addRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) + db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) .setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type())); // create pre-defined profile @@ -146,7 +146,7 @@ public class QProfileCopierMediumTest { copier.copyToName(QProfileTesting.XOO_P1_KEY, QProfileTesting.XOO_P2_NAME.getName()); verifyOneActiveRule(QProfileTesting.XOO_P2_KEY, Severity.BLOCKER, ActiveRuleDto.INHERITED, ImmutableMap.of("max", "7")); - QualityProfileDto profile2Dto = db.qualityProfileDao().getByKey(dbSession, QProfileTesting.XOO_P2_KEY); + QualityProfileDto profile2Dto = db.qualityProfileDao().selectByKey(dbSession, QProfileTesting.XOO_P2_KEY); assertThat(profile2Dto.getParentKee()).isEqualTo(QProfileTesting.XOO_P1_KEY); } @@ -169,7 +169,7 @@ public class QProfileCopierMediumTest { private void verifyOneActiveRule(QProfileName profileName, String expectedSeverity, @Nullable String expectedInheritance, Map<String, String> expectedParams) { - QualityProfileDto dto = db.qualityProfileDao().getByNameAndLanguage(profileName.getName(), profileName.getLanguage(), dbSession); + QualityProfileDto dto = db.qualityProfileDao().selectByNameAndLanguage(profileName.getName(), profileName.getLanguage(), dbSession); verifyOneActiveRule(dto.getKey(), expectedSeverity, expectedInheritance, expectedParams); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java index fb36be893ea..d4f83316a34 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java @@ -83,14 +83,14 @@ public class QProfileFactoryMediumTest { assertThat(dto.getId()).isNotNull(); // reload the dto - dto = db.qualityProfileDao().getByNameAndLanguage("P1", "xoo", dbSession); + dto = db.qualityProfileDao().selectByNameAndLanguage("P1", "xoo", dbSession); assertThat(dto.getLanguage()).isEqualTo("xoo"); assertThat(dto.getName()).isEqualTo("P1"); assertThat(dto.getKey()).startsWith("xoo-p1"); assertThat(dto.getId()).isNotNull(); assertThat(dto.getParentKee()).isNull(); - assertThat(db.qualityProfileDao().findAll(dbSession)).hasSize(1); + assertThat(db.qualityProfileDao().selectAll(dbSession)).hasSize(1); } @Test @@ -138,7 +138,7 @@ public class QProfileFactoryMediumTest { assertThat(factory.rename(key, "the new name")).isTrue(); dbSession.clearCache(); - QualityProfileDto reloaded = db.qualityProfileDao().getByKey(dbSession, dto.getKee()); + QualityProfileDto reloaded = db.qualityProfileDao().selectByKey(dbSession, dto.getKee()); assertThat(reloaded.getKey()).isEqualTo(key); assertThat(reloaded.getName()).isEqualTo("the new name"); } @@ -153,7 +153,7 @@ public class QProfileFactoryMediumTest { assertThat(factory.rename(key, "P1")).isFalse(); dbSession.clearCache(); - QualityProfileDto reloaded = db.qualityProfileDao().getByKey(dbSession, dto.getKee()); + QualityProfileDto reloaded = db.qualityProfileDao().selectByKey(dbSession, dto.getKee()); assertThat(reloaded.getKey()).isEqualTo(key); assertThat(reloaded.getName()).isEqualTo("P1"); } @@ -209,9 +209,9 @@ public class QProfileFactoryMediumTest { factory.delete(XOO_P1_KEY); dbSession.clearCache(); - assertThat(db.qualityProfileDao().findAll(dbSession)).isEmpty(); - assertThat(db.activeRuleDao().findAll(dbSession)).isEmpty(); - assertThat(db.activeRuleDao().findAllParams(dbSession)).isEmpty(); + assertThat(db.qualityProfileDao().selectAll(dbSession)).isEmpty(); + assertThat(db.activeRuleDao().selectAll(dbSession)).isEmpty(); + assertThat(db.activeRuleDao().selectAllParams(dbSession)).isEmpty(); assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P1_KEY)).isEmpty(); } @@ -226,15 +226,15 @@ public class QProfileFactoryMediumTest { tester.get(RuleActivator.class).activate(dbSession, new RuleActivation(RuleTesting.XOO_X1), XOO_P1_KEY); dbSession.commit(); dbSession.clearCache(); - assertThat(db.qualityProfileDao().findAll(dbSession)).hasSize(3); - assertThat(db.activeRuleDao().findAll(dbSession)).hasSize(3); + assertThat(db.qualityProfileDao().selectAll(dbSession)).hasSize(3); + assertThat(db.activeRuleDao().selectAll(dbSession)).hasSize(3); factory.delete(XOO_P1_KEY); dbSession.clearCache(); - assertThat(db.qualityProfileDao().findAll(dbSession)).isEmpty(); - assertThat(db.activeRuleDao().findAll(dbSession)).isEmpty(); - assertThat(db.activeRuleDao().findAllParams(dbSession)).isEmpty(); + assertThat(db.qualityProfileDao().selectAll(dbSession)).isEmpty(); + assertThat(db.activeRuleDao().selectAll(dbSession)).isEmpty(); + assertThat(db.activeRuleDao().selectAllParams(dbSession)).isEmpty(); assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P1_KEY)).isEmpty(); assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P2_KEY)).isEmpty(); assertThat(index.get(ActiveRuleIndex.class).findByProfile(XOO_P3_KEY)).isEmpty(); @@ -252,7 +252,7 @@ public class QProfileFactoryMediumTest { fail(); } catch (BadRequestException e) { assertThat(e).hasMessage("The profile marked as default can not be deleted: XOO_P1"); - assertThat(db.qualityProfileDao().findAll(dbSession)).hasSize(1); + assertThat(db.qualityProfileDao().selectAll(dbSession)).hasSize(1); } } @@ -270,7 +270,7 @@ public class QProfileFactoryMediumTest { fail(); } catch (BadRequestException e) { assertThat(e).hasMessage("The profile marked as default can not be deleted: XOO_P3"); - assertThat(db.qualityProfileDao().findAll(dbSession)).hasSize(3); + assertThat(db.qualityProfileDao().selectAll(dbSession)).hasSize(3); } } @@ -290,12 +290,12 @@ public class QProfileFactoryMediumTest { dbSession.commit(); dbSession.clearCache(); - assertThat(db.qualityProfileDao().getByKey(dbSession, XOO_P1_KEY).isDefault()).isFalse(); + assertThat(db.qualityProfileDao().selectByKey(dbSession, XOO_P1_KEY).isDefault()).isFalse(); factory.setDefault(XOO_P1_KEY); dbSession.clearCache(); - assertThat(db.qualityProfileDao().getByKey(dbSession, XOO_P1_KEY).isDefault()).isTrue(); + assertThat(db.qualityProfileDao().selectByKey(dbSession, XOO_P1_KEY).isDefault()).isTrue(); } @Test @@ -352,7 +352,7 @@ public class QProfileFactoryMediumTest { RuleDto xooRule1 = RuleTesting.newXooX1(); RuleDto xooRule2 = RuleTesting.newXooX2(); db.ruleDao().insert(dbSession, xooRule1, xooRule2); - db.ruleDao().addRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) + db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) .setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type())); dbSession.commit(); dbSession.clearCache(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java index ed665d97ae7..0fdcec71e60 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java @@ -116,7 +116,7 @@ public class QProfileResetMediumTest { ); RuleKey ruleKey = RuleKey.of("xoo", "x1"); - QualityProfileDto profile = tester.get(QualityProfileDao.class).getByNameAndLanguage("Basic", ServerTester.Xoo.KEY, dbSession); + QualityProfileDto profile = tester.get(QualityProfileDao.class).selectByNameAndLanguage("Basic", ServerTester.Xoo.KEY, dbSession); ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), ruleKey); // Change the severity and the value of the parameter in the active rule @@ -158,7 +158,7 @@ public class QProfileResetMediumTest { .setDescription("Accept whitespaces on the line"); }}, defProfile); - QualityProfileDto profile = tester.get(QualityProfileDao.class).getByNameAndLanguage("Basic", ServerTester.Xoo.KEY, dbSession); + QualityProfileDto profile = tester.get(QualityProfileDao.class).selectByNameAndLanguage("Basic", ServerTester.Xoo.KEY, dbSession); ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), RuleKey.of("xoo", "x1")); // Change param in the rule def diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java index f9700408c99..b032762553c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java @@ -72,13 +72,13 @@ public class RegisterQualityProfilesMediumTest { // Check Profile in DB QualityProfileDao qualityProfileDao = dbClient().qualityProfileDao(); - assertThat(qualityProfileDao.findAll(dbSession)).hasSize(1); - QualityProfileDto profile = qualityProfileDao.getByNameAndLanguage("Basic", "xoo", dbSession); + assertThat(qualityProfileDao.selectAll(dbSession)).hasSize(1); + QualityProfileDto profile = qualityProfileDao.selectByNameAndLanguage("Basic", "xoo", dbSession); assertThat(profile).isNotNull(); // Check ActiveRules in DB ActiveRuleDao activeRuleDao = dbClient().activeRuleDao(); - assertThat(activeRuleDao.findByProfileKey(dbSession, profile.getKey())).hasSize(2); + assertThat(activeRuleDao.selectByProfileKey(dbSession, profile.getKey())).hasSize(2); RuleKey ruleKey = RuleKey.of("xoo", "x1"); ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), ruleKey); @@ -98,7 +98,7 @@ public class RegisterQualityProfilesMediumTest { // TODO // Check ActiveRuleParameters in DB Map<String, ActiveRuleParamDto> params = - ActiveRuleParamDto.groupByKey(activeRuleDao.findParamsByActiveRuleKey(dbSession, activeRule.key())); + ActiveRuleParamDto.groupByKey(activeRuleDao.selectParamsByActiveRuleKey(dbSession, activeRule.key())); assertThat(params).hasSize(2); // set by profile assertThat(params.get("acceptWhitespace").getValue()).isEqualTo("true"); @@ -115,8 +115,8 @@ public class RegisterQualityProfilesMediumTest { // Check Profile in DB QualityProfileDao qualityProfileDao = dbClient().qualityProfileDao(); - assertThat(qualityProfileDao.findAll(dbSession)).hasSize(1); - QualityProfileDto profile = qualityProfileDao.getByNameAndLanguage("Basic", "xoo", dbSession); + assertThat(qualityProfileDao.selectAll(dbSession)).hasSize(1); + QualityProfileDto profile = qualityProfileDao.selectByNameAndLanguage("Basic", "xoo", dbSession); assertThat(profile).isNotNull(); // Check Default Profile @@ -124,7 +124,7 @@ public class RegisterQualityProfilesMediumTest { // Check ActiveRules in DB ActiveRuleDao activeRuleDao = dbClient().activeRuleDao(); - assertThat(activeRuleDao.findByProfileKey(dbSession, profile.getKey())).hasSize(2); + assertThat(activeRuleDao.selectByProfileKey(dbSession, profile.getKey())).hasSize(2); RuleKey ruleKey = RuleKey.of("xoo", "x1"); ActiveRuleDto activeRule = activeRuleDao.getNullableByKey(dbSession, ActiveRuleKey.of(profile.getKey(), ruleKey)); @@ -134,7 +134,7 @@ public class RegisterQualityProfilesMediumTest { // Check ActiveRuleParameters in DB Map<String, ActiveRuleParamDto> params = - ActiveRuleParamDto.groupByKey(activeRuleDao.findParamsByActiveRuleKey(dbSession, activeRule.getKey())); + ActiveRuleParamDto.groupByKey(activeRuleDao.selectParamsByActiveRuleKey(dbSession, activeRule.getKey())); assertThat(params).hasSize(2); // set by profile assertThat(params.get("acceptWhitespace").getValue()).isEqualTo("true"); @@ -151,7 +151,7 @@ public class RegisterQualityProfilesMediumTest { // Check Profile in DB QualityProfileDao qualityProfileDao = dbClient().qualityProfileDao(); - assertThat(qualityProfileDao.findAll(dbSession)).hasSize(0); + assertThat(qualityProfileDao.selectAll(dbSession)).hasSize(0); } @Test @@ -188,7 +188,7 @@ public class RegisterQualityProfilesMediumTest { QualityProfileDao profileDao = dbClient().qualityProfileDao(); DbSession session = dbClient().openSession(false); - QualityProfileDto profileTwo = profileDao.getByNameAndLanguage("two", "xoo", session); + QualityProfileDto profileTwo = profileDao.selectByNameAndLanguage("two", "xoo", session); tester.get(QProfileFactory.class).setDefault(session, profileTwo.getKee()); session.commit(); @@ -220,7 +220,7 @@ public class RegisterQualityProfilesMediumTest { } private void verifyDefaultProfile(String language, String name) { - QualityProfileDto defaultProfile = dbClient().qualityProfileDao().getDefaultProfile(language); + QualityProfileDto defaultProfile = dbClient().qualityProfileDao().selectDefaultProfile(language); assertThat(defaultProfile).isNotNull(); assertThat(defaultProfile.getName()).isEqualTo(name); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java index 5b2d52de134..d11edaedcf2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java @@ -94,17 +94,17 @@ public class RuleActivatorMediumTest { .setSeverity("MINOR").setLanguage("xoo"); RuleDto manualRule = RuleTesting.newDto(MANUAL_RULE_KEY); db.ruleDao().insert(dbSession, javaRule, xooRule1, xooRule2, xooTemplateRule1, manualRule); - db.ruleDao().addRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) + db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) .setName("max").setDefaultValue("10").setType(RuleParamType.INTEGER.type())); - db.ruleDao().addRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) + db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) .setName("min").setType(RuleParamType.INTEGER.type())); - db.ruleDao().addRuleParam(dbSession, xooTemplateRule1, RuleParamDto.createFor(xooTemplateRule1) + db.ruleDao().insertRuleParam(dbSession, xooTemplateRule1, RuleParamDto.createFor(xooTemplateRule1) .setName("format").setType(RuleParamType.STRING.type())); RuleDto xooCustomRule1 = RuleTesting.newCustomRule(xooTemplateRule1).setRuleKey(CUSTOM_RULE_KEY.rule()) .setSeverity("MINOR").setLanguage("xoo"); db.ruleDao().insert(dbSession, xooCustomRule1); - db.ruleDao().addRuleParam(dbSession, xooCustomRule1, RuleParamDto.createFor(xooTemplateRule1) + db.ruleDao().insertRuleParam(dbSession, xooCustomRule1, RuleParamDto.createFor(xooTemplateRule1) .setName("format").setDefaultValue("txt").setType(RuleParamType.STRING.type())); // create pre-defined profile P1 @@ -264,10 +264,10 @@ public class RuleActivatorMediumTest { activation.setSeverity(Severity.BLOCKER); activate(activation, XOO_P1_KEY); - assertThat(db.activeRuleDao().getParamByKeyAndName(activeRuleKey, "max", dbSession)).isNotNull(); - db.activeRuleDao().removeParamByKeyAndName(dbSession, activeRuleKey, "max"); + assertThat(db.activeRuleDao().selectParamByKeyAndName(activeRuleKey, "max", dbSession)).isNotNull(); + db.activeRuleDao().deleteParamByKeyAndName(dbSession, activeRuleKey, "max"); dbSession.commit(); - assertThat(db.activeRuleDao().getParamByKeyAndName(activeRuleKey, "max", dbSession)).isNull(); + assertThat(db.activeRuleDao().selectParamByKeyAndName(activeRuleKey, "max", dbSession)).isNull(); dbSession.clearCache(); // update @@ -853,7 +853,7 @@ public class RuleActivatorMediumTest { // 2. assert that all activation has been commit to DB and ES dbSession.clearCache(); - assertThat(db.activeRuleDao().findByProfileKey(dbSession, XOO_P1_KEY)).hasSize(bulkSize); + assertThat(db.activeRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).hasSize(bulkSize); assertThat(index.findByProfile(XOO_P1_KEY)).hasSize(bulkSize); assertThat(result.countSucceeded()).isEqualTo(bulkSize); assertThat(result.countFailed()).isEqualTo(0); @@ -867,7 +867,7 @@ public class RuleActivatorMediumTest { // 2. assert that all activations have been commit to DB and ES // -> xoo rules x1, x2 and custom1 dbSession.clearCache(); - assertThat(db.activeRuleDao().findByProfileKey(dbSession, XOO_P1_KEY)).hasSize(3); + assertThat(db.activeRuleDao().selectByProfileKey(dbSession, XOO_P1_KEY)).hasSize(3); assertThat(index.findByProfile(XOO_P1_KEY)).hasSize(3); assertThat(result.countSucceeded()).isEqualTo(3); assertThat(result.countFailed()).isGreaterThan(0); @@ -891,7 +891,7 @@ public class RuleActivatorMediumTest { // set parent -> child profile inherits rule x1 and still has x2 ruleActivator.setParent(XOO_P2_KEY, XOO_P1_KEY); dbSession.clearCache(); - assertThat(db.qualityProfileDao().getByKey(dbSession, XOO_P2_KEY).getParentKee()).isEqualTo(XOO_P1_KEY); + assertThat(db.qualityProfileDao().selectByKey(dbSession, XOO_P2_KEY).getParentKee()).isEqualTo(XOO_P1_KEY); verifyHasActiveRule(ActiveRuleKey.of(XOO_P2_KEY, RuleTesting.XOO_X1), Severity.MAJOR, ActiveRuleDto.INHERITED, ImmutableMap.of("max", "10")); verifyHasActiveRule(ActiveRuleKey.of(XOO_P2_KEY, RuleTesting.XOO_X2), Severity.MAJOR, null, Collections.<String, String>emptyMap()); @@ -899,7 +899,7 @@ public class RuleActivatorMediumTest { dbSession.clearCache(); ruleActivator.setParent(XOO_P2_KEY, null); assertThat(countActiveRules(XOO_P2_KEY)).isEqualTo(1); - assertThat(db.qualityProfileDao().getByKey(dbSession, XOO_P2_KEY).getParentKee()).isNull(); + assertThat(db.qualityProfileDao().selectByKey(dbSession, XOO_P2_KEY).getParentKee()).isNull(); verifyHasActiveRule(ActiveRuleKey.of(XOO_P2_KEY, RuleTesting.XOO_X2), Severity.MAJOR, null, Collections.<String, String>emptyMap()); } @@ -907,7 +907,7 @@ public class RuleActivatorMediumTest { public void unset_no_parent_does_not_fail() { // P1 has no parent ! ruleActivator.setParent(XOO_P1_KEY, null); - assertThat(db.qualityProfileDao().getByKey(dbSession, XOO_P1_KEY).getParentKee()).isNull(); + assertThat(db.qualityProfileDao().selectByKey(dbSession, XOO_P1_KEY).getParentKee()).isNull(); } @Test @@ -948,7 +948,7 @@ public class RuleActivatorMediumTest { // unset parent -> keep x1 ruleActivator.setParent(XOO_P2_KEY, null); dbSession.clearCache(); - assertThat(db.qualityProfileDao().getByKey(dbSession, XOO_P2_KEY).getParentKee()).isNull(); + assertThat(db.qualityProfileDao().selectByKey(dbSession, XOO_P2_KEY).getParentKee()).isNull(); verifyOneActiveRule(XOO_P2_KEY, RuleTesting.XOO_X1, Severity.BLOCKER, null, ImmutableMap.of("max", "333")); } @@ -974,7 +974,7 @@ public class RuleActivatorMediumTest { ruleActivator.setParent(XOO_P2_KEY, XOO_P1_KEY); dbSession.clearCache(); - assertThat(db.qualityProfileDao().getByKey(dbSession, XOO_P2_KEY).getParentKee()).isEqualTo(XOO_P1_KEY); + assertThat(db.qualityProfileDao().selectByKey(dbSession, XOO_P2_KEY).getParentKee()).isEqualTo(XOO_P1_KEY); assertThat(countActiveRules(XOO_P2_KEY)).isEqualTo(1); verifyHasActiveRule(ActiveRuleKey.of(XOO_P2_KEY, RuleTesting.XOO_X2), Severity.MAJOR, ActiveRuleDto.INHERITED, Collections.<String, String>emptyMap()); } @@ -1035,7 +1035,7 @@ public class RuleActivatorMediumTest { } private int countActiveRules(String profileKey) { - List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().findByProfileKey(dbSession, profileKey); + List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().selectByProfileKey(dbSession, profileKey); List<ActiveRule> activeRules = Lists.newArrayList(index.findByProfile(profileKey)); assertThat(activeRuleDtos.size()).as("Not same active rules between db and index").isEqualTo(activeRules.size()); return activeRuleDtos.size(); @@ -1056,7 +1056,7 @@ public class RuleActivatorMediumTest { @Nullable String expectedInheritance, Map<String, String> expectedParams) { // verify db boolean found = false; - List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().findByProfileKey(dbSession, activeRuleKey.qProfile()); + List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().selectByProfileKey(dbSession, activeRuleKey.qProfile()); for (ActiveRuleDto activeRuleDto : activeRuleDtos) { if (activeRuleDto.getKey().equals(activeRuleKey)) { found = true; @@ -1066,10 +1066,10 @@ public class RuleActivatorMediumTest { assertThat(activeRuleDto.getCreatedAt()).isNotNull(); assertThat(activeRuleDto.getUpdatedAt()).isNotNull(); - List<ActiveRuleParamDto> paramDtos = db.activeRuleDao().findParamsByActiveRuleKey(dbSession, activeRuleDto.getKey()); + List<ActiveRuleParamDto> paramDtos = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey()); assertThat(paramDtos).hasSize(expectedParams.size()); for (Map.Entry<String, String> entry : expectedParams.entrySet()) { - ActiveRuleParamDto paramDto = db.activeRuleDao().getParamByKeyAndName(activeRuleDto.getKey(), entry.getKey(), dbSession); + ActiveRuleParamDto paramDto = db.activeRuleDao().selectParamByKeyAndName(activeRuleDto.getKey(), entry.getKey(), dbSession); assertThat(paramDto).isNotNull(); assertThat(paramDto.getValue()).isEqualTo(entry.getValue()); } @@ -1117,7 +1117,7 @@ public class RuleActivatorMediumTest { private void verifyZeroActiveRules(String key) { // verify db dbSession.clearCache(); - List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().findByProfileKey(dbSession, key); + List<ActiveRuleDto> activeRuleDtos = db.activeRuleDao().selectByProfileKey(dbSession, key); assertThat(activeRuleDtos).isEmpty(); // verify es diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java index 6b3bf179238..221738cd538 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java @@ -82,7 +82,7 @@ public class ChangeParentActionMediumTest { createActiveRule(rule1, parent1); session.commit(); - assertThat(db.activeRuleDao().findByProfileKey(session, child.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty(); // Set parent wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent") @@ -92,7 +92,7 @@ public class ChangeParentActionMediumTest { session.clearCache(); // Check rule 1 enabled - List<ActiveRuleDto> activeRules1 = db.activeRuleDao().findByProfileKey(session, child.getKey()); + List<ActiveRuleDto> activeRules1 = db.activeRuleDao().selectByProfileKey(session, child.getKey()); assertThat(activeRules1).hasSize(1); assertThat(activeRules1.get(0).getKey().ruleKey().rule()).isEqualTo("rule1"); } @@ -121,7 +121,7 @@ public class ChangeParentActionMediumTest { session.clearCache(); // Check rule 2 enabled - List<ActiveRuleDto> activeRules2 = db.activeRuleDao().findByProfileKey(session, child.getKey()); + List<ActiveRuleDto> activeRules2 = db.activeRuleDao().selectByProfileKey(session, child.getKey()); assertThat(activeRules2).hasSize(1); assertThat(activeRules2.get(0).getKey().ruleKey().rule()).isEqualTo("rule2"); } @@ -146,7 +146,7 @@ public class ChangeParentActionMediumTest { session.clearCache(); // Check no rule enabled - List<ActiveRuleDto> activeRules = db.activeRuleDao().findByProfileKey(session, child.getKey()); + List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(session, child.getKey()); assertThat(activeRules).isEmpty(); } @@ -162,7 +162,7 @@ public class ChangeParentActionMediumTest { createActiveRule(rule2, parent2); session.commit(); - assertThat(db.activeRuleDao().findByProfileKey(session, child.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty(); // 1. Set parent 1 wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent") @@ -173,7 +173,7 @@ public class ChangeParentActionMediumTest { session.clearCache(); // 1. check rule 1 enabled - List<ActiveRuleDto> activeRules1 = db.activeRuleDao().findByProfileKey(session, child.getKey()); + List<ActiveRuleDto> activeRules1 = db.activeRuleDao().selectByProfileKey(session, child.getKey()); assertThat(activeRules1).hasSize(1); assertThat(activeRules1.get(0).getKey().ruleKey().rule()).isEqualTo("rule1"); @@ -186,7 +186,7 @@ public class ChangeParentActionMediumTest { session.clearCache(); // 2. check rule 2 enabled - List<ActiveRuleDto> activeRules2 = db.activeRuleDao().findByProfileKey(session, child.getKey()); + List<ActiveRuleDto> activeRules2 = db.activeRuleDao().selectByProfileKey(session, child.getKey()); assertThat(activeRules2).hasSize(1); assertThat(activeRules2.get(0).getKey().ruleKey().rule()).isEqualTo("rule2"); @@ -199,7 +199,7 @@ public class ChangeParentActionMediumTest { session.clearCache(); // 3. check no rule enabled - List<ActiveRuleDto> activeRules = db.activeRuleDao().findByProfileKey(session, child.getKey()); + List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(session, child.getKey()); assertThat(activeRules).isEmpty(); } @@ -212,7 +212,7 @@ public class ChangeParentActionMediumTest { createActiveRule(rule1, parent); session.commit(); - assertThat(db.activeRuleDao().findByProfileKey(session, child.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty(); // Set parent tester.get(RuleActivator.class).setParent(child.getKey(), parent.getKey()); @@ -226,7 +226,7 @@ public class ChangeParentActionMediumTest { session.clearCache(); // Check no rule enabled - List<ActiveRuleDto> activeRules = db.activeRuleDao().findByProfileKey(session, child.getKey()); + List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(session, child.getKey()); assertThat(activeRules).isEmpty(); } @@ -235,7 +235,7 @@ public class ChangeParentActionMediumTest { QualityProfileDto child = createProfile("xoo", "Child"); session.commit(); - assertThat(db.activeRuleDao().findByProfileKey(session, child.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty(); wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent") .setParam(QProfileIdentificationParamUtils.PARAM_PROFILE_KEY, child.getKee()) @@ -249,7 +249,7 @@ public class ChangeParentActionMediumTest { QualityProfileDto child = createProfile("xoo", "Child"); session.commit(); - assertThat(db.activeRuleDao().findByProfileKey(session, child.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty(); wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent") .setParam(QProfileIdentificationParamUtils.PARAM_PROFILE_KEY, child.getKee()) diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java index b4e189c2a71..bd2e631a4f5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java @@ -202,14 +202,14 @@ public class CompareActionMediumTest { .setStatus(RuleStatus.READY); db.ruleDao().insert(session, rule); RuleParamDto param = RuleParamDto.createFor(rule).setName("param_" + id).setType(RuleParamType.STRING.toString()); - db.ruleDao().addRuleParam(session, rule, param); + db.ruleDao().insertRuleParam(session, rule, param); return rule; } private RuleDto createRuleWithParam(String lang, String id) { RuleDto rule = createRule(lang, id); RuleParamDto param = RuleParamDto.createFor(rule).setName("param_" + id).setType(RuleParamType.STRING.toString()); - db.ruleDao().addRuleParam(session, rule, param); + db.ruleDao().insertRuleParam(session, rule, param); return rule; } @@ -222,9 +222,9 @@ public class CompareActionMediumTest { private ActiveRuleDto createActiveRuleWithParam(RuleDto rule, QualityProfileDto profile, String value) { ActiveRuleDto activeRule = createActiveRule(rule, profile); - RuleParamDto paramDto = db.ruleDao().findRuleParamsByRuleKey(session, rule.getKey()).get(0); + RuleParamDto paramDto = db.ruleDao().selectRuleParamsByRuleKey(session, rule.getKey()).get(0); ActiveRuleParamDto activeRuleParam = ActiveRuleParamDto.createFor(paramDto).setValue(value); - db.activeRuleDao().addParam(session, activeRule, activeRuleParam); + db.activeRuleDao().insertParam(session, activeRule, activeRuleParam); return activeRule; } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java index 5e48fd13e44..819ef227e32 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java @@ -107,7 +107,7 @@ public class DeleteActionTest { tester.newPostRequest("api/qualityprofiles", "delete").setParam("profileKey", "sonar-way-xoo1-12345").execute().assertNoContent(); - assertThat(qualityProfileDao.getByKey(session, "sonar-way-xoo1-12345")).isNull(); + assertThat(qualityProfileDao.selectByKey(session, "sonar-way-xoo1-12345")).isNull(); assertThat(qualityProfileDao.selectProjects("Sonar way", xoo1.getName())).isEmpty(); } @@ -125,7 +125,7 @@ public class DeleteActionTest { tester.newPostRequest("api/qualityprofiles", "delete").setParam("profileName", "Sonar way").setParam("language", xoo1.getKey()).execute().assertNoContent(); - assertThat(qualityProfileDao.getByKey(session, "sonar-way-xoo1-12345")).isNull(); + assertThat(qualityProfileDao.selectByKey(session, "sonar-way-xoo1-12345")).isNull(); assertThat(qualityProfileDao.selectProjects("Sonar way", xoo1.getName())).isEmpty(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java index 5c9810631ba..1185ca1296c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java @@ -89,7 +89,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(1); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1); // 1. Deactivate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.DEACTIVATE_ACTION); @@ -99,7 +99,7 @@ public class QProfilesWsMediumTest { session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); } @Test @@ -116,7 +116,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(4); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4); // 1. Deactivate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_DEACTIVATE_ACTION); @@ -125,7 +125,7 @@ public class QProfilesWsMediumTest { session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); } @Test @@ -141,7 +141,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(2); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2); // 1. Deactivate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_DEACTIVATE_ACTION); @@ -150,8 +150,8 @@ public class QProfilesWsMediumTest { session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(0); - assertThat(db.activeRuleDao().findByProfileKey(session, php.getKey())).hasSize(2); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0); + assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2); } @Test @@ -164,7 +164,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(2); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2); // 1. Deactivate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_DEACTIVATE_ACTION); @@ -174,7 +174,7 @@ public class QProfilesWsMediumTest { session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(1); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1); } @Test @@ -184,7 +184,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); // 1. Activate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.ACTIVATE_ACTION); @@ -194,7 +194,7 @@ public class QProfilesWsMediumTest { session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(1); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1); } @Test @@ -204,7 +204,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); try { // 1. Activate Rule @@ -226,7 +226,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); // 1. Activate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, RuleActivationActions.ACTIVATE_ACTION); @@ -253,7 +253,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); // 1. Activate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION); @@ -263,7 +263,7 @@ public class QProfilesWsMediumTest { session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(4); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4); } @Test @@ -277,7 +277,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, php.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).isEmpty(); // 1. Activate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION); @@ -287,7 +287,7 @@ public class QProfilesWsMediumTest { session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().findByProfileKey(session, php.getKey())).hasSize(2); + assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2); } @Test @@ -300,7 +300,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); // 1. Activate Rule with query returning 0 hits WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION); @@ -310,7 +310,7 @@ public class QProfilesWsMediumTest { session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(0); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0); // 1. Activate Rule with query returning 1 hits request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION); @@ -320,7 +320,7 @@ public class QProfilesWsMediumTest { session.commit(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(1); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1); } @Test @@ -331,8 +331,8 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).isEmpty(); - assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(0); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0); // 2. Assert ActiveRule with BLOCKER severity assertThat(tester.get(RuleIndex.class).search( diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java index fe7caf986d8..3637e6acec6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java @@ -88,7 +88,7 @@ public class RenameActionTest { .setParam("name", "Other Sonar Way") .execute().assertNoContent(); - assertThat(qualityProfileDao.getNonNullByKey(session, "sonar-way-xoo2-23456").getName()).isEqualTo("Other Sonar Way"); + assertThat(qualityProfileDao.selectOrFailByKey(session, "sonar-way-xoo2-23456").getName()).isEqualTo("Other Sonar Way"); } @Test(expected = BadRequestException.class) diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java index c7f1ffd5317..e3562d129e7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java @@ -94,8 +94,8 @@ public class SetDefaultActionTest { checkDefaultProfile(xoo1Key, "sonar-way-xoo1-12345"); checkDefaultProfile(xoo2Key, "sonar-way-xoo2-23456"); - assertThat(dbClient.qualityProfileDao().getByKey(session, "sonar-way-xoo2-23456").isDefault()).isTrue(); - assertThat(dbClient.qualityProfileDao().getByKey(session, "my-sonar-way-xoo2-34567").isDefault()).isFalse(); + assertThat(dbClient.qualityProfileDao().selectByKey(session, "sonar-way-xoo2-23456").isDefault()).isTrue(); + assertThat(dbClient.qualityProfileDao().selectByKey(session, "my-sonar-way-xoo2-34567").isDefault()).isFalse(); // One more time! tester.newPostRequest("api/qualityprofiles", "set_default").setParam("profileKey", "sonar-way-xoo2-23456").execute().assertNoContent(); @@ -165,6 +165,6 @@ public class SetDefaultActionTest { } private void checkDefaultProfile(String language, String key) { - assertThat(dbClient.qualityProfileDao().getDefaultProfile(language).getKey()).isEqualTo(key); + assertThat(dbClient.qualityProfileDao().selectDefaultProfile(language).getKey()).isEqualTo(key); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java index 796f154de7c..acf991bb941 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java @@ -129,10 +129,10 @@ public class RegisterRulesMediumTest { }); // verify db : rule x1 + 6 common rules - List<RuleDto> rules = db.ruleDao().findAll(dbSession); + List<RuleDto> rules = db.ruleDao().selectAll(dbSession); assertThat(rules).hasSize(7); assertThat(rules).extracting("key").contains(X1_KEY); - List<RuleParamDto> ruleParams = db.ruleDao().findRuleParamsByRuleKey(dbSession, X1_KEY); + List<RuleParamDto> ruleParams = db.ruleDao().selectRuleParamsByRuleKey(dbSession, X1_KEY); assertThat(ruleParams).hasSize(2); // verify es : rule x1 + 6 common rules diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java index a039d7e78a6..373e0eca5e2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java @@ -79,7 +79,7 @@ public class RegisterRulesTest { execute(new FakeRepositoryV1()); // verify db - assertThat(dbClient.ruleDao().findAll(dbTester.getSession())).hasSize(2); + assertThat(dbClient.ruleDao().selectAll(dbTester.getSession())).hasSize(2); RuleKey ruleKey1 = RuleKey.of("fake", "rule1"); RuleDto rule1 = dbClient.ruleDao().getNullableByKey(dbTester.getSession(), ruleKey1); assertThat(rule1.getName()).isEqualTo("One"); @@ -93,7 +93,7 @@ public class RegisterRulesTest { assertThat(rule1.getUpdatedAt()).isEqualTo(DATE1); // TODO check characteristic and remediation function - List<RuleParamDto> params = dbClient.ruleDao().findRuleParamsByRuleKey(dbTester.getSession(), ruleKey1); + List<RuleParamDto> params = dbClient.ruleDao().selectRuleParamsByRuleKey(dbTester.getSession(), ruleKey1); assertThat(params).hasSize(2); RuleParamDto param = getParam(params, "param1"); assertThat(param.getDescription()).isEqualTo("parameter one"); @@ -103,7 +103,7 @@ public class RegisterRulesTest { @Test public void do_not_update_rules_when_no_changes() { execute(new FakeRepositoryV1()); - assertThat(dbClient.ruleDao().findAll(dbTester.getSession())).hasSize(2); + assertThat(dbClient.ruleDao().selectAll(dbTester.getSession())).hasSize(2); when(system.now()).thenReturn(DATE2.getTime()); execute(new FakeRepositoryV1()); @@ -117,7 +117,7 @@ public class RegisterRulesTest { @Test public void update_and_remove_rules_on_changes() { execute(new FakeRepositoryV1()); - assertThat(dbClient.ruleDao().findAll(dbTester.getSession())).hasSize(2); + assertThat(dbClient.ruleDao().selectAll(dbTester.getSession())).hasSize(2); // user adds tags and sets markdown note RuleKey ruleKey1 = RuleKey.of("fake", "rule1"); @@ -146,7 +146,7 @@ public class RegisterRulesTest { assertThat(rule1.getUpdatedAt()).isEqualTo(DATE2); // TODO check characteristic and remediation function - List<RuleParamDto> params = dbClient.ruleDao().findRuleParamsByRuleKey(dbTester.getSession(), ruleKey1); + List<RuleParamDto> params = dbClient.ruleDao().selectRuleParamsByRuleKey(dbTester.getSession(), ruleKey1); assertThat(params).hasSize(2); RuleParamDto param = getParam(params, "param1"); assertThat(param.getDescription()).isEqualTo("parameter one v2"); @@ -166,7 +166,7 @@ public class RegisterRulesTest { @Test public void do_not_update_already_removed_rules() { execute(new FakeRepositoryV1()); - assertThat(dbClient.ruleDao().findAll(dbTester.getSession())).hasSize(2); + assertThat(dbClient.ruleDao().selectAll(dbTester.getSession())).hasSize(2); RuleDto rule2 = dbClient.ruleDao().getByKey(dbTester.getSession(), RuleKey.of("fake", "rule2")); assertThat(rule2.getStatus()).isEqualTo(RuleStatus.READY); @@ -195,14 +195,14 @@ public class RegisterRulesTest { @Test public void mass_insert() { execute(new BigRepository()); - assertThat(dbClient.ruleDao().findAll(dbTester.getSession())).hasSize(BigRepository.SIZE); - assertThat(dbClient.ruleDao().findAllRuleParams(dbTester.getSession())).hasSize(BigRepository.SIZE * 20); + assertThat(dbClient.ruleDao().selectAll(dbTester.getSession())).hasSize(BigRepository.SIZE); + assertThat(dbClient.ruleDao().selectAllRuleParams(dbTester.getSession())).hasSize(BigRepository.SIZE * 20); } @Test public void manage_repository_extensions() { execute(new FindbugsRepository(), new FbContribRepository()); - List<RuleDto> rules = dbClient.ruleDao().findAll(dbTester.getSession()); + List<RuleDto> rules = dbClient.ruleDao().selectAll(dbTester.getSession()); assertThat(rules).hasSize(2); for (RuleDto rule : rules) { assertThat(rule.getRepositoryKey()).isEqualTo("findbugs"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java index d2e8b506936..20de347d78c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java @@ -159,13 +159,13 @@ public class RuleBackendMediumTest { .setType(RuleParamType.INTEGER.type()) .setDefaultValue("2") .setDescription("Minimum"); - dao.addRuleParam(dbSession, ruleDto, minParamDto); + dao.insertRuleParam(dbSession, ruleDto, minParamDto); RuleParamDto maxParamDto = new RuleParamDto() .setName("max") .setType(RuleParamType.INTEGER.type()) .setDefaultValue("10") .setDescription("Maximum"); - dao.addRuleParam(dbSession, ruleDto, maxParamDto); + dao.insertRuleParam(dbSession, ruleDto, maxParamDto); dbSession.commit(); //Verify that RuleDto has date from insertion @@ -174,7 +174,7 @@ public class RuleBackendMediumTest { assertThat(theRule.getUpdatedAt()).isNotNull(); // verify that parameters are persisted in db - List<RuleParamDto> persistedDtos = dao.findRuleParamsByRuleKey(dbSession, theRule.getKey()); + List<RuleParamDto> persistedDtos = dao.selectRuleParamsByRuleKey(dbSession, theRule.getKey()); assertThat(persistedDtos).hasSize(2); // verify that parameters are indexed in es @@ -202,25 +202,25 @@ public class RuleBackendMediumTest { .setType(RuleParamType.INTEGER.type()) .setDefaultValue("2") .setDescription("Minimum"); - dao.addRuleParam(dbSession, ruleDto, minParamDto); + dao.insertRuleParam(dbSession, ruleDto, minParamDto); RuleParamDto maxParamDto = new RuleParamDto() .setName("max") .setType(RuleParamType.INTEGER.type()) .setDefaultValue("10") .setDescription("Maximum"); - dao.addRuleParam(dbSession, ruleDto, maxParamDto); + dao.insertRuleParam(dbSession, ruleDto, maxParamDto); dbSession.commit(); // 0. Verify that RuleDto has date from insertion - assertThat(dao.findRuleParamsByRuleKey(dbSession, RuleTesting.XOO_X1)).hasSize(2); + assertThat(dao.selectRuleParamsByRuleKey(dbSession, RuleTesting.XOO_X1)).hasSize(2); assertThat(index.getByKey(RuleTesting.XOO_X1).params()).hasSize(2); // 1. Delete parameter - dao.removeRuleParam(dbSession, ruleDto, maxParamDto); + dao.deleteRuleParam(dbSession, ruleDto, maxParamDto); dbSession.commit(); // 2. assert only one param left - assertThat(dao.findRuleParamsByRuleKey(dbSession, RuleTesting.XOO_X1)).hasSize(1); + assertThat(dao.selectRuleParamsByRuleKey(dbSession, RuleTesting.XOO_X1)).hasSize(1); assertThat(index.getByKey(RuleTesting.XOO_X1).params()).hasSize(1); } @@ -266,14 +266,14 @@ public class RuleBackendMediumTest { .setType(RuleParamType.INTEGER.type()) .setDefaultValue("2") .setDescription("Minimum"); - dao.addRuleParam(dbSession, ruleDto, minParamDto); + dao.insertRuleParam(dbSession, ruleDto, minParamDto); RuleParamDto maxParamDto = new RuleParamDto() .setName("max") .setType(RuleParamType.INTEGER.type()) .setDefaultValue("10") .setDescription("Maximum"); - dao.addRuleParam(dbSession, ruleDto, maxParamDto); + dao.insertRuleParam(dbSession, ruleDto, maxParamDto); dbSession.commit(); // verify that parameters are indexed in es @@ -327,12 +327,12 @@ public class RuleBackendMediumTest { public void insert_update_characteristics() { CharacteristicDto char1 = DebtTesting.newCharacteristicDto("c1"); - db.debtCharacteristicDao().insert(char1, dbSession); + db.debtCharacteristicDao().insert(dbSession, char1); dbSession.commit(); CharacteristicDto char11 = DebtTesting.newCharacteristicDto("c11") .setParentId(char1.getId()); - db.debtCharacteristicDao().insert(char11, dbSession); + db.debtCharacteristicDao().insert(dbSession, char11); dao.insert(dbSession, RuleTesting.newXooX1() @@ -359,11 +359,11 @@ public class RuleBackendMediumTest { // 3. set Non-default characteristics RuleDto ruleDto = db.ruleDao().getByKey(dbSession, RuleTesting.XOO_X1); CharacteristicDto char2 = DebtTesting.newCharacteristicDto("c2"); - db.debtCharacteristicDao().insert(char2, dbSession); + db.debtCharacteristicDao().insert(dbSession, char2); CharacteristicDto char21 = DebtTesting.newCharacteristicDto("c21") .setParentId(char2.getId()); - db.debtCharacteristicDao().insert(char21, dbSession); + db.debtCharacteristicDao().insert(dbSession, char21); ruleDto.setSubCharacteristicId(char21.getId()); dao.update(dbSession, ruleDto); @@ -430,7 +430,7 @@ public class RuleBackendMediumTest { dbSession.commit(); // 0. Assert rules are in DB - assertThat(dao.findAll(dbSession)).hasSize(2); + assertThat(dao.selectAll(dbSession)).hasSize(2); // 1. assert getBy for removed assertThat(index.getByKey(RuleTesting.XOO_X2)).isNotNull(); @@ -449,7 +449,7 @@ public class RuleBackendMediumTest { dbSession.commit(); // 0. Assert rules are in DB - assertThat(dao.findAll(dbSession)).hasSize(1); + assertThat(dao.selectAll(dbSession)).hasSize(1); assertThat(index.countAll()).isEqualTo(1); tester.clearIndexes(); @@ -467,11 +467,11 @@ public class RuleBackendMediumTest { // insert db dao.insert(dbSession, rule); - dao.addRuleParam(dbSession, rule, RuleParamDto.createFor(rule).setName("MyParam").setType("STRING").setDefaultValue("test")); + dao.insertRuleParam(dbSession, rule, RuleParamDto.createFor(rule).setName("MyParam").setType("STRING").setDefaultValue("test")); dbSession.commit(); // 0. Assert rules are in DB - assertThat(dao.findAll(dbSession)).hasSize(1); + assertThat(dao.selectAll(dbSession)).hasSize(1); assertThat(index.countAll()).isEqualTo(1); tester.clearIndexes(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java index 19abfcac3d2..5bb4bb50e92 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java @@ -107,7 +107,7 @@ public class RuleCreatorMediumTest { assertThat(rule.getTags()).containsOnly("usertag1", "usertag2"); assertThat(rule.getSystemTags()).containsOnly("tag1", "tag4"); - List<RuleParamDto> params = db.ruleDao().findRuleParamsByRuleKey(dbSession, customRuleKey); + List<RuleParamDto> params = db.ruleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey); assertThat(params).hasSize(1); RuleParamDto param = params.get(0); @@ -134,7 +134,7 @@ public class RuleCreatorMediumTest { RuleKey customRuleKey = creator.create(newRule); dbSession.clearCache(); - List<RuleParamDto> params = db.ruleDao().findRuleParamsByRuleKey(dbSession, customRuleKey); + List<RuleParamDto> params = db.ruleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey); assertThat(params).hasSize(1); RuleParamDto param = params.get(0); @@ -158,7 +158,7 @@ public class RuleCreatorMediumTest { RuleKey customRuleKey = creator.create(newRule); dbSession.clearCache(); - List<RuleParamDto> params = db.ruleDao().findRuleParamsByRuleKey(dbSession, customRuleKey); + List<RuleParamDto> params = db.ruleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey); assertThat(params).hasSize(1); RuleParamDto param = params.get(0); @@ -183,7 +183,7 @@ public class RuleCreatorMediumTest { RuleKey customRuleKey = creator.create(newRule); dbSession.clearCache(); - List<RuleParamDto> params = db.ruleDao().findRuleParamsByRuleKey(dbSession, customRuleKey); + List<RuleParamDto> params = db.ruleDao().selectRuleParamsByRuleKey(dbSession, customRuleKey); assertThat(params).hasSize(1); RuleParamDto param = params.get(0); @@ -253,7 +253,7 @@ public class RuleCreatorMediumTest { .setDescription("Old description") .setDescriptionFormat(Format.MARKDOWN) .setSeverity(Severity.INFO)); - dao.addRuleParam(dbSession, rule, dao.findRuleParamsByRuleKey(dbSession, templateRule.getKey()).get(0).setDefaultValue("a.*")); + dao.insertRuleParam(dbSession, rule, dao.selectRuleParamsByRuleKey(dbSession, templateRule.getKey()).get(0).setDefaultValue("a.*")); dbSession.commit(); dbSession.clearCache(); @@ -296,7 +296,7 @@ public class RuleCreatorMediumTest { .setName("Old name") .setDescription("Old description") .setSeverity(Severity.INFO)); - dao.addRuleParam(dbSession, rule, dao.findRuleParamsByRuleKey(dbSession, templateRule.getKey()).get(0).setDefaultValue("a.*")); + dao.insertRuleParam(dbSession, rule, dao.selectRuleParamsByRuleKey(dbSession, templateRule.getKey()).get(0).setDefaultValue("a.*")); dbSession.commit(); dbSession.clearCache(); @@ -684,7 +684,7 @@ public class RuleCreatorMediumTest { .setSystemTags(Sets.newHashSet("tag1", "tag4")) ); RuleParamDto ruleParamDto = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*"); - dao.addRuleParam(dbSession, templateRule, ruleParamDto); + dao.insertRuleParam(dbSession, templateRule, ruleParamDto); dbSession.commit(); return templateRule; } @@ -703,7 +703,7 @@ public class RuleCreatorMediumTest { ); RuleParamDto ruleParamDto = RuleParamDto.createFor(templateRule) .setName("myIntegers").setType("INTEGER,multiple=true,values=1;2;3").setDescription("My Integers").setDefaultValue("1"); - dao.addRuleParam(dbSession, templateRule, ruleParamDto); + dao.insertRuleParam(dbSession, templateRule, ruleParamDto); dbSession.commit(); return templateRule; } @@ -722,10 +722,10 @@ public class RuleCreatorMediumTest { ); RuleParamDto ruleParam1Dto = RuleParamDto.createFor(templateRule) .setName("first").setType("INTEGER").setDescription("First integer").setDefaultValue("0"); - dao.addRuleParam(dbSession, templateRule, ruleParam1Dto); + dao.insertRuleParam(dbSession, templateRule, ruleParam1Dto); RuleParamDto ruleParam2Dto = RuleParamDto.createFor(templateRule) .setName("second").setType("INTEGER").setDescription("Second integer").setDefaultValue("0"); - dao.addRuleParam(dbSession, templateRule, ruleParam2Dto); + dao.insertRuleParam(dbSession, templateRule, ruleParam2Dto); dbSession.commit(); return templateRule; } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java index b20cfe5cdad..5f35a88dd02 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java @@ -89,9 +89,9 @@ public class RuleOperationsTest { when(characteristicDao.selectByKey("COMPILER", session)).thenReturn(subCharacteristic); // Call when reindexing rule in E/S - when(characteristicDao.selectById(2, session)).thenReturn(subCharacteristic); + when(characteristicDao.selectById(session, 2)).thenReturn(subCharacteristic); CharacteristicDto characteristic = new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability").setOrder(2); - when(characteristicDao.selectById(1, session)).thenReturn(characteristic); + when(characteristicDao.selectById(session, 1)).thenReturn(characteristic); operations.updateRule( new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey("COMPILER") @@ -122,9 +122,9 @@ public class RuleOperationsTest { CharacteristicDto subCharacteristic = new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler").setParentId(1); when(characteristicDao.selectByKey("COMPILER", session)).thenReturn(subCharacteristic); - when(characteristicDao.selectById(2, session)).thenReturn(subCharacteristic); + when(characteristicDao.selectById(session, 2)).thenReturn(subCharacteristic); CharacteristicDto characteristic = new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability").setOrder(2); - when(characteristicDao.selectById(1, session)).thenReturn(characteristic); + when(characteristicDao.selectById(session, 1)).thenReturn(characteristic); operations.updateRule( // Same value as default values -> overridden values will be set to null @@ -176,9 +176,9 @@ public class RuleOperationsTest { CharacteristicDto subCharacteristic = new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler").setParentId(1); when(characteristicDao.selectByKey("COMPILER", session)).thenReturn(subCharacteristic); - when(characteristicDao.selectById(2, session)).thenReturn(subCharacteristic); + when(characteristicDao.selectById(session, 2)).thenReturn(subCharacteristic); CharacteristicDto characteristic = new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability").setOrder(2); - when(characteristicDao.selectById(1, session)).thenReturn(characteristic); + when(characteristicDao.selectById(session, 1)).thenReturn(characteristic); operations.updateRule( // Remediation function is not the same as default one -> Overridden value should be set @@ -209,9 +209,9 @@ public class RuleOperationsTest { CharacteristicDto subCharacteristic = new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler").setParentId(1); when(characteristicDao.selectByKey("COMPILER", session)).thenReturn(subCharacteristic); - when(characteristicDao.selectById(2, session)).thenReturn(subCharacteristic); + when(characteristicDao.selectById(session, 2)).thenReturn(subCharacteristic); CharacteristicDto characteristic = new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability").setOrder(2); - when(characteristicDao.selectById(1, session)).thenReturn(characteristic); + when(characteristicDao.selectById(session, 1)).thenReturn(characteristic); operations.updateRule( // Characteristic is the not same as the default one -> Overridden values should be set @@ -267,9 +267,9 @@ public class RuleOperationsTest { CharacteristicDto subCharacteristic = new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler").setParentId(1); when(characteristicDao.selectByKey("COMPILER", session)).thenReturn(subCharacteristic); - when(characteristicDao.selectById(2, session)).thenReturn(subCharacteristic); + when(characteristicDao.selectById(session, 2)).thenReturn(subCharacteristic); CharacteristicDto characteristic = new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability").setOrder(2); - when(characteristicDao.selectById(1, session)).thenReturn(characteristic); + when(characteristicDao.selectById(session, 1)).thenReturn(characteristic); operations.updateRule(new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey("COMPILER"), authorizedUserSession); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java index 7e8de30fc8a..3ab98ee0f4c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterMediumTest.java @@ -405,8 +405,8 @@ public class RuleUpdaterMediumTest { ruleDao.insert(dbSession, templateRule); RuleParamDto templateRuleParam1 = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*"); RuleParamDto templateRuleParam2 = RuleParamDto.createFor(templateRule).setName("format").setType("STRING").setDescription("Format"); - ruleDao.addRuleParam(dbSession, templateRule, templateRuleParam1); - ruleDao.addRuleParam(dbSession, templateRule, templateRuleParam2); + ruleDao.insertRuleParam(dbSession, templateRule, templateRuleParam1); + ruleDao.insertRuleParam(dbSession, templateRule, templateRuleParam2); // Create custom rule RuleDto customRule = RuleTesting.newCustomRule(templateRule) @@ -415,8 +415,8 @@ public class RuleUpdaterMediumTest { .setSeverity(Severity.MINOR) .setStatus(RuleStatus.BETA); ruleDao.insert(dbSession, customRule); - ruleDao.addRuleParam(dbSession, customRule, templateRuleParam1.setDefaultValue("a.*")); - ruleDao.addRuleParam(dbSession, customRule, templateRuleParam2.setDefaultValue(null)); + ruleDao.insertRuleParam(dbSession, customRule, templateRuleParam1.setDefaultValue("a.*")); + ruleDao.insertRuleParam(dbSession, customRule, templateRuleParam2.setDefaultValue(null)); dbSession.commit(); @@ -450,7 +450,7 @@ public class RuleUpdaterMediumTest { RuleDto templateRule = RuleTesting.newTemplateRule(RuleKey.of("java", "S001")); ruleDao.insert(dbSession, templateRule); RuleParamDto templateRuleParam = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex"); - ruleDao.addRuleParam(dbSession, templateRule, templateRuleParam); + ruleDao.insertRuleParam(dbSession, templateRule, templateRuleParam); // Create custom rule RuleDto customRule = RuleTesting.newCustomRule(templateRule) @@ -459,7 +459,7 @@ public class RuleUpdaterMediumTest { .setSeverity(Severity.MINOR) .setStatus(RuleStatus.BETA); ruleDao.insert(dbSession, customRule); - ruleDao.addRuleParam(dbSession, customRule, templateRuleParam); + ruleDao.insertRuleParam(dbSession, customRule, templateRuleParam); dbSession.commit(); @@ -485,18 +485,18 @@ public class RuleUpdaterMediumTest { RuleDto templateRule = RuleTesting.newTemplateRule(RuleKey.of("java", "S001")).setLanguage("xoo"); ruleDao.insert(dbSession, templateRule); RuleParamDto templateRuleParam1 = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*"); - ruleDao.addRuleParam(dbSession, templateRule, templateRuleParam1); + ruleDao.insertRuleParam(dbSession, templateRule, templateRuleParam1); RuleParamDto templateRuleParam2 = RuleParamDto.createFor(templateRule).setName("format").setType("STRING").setDescription("format").setDefaultValue("csv"); - ruleDao.addRuleParam(dbSession, templateRule, templateRuleParam2); + ruleDao.insertRuleParam(dbSession, templateRule, templateRuleParam2); RuleParamDto templateRuleParam3 = RuleParamDto.createFor(templateRule).setName("message").setType("STRING").setDescription("message"); - ruleDao.addRuleParam(dbSession, templateRule, templateRuleParam3); + ruleDao.insertRuleParam(dbSession, templateRule, templateRuleParam3); // Create custom rule RuleDto customRule = RuleTesting.newCustomRule(templateRule).setSeverity(Severity.MAJOR).setLanguage("xoo"); ruleDao.insert(dbSession, customRule); - ruleDao.addRuleParam(dbSession, customRule, templateRuleParam1.setDefaultValue("a.*")); - ruleDao.addRuleParam(dbSession, customRule, templateRuleParam2.setDefaultValue("txt")); - ruleDao.addRuleParam(dbSession, customRule, templateRuleParam3); + ruleDao.insertRuleParam(dbSession, customRule, templateRuleParam1.setDefaultValue("a.*")); + ruleDao.insertRuleParam(dbSession, customRule, templateRuleParam2.setDefaultValue("txt")); + ruleDao.insertRuleParam(dbSession, customRule, templateRuleParam3); // Create a quality profile QualityProfileDto profileDto = QProfileTesting.newXooP1(); @@ -709,16 +709,16 @@ public class RuleUpdaterMediumTest { private void insertDebtCharacteristics(DbSession dbSession) { CharacteristicDto reliability = DebtTesting.newCharacteristicDto("RELIABILITY"); - db.debtCharacteristicDao().insert(reliability, dbSession); + db.debtCharacteristicDao().insert(dbSession, reliability); CharacteristicDto softReliability = DebtTesting.newCharacteristicDto("SOFT_RELIABILITY") .setParentId(reliability.getId()); - db.debtCharacteristicDao().insert(softReliability, dbSession); + db.debtCharacteristicDao().insert(dbSession, softReliability); softReliabilityId = softReliability.getId(); CharacteristicDto hardReliability = DebtTesting.newCharacteristicDto("HARD_RELIABILITY") .setParentId(reliability.getId()); - db.debtCharacteristicDao().insert(hardReliability, dbSession); + db.debtCharacteristicDao().insert(dbSession, hardReliability); hardReliabilityId = hardReliability.getId(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java index be6d3e8d80c..fbf5a7c9e8b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/db/RuleDaoTest.java @@ -52,7 +52,7 @@ public class RuleDaoTest { @Test public void select_all() { dbTester.prepareDbUnit(getClass(), "selectAll.xml"); - List<RuleDto> ruleDtos = dao.findAll(dbTester.getSession()); + List<RuleDto> ruleDtos = dao.selectAll(dbTester.getSession()); assertThat(ruleDtos).hasSize(1); @@ -78,7 +78,7 @@ public class RuleDaoTest { @Test public void select_enables_and_non_manual() { dbTester.prepareDbUnit(getClass(), "select_enables_and_non_manual.xml"); - List<RuleDto> ruleDtos = dao.findByEnabledAndNotManual(dbTester.getSession()); + List<RuleDto> ruleDtos = dao.selectByEnabledAndNotManual(dbTester.getSession()); assertThat(ruleDtos.size()).isEqualTo(1); RuleDto ruleDto = ruleDtos.get(0); @@ -103,7 +103,7 @@ public class RuleDaoTest { @Test public void select_by_id() { dbTester.prepareDbUnit(getClass(), "selectById.xml"); - RuleDto ruleDto = dao.getById(dbTester.getSession(), 2); + RuleDto ruleDto = dao.selectById(dbTester.getSession(), 2); assertThat(ruleDto.getId()).isEqualTo(2); assertThat(ruleDto.getName()).isEqualTo("Avoid Null"); @@ -138,7 +138,7 @@ public class RuleDaoTest { @Test public void select_non_manual() { dbTester.prepareDbUnit(getClass(), "selectNonManual.xml"); - List<RuleDto> ruleDtos = dao.findByNonManual(dbTester.getSession()); + List<RuleDto> ruleDtos = dao.selectByNonManual(dbTester.getSession()); dbTester.getSession().commit(); dbTester.getSession().close(); @@ -287,7 +287,7 @@ public class RuleDaoTest { @Test public void select_parameters() { dbTester.prepareDbUnit(getClass(), "selectParameters.xml"); - List<RuleParamDto> ruleDtos = dao.findAllRuleParams(dbTester.getSession()); + List<RuleParamDto> ruleDtos = dao.selectAllRuleParams(dbTester.getSession()); assertThat(ruleDtos.size()).isEqualTo(1); RuleParamDto ruleDto = ruleDtos.get(0); @@ -301,8 +301,8 @@ public class RuleDaoTest { @Test public void select_parameters_by_rule_id() { dbTester.prepareDbUnit(getClass(), "select_parameters_by_rule_id.xml"); - RuleDto rule = dao.getById(dbTester.getSession(), 1); - List<RuleParamDto> ruleDtos = dao.findRuleParamsByRuleKey(dbTester.getSession(), rule.getKey()); + RuleDto rule = dao.selectById(dbTester.getSession(), 1); + List<RuleParamDto> ruleDtos = dao.selectRuleParamsByRuleKey(dbTester.getSession(), rule.getKey()); assertThat(ruleDtos.size()).isEqualTo(1); RuleParamDto ruleDto = ruleDtos.get(0); @@ -317,7 +317,7 @@ public class RuleDaoTest { public void insert_parameter() { dbTester.prepareDbUnit(getClass(), "insert_parameter.xml"); - RuleDto rule1 = dao.getById(dbTester.getSession(), 1); + RuleDto rule1 = dao.selectById(dbTester.getSession(), 1); RuleParamDto param = RuleParamDto.createFor(rule1) .setName("max") @@ -325,7 +325,7 @@ public class RuleDaoTest { .setDefaultValue("30") .setDescription("My Parameter"); - dao.addRuleParam(dbTester.getSession(), rule1, param); + dao.insertRuleParam(dbTester.getSession(), rule1, param); dbTester.getSession().commit(); dbTester.assertDbUnit(getClass(), "insert_parameter-result.xml", "rules_parameters"); @@ -335,9 +335,9 @@ public class RuleDaoTest { public void update_parameter() { dbTester.prepareDbUnit(getClass(), "update_parameter.xml"); - RuleDto rule1 = dao.getById(dbTester.getSession(), 1); + RuleDto rule1 = dao.selectById(dbTester.getSession(), 1); - List<RuleParamDto> params = dao.findRuleParamsByRuleKey(dbTester.getSession(), rule1.getKey()); + List<RuleParamDto> params = dao.selectRuleParamsByRuleKey(dbTester.getSession(), rule1.getKey()); assertThat(params).hasSize(1); RuleParamDto param = Iterables.getFirst(params, null); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java index 9817fbdc6f8..fa441160e8c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java @@ -309,14 +309,14 @@ public class RuleIndexMediumTest { CharacteristicDto char1 = DebtTesting.newCharacteristicDto("c1") .setEnabled(true) .setName("char1"); - db.debtCharacteristicDao().insert(char1, dbSession); + db.debtCharacteristicDao().insert(dbSession, char1); dbSession.commit(); CharacteristicDto char11 = DebtTesting.newCharacteristicDto("c11") .setEnabled(true) .setName("char11") .setParentId(char1.getId()); - db.debtCharacteristicDao().insert(char11, dbSession); + db.debtCharacteristicDao().insert(dbSession, char11); // Rule with default characteristic dao.insert(dbSession, RuleTesting.newDto(RuleKey.of("findbugs", "S001")) @@ -354,14 +354,14 @@ public class RuleIndexMediumTest { CharacteristicDto char1 = DebtTesting.newCharacteristicDto("c1") .setEnabled(true) .setName("char1"); - db.debtCharacteristicDao().insert(char1, dbSession); + db.debtCharacteristicDao().insert(dbSession, char1); dbSession.commit(); CharacteristicDto char11 = DebtTesting.newCharacteristicDto("c11") .setEnabled(true) .setName("char11") .setParentId(char1.getId()); - db.debtCharacteristicDao().insert(char11, dbSession); + db.debtCharacteristicDao().insert(dbSession, char11); // Rule with default characteristic dao.insert(dbSession, RuleTesting.newDto(RuleKey.of("findbugs", "S001")) @@ -489,11 +489,11 @@ public class RuleIndexMediumTest { @Test public void search_by_characteristics() { CharacteristicDto char1 = DebtTesting.newCharacteristicDto("RELIABILITY"); - db.debtCharacteristicDao().insert(char1, dbSession); + db.debtCharacteristicDao().insert(dbSession, char1); CharacteristicDto char11 = DebtTesting.newCharacteristicDto("SOFT_RELIABILITY") .setParentId(char1.getId()); - db.debtCharacteristicDao().insert(char11, dbSession); + db.debtCharacteristicDao().insert(dbSession, char11); dbSession.commit(); dao.insert(dbSession, RuleTesting.newDto(RuleKey.of("java", "S001")) @@ -543,19 +543,19 @@ public class RuleIndexMediumTest { @Test public void search_by_characteristics_with_default_and_overridden_char() { CharacteristicDto char1 = DebtTesting.newCharacteristicDto("RELIABILITY"); - db.debtCharacteristicDao().insert(char1, dbSession); + db.debtCharacteristicDao().insert(dbSession, char1); CharacteristicDto char11 = DebtTesting.newCharacteristicDto("SOFT_RELIABILITY") .setParentId(char1.getId()); - db.debtCharacteristicDao().insert(char11, dbSession); + db.debtCharacteristicDao().insert(dbSession, char11); dbSession.commit(); CharacteristicDto char2 = DebtTesting.newCharacteristicDto("TESTABILITY"); - db.debtCharacteristicDao().insert(char2, dbSession); + db.debtCharacteristicDao().insert(dbSession, char2); CharacteristicDto char21 = DebtTesting.newCharacteristicDto("UNIT_TESTABILITY") .setParentId(char2.getId()); - db.debtCharacteristicDao().insert(char21, dbSession); + db.debtCharacteristicDao().insert(dbSession, char21); dbSession.commit(); // Rule with only default sub characteristic -> should be find by char11 and char1 @@ -888,7 +888,7 @@ public class RuleIndexMediumTest { .setName("testing") .setType("STRING") .setDefaultValue(value); - dao.addRuleParam(dbSession, rule, param); + dao.insertRuleParam(dbSession, rule, param); dbSession.commit(); @@ -997,12 +997,12 @@ public class RuleIndexMediumTest { RuleDto templateRule = RuleTesting.newDto(RuleKey.of("java", "S001")).setIsTemplate(true); RuleParamDto ruleParamDto = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*"); dao.insert(dbSession, templateRule); - dao.addRuleParam(dbSession, templateRule, ruleParamDto); + dao.insertRuleParam(dbSession, templateRule, ruleParamDto); RuleDto customRule = RuleTesting.newDto(RuleKey.of("java", "S001_MY_CUSTOM")).setTemplateId(templateRule.getId()); RuleParamDto customRuleParam = RuleParamDto.createFor(customRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue("a.*"); dao.insert(dbSession, customRule); - dao.addRuleParam(dbSession, customRule, customRuleParam); + dao.insertRuleParam(dbSession, customRule, customRuleParam); dbSession.commit(); // find all diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/CreateActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/CreateActionMediumTest.java index 4145b41208c..2829f157d0d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/CreateActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/CreateActionMediumTest.java @@ -76,7 +76,7 @@ public class CreateActionMediumTest { // Template rule RuleDto templateRule = ruleDao.insert(session, RuleTesting.newTemplateRule(RuleKey.of("java", "S001"))); RuleParamDto param = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*"); - ruleDao.addRuleParam(session, templateRule, param); + ruleDao.insertRuleParam(session, templateRule, param); session.commit(); WsTester.TestRequest request = wsTester.newPostRequest("api/rules", "create") diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java index 9cc24440ba4..80a4784197f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java @@ -466,25 +466,25 @@ public class RulesWsMediumTest { .setType("string") .setDescription("My small description") .setName("my_var"); - ruleDao.addRuleParam(session, rule, param); + ruleDao.insertRuleParam(session, rule, param); RuleParamDto param2 = RuleParamDto.createFor(rule) .setDefaultValue("other value") .setType("integer") .setDescription("My small description") .setName("the_var"); - ruleDao.addRuleParam(session, rule, param2); + ruleDao.insertRuleParam(session, rule, param2); ActiveRuleDto activeRule = newActiveRule(profile, rule); tester.get(ActiveRuleDao.class).insert(session, activeRule); ActiveRuleParamDto activeRuleParam = ActiveRuleParamDto.createFor(param) .setValue("The VALUE"); - tester.get(ActiveRuleDao.class).addParam(session, activeRule, activeRuleParam); + tester.get(ActiveRuleDao.class).insertParam(session, activeRule, activeRuleParam); ActiveRuleParamDto activeRuleParam2 = ActiveRuleParamDto.createFor(param2) .setValue("The Other Value"); - tester.get(ActiveRuleDao.class).addParam(session, activeRule, activeRuleParam2); + tester.get(ActiveRuleDao.class).insertParam(session, activeRule, activeRuleParam2); session.commit(); WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD); @@ -642,16 +642,16 @@ public class RulesWsMediumTest { private void insertDebtCharacteristics(DbSession dbSession) { CharacteristicDto reliability = DebtTesting.newCharacteristicDto("RELIABILITY").setName("Reliability"); - db.debtCharacteristicDao().insert(reliability, dbSession); + db.debtCharacteristicDao().insert(dbSession, reliability); CharacteristicDto softReliability = DebtTesting.newCharacteristicDto("SOFT_RELIABILITY").setName("Soft Reliability") .setParentId(reliability.getId()); - db.debtCharacteristicDao().insert(softReliability, dbSession); + db.debtCharacteristicDao().insert(dbSession, softReliability); softReliabilityId = softReliability.getId(); CharacteristicDto hardReliability = DebtTesting.newCharacteristicDto("HARD_RELIABILITY").setName("Hard Reliability") .setParentId(reliability.getId()); - db.debtCharacteristicDao().insert(hardReliability, dbSession); + db.debtCharacteristicDao().insert(dbSession, hardReliability); hardReliabilityId = hardReliability.getId(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java index 3717910d88d..bad2f0c2f3c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java @@ -89,7 +89,7 @@ public class ShowActionMediumTest { .setSystemTags(newHashSet("systag1", "systag2")) ); RuleParamDto param = RuleParamDto.createFor(ruleDto).setName("regex").setType("STRING").setDescription("Reg *exp*").setDefaultValue(".*"); - ruleDao.addRuleParam(session, ruleDto, param); + ruleDao.insertRuleParam(session, ruleDto, param); session.commit(); session.clearCache(); @@ -101,9 +101,9 @@ public class ShowActionMediumTest { @Test public void show_rule_with_default_debt_infos() throws Exception { CharacteristicDto characteristicDto = new CharacteristicDto().setKey("API").setName("Api").setEnabled(true); - tester.get(CharacteristicDao.class).insert(characteristicDto, session); + tester.get(CharacteristicDao.class).insert(session, characteristicDto); CharacteristicDto subCharacteristicDto = new CharacteristicDto().setKey("API_ABUSE").setName("API Abuse").setEnabled(true).setParentId(characteristicDto.getId()); - tester.get(CharacteristicDao.class).insert(subCharacteristicDto, session); + tester.get(CharacteristicDao.class).insert(session, subCharacteristicDto); RuleDto ruleDto = ruleDao.insert(session, RuleTesting.newDto(RuleKey.of("java", "S001")) @@ -135,9 +135,9 @@ public class ShowActionMediumTest { @Test public void show_rule_with_overridden_debt() throws Exception { CharacteristicDto characteristicDto = new CharacteristicDto().setKey("API").setName("Api").setEnabled(true); - tester.get(CharacteristicDao.class).insert(characteristicDto, session); + tester.get(CharacteristicDao.class).insert(session, characteristicDto); CharacteristicDto subCharacteristicDto = new CharacteristicDto().setKey("API_ABUSE").setName("API Abuse").setEnabled(true).setParentId(characteristicDto.getId()); - tester.get(CharacteristicDao.class).insert(subCharacteristicDto, session); + tester.get(CharacteristicDao.class).insert(session, subCharacteristicDto); RuleDto ruleDto = ruleDao.insert(session, RuleTesting.newDto(RuleKey.of("java", "S001")) @@ -167,14 +167,14 @@ public class ShowActionMediumTest { @Test public void show_rule_with_default_and_overridden_debt_infos() throws Exception { CharacteristicDto defaultCharacteristic = new CharacteristicDto().setKey("API").setName("Api").setEnabled(true); - tester.get(CharacteristicDao.class).insert(defaultCharacteristic, session); + tester.get(CharacteristicDao.class).insert(session, defaultCharacteristic); CharacteristicDto defaultSubCharacteristic = new CharacteristicDto().setKey("API_ABUSE").setName("API Abuse").setEnabled(true).setParentId(defaultCharacteristic.getId()); - tester.get(CharacteristicDao.class).insert(defaultSubCharacteristic, session); + tester.get(CharacteristicDao.class).insert(session, defaultSubCharacteristic); CharacteristicDto characteristic = new CharacteristicDto().setKey("OS").setName("Os").setEnabled(true); - tester.get(CharacteristicDao.class).insert(characteristic, session); + tester.get(CharacteristicDao.class).insert(session, characteristic); CharacteristicDto subCharacteristic = new CharacteristicDto().setKey("OS_RELATED_PORTABILITY").setName("Portability").setEnabled(true).setParentId(characteristic.getId()); - tester.get(CharacteristicDao.class).insert(subCharacteristic, session); + tester.get(CharacteristicDao.class).insert(session, subCharacteristic); RuleDto ruleDto = ruleDao.insert(session, RuleTesting.newDto(RuleKey.of("java", "S001")) diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionMediumTest.java index 35229551239..a4c75e694d6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionMediumTest.java @@ -78,7 +78,7 @@ public class UpdateActionMediumTest { // Template rule RuleDto templateRule = ruleDao.insert(session, RuleTesting.newTemplateRule(RuleKey.of("java", "S001"))); RuleParamDto param = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*"); - ruleDao.addRuleParam(session, templateRule, param); + ruleDao.insertRuleParam(session, templateRule, param); session.commit(); // Custom rule diff --git a/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterNewMeasureFiltersTest.java b/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterNewMeasureFiltersTest.java index 97b3e465edc..bc49c238dd6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterNewMeasureFiltersTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterNewMeasureFiltersTest.java @@ -82,7 +82,7 @@ public class RegisterNewMeasureFiltersTest { @Test public void should_not_recreate_filter() { - when(filterDao.findSystemFilterByName("Fake")).thenReturn(new MeasureFilterDto()); + when(filterDao.selectSystemFilterByName("Fake")).thenReturn(new MeasureFilterDto()); MeasureFilterDto filterDto = registration.register("Fake", null); diff --git a/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterPermissionTemplatesTest.java b/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterPermissionTemplatesTest.java index ea05f59fc51..25f59befed5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterPermissionTemplatesTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/startup/RegisterPermissionTemplatesTest.java @@ -66,7 +66,7 @@ public class RegisterPermissionTemplatesTest { when(loadedTemplateDao.countByTypeAndKey(LoadedTemplateDto.PERMISSION_TEMPLATE_TYPE, PermissionTemplateDto.DEFAULT.getKee())) .thenReturn(0); - when(permissionTemplateDao.createPermissionTemplate(PermissionTemplateDto.DEFAULT.getName(), PermissionTemplateDto.DEFAULT.getDescription(), null)) + when(permissionTemplateDao.insertPermissionTemplate(PermissionTemplateDto.DEFAULT.getName(), PermissionTemplateDto.DEFAULT.getDescription(), null)) .thenReturn(permissionTemplate); when(userDao.selectGroupByName(DefaultGroups.ADMINISTRATORS)).thenReturn(new GroupDto().setId(1L)); when(userDao.selectGroupByName(DefaultGroups.USERS)).thenReturn(new GroupDto().setId(2L)); @@ -75,11 +75,11 @@ public class RegisterPermissionTemplatesTest { initializer.start(); verify(loadedTemplateDao).insert(argThat(Matches.template(expectedTemplate))); - verify(permissionTemplateDao).createPermissionTemplate(PermissionTemplateDto.DEFAULT.getName(), PermissionTemplateDto.DEFAULT.getDescription(), null); - verify(permissionTemplateDao).addGroupPermission(1L, 1L, UserRole.ADMIN); - verify(permissionTemplateDao).addGroupPermission(1L, 1L, UserRole.ISSUE_ADMIN); - verify(permissionTemplateDao).addGroupPermission(1L, null, UserRole.USER); - verify(permissionTemplateDao).addGroupPermission(1L, null, UserRole.CODEVIEWER); + verify(permissionTemplateDao).insertPermissionTemplate(PermissionTemplateDto.DEFAULT.getName(), PermissionTemplateDto.DEFAULT.getDescription(), null); + verify(permissionTemplateDao).insertGroupPermission(1L, 1L, UserRole.ADMIN); + verify(permissionTemplateDao).insertGroupPermission(1L, 1L, UserRole.ISSUE_ADMIN); + verify(permissionTemplateDao).insertGroupPermission(1L, null, UserRole.USER); + verify(permissionTemplateDao).insertGroupPermission(1L, null, UserRole.CODEVIEWER); verifyNoMoreInteractions(permissionTemplateDao); verify(settings).saveProperty(RegisterPermissionTemplates.DEFAULT_TEMPLATE_PROPERTY, PermissionTemplateDto.DEFAULT.getKee()); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/test/CoverageServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/test/CoverageServiceTest.java index 447158852ba..80a01ab160a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/test/CoverageServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/test/CoverageServiceTest.java @@ -75,42 +75,42 @@ public class CoverageServiceTest { @Test public void get_hits_data() { service.getHits(COMPONENT_KEY, CoverageService.TYPE.UT); - verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY); + verify(measureDao).selectByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY); service.getHits(COMPONENT_KEY, CoverageService.TYPE.IT); - verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.IT_COVERAGE_LINE_HITS_DATA_KEY); + verify(measureDao).selectByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.IT_COVERAGE_LINE_HITS_DATA_KEY); service.getHits(COMPONENT_KEY, CoverageService.TYPE.OVERALL); - verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA_KEY); + verify(measureDao).selectByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA_KEY); } @Test public void not_get_hits_data_if_no_data() { - when(measureDao.findByComponentKeyAndMetricKey(eq(session), anyString(), anyString())).thenReturn(null); + when(measureDao.selectByComponentKeyAndMetricKey(eq(session), anyString(), anyString())).thenReturn(null); assertThat(service.getHits(COMPONENT_KEY, CoverageService.TYPE.UT)).isEqualTo(Collections.emptyMap()); } @Test public void get_conditions_data() { service.getConditions(COMPONENT_KEY, CoverageService.TYPE.UT); - verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.CONDITIONS_BY_LINE_KEY); + verify(measureDao).selectByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.CONDITIONS_BY_LINE_KEY); service.getConditions(COMPONENT_KEY, CoverageService.TYPE.IT); - verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.IT_CONDITIONS_BY_LINE_KEY); + verify(measureDao).selectByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.IT_CONDITIONS_BY_LINE_KEY); service.getConditions(COMPONENT_KEY, CoverageService.TYPE.OVERALL); - verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.OVERALL_CONDITIONS_BY_LINE_KEY); + verify(measureDao).selectByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.OVERALL_CONDITIONS_BY_LINE_KEY); } @Test public void get_covered_conditions_data() { service.getCoveredConditions(COMPONENT_KEY, CoverageService.TYPE.UT); - verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY); + verify(measureDao).selectByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY); service.getCoveredConditions(COMPONENT_KEY, CoverageService.TYPE.IT); - verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE_KEY); + verify(measureDao).selectByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE_KEY); service.getCoveredConditions(COMPONENT_KEY, CoverageService.TYPE.OVERALL); - verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE_KEY); + verify(measureDao).selectByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE_KEY); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java index 31a5aa890e4..980f6a4afcb 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentNavigationActionTest.java @@ -132,7 +132,7 @@ public class ComponentNavigationActionTest { ComponentDto project = ComponentTesting.newProjectDto("abcd") .setKey("polop").setName("Polop"); dbClient.componentDao().insert(dbTester.getSession(), project); - dbClient.propertiesDao().setProperty(new PropertyDto().setKey("favourite").setResourceId(project.getId()).setUserId((long) userId), dbTester.getSession()); + dbClient.propertiesDao().insertProperty(dbTester.getSession(), new PropertyDto().setKey("favourite").setResourceId(project.getId()).setUserId((long) userId)); dbTester.getSession().commit(); userSessionRule.login("obiwan").setUserId(userId).addProjectUuidPermissions(UserRole.USER, "abcd"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ServerUserSessionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ServerUserSessionTest.java index 044efcb08e3..5e963f70059 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/ServerUserSessionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/ServerUserSessionTest.java @@ -170,7 +170,7 @@ public class ServerUserSessionTest { ComponentDto project = ComponentTesting.newProjectDto(); ComponentDto file = ComponentTesting.newFileDto(project, "file-uuid"); - when(resourceDao.getResource("file-uuid")).thenReturn(new ResourceDto().setProjectUuid(project.uuid())); + when(resourceDao.selectResource("file-uuid")).thenReturn(new ResourceDto().setProjectUuid(project.uuid())); when(authorizationDao.selectAuthorizedRootProjectsUuids(1, UserRole.USER)).thenReturn(newArrayList(project.uuid())); session.checkComponentUuidPermission(UserRole.USER, file.uuid()); @@ -182,7 +182,7 @@ public class ServerUserSessionTest { ComponentDto project = ComponentTesting.newProjectDto(); ComponentDto file = ComponentTesting.newFileDto(project, "file-uuid"); - when(resourceDao.getResource("file-uuid")).thenReturn(new ResourceDto().setProjectUuid(project.uuid())); + when(resourceDao.selectResource("file-uuid")).thenReturn(new ResourceDto().setProjectUuid(project.uuid())); when(authorizationDao.selectAuthorizedRootProjectsUuids(1, UserRole.USER)).thenReturn(newArrayList(project.uuid())); session.checkComponentUuidPermission(UserRole.USER, "another-uuid"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterTest.java index 44296c3a607..64a6d7177a8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterTest.java @@ -124,7 +124,7 @@ public class UserUpdaterTest { .setPasswordConfirmation("password") .setScmAccounts(newArrayList("u1", "u_1", "User 1"))); - UserDto dto = userDao.selectNullableByLogin(session, "user"); + UserDto dto = userDao.selectByLogin(session, "user"); assertThat(dto.getId()).isNotNull(); assertThat(dto.getLogin()).isEqualTo("user"); assertThat(dto.getName()).isEqualTo("User"); @@ -158,7 +158,7 @@ public class UserUpdaterTest { .setPassword("password") .setPasswordConfirmation("password")); - UserDto dto = userDao.selectNullableByLogin(session, "user"); + UserDto dto = userDao.selectByLogin(session, "user"); assertThat(dto.getId()).isNotNull(); assertThat(dto.getLogin()).isEqualTo("user"); assertThat(dto.getName()).isEqualTo("User"); @@ -179,7 +179,7 @@ public class UserUpdaterTest { .setPasswordConfirmation("password") .setScmAccounts(newArrayList("u1", "", null))); - assertThat(userDao.selectNullableByLogin(session, "user").getScmAccountsAsList()).containsOnly("u1"); + assertThat(userDao.selectByLogin(session, "user").getScmAccountsAsList()).containsOnly("u1"); } @Test @@ -194,7 +194,7 @@ public class UserUpdaterTest { .setPasswordConfirmation("password") .setScmAccounts(newArrayList(""))); - assertThat(userDao.selectNullableByLogin(session, "user").getScmAccounts()).isNull(); + assertThat(userDao.selectByLogin(session, "user").getScmAccounts()).isNull(); } @Test @@ -209,7 +209,7 @@ public class UserUpdaterTest { .setPasswordConfirmation("password") .setScmAccounts(newArrayList("u1", "u1"))); - assertThat(userDao.selectNullableByLogin(session, "user").getScmAccountsAsList()).containsOnly("u1"); + assertThat(userDao.selectByLogin(session, "user").getScmAccountsAsList()).containsOnly("u1"); } @Test @@ -530,7 +530,7 @@ public class UserUpdaterTest { .setPasswordConfirmation("password2")); session.commit(); - UserDto dto = userDao.selectNullableByLogin(session, "marius"); + UserDto dto = userDao.selectByLogin(session, "marius"); assertThat(dto.isActive()).isTrue(); assertThat(dto.getName()).isEqualTo("Marius2"); assertThat(dto.getEmail()).isEqualTo("marius2@mail.com"); @@ -596,7 +596,7 @@ public class UserUpdaterTest { session.commit(); session.clearCache(); - UserDto dto = userDao.selectNullableByLogin(session, "marius"); + UserDto dto = userDao.selectByLogin(session, "marius"); assertThat(dto.isActive()).isTrue(); assertThat(dto.getName()).isEqualTo("Marius2"); assertThat(dto.getEmail()).isEqualTo("marius2@mail.com"); @@ -631,7 +631,7 @@ public class UserUpdaterTest { session.commit(); session.clearCache(); - UserDto dto = userDao.selectNullableByLogin(session, "marius"); + UserDto dto = userDao.selectByLogin(session, "marius"); assertThat(dto.isActive()).isTrue(); assertThat(dto.getName()).isEqualTo("Marius2"); assertThat(dto.getEmail()).isEqualTo("marius2@mail.com"); @@ -665,7 +665,7 @@ public class UserUpdaterTest { session.commit(); session.clearCache(); - UserDto dto = userDao.selectNullableByLogin(session, "marius"); + UserDto dto = userDao.selectByLogin(session, "marius"); assertThat(dto.getScmAccountsAsList()).containsOnly("ma2"); } @@ -679,7 +679,7 @@ public class UserUpdaterTest { session.commit(); session.clearCache(); - UserDto dto = userDao.selectNullableByLogin(session, "marius"); + UserDto dto = userDao.selectByLogin(session, "marius"); assertThat(dto.getName()).isEqualTo("Marius2"); // Following fields has not changed @@ -699,7 +699,7 @@ public class UserUpdaterTest { session.commit(); session.clearCache(); - UserDto dto = userDao.selectNullableByLogin(session, "marius"); + UserDto dto = userDao.selectByLogin(session, "marius"); assertThat(dto.getEmail()).isEqualTo("marius2@mail.com"); // Following fields has not changed @@ -719,7 +719,7 @@ public class UserUpdaterTest { session.commit(); session.clearCache(); - UserDto dto = userDao.selectNullableByLogin(session, "marius"); + UserDto dto = userDao.selectByLogin(session, "marius"); assertThat(dto.getScmAccountsAsList()).containsOnly("ma2"); // Following fields has not changed @@ -739,7 +739,7 @@ public class UserUpdaterTest { session.commit(); session.clearCache(); - UserDto dto = userDao.selectNullableByLogin(session, "marius"); + UserDto dto = userDao.selectByLogin(session, "marius"); assertThat(dto.getScmAccountsAsList()).containsOnly("ma", "marius33"); } @@ -753,7 +753,7 @@ public class UserUpdaterTest { session.commit(); session.clearCache(); - UserDto dto = userDao.selectNullableByLogin(session, "marius"); + UserDto dto = userDao.selectByLogin(session, "marius"); assertThat(dto.getScmAccounts()).isNull(); } @@ -768,7 +768,7 @@ public class UserUpdaterTest { session.commit(); session.clearCache(); - UserDto dto = userDao.selectNullableByLogin(session, "marius"); + UserDto dto = userDao.selectByLogin(session, "marius"); assertThat(dto.getSalt()).isNotEqualTo("79bd6a8e79fb8c76ac8b121cc7e8e11ad1af8365"); assertThat(dto.getCryptedPassword()).isNotEqualTo("650d2261c98361e2f67f90ce5c65a95e7d8ea2fg"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java index 7adda5b93cc..71939b83e3f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java @@ -132,7 +132,7 @@ public class ChangePasswordActionTest { public void update_password() throws Exception { createUser(); session.clearCache(); - String originalPassword = dbClient.userDao().selectByLogin(session, "john").getCryptedPassword(); + String originalPassword = dbClient.userDao().selectOrFailByLogin(session, "john").getCryptedPassword(); tester.newPostRequest("api/users", "change_password") .setParam("login", "john") @@ -141,7 +141,7 @@ public class ChangePasswordActionTest { .assertNoContent(); session.clearCache(); - String newPassword = dbClient.userDao().selectByLogin(session, "john").getCryptedPassword(); + String newPassword = dbClient.userDao().selectOrFailByLogin(session, "john").getCryptedPassword(); assertThat(newPassword).isNotEqualTo(originalPassword); } @@ -149,7 +149,7 @@ public class ChangePasswordActionTest { public void update_password_on_self() throws Exception { createUser(); session.clearCache(); - String originalPassword = dbClient.userDao().selectByLogin(session, "john").getCryptedPassword(); + String originalPassword = dbClient.userDao().selectOrFailByLogin(session, "john").getCryptedPassword(); userSessionRule.login("john"); tester.newPostRequest("api/users", "change_password") @@ -160,7 +160,7 @@ public class ChangePasswordActionTest { .assertNoContent(); session.clearCache(); - String newPassword = dbClient.userDao().selectByLogin(session, "john").getCryptedPassword(); + String newPassword = dbClient.userDao().selectOrFailByLogin(session, "john").getCryptedPassword(); assertThat(newPassword).isNotEqualTo(originalPassword); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java index ad08e6dd95f..68365e85afb 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java @@ -139,7 +139,7 @@ public class DeleteActionTest { @Test public void delete_with_permission_templates() throws Exception { GroupDto group = groupDao.insert(session, new GroupDto().setName("to-delete")); - permissionTemplateDao.addGroupPermission(42L, group.getId(), UserRole.ADMIN); + permissionTemplateDao.insertGroupPermission(42L, group.getId(), UserRole.ADMIN); session.commit(); loginAsAdmin(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java index b54acb862f4..0b374deab8f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java @@ -167,7 +167,7 @@ public class SearchActionTest { } private void insertMembers(String groupName, int count) { - long groupId = groupDao.selectByKey(session, groupName).getId(); + long groupId = groupDao.selectOrFailByKey(session, groupName).getId(); for (int i = 0; i < count; i++) { userGroupDao.insert(session, new UserGroupDto().setGroupId(groupId).setUserId((long) i + 1)); } diff --git a/sonar-db/src/main/java/org/sonar/core/properties/PropertiesDao.java b/sonar-db/src/main/java/org/sonar/core/properties/PropertiesDao.java index 58437280428..dede72261b5 100644 --- a/sonar-db/src/main/java/org/sonar/core/properties/PropertiesDao.java +++ b/sonar-db/src/main/java/org/sonar/core/properties/PropertiesDao.java @@ -35,6 +35,6 @@ public class PropertiesDao extends org.sonar.db.property.PropertiesDao { } public void setProperty(PropertyDto property) { - super.setProperty(property); + super.insertProperty(property); } } diff --git a/sonar-db/src/main/java/org/sonar/core/user/DeprecatedUserFinder.java b/sonar-db/src/main/java/org/sonar/core/user/DeprecatedUserFinder.java index 2413ce4babc..d379d878ad3 100644 --- a/sonar-db/src/main/java/org/sonar/core/user/DeprecatedUserFinder.java +++ b/sonar-db/src/main/java/org/sonar/core/user/DeprecatedUserFinder.java @@ -38,7 +38,7 @@ public class DeprecatedUserFinder implements UserFinder { @Override public User findById(int id) { - return copy(userDao.getUser(id)); + return copy(userDao.selectUserById(id)); } @Override diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java index 6f30ebec41a..78b517317c6 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java @@ -40,7 +40,7 @@ import static com.google.common.collect.Maps.newHashMapWithExpectedSize; public class ComponentDao implements Dao { - public ComponentDto selectNonNullById(DbSession session, long id) { + public ComponentDto selectOrFailById(DbSession session, long id) { Optional<ComponentDto> componentDto = selectById(session, id); if (!componentDto.isPresent()) { throw new IllegalArgumentException(String.format("Component id does not exist: %d", id)); @@ -56,7 +56,7 @@ public class ComponentDao implements Dao { return Optional.fromNullable(mapper(session).selectByUuid(uuid)); } - public ComponentDto selectNonNullByUuid(DbSession session, String uuid) { + public ComponentDto selectOrFailByUuid(DbSession session, String uuid) { Optional<ComponentDto> componentDto = selectByUuid(session, uuid); if (!componentDto.isPresent()) { throw new IllegalArgumentException(String.format("Component with uuid '%s' not found", uuid)); diff --git a/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java b/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java index 7eca76f1ce9..b6e8f1386b2 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ResourceDao.java @@ -46,17 +46,17 @@ public class ResourceDao extends AbstractDao { * the first row is returned. */ @CheckForNull - public ResourceDto getResource(ResourceQuery query) { + public ResourceDto selectResource(ResourceQuery query) { DbSession session = myBatis().openSession(false); try { - return getResource(query, session); + return selectResource(query, session); } finally { myBatis().closeQuietly(session); } } @CheckForNull - private ResourceDto getResource(ResourceQuery query, DbSession session) { + private ResourceDto selectResource(ResourceQuery query, DbSession session) { List<ResourceDto> resources = getResources(query, session); if (!resources.isEmpty()) { return resources.get(0); @@ -69,7 +69,7 @@ public class ResourceDao extends AbstractDao { } @CheckForNull - public ResourceDto getResource(String componentUuid) { + public ResourceDto selectResource(String componentUuid) { SqlSession session = myBatis().openSession(false); try { return session.getMapper(ResourceMapper.class).selectResourceByUuid(componentUuid); @@ -78,7 +78,7 @@ public class ResourceDao extends AbstractDao { } } - public ResourceDto getResource(long projectId, SqlSession session) { + public ResourceDto selectResource(long projectId, SqlSession session) { return session.getMapper(ResourceMapper.class).selectResource(projectId); } @@ -107,8 +107,8 @@ public class ResourceDao extends AbstractDao { } @CheckForNull - public Component findByKey(String key) { - ResourceDto resourceDto = getResource(ResourceQuery.create().setKey(key)); + public Component selectByKey(String key) { + ResourceDto resourceDto = selectResource(ResourceQuery.create().setKey(key)); return resourceDto != null ? toComponent(resourceDto) : null; } @@ -121,7 +121,7 @@ public class ResourceDao extends AbstractDao { */ @CheckForNull private ResourceDto getRootProjectByComponentKey(DbSession session, String componentKey) { - ResourceDto component = getResource(ResourceQuery.create().setKey(componentKey), session); + ResourceDto component = selectResource(ResourceQuery.create().setKey(componentKey), session); if (component != null) { Long rootId = component.getRootId(); if (rootId != null) { @@ -145,7 +145,7 @@ public class ResourceDao extends AbstractDao { @CheckForNull private ResourceDto getParentModuleByComponentId(Long componentId, DbSession session) { - ResourceDto component = getResource(componentId, session); + ResourceDto component = selectResource(componentId, session); if (component != null) { Long rootId = component.getRootId(); if (rootId != null) { diff --git a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java index d23eeb5a934..e5a09655ef5 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java @@ -33,12 +33,12 @@ import org.sonar.db.DbSession; public class SnapshotDao implements Dao { @CheckForNull - public SnapshotDto selectNullableById(DbSession session, long id) { + public SnapshotDto selectById(DbSession session, long id) { return mapper(session).selectByKey(id); } - public SnapshotDto selectById(DbSession session, long id) { - SnapshotDto value = selectNullableById(session, id); + public SnapshotDto selectOrFailById(DbSession session, long id) { + SnapshotDto value = selectById(session, id); if (value == null) { throw new IllegalArgumentException(String.format("Snapshot id does not exist: %d", id)); } diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardDao.java b/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardDao.java index c29f495047e..294cd2951b9 100644 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardDao.java +++ b/sonar-db/src/main/java/org/sonar/db/dashboard/ActiveDashboardDao.java @@ -36,7 +36,7 @@ public class ActiveDashboardDao implements Dao { public void insert(ActiveDashboardDto activeDashboardDto) { SqlSession session = mybatis.openSession(false); try { - getMapper(session).insert(activeDashboardDto); + mapper(session).insert(activeDashboardDto); session.commit(); } finally { MyBatis.closeQuietly(session); @@ -46,7 +46,7 @@ public class ActiveDashboardDao implements Dao { public int selectMaxOrderIndexForNullUser() { SqlSession session = mybatis.openSession(false); try { - Integer max = getMapper(session).selectMaxOrderIndexForNullUser(); + Integer max = mapper(session).selectMaxOrderIndexForNullUser(); return max != null ? max.intValue() : 0; } finally { session.close(); @@ -57,7 +57,7 @@ public class ActiveDashboardDao implements Dao { public List<DashboardDto> selectGlobalDashboardsForUserLogin(@Nullable String login) { SqlSession session = mybatis.openSession(false); try { - return getMapper(session).selectGlobalDashboardsForUserLogin(login); + return mapper(session).selectGlobalDashboardsForUserLogin(login); } finally { session.close(); } @@ -73,10 +73,10 @@ public class ActiveDashboardDao implements Dao { } public List<DashboardDto> selectProjectDashboardsForUserLogin(SqlSession session, @Nullable String login) { - return getMapper(session).selectProjectDashboardsForUserLogin(login); + return mapper(session).selectProjectDashboardsForUserLogin(login); } - private ActiveDashboardMapper getMapper(SqlSession session) { + private ActiveDashboardMapper mapper(SqlSession session) { return session.getMapper(ActiveDashboardMapper.class); } } diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java b/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java index 4462c1c24c8..95052caaf4e 100644 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java +++ b/sonar-db/src/main/java/org/sonar/db/dashboard/DashboardDao.java @@ -66,7 +66,7 @@ public class DashboardDao implements Dao { } @CheckForNull - public DashboardDto getNullableByKey(DbSession session, Long key) { + public DashboardDto selectByKey(DbSession session, Long key) { return mapper(session).selectById(key); } @@ -75,7 +75,7 @@ public class DashboardDao implements Dao { * @param userId id of logged-in user, null if anonymous */ @CheckForNull - public DashboardDto getAllowedByKey(DbSession session, Long key, @Nullable Long userId) { + public DashboardDto selectAllowedByKey(DbSession session, Long key, @Nullable Long userId) { return mapper(session).selectAllowedById(key, userId != null ? userId : -1L); } diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetDao.java b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetDao.java index e0ee86b405f..9f368e59fcd 100644 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetDao.java +++ b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetDao.java @@ -32,16 +32,16 @@ public class WidgetDao implements Dao { this.myBatis = myBatis; } - public WidgetDto getNullableByKey(Long widgetId) { + public WidgetDto selectByKey(Long widgetId) { DbSession session = myBatis.openSession(false); try { - return getNullableByKey(session, widgetId); + return selectByKey(session, widgetId); } finally { MyBatis.closeQuietly(session); } } - public WidgetDto getNullableByKey(DbSession session, Long widgetId) { + public WidgetDto selectByKey(DbSession session, Long widgetId) { return mapper(session).selectById(widgetId); } diff --git a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java index af69ea26624..51c242ae328 100644 --- a/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java +++ b/sonar-db/src/main/java/org/sonar/db/dashboard/WidgetPropertyDao.java @@ -56,20 +56,20 @@ public class WidgetPropertyDao implements Dao { } } - public WidgetPropertyDto getNullableByKey(Long propertyId) { + public WidgetPropertyDto selectByKey(Long propertyId) { DbSession session = myBatis.openSession(false); try { - return getNullableByKey(session, propertyId); + return selectByKey(session, propertyId); } finally { MyBatis.closeQuietly(session); } } - public WidgetPropertyDto getNullableByKey(DbSession session, Long propertyId) { + public WidgetPropertyDto selectByKey(DbSession session, Long propertyId) { return mapper(session).selectById(propertyId); } - public Collection<WidgetPropertyDto> findByDashboard(DbSession session, long dashboardKey) { + public Collection<WidgetPropertyDto> selectByDashboard(DbSession session, long dashboardKey) { return mapper(session).selectByDashboard(dashboardKey); } diff --git a/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDao.java b/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDao.java index 789c94a1f12..f31d469a328 100644 --- a/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDao.java +++ b/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDao.java @@ -140,14 +140,14 @@ public class CharacteristicDao implements Dao { public CharacteristicDto selectById(int id) { SqlSession session = mybatis.openSession(false); try { - return selectById(id, session); + return selectById(session, id); } finally { MyBatis.closeQuietly(session); } } @CheckForNull - public CharacteristicDto selectById(int id, SqlSession session) { + public CharacteristicDto selectById(SqlSession session, int id) { return session.getMapper(CharacteristicMapper.class).selectById(id); } @@ -155,14 +155,14 @@ public class CharacteristicDao implements Dao { public CharacteristicDto selectByName(String name) { SqlSession session = mybatis.openSession(false); try { - return selectByName(name, session); + return selectByName(session, name); } finally { MyBatis.closeQuietly(session); } } @CheckForNull - public CharacteristicDto selectByName(String name, SqlSession session) { + public CharacteristicDto selectByName(SqlSession session, String name) { return session.getMapper(CharacteristicMapper.class).selectByName(name); } @@ -180,14 +180,14 @@ public class CharacteristicDao implements Dao { return result != null ? result : 0; } - public void insert(CharacteristicDto dto, SqlSession session) { + public void insert(SqlSession session, CharacteristicDto dto) { session.getMapper(CharacteristicMapper.class).insert(dto); } public void insert(CharacteristicDto dto) { SqlSession session = mybatis.openSession(false); try { - insert(dto, session); + insert(session, dto); session.commit(); } finally { MyBatis.closeQuietly(session); @@ -196,7 +196,7 @@ public class CharacteristicDao implements Dao { public void insert(DbSession session, Collection<CharacteristicDto> items) { for (CharacteristicDto item : items) { - insert(item, session); + insert(session, item); } } 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 index 5c061ad2407..b925c34b6ae 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDao.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanDao.java @@ -68,7 +68,7 @@ public class ActionPlanDao implements Dao { } } - public ActionPlanDto findByKey(String key) { + public ActionPlanDto selectByKey(String key) { SqlSession session = mybatis.openSession(false); try { return session.getMapper(ActionPlanMapper.class).findByKey(key); @@ -77,7 +77,7 @@ public class ActionPlanDao implements Dao { } } - public List<ActionPlanDto> findByKeys(Collection<String> keys) { + public List<ActionPlanDto> selectByKeys(Collection<String> keys) { if (keys.isEmpty()) { return Collections.emptyList(); } @@ -95,7 +95,7 @@ public class ActionPlanDao implements Dao { } } - public List<ActionPlanDto> findOpenByProjectId(Long projectId) { + public List<ActionPlanDto> selectOpenByProjectId(Long projectId) { SqlSession session = mybatis.openSession(false); try { return session.getMapper(ActionPlanMapper.class).findOpenByProjectId(projectId); @@ -104,7 +104,7 @@ public class ActionPlanDao implements Dao { } } - public List<ActionPlanDto> findByNameAndProjectId(String name, Long projectId) { + public List<ActionPlanDto> selectByNameAndProjectId(String name, Long projectId) { SqlSession session = mybatis.openSession(false); try { return session.getMapper(ActionPlanMapper.class).findByNameAndProjectId(name, 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 index 4d653374b5c..57aa87a1dd3 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsDao.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/ActionPlanStatsDao.java @@ -32,7 +32,7 @@ public class ActionPlanStatsDao extends AbstractDao { super(myBatis, system2); } - public List<ActionPlanStatsDto> findByProjectId(Long projectId) { + public List<ActionPlanStatsDto> selectByProjectId(Long projectId) { SqlSession session = myBatis().openSession(false); try { return session.getMapper(ActionPlanStatsMapper.class).findByProjectId(projectId); diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterDao.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterDao.java index 6d187866547..bdb26dfa746 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterDao.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterDao.java @@ -39,7 +39,7 @@ public class IssueFilterDao implements Dao { SqlSession session = mybatis.openSession(false); try { session.getMapper(IssueFilterMapper.class); - return getMapper(session).selectById(id); + return mapper(session).selectById(id); } finally { MyBatis.closeQuietly(session); } @@ -48,7 +48,7 @@ public class IssueFilterDao implements Dao { public List<IssueFilterDto> selectByUser(String user) { SqlSession session = mybatis.openSession(false); try { - return getMapper(session).selectByUser(user); + return mapper(session).selectByUser(user); } finally { MyBatis.closeQuietly(session); } @@ -57,7 +57,7 @@ public class IssueFilterDao implements Dao { public List<IssueFilterDto> selectFavoriteFiltersByUser(String user) { SqlSession session = mybatis.openSession(false); try { - return getMapper(session).selectFavoriteFiltersByUser(user); + return mapper(session).selectFavoriteFiltersByUser(user); } finally { MyBatis.closeQuietly(session); } @@ -66,7 +66,7 @@ public class IssueFilterDao implements Dao { public IssueFilterDto selectProvidedFilterByName(String name) { SqlSession session = mybatis.openSession(false); try { - return getMapper(session).selectProvidedFilterByName(name); + return mapper(session).selectProvidedFilterByName(name); } finally { MyBatis.closeQuietly(session); } @@ -75,7 +75,7 @@ public class IssueFilterDao implements Dao { public List<IssueFilterDto> selectSharedFilters() { SqlSession session = mybatis.openSession(false); try { - return getMapper(session).selectSharedFilters(); + return mapper(session).selectSharedFilters(); } finally { MyBatis.closeQuietly(session); } @@ -84,7 +84,7 @@ public class IssueFilterDao implements Dao { public void insert(IssueFilterDto filter) { SqlSession session = mybatis.openSession(false); try { - getMapper(session).insert(filter); + mapper(session).insert(filter); session.commit(); } finally { MyBatis.closeQuietly(session); @@ -94,7 +94,7 @@ public class IssueFilterDao implements Dao { public void update(IssueFilterDto filter) { SqlSession session = mybatis.openSession(false); try { - getMapper(session).update(filter); + mapper(session).update(filter); session.commit(); } finally { MyBatis.closeQuietly(session); @@ -104,14 +104,14 @@ public class IssueFilterDao implements Dao { public void delete(long id) { SqlSession session = mybatis.openSession(false); try { - getMapper(session).delete(id); + mapper(session).delete(id); session.commit(); } finally { MyBatis.closeQuietly(session); } } - private IssueFilterMapper getMapper(SqlSession session) { + private IssueFilterMapper mapper(SqlSession session) { return session.getMapper(IssueFilterMapper.class); } } diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteDao.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteDao.java index 7f1f06ce324..7e7e20b634b 100644 --- a/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteDao.java +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueFilterFavouriteDao.java @@ -36,7 +36,7 @@ public class IssueFilterFavouriteDao implements Dao { public IssueFilterFavouriteDto selectById(long id) { SqlSession session = mybatis.openSession(false); try { - return getMapper(session).selectById(id); + return mapper(session).selectById(id); } finally { MyBatis.closeQuietly(session); } @@ -45,7 +45,7 @@ public class IssueFilterFavouriteDao implements Dao { public List<IssueFilterFavouriteDto> selectByFilterId(long filterId) { SqlSession session = mybatis.openSession(false); try { - return getMapper(session).selectByFilterId(filterId); + return mapper(session).selectByFilterId(filterId); } finally { MyBatis.closeQuietly(session); } @@ -54,7 +54,7 @@ public class IssueFilterFavouriteDao implements Dao { public void insert(IssueFilterFavouriteDto filter) { SqlSession session = mybatis.openSession(false); try { - getMapper(session).insert(filter); + mapper(session).insert(filter); session.commit(); } finally { MyBatis.closeQuietly(session); @@ -64,7 +64,7 @@ public class IssueFilterFavouriteDao implements Dao { public void delete(long id) { SqlSession session = mybatis.openSession(false); try { - getMapper(session).delete(id); + mapper(session).delete(id); session.commit(); } finally { MyBatis.closeQuietly(session); @@ -74,14 +74,14 @@ public class IssueFilterFavouriteDao implements Dao { public void deleteByFilterId(long filterId) { SqlSession session = mybatis.openSession(false); try { - getMapper(session).deleteByFilterId(filterId); + mapper(session).deleteByFilterId(filterId); session.commit(); } finally { MyBatis.closeQuietly(session); } } - private IssueFilterFavouriteMapper getMapper(SqlSession session) { + private IssueFilterFavouriteMapper mapper(SqlSession session) { return session.getMapper(IssueFilterFavouriteMapper.class); } } diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDao.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDao.java index 87280d2ced9..d63bc82197a 100644 --- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDao.java +++ b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDao.java @@ -38,11 +38,11 @@ public class MeasureDao implements Dao { } @CheckForNull - public MeasureDto findByComponentKeyAndMetricKey(DbSession session, String componentKey, String metricKey) { + public MeasureDto selectByComponentKeyAndMetricKey(DbSession session, String componentKey, String metricKey) { return mapper(session).selectByComponentAndMetric(componentKey, metricKey); } - public List<MeasureDto> findByComponentKeyAndMetricKeys(final DbSession session, final String componentKey, List<String> metricKeys) { + public List<MeasureDto> selectByComponentKeyAndMetricKeys(final DbSession session, final String componentKey, List<String> metricKeys) { return DatabaseUtils.executeLargeInputs(metricKeys, new Function<List<String>, List<MeasureDto>>() { @Override public List<MeasureDto> apply(List<String> keys) { diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterDao.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterDao.java index 8b5981caa45..59b916f5e2c 100644 --- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterDao.java +++ b/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterDao.java @@ -30,7 +30,7 @@ public class MeasureFilterDao implements Dao { this.mybatis = mybatis; } - public MeasureFilterDto findSystemFilterByName(String name) { + public MeasureFilterDto selectSystemFilterByName(String name) { SqlSession session = mybatis.openSession(false); try { MeasureFilterMapper mapper = session.getMapper(MeasureFilterMapper.class); diff --git a/sonar-db/src/main/java/org/sonar/db/measure/custom/CustomMeasureDao.java b/sonar-db/src/main/java/org/sonar/db/measure/custom/CustomMeasureDao.java index 28af785ebcd..4abe75f49ef 100644 --- a/sonar-db/src/main/java/org/sonar/db/measure/custom/CustomMeasureDao.java +++ b/sonar-db/src/main/java/org/sonar/db/measure/custom/CustomMeasureDao.java @@ -55,12 +55,12 @@ public class CustomMeasureDao implements Dao { } @CheckForNull - public CustomMeasureDto selectNullableById(DbSession session, long id) { + public CustomMeasureDto selectById(DbSession session, long id) { return mapper(session).selectById(id); } - public CustomMeasureDto selectById(DbSession session, long id) { - CustomMeasureDto customMeasure = selectNullableById(session, id); + public CustomMeasureDto selectOrFail(DbSession session, long id) { + CustomMeasureDto customMeasure = selectById(session, id); if (customMeasure == null) { throw new IllegalArgumentException(String.format("Custom measure '%d' not found.", id)); } diff --git a/sonar-db/src/main/java/org/sonar/db/metric/MetricDao.java b/sonar-db/src/main/java/org/sonar/db/metric/MetricDao.java index 453096efb85..c0178b419e9 100644 --- a/sonar-db/src/main/java/org/sonar/db/metric/MetricDao.java +++ b/sonar-db/src/main/java/org/sonar/db/metric/MetricDao.java @@ -43,11 +43,11 @@ import static com.google.common.collect.Lists.newArrayList; public class MetricDao implements Dao { @CheckForNull - public MetricDto selectNullableByKey(DbSession session, String key) { + public MetricDto selectByKey(DbSession session, String key) { return mapper(session).selectByKey(key); } - public List<MetricDto> selectNullableByKeys(final DbSession session, List<String> keys) { + public List<MetricDto> selectByKeys(final DbSession session, List<String> keys) { return DatabaseUtils.executeLargeInputs(keys, new Function<List<String>, List<MetricDto>>() { @Override public List<MetricDto> apply(@Nonnull List<String> input) { @@ -56,8 +56,8 @@ public class MetricDao implements Dao { }); } - public MetricDto selectByKey(DbSession session, String key) { - MetricDto metric = selectNullableByKey(session, key); + public MetricDto selectOrFailByKey(DbSession session, String key) { + MetricDto metric = selectByKey(session, key); if (metric == null) { throw new IllegalStateException(String.format("Metric key '%s' not found", key)); } diff --git a/sonar-db/src/main/java/org/sonar/db/notification/NotificationQueueDao.java b/sonar-db/src/main/java/org/sonar/db/notification/NotificationQueueDao.java index 6fc69f7818e..8fb47d2fc09 100644 --- a/sonar-db/src/main/java/org/sonar/db/notification/NotificationQueueDao.java +++ b/sonar-db/src/main/java/org/sonar/db/notification/NotificationQueueDao.java @@ -61,7 +61,7 @@ public class NotificationQueueDao implements Dao { } } - public List<NotificationQueueDto> findOldest(int count) { + public List<NotificationQueueDto> selectOldest(int count) { if (count < 1) { return Collections.emptyList(); } diff --git a/sonar-db/src/main/java/org/sonar/db/permission/PermissionFacade.java b/sonar-db/src/main/java/org/sonar/db/permission/PermissionFacade.java index 04ed8e8915a..0f8ac527f31 100644 --- a/sonar-db/src/main/java/org/sonar/db/permission/PermissionFacade.java +++ b/sonar-db/src/main/java/org/sonar/db/permission/PermissionFacade.java @@ -197,7 +197,7 @@ public class PermissionFacade { } public void grantDefaultRoles(DbSession session, Long componentId, String qualifier) { - ResourceDto resource = resourceDao.getResource(componentId, session); + ResourceDto resource = resourceDao.selectResource(componentId, session); String applicablePermissionTemplateKey = getApplicablePermissionTemplateKey(session, resource.getKey(), qualifier); applyPermissionTemplate(session, applicablePermissionTemplateKey, componentId); } diff --git a/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java b/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java index 050f19c1cb4..c18fa8b6c4b 100644 --- a/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java +++ b/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java @@ -142,7 +142,7 @@ public class PermissionTemplateDao implements Dao { } } - public PermissionTemplateDto createPermissionTemplate(String templateName, @Nullable String description, @Nullable String keyPattern) { + public PermissionTemplateDto insertPermissionTemplate(String templateName, @Nullable String description, @Nullable String keyPattern) { Date creationDate = now(); PermissionTemplateDto permissionTemplate = new PermissionTemplateDto() .setName(templateName) @@ -190,7 +190,7 @@ public class PermissionTemplateDao implements Dao { } } - public void addUserPermission(Long templateId, Long userId, String permission) { + public void insertUserPermission(Long templateId, Long userId, String permission) { PermissionTemplateUserDto permissionTemplateUser = new PermissionTemplateUserDto() .setTemplateId(templateId) .setUserId(userId) @@ -206,7 +206,7 @@ public class PermissionTemplateDao implements Dao { } } - public void removeUserPermission(Long templateId, Long userId, String permission) { + public void deleteUserPermission(Long templateId, Long userId, String permission) { PermissionTemplateUserDto permissionTemplateUser = new PermissionTemplateUserDto() .setTemplateId(templateId) .setPermission(permission) @@ -220,7 +220,7 @@ public class PermissionTemplateDao implements Dao { } } - public void addGroupPermission(Long templateId, @Nullable Long groupId, String permission) { + public void insertGroupPermission(Long templateId, @Nullable Long groupId, String permission) { PermissionTemplateGroupDto permissionTemplateGroup = new PermissionTemplateGroupDto() .setTemplateId(templateId) .setPermission(permission) @@ -236,7 +236,7 @@ public class PermissionTemplateDao implements Dao { } } - public void removeGroupPermission(Long templateId, @Nullable Long groupId, String permission) { + public void deleteGroupPermission(Long templateId, @Nullable Long groupId, String permission) { PermissionTemplateGroupDto permissionTemplateGroup = new PermissionTemplateGroupDto() .setTemplateId(templateId) .setPermission(permission) @@ -253,7 +253,7 @@ public class PermissionTemplateDao implements Dao { /** * Remove a group from all templates (used when removing a group) */ - public void removeByGroup(Long groupId, SqlSession session) { + public void deleteByGroup(SqlSession session, Long groupId) { session.getMapper(PermissionTemplateMapper.class).deleteByGroupId(groupId); } diff --git a/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java b/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java index 0855274c3c3..2b2637ed2d4 100644 --- a/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java +++ b/sonar-db/src/main/java/org/sonar/db/property/PropertiesDao.java @@ -54,8 +54,8 @@ public class PropertiesDao implements Dao { * * @return the list of logins (maybe be empty - obviously) */ - public List<String> findUsersForNotification(String notificationDispatcherKey, String notificationChannelKey, - @Nullable String projectUuid) { + public List<String> selectUsersForNotification(String notificationDispatcherKey, String notificationChannelKey, + @Nullable String projectUuid) { SqlSession session = mybatis.openSession(false); PropertiesMapper mapper = session.getMapper(PropertiesMapper.class); try { @@ -65,7 +65,7 @@ public class PropertiesDao implements Dao { } } - public List<String> findNotificationSubscribers(String notificationDispatcherKey, String notificationChannelKey, @Nullable String componentKey) { + public List<String> selectNotificationSubscribers(String notificationDispatcherKey, String notificationChannelKey, @Nullable String componentKey) { SqlSession session = mybatis.openSession(false); PropertiesMapper mapper = session.getMapper(PropertiesMapper.class); try { @@ -156,7 +156,7 @@ public class PropertiesDao implements Dao { return session.getMapper(PropertiesMapper.class).selectByQuery(query); } - public void setProperty(PropertyDto property, SqlSession session) { + public void insertProperty(SqlSession session, PropertyDto property) { PropertiesMapper mapper = session.getMapper(PropertiesMapper.class); PropertyDto persistedProperty = mapper.selectByKey(property); if (persistedProperty != null && !StringUtils.equals(persistedProperty.getValue(), property.getValue())) { @@ -167,10 +167,10 @@ public class PropertiesDao implements Dao { } } - public void setProperty(PropertyDto property) { + public void insertProperty(PropertyDto property) { SqlSession session = mybatis.openSession(false); try { - setProperty(property, session); + insertProperty(session, property); session.commit(); } finally { MyBatis.closeQuietly(session); @@ -246,7 +246,7 @@ public class PropertiesDao implements Dao { } } - public void saveGlobalProperties(Map<String, String> properties) { + public void insertGlobalProperties(Map<String, String> properties) { DbSession session = mybatis.openSession(true); PropertiesMapper mapper = session.getMapper(PropertiesMapper.class); try { diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java index e7d1fe5a945..abd114538ce 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java @@ -227,7 +227,7 @@ public class PurgeDao implements Dao { */ private List<ResourceDto> getProjects(long rootProjectId, SqlSession session) { List<ResourceDto> projects = Lists.newArrayList(); - projects.add(resourceDao.getResource(rootProjectId, session)); + projects.add(resourceDao.selectResource(rootProjectId, session)); projects.addAll(resourceDao.getDescendantProjects(rootProjectId, session)); return projects; } diff --git a/sonar-db/src/main/java/org/sonar/db/qualitygate/QualityGateConditionDao.java b/sonar-db/src/main/java/org/sonar/db/qualitygate/QualityGateConditionDao.java index df5f6886f25..ca6ec6a57aa 100644 --- a/sonar-db/src/main/java/org/sonar/db/qualitygate/QualityGateConditionDao.java +++ b/sonar-db/src/main/java/org/sonar/db/qualitygate/QualityGateConditionDao.java @@ -47,7 +47,7 @@ public class QualityGateConditionDao implements Dao { } public void insert(QualityGateConditionDto newQualityGate, SqlSession session) { - getMapper(session).insert(newQualityGate.setCreatedAt(new Date())); + mapper(session).insert(newQualityGate.setCreatedAt(new Date())); } public Collection<QualityGateConditionDto> selectForQualityGate(long qGateId) { @@ -60,7 +60,7 @@ public class QualityGateConditionDao implements Dao { } public Collection<QualityGateConditionDto> selectForQualityGate(long qGateId, SqlSession session) { - return getMapper(session).selectForQualityGate(qGateId); + return mapper(session).selectForQualityGate(qGateId); } public QualityGateConditionDto selectById(long id) { @@ -73,7 +73,7 @@ public class QualityGateConditionDao implements Dao { } public QualityGateConditionDto selectById(long id, SqlSession session) { - return getMapper(session).selectById(id); + return mapper(session).selectById(id); } public void delete(QualityGateConditionDto qGate) { @@ -87,7 +87,7 @@ public class QualityGateConditionDao implements Dao { } public void delete(QualityGateConditionDto qGate, SqlSession session) { - getMapper(session).delete(qGate.getId()); + mapper(session).delete(qGate.getId()); } public void update(QualityGateConditionDto qGate) { @@ -101,7 +101,7 @@ public class QualityGateConditionDao implements Dao { } public void update(QualityGateConditionDto qGate, SqlSession session) { - getMapper(session).update(qGate.setUpdatedAt(new Date())); + mapper(session).update(qGate.setUpdatedAt(new Date())); } public void deleteConditionsWithInvalidMetrics() { @@ -115,10 +115,10 @@ public class QualityGateConditionDao implements Dao { } public void deleteConditionsWithInvalidMetrics(SqlSession session) { - getMapper(session).deleteConditionsWithInvalidMetrics(); + mapper(session).deleteConditionsWithInvalidMetrics(); } - private QualityGateConditionMapper getMapper(SqlSession session) { + private QualityGateConditionMapper mapper(SqlSession session) { return session.getMapper(QualityGateConditionMapper.class); } } diff --git a/sonar-db/src/main/java/org/sonar/db/qualitygate/QualityGateDao.java b/sonar-db/src/main/java/org/sonar/db/qualitygate/QualityGateDao.java index f6945e54af6..ef1ebc09781 100644 --- a/sonar-db/src/main/java/org/sonar/db/qualitygate/QualityGateDao.java +++ b/sonar-db/src/main/java/org/sonar/db/qualitygate/QualityGateDao.java @@ -21,6 +21,7 @@ package org.sonar.db.qualitygate; import java.util.Collection; import java.util.Date; +import javax.annotation.CheckForNull; import org.apache.ibatis.session.SqlSession; import org.sonar.db.Dao; import org.sonar.db.MyBatis; @@ -44,7 +45,7 @@ public class QualityGateDao implements Dao{ } public void insert(QualityGateDto newQualityGate, SqlSession session) { - getMapper(session).insert(newQualityGate.setCreatedAt(new Date())); + mapper(session).insert(newQualityGate.setCreatedAt(new Date())); } public Collection<QualityGateDto> selectAll() { @@ -57,33 +58,37 @@ public class QualityGateDao implements Dao{ } public Collection<QualityGateDto> selectAll(SqlSession session) { - return getMapper(session).selectAll(); + return mapper(session).selectAll(); } + @CheckForNull public QualityGateDto selectByName(String name) { SqlSession session = myBatis.openSession(false); try { - return selectByName(name, session); + return selectByName(session, name); } finally { MyBatis.closeQuietly(session); } } - public QualityGateDto selectByName(String name, SqlSession session) { - return getMapper(session).selectByName(name); + @CheckForNull + public QualityGateDto selectByName(SqlSession session, String name) { + return mapper(session).selectByName(name); } + @CheckForNull public QualityGateDto selectById(long id) { SqlSession session = myBatis.openSession(false); try { - return selectById(id, session); + return selectById(session, id); } finally { MyBatis.closeQuietly(session); } } - public QualityGateDto selectById(long id, SqlSession session) { - return getMapper(session).selectById(id); + @CheckForNull + public QualityGateDto selectById(SqlSession session, long id) { + return mapper(session).selectById(id); } public void delete(QualityGateDto qGate) { @@ -97,7 +102,7 @@ public class QualityGateDao implements Dao{ } public void delete(QualityGateDto qGate, SqlSession session) { - getMapper(session).delete(qGate.getId()); + mapper(session).delete(qGate.getId()); } public void update(QualityGateDto qGate) { @@ -111,10 +116,10 @@ public class QualityGateDao implements Dao{ } public void update(QualityGateDto qGate, SqlSession session) { - getMapper(session).update(qGate.setUpdatedAt(new Date())); + mapper(session).update(qGate.setUpdatedAt(new Date())); } - private QualityGateMapper getMapper(SqlSession session) { + private QualityGateMapper mapper(SqlSession session) { return session.getMapper(QualityGateMapper.class); } } diff --git a/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java b/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java index a8e38693003..13301240367 100644 --- a/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java +++ b/sonar-db/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java @@ -47,24 +47,24 @@ public class QualityProfileDao implements Dao { } @CheckForNull - public QualityProfileDto getByKey(DbSession session, String key) { - return getMapper(session).selectByKey(key); + public QualityProfileDto selectByKey(DbSession session, String key) { + return mapper(session).selectByKey(key); } - public QualityProfileDto getNonNullByKey(DbSession session, String key) { - QualityProfileDto dto = getByKey(session, key); + public QualityProfileDto selectOrFailByKey(DbSession session, String key) { + QualityProfileDto dto = selectByKey(session, key); if (dto == null) { throw new IllegalArgumentException("Quality profile not found: " + key); } return dto; } - public List<QualityProfileDto> findAll(DbSession session) { - return getMapper(session).selectAll(); + public List<QualityProfileDto> selectAll(DbSession session) { + return mapper(session).selectAll(); } public void insert(DbSession session, QualityProfileDto profile, QualityProfileDto... otherProfiles) { - QualityProfileMapper mapper = getMapper(session); + QualityProfileMapper mapper = mapper(session); doInsert(mapper, profile); for (QualityProfileDto other : otherProfiles) { doInsert(mapper, other); @@ -94,7 +94,7 @@ public class QualityProfileDao implements Dao { } public void update(DbSession session, QualityProfileDto profile, QualityProfileDto... otherProfiles) { - QualityProfileMapper mapper = getMapper(session); + QualityProfileMapper mapper = mapper(session); doUpdate(mapper, profile); for (QualityProfileDto otherProfile : otherProfiles) { doUpdate(mapper, otherProfile); @@ -122,7 +122,7 @@ public class QualityProfileDao implements Dao { } public void delete(DbSession session, QualityProfileDto profile, QualityProfileDto... otherProfiles) { - QualityProfileMapper mapper = getMapper(session); + QualityProfileMapper mapper = mapper(session); doDelete(mapper, profile); for (QualityProfileDto otherProfile : otherProfiles) { doDelete(mapper, otherProfile); @@ -139,7 +139,7 @@ public class QualityProfileDao implements Dao { */ @Deprecated public void delete(int id, DbSession session) { - getMapper(session).delete(id); + mapper(session).delete(id); } /** @@ -158,52 +158,52 @@ public class QualityProfileDao implements Dao { /** * @deprecated Replaced by - * {@link #findAll(DbSession)} + * {@link #selectAll(DbSession)} */ @Deprecated - public List<QualityProfileDto> findAll() { + public List<QualityProfileDto> selectAll() { DbSession session = mybatis.openSession(false); try { - return getMapper(session).selectAll(); + return mapper(session).selectAll(); } finally { MyBatis.closeQuietly(session); } } @CheckForNull - public QualityProfileDto getDefaultProfile(String language, DbSession session) { - return getMapper(session).selectDefaultProfile(language); + public QualityProfileDto selectDefaultProfile(DbSession session, String language) { + return mapper(session).selectDefaultProfile(language); } @CheckForNull - public QualityProfileDto getDefaultProfile(String language) { + public QualityProfileDto selectDefaultProfile(String language) { DbSession session = mybatis.openSession(false); try { - return getDefaultProfile(language, session); + return selectDefaultProfile(session, language); } finally { MyBatis.closeQuietly(session); } } @CheckForNull - public QualityProfileDto getByProjectAndLanguage(long projectId, String language) { + public QualityProfileDto selectByProjectAndLanguage(long projectId, String language) { DbSession session = mybatis.openSession(false); try { - return getMapper(session).selectByProjectIdAndLanguage(projectId, language); + return mapper(session).selectByProjectIdAndLanguage(projectId, language); } finally { MyBatis.closeQuietly(session); } } @CheckForNull - public QualityProfileDto getByProjectAndLanguage(String projectKey, String language, DbSession session) { - return getMapper(session).selectByProjectAndLanguage(projectKey, language); + public QualityProfileDto selectByProjectAndLanguage(DbSession session, String projectKey, String language) { + return mapper(session).selectByProjectAndLanguage(projectKey, language); } - public List<QualityProfileDto> findByLanguage(String language) { + public List<QualityProfileDto> selectByLanguage(String language) { DbSession session = mybatis.openSession(false); try { - return getMapper(session).selectByLanguage(language); + return mapper(session).selectByLanguage(language); } finally { MyBatis.closeQuietly(session); } @@ -211,78 +211,78 @@ public class QualityProfileDao implements Dao { /** * @deprecated Replaced by - * {@link #getByKey(DbSession, String)} + * {@link #selectByKey(DbSession, String)} */ @Deprecated @CheckForNull - public QualityProfileDto getById(int id, DbSession session) { - return getMapper(session).selectById(id); + public QualityProfileDto selectById(DbSession session, int id) { + return mapper(session).selectById(id); } /** * @deprecated Replaced by - * {@link #getByKey(DbSession, String)} + * {@link #selectByKey(DbSession, String)} */ @Deprecated @CheckForNull - public QualityProfileDto getById(int id) { + public QualityProfileDto selectById(int id) { DbSession session = mybatis.openSession(false); try { - return getById(id, session); + return selectById(session, id); } finally { MyBatis.closeQuietly(session); } } @CheckForNull - public QualityProfileDto getParent(String childKey, DbSession session) { - return getMapper(session).selectParent(childKey); + public QualityProfileDto selectParent(DbSession session, String childKey) { + return mapper(session).selectParent(childKey); } @CheckForNull - public QualityProfileDto getParent(String childKey) { + public QualityProfileDto selectParent(String childKey) { DbSession session = mybatis.openSession(false); try { - return getParent(childKey, session); + return selectParent(session, childKey); } finally { MyBatis.closeQuietly(session); } } @CheckForNull - public QualityProfileDto getParentById(int childId, DbSession session) { - return getMapper(session).selectParentById(childId); + public QualityProfileDto selectParentById(DbSession session, int childId) { + return mapper(session).selectParentById(childId); } @CheckForNull - public QualityProfileDto getParentById(int childId) { + public QualityProfileDto selectParentById(int childId) { DbSession session = mybatis.openSession(false); try { - return getParentById(childId, session); + return selectParentById(session, childId); } finally { MyBatis.closeQuietly(session); } } - public List<QualityProfileDto> findChildren(DbSession session, String key) { - return getMapper(session).selectChildren(key); + public List<QualityProfileDto> selectChildren(DbSession session, String key) { + return mapper(session).selectChildren(key); } /** * All descendants, in the top-down order. */ - public List<QualityProfileDto> findDescendants(DbSession session, String key) { + public List<QualityProfileDto> selectDescendants(DbSession session, String key) { List<QualityProfileDto> descendants = Lists.newArrayList(); - for (QualityProfileDto child : findChildren(session, key)) { + for (QualityProfileDto child : selectChildren(session, key)) { descendants.add(child); - descendants.addAll(findDescendants(session, child.getKey())); + descendants.addAll(selectDescendants(session, child.getKey())); } return descendants; } @CheckForNull - public QualityProfileDto getByNameAndLanguage(String name, String language, DbSession session) { - return getMapper(session).selectByNameAndLanguage(name, language); + public QualityProfileDto selectByNameAndLanguage(String name, String language, DbSession session) { + return mapper(session).selectByNameAndLanguage(name, language); } public List<ComponentDto> selectProjects(String profileName, String language) { @@ -295,13 +295,13 @@ public class QualityProfileDao implements Dao { } public List<ComponentDto> selectProjects(String profileName, String language, DbSession session) { - return getMapper(session).selectProjects(profileName, language); + return mapper(session).selectProjects(profileName, language); } public int countProjects(String profileName, String language) { DbSession session = mybatis.openSession(false); try { - return getMapper(session).countProjects(profileName, language); + return mapper(session).countProjects(profileName, language); } finally { MyBatis.closeQuietly(session); } @@ -311,7 +311,7 @@ public class QualityProfileDao implements Dao { DbSession session = mybatis.openSession(false); try { Map<String, Long> countByKey = Maps.newHashMap(); - for (QualityProfileProjectCount count : getMapper(session).countProjectsByProfile()) { + for (QualityProfileProjectCount count : mapper(session).countProjectsByProfile()) { countByKey.put(count.getProfileKey(), count.getProjectCount()); } return countByKey; @@ -321,41 +321,41 @@ public class QualityProfileDao implements Dao { } public void insertProjectProfileAssociation(String projectUuid, String profileKey, DbSession session) { - getMapper(session).insertProjectProfileAssociation(projectUuid, profileKey); + mapper(session).insertProjectProfileAssociation(projectUuid, profileKey); } public void deleteProjectProfileAssociation(String projectUuid, String profileKey, DbSession session) { - getMapper(session).deleteProjectProfileAssociation(projectUuid, profileKey); + mapper(session).deleteProjectProfileAssociation(projectUuid, profileKey); } public void updateProjectProfileAssociation(String projectUuid, String profileKey, DbSession session) { - getMapper(session).updateProjectProfileAssociation(projectUuid, profileKey); + mapper(session).updateProjectProfileAssociation(projectUuid, profileKey); } public void deleteAllProjectProfileAssociation(String profileKey, DbSession session) { - getMapper(session).deleteAllProjectProfileAssociation(profileKey); + mapper(session).deleteAllProjectProfileAssociation(profileKey); } public List<ProjectQprofileAssociationDto> selectSelectedProjects(String profileKey, @Nullable String query, DbSession session) { String nameQuery = sqlQueryString(query); - return getMapper(session).selectSelectedProjects(profileKey, nameQuery); + return mapper(session).selectSelectedProjects(profileKey, nameQuery); } public List<ProjectQprofileAssociationDto> selectDeselectedProjects(String profileKey, @Nullable String query, DbSession session) { String nameQuery = sqlQueryString(query); - return getMapper(session).selectDeselectedProjects(profileKey, nameQuery); + return mapper(session).selectDeselectedProjects(profileKey, nameQuery); } public List<ProjectQprofileAssociationDto> selectProjectAssociations(String profileKey, @Nullable String query, DbSession session) { String nameQuery = sqlQueryString(query); - return getMapper(session).selectProjectAssociations(profileKey, nameQuery); + return mapper(session).selectProjectAssociations(profileKey, nameQuery); } private String sqlQueryString(String query) { return query == null ? "%" : "%" + query.toUpperCase() + "%"; } - private QualityProfileMapper getMapper(DbSession session) { + private QualityProfileMapper mapper(DbSession session) { return session.getMapper(QualityProfileMapper.class); } diff --git a/sonar-db/src/main/java/org/sonar/db/user/AuthorDao.java b/sonar-db/src/main/java/org/sonar/db/user/AuthorDao.java index d062151dd60..63c9ac78167 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/AuthorDao.java +++ b/sonar-db/src/main/java/org/sonar/db/user/AuthorDao.java @@ -102,15 +102,6 @@ public class AuthorDao implements Dao { authorMapper.insert(authorDto); } - public List<String> selectScmAccountsByDeveloperUuids(Collection<String> developerUuid) { - SqlSession session = mybatis.openSession(false); - try { - return selectScmAccountsByDeveloperUuids(session, developerUuid); - } finally { - MyBatis.closeQuietly(session); - } - } - public List<String> selectScmAccountsByDeveloperUuids(final SqlSession session, Collection<String> developerUuids) { return DatabaseUtils.executeLargeInputs(developerUuids, new Function<List<String>, List<String>>() { @Override diff --git a/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java b/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java index a642b77c6b5..a8621e0bf0a 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java +++ b/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java @@ -40,8 +40,8 @@ public class GroupDao implements Dao { this.system = system; } - public GroupDto selectByKey(DbSession session, String key) { - GroupDto group = selectNullableByKey(session, key); + public GroupDto selectOrFailByKey(DbSession session, String key) { + GroupDto group = selectByKey(session, key); if (group == null) { throw new RowNotFoundException(String.format("Could not find a group with name '%s'", key)); } @@ -49,12 +49,12 @@ public class GroupDao implements Dao { } @CheckForNull - public GroupDto selectNullableByKey(DbSession session, String key) { + public GroupDto selectByKey(DbSession session, String key) { return mapper(session).selectByKey(key); } - public GroupDto selectById(DbSession dbSession, long groupId) { - GroupDto group = selectNullableById(dbSession, groupId); + public GroupDto selectOrFailById(DbSession dbSession, long groupId) { + GroupDto group = selectById(dbSession, groupId); if (group == null) { throw new RowNotFoundException(String.format("Could not find a group with id '%d'", groupId)); } @@ -62,7 +62,7 @@ public class GroupDao implements Dao { } @CheckForNull - public GroupDto selectNullableById(DbSession dbSession, long groupId) { + public GroupDto selectById(DbSession dbSession, long groupId) { return mapper(dbSession).selectById(groupId); } @@ -92,14 +92,10 @@ public class GroupDao implements Dao { return item; } - public List<GroupDto> findByUserLogin(DbSession session, String login){ + public List<GroupDto> selectByUserLogin(DbSession session, String login){ return mapper(session).selectByUserLogin(login); } - private GroupMapper mapper(DbSession session) { - return session.getMapper(GroupMapper.class); - } - private String groupSearchToSql(@Nullable String query) { String sql = SQL_WILDCARD; if (query != null) { @@ -109,4 +105,8 @@ public class GroupDao implements Dao { } return sql; } + + private GroupMapper mapper(DbSession session) { + return session.getMapper(GroupMapper.class); + } } diff --git a/sonar-db/src/main/java/org/sonar/db/user/UserDao.java b/sonar-db/src/main/java/org/sonar/db/user/UserDao.java index 4d220bf8a87..643749f6f01 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/UserDao.java +++ b/sonar-db/src/main/java/org/sonar/db/user/UserDao.java @@ -40,16 +40,16 @@ public class UserDao implements Dao { this.system2 = system2; } - public UserDto getUser(long userId) { + public UserDto selectUserById(long userId) { SqlSession session = mybatis.openSession(false); try { - return getUser(userId, session); + return selectUserById(session, userId); } finally { MyBatis.closeQuietly(session); } } - public UserDto getUser(long userId, SqlSession session) { + public UserDto selectUserById(SqlSession session, long userId) { return session.getMapper(UserMapper.class).selectUser(userId); } @@ -175,19 +175,19 @@ public class UserDao implements Dao { } @CheckForNull - public UserDto selectNullableByLogin(DbSession session, String login) { + public UserDto selectByLogin(DbSession session, String login) { return mapper(session).selectByLogin(login); } - public UserDto selectByLogin(DbSession session, String login) { - UserDto user = selectNullableByLogin(session, login); + public UserDto selectOrFailByLogin(DbSession session, String login) { + UserDto user = selectByLogin(session, login); if (user == null) { throw new RowNotFoundException(String.format("User with login '%s' has not been found", login)); } return user; } - public List<UserDto> selectNullableByScmAccountOrLoginOrEmail(DbSession session, String scmAccountOrLoginOrEmail) { + public List<UserDto> selectByScmAccountOrLoginOrEmail(DbSession session, String scmAccountOrLoginOrEmail) { String like = new StringBuilder().append("%") .append(UserDto.SCM_ACCOUNTS_SEPARATOR).append(scmAccountOrLoginOrEmail) .append(UserDto.SCM_ACCOUNTS_SEPARATOR).append("%").toString(); diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java index dde4347b69c..eccbc11f9d9 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java @@ -106,7 +106,7 @@ public class ComponentDaoTest { db.prepareDbUnit(getClass(), "shared.xml"); - underTest.selectNonNullByUuid(db.getSession(), "unknown"); + underTest.selectOrFailByUuid(db.getSession(), "unknown"); } @Test @@ -258,7 +258,7 @@ public class ComponentDaoTest { public void get_by_id() { db.prepareDbUnit(getClass(), "shared.xml"); - assertThat(underTest.selectNonNullById(db.getSession(), 4L)).isNotNull(); + assertThat(underTest.selectOrFailById(db.getSession(), 4L)).isNotNull(); } @Test @@ -274,7 +274,7 @@ public class ComponentDaoTest { public void fail_to_get_by_id_when_project_not_found() { db.prepareDbUnit(getClass(), "shared.xml"); - underTest.selectNonNullById(db.getSession(), 111L); + underTest.selectOrFailById(db.getSession(), 111L); } @Test diff --git a/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java index e9737aada6f..394038e9bb5 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ResourceDaoTest.java @@ -53,7 +53,7 @@ public class ResourceDaoTest { public void get_resource_by_uuid() { dbTester.prepareDbUnit(getClass(), "fixture.xml"); - ResourceDto resource = underTest.getResource("ABCD"); + ResourceDto resource = underTest.selectResource("ABCD"); assertThat(resource.getUuid()).isEqualTo("ABCD"); assertThat(resource.getProjectUuid()).isEqualTo("ABCD"); @@ -74,7 +74,7 @@ public class ResourceDaoTest { ResourceQuery query = ResourceQuery.create().setKey("org.struts:struts-core"); - assertThat(underTest.getResource(query).getKey()).isEqualTo("org.struts:struts-core"); + assertThat(underTest.selectResource(query).getKey()).isEqualTo("org.struts:struts-core"); } @Test @@ -114,11 +114,11 @@ public class ResourceDaoTest { public void should_find_component_by_key() { dbTester.prepareDbUnit(getClass(), "fixture.xml"); - assertThat(underTest.findByKey("org.struts:struts")).isNotNull(); - Component component = underTest.findByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); + assertThat(underTest.selectByKey("org.struts:struts")).isNotNull(); + Component component = underTest.selectByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); assertThat(component).isNotNull(); assertThat(component.path()).isEqualTo("src/org/struts/RequestContext.java"); - assertThat(underTest.findByKey("unknown")).isNull(); + assertThat(underTest.selectByKey("unknown")).isNull(); } @Test diff --git a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java index f1afab1e9aa..815a3bd0e16 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java @@ -47,7 +47,7 @@ public class SnapshotDaoTest { public void get_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - SnapshotDto result = underTest.selectNullableById(db.getSession(), 3L); + SnapshotDto result = underTest.selectById(db.getSession(), 3L); assertThat(result).isNotNull(); assertThat(result.getId()).isEqualTo(3L); assertThat(result.getComponentId()).isEqualTo(3L); @@ -82,7 +82,7 @@ public class SnapshotDaoTest { assertThat(result.getCreatedAt()).isEqualTo(1228172400000L); assertThat(result.getBuildDate()).isEqualTo(1317247200000L); - assertThat(underTest.selectNullableById(db.getSession(), 999L)).isNull(); + assertThat(underTest.selectById(db.getSession(), 999L)).isNull(); } @Test 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 index 3862cbd3a9a..2b95e08d5a4 100644 --- a/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanDaoTest.java @@ -78,7 +78,7 @@ public class ActionPlanDaoTest { public void should_find_by_key() { dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_key.xml"); - ActionPlanDto result = dao.findByKey("ABC"); + ActionPlanDto result = dao.selectByKey("ABC"); assertThat(result).isNotNull(); assertThat(result.getKey()).isEqualTo("ABC"); assertThat(result.getProjectKey()).isEqualTo("org.sonar.Sample"); @@ -88,7 +88,7 @@ public class ActionPlanDaoTest { public void should_find_by_keys() { dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_keys.xml"); - Collection<ActionPlanDto> result = dao.findByKeys(newArrayList("ABC", "ABD", "ABE")); + Collection<ActionPlanDto> result = dao.selectByKeys(newArrayList("ABC", "ABD", "ABE")); assertThat(result).hasSize(3); } @@ -100,7 +100,7 @@ public class ActionPlanDaoTest { for (int i = 0; i < 4500; i++) { hugeNbOKeys.add("ABCD" + i); } - List<ActionPlanDto> result = dao.findByKeys(hugeNbOKeys); + 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(); @@ -110,7 +110,7 @@ public class ActionPlanDaoTest { public void should_find_open_by_project_id() { dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_open_by_project_id.xml"); - Collection<ActionPlanDto> result = dao.findOpenByProjectId(1l); + Collection<ActionPlanDto> result = dao.selectOpenByProjectId(1l); assertThat(result).hasSize(2); } @@ -118,7 +118,7 @@ public class ActionPlanDaoTest { 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.findByNameAndProjectId("SHORT_TERM", 1l); + 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 index 1439cff7017..e2c1f587dbc 100644 --- a/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanStatsDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/issue/ActionPlanStatsDaoTest.java @@ -42,7 +42,7 @@ public class ActionPlanStatsDaoTest { public void should_find_by_project() { dbTester.prepareDbUnit(getClass(), "shared.xml", "should_find_by_project.xml"); - Collection<ActionPlanStatsDto> result = dao.findByProjectId(1l); + Collection<ActionPlanStatsDto> result = dao.selectByProjectId(1l); assertThat(result).isNotEmpty(); ActionPlanStatsDto actionPlanStatsDto = result.iterator().next(); diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java index 196f1cba010..5a8e42922b5 100644 --- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java @@ -48,7 +48,7 @@ public class MeasureDaoTest { public void get_value_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); + MeasureDto result = underTest.selectByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); assertThat(result.getId()).isEqualTo(22); assertThat(result.getValue()).isEqualTo(10d); assertThat(result.getData()).isNull(); @@ -66,7 +66,7 @@ public class MeasureDaoTest { public void get_data_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "authors_by_line"); + MeasureDto result = underTest.selectByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "authors_by_line"); assertThat(result.getId()).isEqualTo(20); assertThat(result.getData()).isEqualTo("0123456789012345678901234567890123456789"); } @@ -75,7 +75,7 @@ public class MeasureDaoTest { public void get_text_value_by_key() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "coverage_line_hits_data"); + MeasureDto result = underTest.selectByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "coverage_line_hits_data"); assertThat(result.getId()).isEqualTo(21); assertThat(result.getData()).isEqualTo("36=1;37=1;38=1;39=1;43=1;48=1;53=1"); } @@ -84,11 +84,11 @@ public class MeasureDaoTest { public void find_by_component_key_and_metrics() { db.prepareDbUnit(getClass(), "shared.xml"); - List<MeasureDto> results = underTest.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", + List<MeasureDto> results = underTest.selectByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc", "authors_by_line")); assertThat(results).hasSize(2); - results = underTest.findByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc")); + results = underTest.selectByComponentKeyAndMetricKeys(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc")); assertThat(results).hasSize(1); MeasureDto result = results.get(0); @@ -107,7 +107,7 @@ public class MeasureDaoTest { public void find_by_component_key_and_metric() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); + MeasureDto result = underTest.selectByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); assertThat(result.getId()).isEqualTo(22); assertThat(result.getValue()).isEqualTo(10d); assertThat(result.getMetricKey()).isEqualTo("ncloc"); @@ -118,7 +118,7 @@ public class MeasureDaoTest { assertThat(result.getVariation(4)).isEqualTo(4d); assertThat(result.getVariation(5)).isEqualTo(-5d); - assertThat(underTest.findByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isNull(); + assertThat(underTest.selectByComponentKeyAndMetricKey(db.getSession(), "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isNull(); } @Test diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java index d48d00835b4..45c511ec26a 100644 --- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java @@ -37,7 +37,7 @@ public class MeasureFilterDaoTest { public void should_find_filter() { db.prepareDbUnit(getClass(), "shared.xml"); - MeasureFilterDto filter = dao.findSystemFilterByName("Projects"); + MeasureFilterDto filter = dao.selectSystemFilterByName("Projects"); assertThat(filter.getId()).isEqualTo(1L); assertThat(filter.getName()).isEqualTo("Projects"); @@ -47,7 +47,7 @@ public class MeasureFilterDaoTest { public void should_not_find_filter() { db.prepareDbUnit(getClass(), "shared.xml"); - assertThat(dao.findSystemFilterByName("Unknown")).isNull(); + assertThat(dao.selectSystemFilterByName("Unknown")).isNull(); } @Test diff --git a/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java index 31307a148b4..7a0805d11d6 100644 --- a/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/measure/custom/CustomMeasureDaoTest.java @@ -59,7 +59,7 @@ public class CustomMeasureDaoTest { underTest.insert(session, measure); - CustomMeasureDto result = underTest.selectById(session, measure.getId()); + CustomMeasureDto result = underTest.selectOrFail(session, measure.getId()); assertThat(result.getId()).isEqualTo(measure.getId()); assertThat(result.getMetricId()).isEqualTo(measure.getMetricId()); assertThat(result.getComponentUuid()).isEqualTo(measure.getComponentUuid()); @@ -75,11 +75,11 @@ public class CustomMeasureDaoTest { public void delete_by_metric_id() { CustomMeasureDto measure = newCustomMeasureDto(); underTest.insert(session, measure); - assertThat(underTest.selectNullableById(session, measure.getId())).isNotNull(); + assertThat(underTest.selectById(session, measure.getId())).isNotNull(); underTest.deleteByMetricIds(session, Arrays.asList(measure.getMetricId())); - assertThat(underTest.selectNullableById(session, measure.getId())).isNull(); + assertThat(underTest.selectById(session, measure.getId())).isNull(); } @Test @@ -90,7 +90,7 @@ public class CustomMeasureDaoTest { underTest.update(session, measure); - assertThat(underTest.selectNullableById(session, measure.getId()).getDescription()).isEqualTo("new-description"); + assertThat(underTest.selectById(session, measure.getId()).getDescription()).isEqualTo("new-description"); } @Test @@ -99,7 +99,7 @@ public class CustomMeasureDaoTest { underTest.insert(session, measure); underTest.delete(session, measure.getId()); - assertThat(underTest.selectNullableById(session, measure.getId())).isNull(); + assertThat(underTest.selectById(session, measure.getId())).isNull(); } @Test @@ -153,7 +153,7 @@ public class CustomMeasureDaoTest { public void select_by_id_fail_if_no_measure_found() { expectedException.expect(IllegalArgumentException.class); - underTest.selectById(session, 42L); + underTest.selectOrFail(session, 42L); } } diff --git a/sonar-db/src/test/java/org/sonar/db/metric/MetricDaoTest.java b/sonar-db/src/test/java/org/sonar/db/metric/MetricDaoTest.java index 162cb647e50..1e1c17b7e62 100644 --- a/sonar-db/src/test/java/org/sonar/db/metric/MetricDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/metric/MetricDaoTest.java @@ -58,7 +58,7 @@ public class MetricDaoTest { public void get_by_key() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - MetricDto result = dao.selectNullableByKey(session, "coverage"); + MetricDto result = dao.selectByKey(session, "coverage"); assertThat(result.getId()).isEqualTo(2); assertThat(result.getKey()).isEqualTo("coverage"); assertThat(result.getShortName()).isEqualTo("Coverage"); @@ -76,21 +76,21 @@ public class MetricDaoTest { assertThat(result.isEnabled()).isTrue(); // Disabled metrics are returned - result = dao.selectNullableByKey(session, "disabled"); + result = dao.selectByKey(session, "disabled"); assertThat(result.getId()).isEqualTo(3); assertThat(result.isEnabled()).isFalse(); } @Test(expected = IllegalStateException.class) public void get_nullable_by_key() { - dao.selectByKey(session, "unknown"); + dao.selectOrFailByKey(session, "unknown"); } @Test public void get_manual_metric() { dbTester.prepareDbUnit(getClass(), "manual_metric.xml"); - MetricDto result = dao.selectNullableByKey(session, "manual"); + MetricDto result = dao.selectByKey(session, "manual"); assertThat(result.getId()).isEqualTo(1); assertThat(result.getKey()).isEqualTo("manual"); assertThat(result.getShortName()).isEqualTo("Manual metric"); @@ -133,7 +133,7 @@ public class MetricDaoTest { .setDeleteHistoricalData(true) .setEnabled(true)); - MetricDto result = dao.selectNullableByKey(session, "coverage"); + MetricDto result = dao.selectByKey(session, "coverage"); assertThat(result.getId()).isNotNull(); assertThat(result.getKey()).isEqualTo("coverage"); assertThat(result.getShortName()).isEqualTo("Coverage"); diff --git a/sonar-db/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java b/sonar-db/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java index f509c63164e..5c8e937aa0d 100644 --- a/sonar-db/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java @@ -46,7 +46,7 @@ public class NotificationQueueDaoTest { dao.insert(Arrays.asList(notificationQueueDto)); assertThat(dao.count()).isEqualTo(1); - assertThat(dao.findOldest(1).get(0).toNotification().getType()).isEqualTo("email"); + assertThat(dao.selectOldest(1).get(0).toNotification().getType()).isEqualTo("email"); } @Test @@ -78,11 +78,11 @@ public class NotificationQueueDaoTest { public void should_findOldest() { db.prepareDbUnit(getClass(), "should_findOldest.xml"); - Collection<NotificationQueueDto> result = dao.findOldest(3); + Collection<NotificationQueueDto> result = dao.selectOldest(3); assertThat(result).hasSize(3); assertThat(result).extracting("id").containsOnly(1L, 2L, 3L); - result = dao.findOldest(6); + result = dao.selectOldest(6); assertThat(result).hasSize(4); } } diff --git a/sonar-db/src/test/java/org/sonar/db/permission/PermissionFacadeTest.java b/sonar-db/src/test/java/org/sonar/db/permission/PermissionFacadeTest.java index 7e61c09fbe2..fb880b68178 100644 --- a/sonar-db/src/test/java/org/sonar/db/permission/PermissionFacadeTest.java +++ b/sonar-db/src/test/java/org/sonar/db/permission/PermissionFacadeTest.java @@ -74,7 +74,7 @@ public class PermissionFacadeTest { assertThat(permissionFacade.selectUserPermissions(dbTester.getSession(), "marius", 123L)).containsOnly("admin"); - assertThat(dbTester.getDbClient().resourceDao().getResource(123L, dbTester.getSession()).getAuthorizationUpdatedAt()).isEqualTo(123456789L); + assertThat(dbTester.getDbClient().resourceDao().selectResource(123L, dbTester.getSession()).getAuthorizationUpdatedAt()).isEqualTo(123456789L); } @Test diff --git a/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java b/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java index 5ba59ca9351..fdb77f761d0 100644 --- a/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java @@ -52,7 +52,7 @@ public class PermissionTemplateDaoTest { Date now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2013-01-02 01:04:05"); when(system.now()).thenReturn(now.getTime()); - PermissionTemplateDto permissionTemplate = permissionTemplateDao.createPermissionTemplate("my template", "my description", "myregexp"); + PermissionTemplateDto permissionTemplate = permissionTemplateDao.insertPermissionTemplate("my template", "my description", "myregexp"); assertThat(permissionTemplate).isNotNull(); assertThat(permissionTemplate.getId()).isEqualTo(1L); @@ -66,7 +66,7 @@ public class PermissionTemplateDaoTest { Date now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2013-01-02 01:04:05"); when(system.now()).thenReturn(now.getTime()); - PermissionTemplateDto permissionTemplate = permissionTemplateDao.createPermissionTemplate("Môü Gnô Gnèçàß", "my description", null); + PermissionTemplateDto permissionTemplate = permissionTemplateDao.insertPermissionTemplate("Môü Gnô Gnèçàß", "my description", null); assertThat(permissionTemplate).isNotNull(); assertThat(permissionTemplate.getId()).isEqualTo(1L); @@ -86,7 +86,7 @@ public class PermissionTemplateDaoTest { when(myBatis.openSession(false)).thenReturn(session); permissionTemplateDao = new PermissionTemplateDao(myBatis, system); - PermissionTemplateDto permissionTemplate = permissionTemplateDao.createPermissionTemplate(PermissionTemplateDto.DEFAULT.getName(), null, null); + PermissionTemplateDto permissionTemplate = permissionTemplateDao.insertPermissionTemplate(PermissionTemplateDto.DEFAULT.getName(), null, null); verify(mapper).insert(permissionTemplate); verify(session).commit(); @@ -176,7 +176,7 @@ public class PermissionTemplateDaoTest { public void should_add_user_permission_to_template() { db.prepareDbUnit(getClass(), "addUserPermissionToTemplate.xml"); - permissionTemplateDao.addUserPermission(1L, 1L, "new_permission"); + permissionTemplateDao.insertUserPermission(1L, 1L, "new_permission"); checkTemplateTables("addUserPermissionToTemplate-result.xml"); } @@ -185,7 +185,7 @@ public class PermissionTemplateDaoTest { public void should_remove_user_permission_from_template() { db.prepareDbUnit(getClass(), "removeUserPermissionFromTemplate.xml"); - permissionTemplateDao.removeUserPermission(1L, 2L, "permission_to_remove"); + permissionTemplateDao.deleteUserPermission(1L, 2L, "permission_to_remove"); checkTemplateTables("removeUserPermissionFromTemplate-result.xml"); } @@ -194,7 +194,7 @@ public class PermissionTemplateDaoTest { public void should_add_group_permission_to_template() { db.prepareDbUnit(getClass(), "addGroupPermissionToTemplate.xml"); - permissionTemplateDao.addGroupPermission(1L, 1L, "new_permission"); + permissionTemplateDao.insertGroupPermission(1L, 1L, "new_permission"); checkTemplateTables("addGroupPermissionToTemplate-result.xml"); } @@ -203,7 +203,7 @@ public class PermissionTemplateDaoTest { public void should_remove_group_permission_from_template() { db.prepareDbUnit(getClass(), "removeGroupPermissionFromTemplate.xml"); - permissionTemplateDao.removeGroupPermission(1L, 2L, "permission_to_remove"); + permissionTemplateDao.deleteGroupPermission(1L, 2L, "permission_to_remove"); checkTemplateTables("removeGroupPermissionFromTemplate-result.xml"); } @@ -212,7 +212,7 @@ public class PermissionTemplateDaoTest { public void remove_by_group() { db.prepareDbUnit(getClass(), "remove_by_group.xml"); - permissionTemplateDao.removeByGroup(2L, db.getSession()); + permissionTemplateDao.deleteByGroup(db.getSession(), 2L); db.getSession().commit(); db.assertDbUnitTable(getClass(), "remove_by_group-result.xml", "permission_templates", "id", "name", "kee", "description"); @@ -222,7 +222,7 @@ public class PermissionTemplateDaoTest { public void should_add_group_permission_with_null_name() { db.prepareDbUnit(getClass(), "addNullGroupPermissionToTemplate.xml"); - permissionTemplateDao.addGroupPermission(1L, null, "new_permission"); + permissionTemplateDao.insertGroupPermission(1L, null, "new_permission"); checkTemplateTables("addNullGroupPermissionToTemplate-result.xml"); } @@ -231,7 +231,7 @@ public class PermissionTemplateDaoTest { public void should_remove_group_permission_with_null_name() { db.prepareDbUnit(getClass(), "removeNullGroupPermissionFromTemplate.xml"); - permissionTemplateDao.removeGroupPermission(1L, null, "permission_to_remove"); + permissionTemplateDao.deleteGroupPermission(1L, null, "permission_to_remove"); checkTemplateTables("removeNullGroupPermissionFromTemplate-result.xml"); } diff --git a/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java b/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java index a36d4846832..71dd8551c4b 100644 --- a/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java @@ -50,24 +50,24 @@ public class PropertiesDaoTest { public void shouldFindUsersForNotification() { dbTester.prepareDbUnit(getClass(), "shouldFindUsersForNotification.xml"); - List<String> users = dao.findUsersForNotification("NewViolations", "Email", null); + List<String> users = dao.selectUsersForNotification("NewViolations", "Email", null); assertThat(users).isEmpty(); - users = dao.findUsersForNotification("NewViolations", "Email", "uuid_78"); + users = dao.selectUsersForNotification("NewViolations", "Email", "uuid_78"); assertThat(users).isEmpty(); - users = dao.findUsersForNotification("NewViolations", "Email", "uuid_45"); + users = dao.selectUsersForNotification("NewViolations", "Email", "uuid_45"); assertThat(users).hasSize(1); assertThat(users).containsOnly("user2"); - users = dao.findUsersForNotification("NewViolations", "Twitter", null); + users = dao.selectUsersForNotification("NewViolations", "Twitter", null); assertThat(users).hasSize(1); assertThat(users).containsOnly("user3"); - users = dao.findUsersForNotification("NewViolations", "Twitter", "uuid_78"); + users = dao.selectUsersForNotification("NewViolations", "Twitter", "uuid_78"); assertThat(users).isEmpty(); - users = dao.findUsersForNotification("NewViolations", "Twitter", "uuid_56"); + users = dao.selectUsersForNotification("NewViolations", "Twitter", "uuid_56"); assertThat(users).hasSize(2); assertThat(users).containsOnly("user1", "user3"); } @@ -77,22 +77,22 @@ public class PropertiesDaoTest { dbTester.prepareDbUnit(getClass(), "findNotificationSubscribers.xml"); // Nobody is subscribed - List<String> users = dao.findNotificationSubscribers("NotSexyDispatcher", "Email", "org.apache:struts"); + List<String> users = dao.selectNotificationSubscribers("NotSexyDispatcher", "Email", "org.apache:struts"); assertThat(users).isEmpty(); // Global subscribers - users = dao.findNotificationSubscribers("DispatcherWithGlobalSubscribers", "Email", "org.apache:struts"); + users = dao.selectNotificationSubscribers("DispatcherWithGlobalSubscribers", "Email", "org.apache:struts"); assertThat(users).containsOnly("simon"); - users = dao.findNotificationSubscribers("DispatcherWithGlobalSubscribers", "Email", null); + users = dao.selectNotificationSubscribers("DispatcherWithGlobalSubscribers", "Email", null); assertThat(users).containsOnly("simon"); // Project subscribers - users = dao.findNotificationSubscribers("DispatcherWithProjectSubscribers", "Email", "org.apache:struts"); + users = dao.selectNotificationSubscribers("DispatcherWithProjectSubscribers", "Email", "org.apache:struts"); assertThat(users).containsOnly("eric"); // Global + Project subscribers - users = dao.findNotificationSubscribers("DispatcherWithGlobalAndProjectSubscribers", "Email", "org.apache:struts"); + users = dao.selectNotificationSubscribers("DispatcherWithGlobalAndProjectSubscribers", "Email", "org.apache:struts"); assertThat(users).containsOnly("eric", "simon"); } @@ -200,10 +200,10 @@ public class PropertiesDaoTest { public void setProperty_update() { dbTester.prepareDbUnit(getClass(), "update.xml"); - dao.setProperty(new PropertyDto().setKey("global.key").setValue("new_global")); - dao.setProperty(new PropertyDto().setKey("project.key").setResourceId(10L).setValue("new_project")); - dao.setProperty(new PropertyDto().setKey("user.key").setUserId(100L).setValue("new_user")); - dao.setProperty(new PropertyDto().setKey("null.value").setValue(null)); + dao.insertProperty(new PropertyDto().setKey("global.key").setValue("new_global")); + dao.insertProperty(new PropertyDto().setKey("project.key").setResourceId(10L).setValue("new_project")); + dao.insertProperty(new PropertyDto().setKey("user.key").setUserId(100L).setValue("new_user")); + dao.insertProperty(new PropertyDto().setKey("null.value").setValue(null)); dbTester.assertDbUnit(getClass(), "update-result.xml", "properties"); } @@ -212,9 +212,9 @@ public class PropertiesDaoTest { public void setProperty_insert() { dbTester.prepareDbUnit(getClass(), "insert.xml"); - dao.setProperty(new PropertyDto().setKey("global.key").setValue("new_global")); - dao.setProperty(new PropertyDto().setKey("project.key").setResourceId(10L).setValue("new_project")); - dao.setProperty(new PropertyDto().setKey("user.key").setUserId(100L).setValue("new_user")); + dao.insertProperty(new PropertyDto().setKey("global.key").setValue("new_global")); + dao.insertProperty(new PropertyDto().setKey("project.key").setResourceId(10L).setValue("new_project")); + dao.insertProperty(new PropertyDto().setKey("user.key").setUserId(100L).setValue("new_user")); dbTester.assertDbUnit(getClass(), "insert-result.xml", "properties"); } @@ -268,7 +268,7 @@ public class PropertiesDaoTest { public void insertGlobalProperties() { dbTester.prepareDbUnit(getClass(), "insertGlobalProperties.xml"); - dao.saveGlobalProperties(ImmutableMap.of("to_be_inserted", "inserted")); + dao.insertGlobalProperties(ImmutableMap.of("to_be_inserted", "inserted")); dbTester.assertDbUnitTable(getClass(), "insertGlobalProperties-result.xml", "properties", "prop_key", "text_value", "resource_id", "user_id"); } @@ -277,7 +277,7 @@ public class PropertiesDaoTest { public void updateGlobalProperties() { dbTester.prepareDbUnit(getClass(), "updateGlobalProperties.xml"); - dao.saveGlobalProperties(ImmutableMap.of("to_be_updated", "updated")); + dao.insertGlobalProperties(ImmutableMap.of("to_be_updated", "updated")); dbTester.assertDbUnitTable(getClass(), "updateGlobalProperties-result.xml", "properties", "prop_key", "text_value", "resource_id", "user_id"); } diff --git a/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java b/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java index 2343d2fd518..3702c6b5755 100644 --- a/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java @@ -92,7 +92,7 @@ public class QualityProfileDaoTest { public void find_all() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - List<QualityProfileDto> dtos = dao.findAll(dbTester.getSession()); + List<QualityProfileDto> dtos = dao.selectAll(dbTester.getSession()); assertThat(dtos).hasSize(2); @@ -113,7 +113,7 @@ public class QualityProfileDaoTest { public void find_all_is_sorted_by_profile_name() { dbTester.prepareDbUnit(getClass(), "select_all_is_sorted_by_profile_name.xml"); - List<QualityProfileDto> dtos = dao.findAll(); + List<QualityProfileDto> dtos = dao.selectAll(); assertThat(dtos).hasSize(3); assertThat(dtos.get(0).getName()).isEqualTo("First"); @@ -125,32 +125,32 @@ public class QualityProfileDaoTest { public void get_default_profile() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - QualityProfileDto java = dao.getDefaultProfile("java"); + QualityProfileDto java = dao.selectDefaultProfile("java"); assertThat(java).isNotNull(); assertThat(java.getKey()).isEqualTo("java_sonar_way"); - assertThat(dao.getDefaultProfile("js")).isNull(); + assertThat(dao.selectDefaultProfile("js")).isNull(); } @Test public void get_by_name_and_language() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - QualityProfileDto dto = dao.getByNameAndLanguage("Sonar Way", "java", dbTester.getSession()); + QualityProfileDto dto = dao.selectByNameAndLanguage("Sonar Way", "java", dbTester.getSession()); assertThat(dto.getId()).isEqualTo(1); assertThat(dto.getName()).isEqualTo("Sonar Way"); assertThat(dto.getLanguage()).isEqualTo("java"); assertThat(dto.getParentKee()).isNull(); - assertThat(dao.getByNameAndLanguage("Sonar Way", "java", dbTester.getSession())).isNotNull(); - assertThat(dao.getByNameAndLanguage("Sonar Way", "unknown", dbTester.getSession())).isNull(); + assertThat(dao.selectByNameAndLanguage("Sonar Way", "java", dbTester.getSession())).isNotNull(); + assertThat(dao.selectByNameAndLanguage("Sonar Way", "unknown", dbTester.getSession())).isNull(); } @Test public void find_by_language() { dbTester.prepareDbUnit(getClass(), "select_by_language.xml"); - List<QualityProfileDto> result = dao.findByLanguage("java"); + List<QualityProfileDto> result = dao.selectByLanguage("java"); assertThat(result).hasSize(2); assertThat(result.get(0).getName()).isEqualTo("Sonar Way 1"); assertThat(result.get(1).getName()).isEqualTo("Sonar Way 2"); @@ -160,20 +160,20 @@ public class QualityProfileDaoTest { public void get_by_id() { dbTester.prepareDbUnit(getClass(), "shared.xml"); - QualityProfileDto dto = dao.getById(1); + QualityProfileDto dto = dao.selectById(1); assertThat(dto.getId()).isEqualTo(1); assertThat(dto.getName()).isEqualTo("Sonar Way"); assertThat(dto.getLanguage()).isEqualTo("java"); assertThat(dto.getParentKee()).isNull(); - assertThat(dao.getById(555)).isNull(); + assertThat(dao.selectById(555)).isNull(); } @Test public void get_parent_by_id() { dbTester.prepareDbUnit(getClass(), "inheritance.xml"); - QualityProfileDto dto = dao.getParentById(1); + QualityProfileDto dto = dao.selectParentById(1); assertThat(dto.getId()).isEqualTo(3); } @@ -181,7 +181,7 @@ public class QualityProfileDaoTest { public void find_children() { dbTester.prepareDbUnit(getClass(), "inheritance.xml"); - List<QualityProfileDto> dtos = dao.findChildren(dbTester.getSession(), "java_parent"); + List<QualityProfileDto> dtos = dao.selectChildren(dbTester.getSession(), "java_parent"); assertThat(dtos).hasSize(2); @@ -225,7 +225,7 @@ public class QualityProfileDaoTest { public void select_by_project_id_and_language() { dbTester.prepareDbUnit(getClass(), "projects.xml"); - QualityProfileDto dto = dao.getByProjectAndLanguage(1L, "java"); + QualityProfileDto dto = dao.selectByProjectAndLanguage(1L, "java"); assertThat(dto.getId()).isEqualTo(1); } @@ -233,10 +233,10 @@ public class QualityProfileDaoTest { public void select_by_project_key_and_language() { dbTester.prepareDbUnit(getClass(), "projects.xml"); - QualityProfileDto dto = dao.getByProjectAndLanguage("org.codehaus.sonar:sonar", "java", dbTester.getSession()); + QualityProfileDto dto = dao.selectByProjectAndLanguage(dbTester.getSession(), "org.codehaus.sonar:sonar", "java"); assertThat(dto.getId()).isEqualTo(1); - assertThat(dao.getByProjectAndLanguage("org.codehaus.sonar:sonar", "unkown", dbTester.getSession())).isNull(); - assertThat(dao.getByProjectAndLanguage("unknown", "java", dbTester.getSession())).isNull(); + assertThat(dao.selectByProjectAndLanguage(dbTester.getSession(), "org.codehaus.sonar:sonar", "unkown")).isNull(); + assertThat(dao.selectByProjectAndLanguage(dbTester.getSession(), "unknown", "java")).isNull(); } } diff --git a/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java b/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java index 4389dc9a5d6..003f0a46ff0 100644 --- a/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java @@ -62,7 +62,7 @@ public class GroupDaoTest { public void select_by_key() { dbTester.prepareDbUnit(getClass(), "select_by_key.xml"); - GroupDto group = new GroupDao(system2).selectByKey(session, "sonar-users"); + GroupDto group = new GroupDao(system2).selectOrFailByKey(session, "sonar-users"); assertThat(group).isNotNull(); assertThat(group.getId()).isEqualTo(1L); assertThat(group.getName()).isEqualTo("sonar-users"); @@ -75,7 +75,7 @@ public class GroupDaoTest { public void select_by_id() { dbTester.prepareDbUnit(getClass(), "select_by_key.xml"); - GroupDto group = new GroupDao(system2).selectById(session, 1L); + GroupDto group = new GroupDao(system2).selectOrFailById(session, 1L); assertThat(group).isNotNull(); assertThat(group.getId()).isEqualTo(1L); assertThat(group.getName()).isEqualTo("sonar-users"); @@ -88,8 +88,8 @@ public class GroupDaoTest { public void find_by_user_login() { dbTester.prepareDbUnit(getClass(), "find_by_user_login.xml"); - assertThat(dao.findByUserLogin(session, "john")).hasSize(2); - assertThat(dao.findByUserLogin(session, "max")).isEmpty(); + assertThat(dao.selectByUserLogin(session, "john")).hasSize(2); + assertThat(dao.selectByUserLogin(session, "max")).isEmpty(); } @Test diff --git a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java index f1f366f6446..de44fe8ba15 100644 --- a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java @@ -68,7 +68,7 @@ public class UserDaoTest { public void selectUserByLogin_ignore_inactive() { db.prepareDbUnit(getClass(), "selectActiveUserByLogin.xml"); - UserDto user = underTest.getUser(50); + UserDto user = underTest.selectUserById(50); assertThat(user.getLogin()).isEqualTo("inactive_user"); user = underTest.selectActiveUserByLogin("inactive_user"); @@ -233,7 +233,7 @@ public class UserDaoTest { underTest.update(db.getSession(), userDto); db.getSession().commit(); - UserDto user = underTest.getUser(1); + UserDto user = underTest.selectUserById(1); assertThat(user).isNotNull(); assertThat(user.getId()).isEqualTo(1L); assertThat(user.getLogin()).isEqualTo("john"); @@ -259,7 +259,7 @@ public class UserDaoTest { assertThat(underTest.selectActiveUserByLogin(login)).isNull(); - UserDto userDto = underTest.getUser(100); + UserDto userDto = underTest.selectUserById(100); assertThat(userDto.isActive()).isFalse(); assertThat(userDto.getUpdatedAt()).isEqualTo(1500000000000L); @@ -283,7 +283,7 @@ public class UserDaoTest { public void select_by_login() { db.prepareDbUnit(getClass(), "select_by_login.xml"); - UserDto dto = underTest.selectByLogin(session, "marius"); + UserDto dto = underTest.selectOrFailByLogin(session, "marius"); assertThat(dto.getId()).isEqualTo(101); assertThat(dto.getLogin()).isEqualTo("marius"); assertThat(dto.getName()).isEqualTo("Marius"); @@ -300,26 +300,26 @@ public class UserDaoTest { public void select_nullable_by_scm_account() { db.prepareDbUnit(getClass(), "select_nullable_by_scm_account.xml"); - List<UserDto> results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "ma"); + List<UserDto> results = underTest.selectByScmAccountOrLoginOrEmail(session, "ma"); assertThat(results).hasSize(1); assertThat(results.get(0).getLogin()).isEqualTo("marius"); - results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "marius"); + results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius"); assertThat(results).hasSize(1); assertThat(results.get(0).getLogin()).isEqualTo("marius"); - results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); + results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); assertThat(results).hasSize(1); assertThat(results.get(0).getLogin()).isEqualTo("marius"); - results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); + results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); assertThat(results).hasSize(1); assertThat(results.get(0).getLogin()).isEqualTo("marius"); - results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "m"); + results = underTest.selectByScmAccountOrLoginOrEmail(session, "m"); assertThat(results).isEmpty(); - results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "unknown"); + results = underTest.selectByScmAccountOrLoginOrEmail(session, "unknown"); assertThat(results).isEmpty(); } @@ -327,14 +327,14 @@ public class UserDaoTest { public void select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users() { db.prepareDbUnit(getClass(), "select_nullable_by_scm_account_return_many_results_when_same_email_is_used_by_many_users.xml"); - List<UserDto> results = underTest.selectNullableByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); + List<UserDto> results = underTest.selectByScmAccountOrLoginOrEmail(session, "marius@lesbronzes.fr"); assertThat(results).hasSize(2); } @Test public void select_by_login_with_unknown_login() { try { - underTest.selectByLogin(session, "unknown"); + underTest.selectOrFailByLogin(session, "unknown"); fail(); } catch (Exception e) { assertThat(e).isInstanceOf(RowNotFoundException.class).hasMessage("User with login 'unknown' has not been found"); @@ -345,8 +345,8 @@ public class UserDaoTest { public void select_nullable_by_login() { db.prepareDbUnit(getClass(), "select_by_login.xml"); - assertThat(underTest.selectNullableByLogin(session, "marius")).isNotNull(); + assertThat(underTest.selectByLogin(session, "marius")).isNotNull(); - assertThat(underTest.selectNullableByLogin(session, "unknown")).isNull(); + assertThat(underTest.selectByLogin(session, "unknown")).isNull(); } } |