diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-18 17:08:30 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-19 20:12:12 +0200 |
commit | 9bfb3bb8b4775294831f38f7ae7aea35416d680b (patch) | |
tree | 13b20ce874b87d5c1dc7a2f715244ee0ea603bc0 /sonar-core | |
parent | 6fbd7d0754de53986bc1d37ae7fd29c8e32872a1 (diff) | |
download | sonarqube-9bfb3bb8b4775294831f38f7ae7aea35416d680b.tar.gz sonarqube-9bfb3bb8b4775294831f38f7ae7aea35416d680b.zip |
SONAR-5007 add single unique key to quality profiles. Replace DB ID.
Diffstat (limited to 'sonar-core')
35 files changed, 382 insertions, 470 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index b6ff97835d5..0a449c778c4 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -33,7 +33,7 @@ import java.util.List; */ public class DatabaseVersion implements BatchComponent, ServerComponent { - public static final int LAST_VERSION = 548; + public static final int LAST_VERSION = 551; public static enum Status { UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL @@ -94,7 +94,7 @@ public class DatabaseVersion implements BatchComponent, ServerComponent { "widgets", "widget_properties", "activities" - ); + ); private MyBatis mybatis; diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java index e438cf7ca03..fa58e882c90 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java @@ -82,6 +82,7 @@ import org.sonar.core.permission.PermissionTemplateGroupDto; import org.sonar.core.permission.PermissionTemplateMapper; import org.sonar.core.permission.PermissionTemplateUserDto; import org.sonar.core.permission.UserWithPermissionDto; +import org.sonar.core.persistence.migration.v44.Migration44Mapper; import org.sonar.core.properties.PropertiesMapper; import org.sonar.core.properties.PropertyDto; import org.sonar.core.purge.PurgeMapper; @@ -214,7 +215,7 @@ public class MyBatis implements BatchComponent, ServerComponent { Class<?>[] mappers = {ActivityMapper.class, ActiveDashboardMapper.class, AuthorMapper.class, DashboardMapper.class, DependencyMapper.class, DuplicationMapper.class, GraphDtoMapper.class, IssueMapper.class, IssueStatsMapper.class, IssueChangeMapper.class, IssueFilterMapper.class, IssueFilterFavouriteMapper.class, - LoadedTemplateMapper.class, MeasureFilterMapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class, + LoadedTemplateMapper.class, MeasureFilterMapper.class, Migration44Mapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class, ResourceKeyUpdaterMapper.class, ResourceIndexerMapper.class, ResourceSnapshotMapper.class, RoleMapper.class, RuleMapper.class, SchemaMigrationMapper.class, SemaphoreMapper.class, UserMapper.class, WidgetMapper.class, WidgetPropertyMapper.class, org.sonar.api.database.model.MeasureMapper.class, SnapshotDataMapper.class, SnapshotSourceMapper.class, ActionPlanMapper.class, ActionPlanStatsMapper.class, diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/Migration44Mapper.java b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/Migration44Mapper.java new file mode 100644 index 00000000000..9016b016318 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/Migration44Mapper.java @@ -0,0 +1,39 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.core.persistence.migration.v44; + +import org.apache.ibatis.annotations.Param; + +import javax.annotation.CheckForNull; +import java.util.Date; +import java.util.List; + +public interface Migration44Mapper { + + // migration of measures "profile" and "profile_version" + List<ProfileMeasure> selectProfileMeasures(); + int selectProfileVersion(long snapshotId); + @CheckForNull Date selectProfileVersionDate(@Param("profileId") long profileId, @Param("profileVersion") int profileVersion); + void updateProfileMeasure(@Param("measureId") long measureId, @Param("json") String json); + + // creation of columns RULES_PROFILES.CREATED_AT and UPDATED_AT + @CheckForNull Date selectProfileCreatedAt(long profileId); + @CheckForNull Date selectProfileUpdatedAt(long profileId); +} diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/ProfileMeasure.java b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/ProfileMeasure.java new file mode 100644 index 00000000000..1e6dd591fb0 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/persistence/migration/v44/ProfileMeasure.java @@ -0,0 +1,50 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.core.persistence.migration.v44; + +public class ProfileMeasure { + private long id; + private int profileId; + private long snapshotId; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public int getProfileId() { + return profileId; + } + + public void setProfileId(int profileId) { + this.profileId = profileId; + } + + public long getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(long snapshotId) { + this.snapshotId = snapshotId; + } +} diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java index 0f3af1f521f..d65e7af2f6f 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java @@ -22,10 +22,15 @@ package org.sonar.core.qualityprofile.db; import org.apache.ibatis.session.SqlSession; import org.sonar.api.ServerComponent; +import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; import java.util.List; +/** + * @deprecated use the ActiveRuleDao class defined in sonar-server + */ +@Deprecated public class ActiveRuleDao implements ServerComponent { private final MyBatis mybatis; @@ -38,12 +43,12 @@ public class ActiveRuleDao implements ServerComponent { session.getMapper(ActiveRuleMapper.class).insert(dto); } - public List<ActiveRuleDto> selectByProfileId(int profileId) { - SqlSession session = mybatis.openSession(false); + public List<ActiveRuleDto> selectByProfileKey(String profileKey) { + DbSession session = mybatis.openSession(false); try { - return session.getMapper(ActiveRuleMapper.class).selectByProfileId(profileId); + return session.getMapper(ActiveRuleMapper.class).selectByProfileKey(profileKey); } finally { - MyBatis.closeQuietly(session); + session.close(); } } @@ -51,12 +56,12 @@ public class ActiveRuleDao implements ServerComponent { session.getMapper(ActiveRuleMapper.class).insertParameter(dto); } - public List<ActiveRuleParamDto> selectParamsByProfileId(int profileId) { - SqlSession session = mybatis.openSession(false); + public List<ActiveRuleParamDto> selectParamsByProfileKey(String profileKey) { + DbSession session = mybatis.openSession(false); try { - return session.getMapper(ActiveRuleMapper.class).selectParamsByProfileId(profileId); + return session.getMapper(ActiveRuleMapper.class).selectParamsByProfileKey(profileKey); } finally { - MyBatis.closeQuietly(session); + session.close(); } } } diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDto.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDto.java index e32ce95917a..8e730d517ef 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDto.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDto.java @@ -41,8 +41,7 @@ public class ActiveRuleDto extends Dto<ActiveRuleKey> { private String repository; private String ruleField; - private String language; - private String profile; + private String profileKey; private Integer id; private Integer profileId; @@ -54,14 +53,12 @@ public class ActiveRuleDto extends Dto<ActiveRuleKey> { public ActiveRuleDto setKey(ActiveRuleKey key) { this.repository = key.ruleKey().repository(); this.ruleField = key.ruleKey().rule(); - this.language = key.qProfile().lang(); - this.profile = key.qProfile().name(); + this.profileKey = key.qProfile(); return this; } public ActiveRuleKey getKey() { - return ActiveRuleKey.of(QualityProfileKey.of(this.profile, this.language), - RuleKey.of(this.repository, this.ruleField)); + return ActiveRuleKey.of(profileKey, RuleKey.of(repository, ruleField)); } // This field do not exists in db, it's only retrieve by joins @@ -144,12 +141,12 @@ public class ActiveRuleDto extends Dto<ActiveRuleKey> { } public static ActiveRuleDto createFor(QualityProfileDto profileDto, RuleDto ruleDto) { - Preconditions.checkArgument(profileDto.getId()!=null, "Profile is not persisted"); - Preconditions.checkArgument(ruleDto.getId()!=null, "Rule is not persisted"); + Preconditions.checkNotNull(profileDto.getId(), "Profile is not persisted"); + Preconditions.checkNotNull(ruleDto.getId(), "Rule is not persisted"); ActiveRuleDto dto = new ActiveRuleDto(); dto.setProfileId(profileDto.getId()); dto.setRuleId(ruleDto.getId()); - dto.setKey(ActiveRuleKey.of(QualityProfileKey.of(profileDto.getName(), profileDto.getLanguage()), ruleDto.getKey())); + dto.setKey(ActiveRuleKey.of(profileDto.getKee(), ruleDto.getKey())); return dto; } @@ -158,5 +155,4 @@ public class ActiveRuleDto extends Dto<ActiveRuleKey> { return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString(); } - } diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleKey.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleKey.java index f71b11413e9..4aa7bc2281c 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleKey.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleKey.java @@ -30,10 +30,10 @@ import java.io.Serializable; */ public class ActiveRuleKey implements Serializable { - private final QualityProfileKey qualityProfileKey; + private final String qualityProfileKey; private final RuleKey ruleKey; - protected ActiveRuleKey(QualityProfileKey qualityProfileKey, RuleKey ruleKey) { + protected ActiveRuleKey(String qualityProfileKey, RuleKey ruleKey) { this.qualityProfileKey = qualityProfileKey; this.ruleKey = ruleKey; } @@ -41,9 +41,9 @@ public class ActiveRuleKey implements Serializable { /** * Create a key. Parameters are NOT null. */ - public static ActiveRuleKey of(QualityProfileKey qualityProfileKey, RuleKey ruleKey) { - Preconditions.checkArgument(qualityProfileKey != null, "QProfile is missing"); - Preconditions.checkArgument(ruleKey != null, "RuleKey is missing key"); + public static ActiveRuleKey of(String qualityProfileKey, RuleKey ruleKey) { + Preconditions.checkNotNull(qualityProfileKey, "QProfile is missing"); + Preconditions.checkNotNull(ruleKey, "RuleKey is missing key"); return new ActiveRuleKey(qualityProfileKey, ruleKey); } @@ -53,9 +53,8 @@ public class ActiveRuleKey implements Serializable { */ public static ActiveRuleKey parse(String s) { String[] split = s.split(":"); - Preconditions.checkArgument(split.length == 4, "Bad format of activeRule key: " + s); - return ActiveRuleKey.of(QualityProfileKey.of(split[0], split[1]), - RuleKey.of(split[2], split[3])); + Preconditions.checkArgument(split.length == 3, "Bad format of activeRule key: " + s); + return ActiveRuleKey.of(split[0], RuleKey.of(split[1], split[2])); } /** @@ -68,7 +67,7 @@ public class ActiveRuleKey implements Serializable { /** * Never null */ - public QualityProfileKey qProfile() { + public String qProfile() { return qualityProfileKey; } @@ -98,11 +97,10 @@ public class ActiveRuleKey implements Serializable { } /** - * Format is "qprofile:rule", for example "Java:squid:AvoidCycle:xpxp" + * Format is "qprofile:rule", for example "12345:squid:AvoidCycle" */ @Override public String toString() { - return String.format("%s:%s", qualityProfileKey.toString(), ruleKey.toString()); + return String.format("%s:%s", qualityProfileKey.toString(), ruleKey.toString()); } } - diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java index 71cd5ba0722..4c3c0773eb5 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleMapper.java @@ -38,9 +38,7 @@ public interface ActiveRuleMapper { List<ActiveRuleDto> selectByRuleId(int ruleId); - List<ActiveRuleDto> selectByProfileId(int profileId); - - List<ActiveRuleDto> selectByProfileKey(QualityProfileKey key); + List<ActiveRuleDto> selectByProfileKey(String key); List<ActiveRuleDto> selectAll(); @@ -57,9 +55,9 @@ public interface ActiveRuleMapper { List<ActiveRuleParamDto> selectParamsByActiveRuleId(int activeRuleId); - List<ActiveRuleParamDto> selectParamsByProfileId(int profileId); + List<ActiveRuleParamDto> selectParamsByProfileKey(String profileKey); - ActiveRuleDto selectByKey(@Param("profile") String profile, @Param("language") String language, + ActiveRuleDto selectByKey(@Param("profileKey") String profileKey, @Param("repository") String repository, @Param("rule") String rule ); List<ActiveRuleParamDto> selectAllParams(); diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java index 8cf36f15f61..25724a1459f 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java @@ -29,6 +29,7 @@ import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; import javax.annotation.CheckForNull; + import java.util.List; public class QualityProfileDao implements ServerComponent, DaoComponent { @@ -40,11 +41,11 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { } @CheckForNull - public QualityProfileDto getByKey(DbSession session, QualityProfileKey key) { - return session.getMapper(QualityProfileMapper.class).selectByNameAndLanguage(key.name(), key.lang()); + public QualityProfileDto getByKey(DbSession session, String key) { + return session.getMapper(QualityProfileMapper.class).selectByKey(key); } - public QualityProfileDto getNonNullByKey(DbSession session, QualityProfileKey key) { + public QualityProfileDto getNonNullByKey(DbSession session, String key) { QualityProfileDto dto = getByKey(session, key); if (dto == null) { throw new IllegalArgumentException("Quality profile not found: " + key); @@ -110,7 +111,6 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { } } - public void delete(DbSession session, QualityProfileDto profile, QualityProfileDto... otherProfiles) { QualityProfileMapper mapper = session.getMapper(QualityProfileMapper.class); doDelete(mapper, profile); @@ -119,7 +119,6 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { } } - private void doDelete(QualityProfileMapper mapper, QualityProfileDto profile) { Preconditions.checkNotNull(profile.getId(), "Quality profile is not persisted"); mapper.delete(profile.getId()); @@ -152,7 +151,7 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { * {@link #findAll(DbSession)} */ @Deprecated - public List<QualityProfileDto> selectAll() { + public List<QualityProfileDto> findAll() { DbSession session = mybatis.openSession(false); try { return session.getMapper(QualityProfileMapper.class).selectAll(); @@ -161,20 +160,23 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { } } - public QualityProfileDto selectDefaultProfile(String language, String key, DbSession session) { - return session.getMapper(QualityProfileMapper.class).selectDefaultProfile(language, key); + @CheckForNull + public QualityProfileDto getDefaultProfile(String language, DbSession session) { + return session.getMapper(QualityProfileMapper.class).selectDefaultProfile(language, String.format("sonar.profile.%s", language)); } - public QualityProfileDto selectDefaultProfile(String language, String key) { + @CheckForNull + public QualityProfileDto getDefaultProfile(String language) { DbSession session = mybatis.openSession(false); try { - return selectDefaultProfile(language, key, session); + return getDefaultProfile(language, session); } finally { MyBatis.closeQuietly(session); } } - public QualityProfileDto selectByProjectAndLanguage(long projectId, String language, String key) { + @CheckForNull + public QualityProfileDto getByProjectAndLanguage(long projectId, String language, String key) { DbSession session = mybatis.openSession(false); try { return session.getMapper(QualityProfileMapper.class).selectByProjectAndLanguage(projectId, language, key); @@ -183,7 +185,7 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { } } - public List<QualityProfileDto> selectByLanguage(String language) { + public List<QualityProfileDto> findByLanguage(String language) { DbSession session = mybatis.openSession(false); try { return session.getMapper(QualityProfileMapper.class).selectByLanguage(language); @@ -194,101 +196,89 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { /** * @deprecated Replaced by - * {@link #getByKey(org.sonar.core.persistence.DbSession, QualityProfileKey)} + * {@link #getByKey(org.sonar.core.persistence.DbSession, String)} */ @Deprecated @CheckForNull - public QualityProfileDto selectById(int id, DbSession session) { + public QualityProfileDto getById(int id, DbSession session) { return session.getMapper(QualityProfileMapper.class).selectById(id); } /** * @deprecated Replaced by - * {@link #getByKey(org.sonar.core.persistence.DbSession, QualityProfileKey)} + * {@link #getByKey(org.sonar.core.persistence.DbSession, String)} */ @Deprecated @CheckForNull - public QualityProfileDto selectById(int id) { + public QualityProfileDto getById(int id) { DbSession session = mybatis.openSession(false); try { - return selectById(id, session); + return getById(id, session); } finally { MyBatis.closeQuietly(session); } } @CheckForNull - public QualityProfileDto selectParent(int childId, DbSession session) { - return session.getMapper(QualityProfileMapper.class).selectParent(childId); + public QualityProfileDto getParent(String childKey, DbSession session) { + return session.getMapper(QualityProfileMapper.class).selectParent(childKey); } @CheckForNull - public QualityProfileDto selectParent(int childId) { + public QualityProfileDto getParent(String childKey) { DbSession session = mybatis.openSession(false); try { - return selectParent(childId, session); + return getParent(childKey, session); } finally { MyBatis.closeQuietly(session); } } - public List<QualityProfileDto> findByParentKey(DbSession session, QualityProfileKey key) { - return session.getMapper(QualityProfileMapper.class).selectChildren(key.name(), key.lang()); + @CheckForNull + public QualityProfileDto getParentById(int childId, DbSession session) { + return session.getMapper(QualityProfileMapper.class).selectParentById(childId); } - /** - * All descendants, in the top-down order. - */ - public List<QualityProfileDto> findDescendants(DbSession session, QualityProfileKey key) { - List<QualityProfileDto> descendants = Lists.newArrayList(); - for (QualityProfileDto child : findByParentKey(session, key)) { - descendants.add(child); - descendants.addAll(findDescendants(session, child.getKey())); + @CheckForNull + public QualityProfileDto getParentById(int childId) { + DbSession session = mybatis.openSession(false); + try { + return getParentById(childId, session); + } finally { + MyBatis.closeQuietly(session); } - return descendants; } - /** - * @deprecated Replaced by - * {@link #findByParentKey(DbSession,QualityProfileKey)} - */ - @Deprecated - public List<QualityProfileDto> selectChildren(String name, String language, DbSession session) { - return session.getMapper(QualityProfileMapper.class).selectChildren(name, language); + public List<QualityProfileDto> findChildren(DbSession session, String key) { + return session.getMapper(QualityProfileMapper.class).selectChildren(key); } /** - * @deprecated Replaced by - * {@link #findByParentKey(DbSession,QualityProfileKey)} + * All descendants, in the top-down order. */ - @Deprecated - public List<QualityProfileDto> selectChildren(String name, String language) { - DbSession session = mybatis.openSession(false); - try { - return selectChildren(name, language, session); - } finally { - MyBatis.closeQuietly(session); + public List<QualityProfileDto> findDescendants(DbSession session, String key) { + List<QualityProfileDto> descendants = Lists.newArrayList(); + for (QualityProfileDto child : findChildren(session, key)) { + descendants.add(child); + descendants.addAll(findDescendants(session, child.getKey())); } + return descendants; } - /** - * @deprecated Replaced by - * {@link #getByKey(org.sonar.core.persistence.DbSession, QualityProfileKey)} - */ - @Deprecated - public QualityProfileDto selectByNameAndLanguage(String name, String language, DbSession session) { + @CheckForNull + public QualityProfileDto getByNameAndLanguage(String name, String language, DbSession session) { return session.getMapper(QualityProfileMapper.class).selectByNameAndLanguage(name, language); } /** * @deprecated Replaced by - * {@link #getByKey(org.sonar.core.persistence.DbSession, QualityProfileKey)} + * {@link #getByNameAndLanguage(String, String, org.sonar.core.persistence.DbSession)} */ @Deprecated - public QualityProfileDto selectByNameAndLanguage(String name, String language) { + public QualityProfileDto getByNameAndLanguage(String name, String language) { DbSession session = mybatis.openSession(false); try { - return selectByNameAndLanguage(name, language, session); + return getByNameAndLanguage(name, language, session); } finally { MyBatis.closeQuietly(session); } @@ -315,14 +305,4 @@ public class QualityProfileDao implements ServerComponent, DaoComponent { MyBatis.closeQuietly(session); } } - - public void updateUsedColumn(int profileId, boolean used) { - DbSession session = mybatis.openSession(false); - try { - session.getMapper(QualityProfileMapper.class).updatedUsedColumn(profileId, used); - session.commit(); - } finally { - MyBatis.closeQuietly(session); - } - } } diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDto.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDto.java index 56262219af3..992b8a7f57a 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDto.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDto.java @@ -25,17 +25,16 @@ import org.sonar.core.persistence.Dto; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -public class QualityProfileDto extends Dto<QualityProfileKey> { +public class QualityProfileDto extends Dto<String> { private Integer id; + private String kee; private String name; private String language; - private String parent; - private Integer version; - private boolean used; + private String parentKee; /** - * @deprecated use {@link #createFor(String, String)} + * @deprecated use {@link #createFor(String)} */ @Deprecated public QualityProfileDto() { @@ -43,8 +42,21 @@ public class QualityProfileDto extends Dto<QualityProfileKey> { } @Override - public QualityProfileKey getKey() { - return QualityProfileKey.of(this.getName(), this.getLanguage()); + public String getKey() { + return kee; + } + + public QualityProfileDto setKey(String s) { + return setKee(s); + } + + public String getKee() { + return kee; + } + + public QualityProfileDto setKee(String s) { + this.kee = s; + return this; } public Integer getId() { @@ -75,52 +87,16 @@ public class QualityProfileDto extends Dto<QualityProfileKey> { } @CheckForNull - public String getParent() { - return parent; - } - - @CheckForNull - public QualityProfileKey getParentKey() { - if (getParent() != null && !getParent().isEmpty()) { - return QualityProfileKey.of(this.getParent(), this.getLanguage()); - } else { - return null; - } + public String getParentKee() { + return parentKee; } - - public QualityProfileDto setParent(@Nullable String parent) { - this.parent = parent; + public QualityProfileDto setParentKee(@Nullable String s) { + this.parentKee = s; return this; } - public Integer getVersion() { - return version; - } - - public QualityProfileDto setVersion(Integer version) { - this.version = version; - return this; - } - - public boolean isUsed() { - return used; - } - - public QualityProfileDto setUsed(boolean used) { - this.used = used; - return this; - } - - public static QualityProfileDto createFor(String name, String language) { - return new QualityProfileDto() - .setName(name) - .setLanguage(language) - .setUsed(false) - .setVersion(1); - } - - public static QualityProfileDto createFor(QualityProfileKey key) { - return createFor(key.name(), key.lang()); + public static QualityProfileDto createFor(String key) { + return new QualityProfileDto().setKee(key); } } diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileKey.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileKey.java deleted file mode 100644 index 7f59ecf5e6d..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileKey.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.core.qualityprofile.db; - -import com.google.common.base.Preconditions; -import com.google.common.base.Strings; - -import java.io.Serializable; - -/** - * - * @since 4.4 - */ -public class QualityProfileKey implements Serializable{ - private final String name, lang; - - private QualityProfileKey(String name, String lang) { - this.lang = lang; - this.name = name; - } - - /** - * Create a key. Parameters are NOT null. - */ - public static QualityProfileKey of(String name, String lang) { - Preconditions.checkArgument(!Strings.isNullOrEmpty(name), "Name must be set"); - Preconditions.checkArgument(!Strings.isNullOrEmpty(lang), "Lang must be set"); - return new QualityProfileKey(name, lang); - } - - /** - * Create a key from a string representation (see {@link #toString()}. An {@link IllegalArgumentException} is raised - * if the format is not valid. - */ - public static QualityProfileKey parse(String s) { - String[] split = s.trim().split(":"); - Preconditions.checkArgument(split.length == 2, "Bad format of QualityProfileKey: " + s); - return QualityProfileKey.of(split[0], split[1]); - } - - /** - * Never null - */ - public String lang() { - return lang; - } - - /** - * Never null - */ - public String name() { - return name; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - QualityProfileKey qualityProfileKey = (QualityProfileKey) o; - if (!lang.equals(qualityProfileKey.lang)) { - return false; - } - if (!name.equals(qualityProfileKey.name)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int result = name.hashCode(); - result = 31 * result + lang.hashCode(); - return result; - } - - /** - * Format is "profile:lang", for example "Java:javascript" - */ - @Override - public String toString() { - return String.format("%s:%s", name, lang); - } -} diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java index 547ad9d8cb6..3acfe871727 100644 --- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileMapper.java @@ -38,7 +38,7 @@ public interface QualityProfileMapper { List<QualityProfileDto> selectAll(); @CheckForNull - QualityProfileDto selectDefaultProfile(@Param("language") String language, @Param("key") String key); + QualityProfileDto selectDefaultProfile(@Param("language") String language, @Param("propKey") String propKey); @CheckForNull QualityProfileDto selectByNameAndLanguage(@Param("name") String name, @Param("language") String language); @@ -46,14 +46,20 @@ public interface QualityProfileMapper { @CheckForNull QualityProfileDto selectById(@Param("id") Integer id); + @CheckForNull + QualityProfileDto selectByKey(String key); + List<QualityProfileDto> selectByLanguage(String language); // INHERITANCE @CheckForNull - QualityProfileDto selectParent(@Param("childId") Integer childId); + QualityProfileDto selectParent(String childKey); - List<QualityProfileDto> selectChildren(@Param("name") String name, @Param("language") String language); + @CheckForNull + QualityProfileDto selectParentById(int childId); + + List<QualityProfileDto> selectChildren(String key); // PROJECTS @@ -62,6 +68,4 @@ public interface QualityProfileMapper { int countProjects(@Param("value") String propertyValue, @Param("key") String propertyKey); QualityProfileDto selectByProjectAndLanguage(@Param("projectId") Long projectId, @Param("language") String language, @Param("key") String propertyKeyPrefix); - - void updatedUsedColumn(@Param("id") int profileId, @Param("used") boolean used); } diff --git a/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java b/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java index faf3b1c89c0..db7d9b128fb 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java +++ b/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; import org.apache.ibatis.session.SqlSession; import org.sonar.api.ServerComponent; +import org.sonar.core.persistence.DaoComponent; import org.sonar.core.persistence.MyBatis; import javax.annotation.Nullable; @@ -35,7 +36,7 @@ import java.util.Set; import static com.google.common.collect.Maps.newHashMap; -public class AuthorizationDao implements ServerComponent { +public class AuthorizationDao implements ServerComponent, DaoComponent { private final MyBatis mybatis; diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/migration/v44/Migration44Mapper.xml b/sonar-core/src/main/resources/org/sonar/core/persistence/migration/v44/Migration44Mapper.xml new file mode 100644 index 00000000000..a4ebc00c627 --- /dev/null +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/migration/v44/Migration44Mapper.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + +<mapper namespace="org.sonar.core.persistence.migration.v44.Migration44Mapper"> + + <select id="selectProfileMeasures" resultType="org.sonar.core.persistence.migration.v44.ProfileMeasure"> + select pm.id as id, pm.value as profileId, pm.snapshot_id as snapshotId + from project_measures pm + inner join metrics m on m.id=pm.metric_id and m.name='profile' + inner join snapshots s on s.islast=#{_true} and pm.snapshot_id=s.id and s.scope='PRJ' + where pm.value is not null + </select> + + <select id="selectProfileVersion" resultType="int" parameterType="long"> + select pm.value from project_measures pm + inner join metrics m on m.id=pm.metric_id and m.name='profile_version' + inner join snapshots s on pm.snapshot_id=s.id + where pm.value is not null and s.id=#{id} + </select> + + <select id="selectProfileVersionDate" resultType="date" parameterType="map"> + select max(change_date) from active_rule_changes + where profile_id=#{profileId} and profile_version=#{profileVersion} + </select> + + <update id="updateProfileMeasure" parameterType="map"> + update project_measures + set text_value=#{json}, value=null + where id=#{measureId} + </update> + + <select id="selectProfileUpdateAt" resultType="date" parameterType="long"> + select max(change_date) from active_rule_changes + where profile_id=#{id} + </select> + + <select id="selectProfileCreatedAt" resultType="date" parameterType="long"> + select min(change_date) from active_rule_changes + where profile_id=#{id} + </select> +</mapper> + diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql index 40529333d55..8b36b94db46 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql @@ -242,6 +242,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('545'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('546'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('547'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('548'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('549'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('551'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl index 9d2566dfb29..3d5c02849c5 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl @@ -49,9 +49,8 @@ CREATE TABLE "RULES_PROFILES" ( "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), "NAME" VARCHAR(100) NOT NULL, "LANGUAGE" VARCHAR(20), - "PARENT_NAME" VARCHAR(100), - "VERSION" INTEGER DEFAULT 1, - "USED_PROFILE" BOOLEAN DEFAULT FALSE + "KEE" VARCHAR(1000) NOT NULL, + "PARENT_KEE" VARCHAR(1000) ); CREATE TABLE "WIDGETS" ( @@ -695,3 +694,5 @@ CREATE UNIQUE INDEX "QUALITY_GATES_UNIQUE" ON "QUALITY_GATES" ("NAME"); CREATE UNIQUE INDEX "ACTIVE_RULES_UNIQUE" ON "ACTIVE_RULES" ("PROFILE_ID","RULE_ID"); CREATE INDEX "SNAPSHOT_DATA_RESOURCE_IDS" ON "SNAPSHOT_DATA" ("RESOURCE_ID"); + +CREATE UNIQUE INDEX "QPROFILE_UNIQUE_KEY" ON "RULES_PROFILES" ("KEE"); diff --git a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml index 4da154a4226..5ff6c7c59fb 100644 --- a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml @@ -11,8 +11,7 @@ a.inheritance as "inheritance", r.plugin_rule_key as "rulefield", r.plugin_name as "repository", - qp.name as profile, - qp.language as language + qp.kee as "profileKey" </sql> <sql id="activeRuleKeyJoin"> @@ -32,7 +31,7 @@ <sql id="activeRuleJoin"> LEFT JOIN rules_profiles qp ON qp.id=a.profile_id - LEFT JOIN rules_profiles profile_parent ON profile_parent.name=qp.parent_name and profile_parent.language=qp.language + LEFT JOIN rules_profiles profile_parent ON profile_parent.kee=qp.parent_kee LEFT JOIN active_rules active_rule_parent ON active_rule_parent.profile_id=profile_parent.id AND a.rule_id=active_rule_parent.rule_id </sql> @@ -40,8 +39,7 @@ SELECT r.plugin_rule_key as "rulefield", r.plugin_name as "repository", - qp.name as "profile", - qp.language as "language" + qp.kee as "profileKey" FROM active_rules a <include refid="activeRuleKeyJoin"/> <where> @@ -63,7 +61,7 @@ WHERE id=#{id} </update> - <update id="delete" parameterType="Integer"> + <update id="delete" parameterType="int" lang="raw"> DELETE FROM active_rules WHERE id=#{id} </update> @@ -79,13 +77,11 @@ </where> </select> - <select id="selectById" parameterType="Integer" resultType="ActiveRule"> + <select id="selectById" parameterType="int" resultType="ActiveRule"> SELECT <include refid="activeRuleColumns"/> FROM active_rules a <include refid="activeRuleJoin"/> - <where> - AND a.id=#{id} - </where> + WHERE a.id=#{id} </select> @@ -94,20 +90,17 @@ <include refid="activeRuleKeyColumns"/> FROM active_rules a <include refid="activeRuleKeyJoin"/> - <where> - AND qp.name = #{profile} - AND qp.language = #{language} + WHERE + qp.kee = #{profileKey} AND r.plugin_rule_key = #{rule} AND r.plugin_name = #{repository} - </where> </select> - <select id="selectByProfileKey" parameterType="map" resultType="ActiveRule"> + <select id="selectByProfileKey" parameterType="string" resultType="ActiveRule"> SELECT <include refid="activeRuleKeyColumns"/> FROM active_rules a <include refid="activeRuleKeyJoin"/> - where qp.name = #{name} - AND qp.language = #{lang} + where qp.kee=#{id} </select> <select id="selectByRuleId" parameterType="Integer" resultType="ActiveRule"> @@ -118,15 +111,6 @@ WHERE a.rule_id=#{ruleId} </select> - <select id="selectByProfileId" parameterType="Integer" resultType="ActiveRule"> - SELECT <include refid="activeRuleColumns"/> - FROM active_rules a - <include refid="activeRuleJoin"/> - <where> - AND a.profile_id=#{profileId} - </where> - </select> - <select id="selectAll" parameterType="map" resultType="ActiveRule"> select <include refid="activeRuleColumns"/> @@ -195,12 +179,13 @@ </where> </select> - <select id="selectParamsByProfileId" parameterType="int" resultType="ActiveRuleParam"> + <select id="selectParamsByProfileKey" parameterType="string" resultType="ActiveRuleParam"> select <include refid="activeRuleParamColumns"/> from active_rule_parameters p inner join active_rules ar on ar.id=p.active_rule_id - where ar.profile_id=#{profileId} + inner join rules_profiles rp on rp.id=ar.profile_id + where rp.kee=#{id} </select> <select id="selectAllParams" resultType="ActiveRuleParam"> diff --git a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml index 370eb6b006a..2593e1a7dbe 100644 --- a/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/QualityProfileMapper.xml @@ -4,30 +4,27 @@ <mapper namespace="org.sonar.core.qualityprofile.db.QualityProfileMapper"> <sql id="profilesColumns"> - p.id, + p.id as id, + p.kee as kee, p.name as name, p.language as language, - p.parent_name as parent, - p.version as version, - p.used_profile as used + p.parent_kee as parentKee </sql> - <insert id="insert" parameterType="QualityProfile" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> - INSERT INTO rules_profiles (name, language, parent_name, version, used_profile) - VALUES (#{name}, #{language}, #{parent}, #{version}, #{used}) + <insert id="insert" parameterType="QualityProfile" keyColumn="id" useGeneratedKeys="true" keyProperty="id" lang="raw"> + INSERT INTO rules_profiles (kee, parent_kee, name, language) + VALUES (#{kee}, #{parentKee}, #{name}, #{language}) </insert> - <update id="update" parameterType="QualityProfile"> + <update id="update" parameterType="QualityProfile" lang="raw"> UPDATE rules_profiles SET name=#{name}, language=#{language}, - parent_name=#{parent}, - version=#{version}, - used_profile=#{used} + parent_kee=#{parentKee} WHERE id=#{id} </update> - <update id="delete" parameterType="Integer"> + <update id="delete" parameterType="int" lang="raw"> DELETE FROM rules_profiles WHERE id=#{id} </update> @@ -40,54 +37,54 @@ <select id="selectByNameAndLanguage" parameterType="map" resultType="QualityProfile"> SELECT <include refid="profilesColumns"/> FROM rules_profiles p - <where> - AND p.name=#{name} - AND p.language=#{language} - </where> + WHERE p.name=#{name} AND p.language=#{language} + </select> + + <select id="selectByKey" parameterType="string" resultType="QualityProfile"> + SELECT <include refid="profilesColumns"/> + FROM rules_profiles p + WHERE p.kee=#{id} </select> <select id="selectByLanguage" parameterType="String" resultType="QualityProfile"> SELECT <include refid="profilesColumns"/> FROM rules_profiles p - <where> - AND p.language=#{language} - </where> + WHERE p.language=#{language} ORDER BY p.name </select> <select id="selectById" parameterType="Integer" resultType="QualityProfile"> SELECT <include refid="profilesColumns"/> FROM rules_profiles p - <where> - AND p.id=#{id} - </where> + WHERE p.id=#{id} </select> - <select id="selectParent" parameterType="Integer" resultType="QualityProfile"> + <select id="selectParent" parameterType="string" resultType="QualityProfile"> SELECT <include refid="profilesColumns"/> FROM rules_profiles p - INNER JOIN rules_profiles child ON child.parent_name=p.name and child.language=p.language and child.id=#{childId} + INNER JOIN rules_profiles child ON child.parent_kee=p.kee AND child.kee=#{id} </select> - <select id="selectChildren" parameterType="map" resultType="QualityProfile"> + <select id="selectParentById" parameterType="int" resultType="QualityProfile"> SELECT <include refid="profilesColumns"/> FROM rules_profiles p - <where> - AND p.parent_name=#{name} - AND p.language=#{language} - </where> + INNER JOIN rules_profiles child ON child.parent_kee=p.kee and child.id=#{id} + </select> + + <select id="selectChildren" parameterType="string" resultType="QualityProfile"> + SELECT <include refid="profilesColumns"/> + FROM rules_profiles p + WHERE p.parent_kee=#{id} ORDER BY p.name </select> - <select id="selectDefaultProfile" parameterType="Integer" resultType="QualityProfile"> + <select id="selectDefaultProfile" parameterType="map" resultType="QualityProfile"> SELECT <include refid="profilesColumns"/> FROM rules_profiles p - INNER JOIN properties prop ON prop.prop_key=#{key} + INNER JOIN properties prop ON prop.prop_key=#{propKey} AND prop.resource_id IS NULL AND prop.text_value LIKE p.name - <where> AND p.language=#{language} - </where> </select> <select id="selectProjects" parameterType="Integer" resultType="Component"> @@ -118,16 +115,8 @@ INNER JOIN properties prop ON prop.resource_id=#{projectId} AND prop.prop_key LIKE #{key} AND prop.text_value LIKE p.name - <where> - AND p.language=#{language} - </where> + WHERE p.language=#{language} </select> - <update id="updatedUsedColumn" parameterType="map"> - UPDATE rules_profiles SET - used_profile=#{used} - WHERE id=#{id} - </update> - </mapper> diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 89586294b3c..a734b36f0eb 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1055,10 +1055,8 @@ widget.description.key=Key widget.description.language=Language widget.description.profile=Profile widget.description.profiles=Profiles -widget.description.profile_version_x=version {0} widget.description.qualitygate=Quality Gate widget.description.alerts=Displays a summary of the project's quality gate status. -widget.description.alerts_rss_feed=RSS Feed widget.description.links=Links widget.events.name=Events diff --git a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java index 30ef5ac5673..2b22304ee20 100644 --- a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest.java @@ -34,7 +34,7 @@ public class ActiveRuleDaoTest extends AbstractDaoTestCase { ActiveRuleDao dao; @Before - public void createDao() { + public void before() { dao = new ActiveRuleDao(getMyBatis()); } @@ -42,7 +42,7 @@ public class ActiveRuleDaoTest extends AbstractDaoTestCase { public void select_by_profile() { setupData("shared"); - List<ActiveRuleDto> result = dao.selectByProfileId(2); + List<ActiveRuleDto> result = dao.selectByProfileKey("parent"); assertThat(result).hasSize(2); } @@ -67,6 +67,6 @@ public class ActiveRuleDaoTest extends AbstractDaoTestCase { public void select_params_by_profile_id() { setupData("shared"); - assertThat(dao.selectParamsByProfileId(1)).hasSize(2); + assertThat(dao.selectParamsByProfileKey("child")).hasSize(2); } } diff --git a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java index d539ddc9e08..ecb8862342f 100644 --- a/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/qualityprofile/db/QualityProfileDaoTest.java @@ -38,17 +38,13 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase { dao = new QualityProfileDao(getMyBatis()); } - @Test public void insert() { setupData("shared"); - QualityProfileDto dto = new QualityProfileDto() - .setName("Sonar Way with Findbugs") - .setLanguage("xoo") - .setParent("Sonar Way") - .setVersion(2) - .setUsed(true); + QualityProfileDto dto = QualityProfileDto.createFor("abcde") + .setName("ABCDE") + .setLanguage("xoo"); dao.insert(dto); @@ -61,11 +57,9 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase { QualityProfileDto dto = new QualityProfileDto() .setId(1) - .setName("New Sonar Way with Findbugs") + .setName("New Name") .setLanguage("js") - .setParent("New Sonar Way") - .setVersion(3) - .setUsed(false); + .setParentKee("fghij"); dao.update(dto); @@ -82,7 +76,7 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase { } @Test - public void select_all() { + public void find_all() { setupData("shared"); DbSession session = getMyBatis().openSession(false); @@ -95,27 +89,23 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase { assertThat(dto1.getId()).isEqualTo(1); assertThat(dto1.getName()).isEqualTo("Sonar Way"); assertThat(dto1.getLanguage()).isEqualTo("java"); - assertThat(dto1.getParent()).isNull(); - assertThat(dto1.getVersion()).isEqualTo(1); - assertThat(dto1.isUsed()).isFalse(); + assertThat(dto1.getParentKee()).isNull(); QualityProfileDto dto2 = dtos.get(1); assertThat(dto2.getId()).isEqualTo(2); assertThat(dto2.getName()).isEqualTo("Sonar Way"); assertThat(dto2.getLanguage()).isEqualTo("js"); - assertThat(dto2.getParent()).isNull(); - assertThat(dto2.getVersion()).isEqualTo(1); - assertThat(dto2.isUsed()).isFalse(); + assertThat(dto2.getParentKee()).isNull(); } finally { session.close(); } } @Test - public void select_all_is_sorted_by_profile_name() { + public void find_all_is_sorted_by_profile_name() { setupData("select_all_is_sorted_by_profile_name"); - List<QualityProfileDto> dtos = dao.selectAll(); + List<QualityProfileDto> dtos = dao.findAll(); assertThat(dtos).hasSize(3); assertThat(dtos.get(0).getName()).isEqualTo("First"); @@ -124,82 +114,86 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase { } @Test - public void select_default_profile() { + public void get_default_profile() { setupData("shared"); - assertThat(dao.selectDefaultProfile("java", "sonar.profile.java")).isNotNull(); - assertThat(dao.selectDefaultProfile("js", "sonar.profile.js")).isNull(); + QualityProfileDto java = dao.getDefaultProfile("java"); + assertThat(java).isNotNull(); + assertThat(java.getKey()).isEqualTo("java_sonar_way"); + + assertThat(dao.getDefaultProfile("js")).isNull(); } @Test - public void select_by_name_and_language() { + public void get_by_name_and_language() { setupData("shared"); - QualityProfileDto dto = dao.selectByNameAndLanguage("Sonar Way", "java"); + QualityProfileDto dto = dao.getByNameAndLanguage("Sonar Way", "java"); assertThat(dto.getId()).isEqualTo(1); assertThat(dto.getName()).isEqualTo("Sonar Way"); assertThat(dto.getLanguage()).isEqualTo("java"); - assertThat(dto.getParent()).isNull(); - assertThat(dto.getVersion()).isEqualTo(1); - assertThat(dto.isUsed()).isFalse(); + assertThat(dto.getParentKee()).isNull(); - assertThat(dao.selectByNameAndLanguage("Sonar Way", "java")).isNotNull(); - assertThat(dao.selectByNameAndLanguage("Sonar Way", "unknown")).isNull(); + assertThat(dao.getByNameAndLanguage("Sonar Way", "java")).isNotNull(); + assertThat(dao.getByNameAndLanguage("Sonar Way", "unknown")).isNull(); } @Test - public void select_by_language() { + public void find_by_language() { setupData("select_by_language"); - List<QualityProfileDto> result = dao.selectByLanguage("java"); + List<QualityProfileDto> result = dao.findByLanguage("java"); assertThat(result).hasSize(2); assertThat(result.get(0).getName()).isEqualTo("Sonar Way 1"); assertThat(result.get(1).getName()).isEqualTo("Sonar Way 2"); } @Test - public void select_by_id() { + public void get_by_id() { setupData("shared"); - QualityProfileDto dto = dao.selectById(1); + QualityProfileDto dto = dao.getById(1); assertThat(dto.getId()).isEqualTo(1); assertThat(dto.getName()).isEqualTo("Sonar Way"); assertThat(dto.getLanguage()).isEqualTo("java"); - assertThat(dto.getParent()).isNull(); - assertThat(dto.getVersion()).isEqualTo(1); - assertThat(dto.isUsed()).isFalse(); + assertThat(dto.getParentKee()).isNull(); - assertThat(dao.selectById(555)).isNull(); + assertThat(dao.getById(555)).isNull(); } @Test - public void select_parent() { + public void get_parent_by_id() { setupData("inheritance"); - QualityProfileDto dto = dao.selectParent(1); + QualityProfileDto dto = dao.getParentById(1); assertThat(dto.getId()).isEqualTo(3); } @Test - public void select_children() { + public void find_children() { setupData("inheritance"); - List<QualityProfileDto> dtos = dao.selectChildren("Parent", "java"); + DbSession session = getMyBatis().openSession(false); + try { + List<QualityProfileDto> dtos = dao.findChildren(session, "java_parent"); + + assertThat(dtos).hasSize(2); - assertThat(dtos).hasSize(2); + QualityProfileDto dto1 = dtos.get(0); + assertThat(dto1.getId()).isEqualTo(1); + assertThat(dto1.getName()).isEqualTo("Child1"); + assertThat(dto1.getLanguage()).isEqualTo("java"); + assertThat(dto1.getParentKee()).isEqualTo("java_parent"); - QualityProfileDto dto1 = dtos.get(0); - assertThat(dto1.getId()).isEqualTo(1); - assertThat(dto1.getName()).isEqualTo("Child1"); - assertThat(dto1.getLanguage()).isEqualTo("java"); - assertThat(dto1.getParent()).isEqualTo("Parent"); - assertThat(dto1.getParentKey().toString()).isEqualTo("Parent:java"); + QualityProfileDto dto2 = dtos.get(1); + assertThat(dto2.getId()).isEqualTo(2); + assertThat(dto2.getName()).isEqualTo("Child2"); + assertThat(dto2.getLanguage()).isEqualTo("java"); + assertThat(dto2.getParentKee()).isEqualTo("java_parent"); - QualityProfileDto dto2 = dtos.get(1); - assertThat(dto2.getId()).isEqualTo(2); - assertThat(dto2.getName()).isEqualTo("Child2"); - assertThat(dto2.getLanguage()).isEqualTo("java"); - assertThat(dto2.getParent()).isEqualTo("Parent"); + } finally { + session.close(); + } } @Test @@ -220,16 +214,7 @@ public class QualityProfileDaoTest extends AbstractDaoTestCase { public void select_by_project_and_language() { setupData("projects"); - QualityProfileDto dto = dao.selectByProjectAndLanguage(1L, "java", "sonar.profile.java"); + QualityProfileDto dto = dao.getByProjectAndLanguage(1L, "java", "sonar.profile.java"); assertThat(dto.getId()).isEqualTo(1); } - - @Test - public void update_used_column() { - setupData("update_used_column"); - - dao.updateUsedColumn(123, true); - - checkTables("update_used_column", "rules_profiles"); - } } diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/multi-modules-with-issues.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/multi-modules-with-issues.xml index 0e4d0a2dfff..66787c61fd8 100644 --- a/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/multi-modules-with-issues.xml +++ b/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/multi-modules-with-issues.xml @@ -23,8 +23,7 @@ <metrics id="2" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]" worst_value="0" optimized_best_value="[true]" best_value="100" direction="1" hidden="[false]" delete_historical_data="[null]"/> - <rules_profiles id="1" name="Sonar way with Findbugs" language="java" parent_name="" version="1" - used_profile="[false]"/> + <rules_profiles id="1" name="Sonar way with Findbugs" language="java" parent_kee="" kee="sonar_way_with_findbugs"/> <projects id="300" kee="struts" root_id="[null]" qualifier="TRK" scope="PRJ" /> <projects id="301" kee="struts-core" root_id="300" qualifier="BRC" scope="PRJ" /> diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database.xml index c787ef6e200..897c196100f 100644 --- a/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database.xml +++ b/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database.xml @@ -4,8 +4,7 @@ <metrics id="2" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]" worst_value="0" optimized_best_value="[true]" best_value="100" direction="1" hidden="[false]" delete_historical_data="[null]"/> - <rules_profiles id="1" name="Sonar way with Findbugs" language="java" parent_name="" version="1" - used_profile="[false]"/> + <rules_profiles id="1" name="Sonar way with Findbugs" language="java" parent_kee="" kee="sonar_way_with_findbugs"/> <projects id="123" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database_with_issues.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database_with_issues.xml index 4f76dd1d7ba..f9e4142991e 100644 --- a/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database_with_issues.xml +++ b/sonar-core/src/test/resources/org/sonar/core/persistence/PreviewDatabaseFactoryTest/should_create_database_with_issues.xml @@ -4,8 +4,7 @@ <metrics id="2" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" enabled="[true]" worst_value="0" optimized_best_value="[true]" best_value="100" direction="1" hidden="[false]" delete_historical_data="[null]"/> - <rules_profiles id="1" name="Sonar way with Findbugs" language="java" parent_name="" version="1" - used_profile="[false]"/> + <rules_profiles id="1" name="Sonar way with Findbugs" language="java" parent_kee="" kee="sonar_way_with_findbugs"/> <projects id="399" kee="struts" root_id="[null]"/> <projects id="400" kee="Action.java" root_id="399"/> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/shared.xml index 629b4d18945..24305b20b2d 100644 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/shared.xml +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/ActiveRuleDaoTest/shared.xml @@ -12,10 +12,8 @@ <active_rule_parameters id="3" active_rule_id="2" rules_parameter_id="1" rules_parameter_key="max" value="15"/> - <rules_profiles id="1" name="Child" language="java" parent_name="Parent" version="1" - used_profile="[false]"/> + <rules_profiles id="1" name="Child" language="java" parent_kee="parent" kee="child"/> - <rules_profiles id="2" name="Parent" language="java" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="2" name="Parent" language="java" parent_kee="[null]" kee="parent"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/delete-result.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/delete-result.xml index 4ee0c55136b..fb2afaf6b07 100644 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/delete-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/delete-result.xml @@ -1,6 +1,5 @@ <dataset> - <rules_profiles id="2" name="Sonar Way" language="js" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/inheritance.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/inheritance.xml index b74e6a003f2..6936254ea4b 100644 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/inheritance.xml +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/inheritance.xml @@ -1,23 +1,17 @@ <dataset> - <rules_profiles id="1" name="Child1" language="java" parent_name="Parent" version="1" - used_profile="[false]"/> + <rules_profiles id="1" name="Child1" language="java" parent_kee="java_parent" kee="java_child1"/> - <rules_profiles id="2" name="Child2" language="java" parent_name="Parent" version="1" - used_profile="[false]"/> + <rules_profiles id="2" name="Child2" language="java" parent_kee="java_parent" kee="java_child2"/> - <rules_profiles id="3" name="Parent" language="java" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="3" name="Parent" language="java" parent_kee="[null]" kee="java_parent"/> <!-- Same profile for another language --> - <rules_profiles id="4" name="Child1" language="js" parent_name="Parent" version="1" - used_profile="[false]"/> + <rules_profiles id="4" name="Child1" language="js" parent_kee="js_parent" kee="js_child1"/> - <rules_profiles id="5" name="Child2" language="js" parent_name="Parent" version="1" - used_profile="[false]"/> + <rules_profiles id="5" name="Child2" language="js" parent_kee="js_parent" kee="js_child2"/> - <rules_profiles id="6" name="Parent" language="js" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="6" name="Parent" language="js" parent_kee="[null]" kee="js_parent"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/insert-result.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/insert-result.xml index 291c7fde5ed..2e66e8d4e86 100644 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/insert-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/insert-result.xml @@ -1,12 +1,10 @@ <dataset> - <rules_profiles id="1" name="Sonar Way" language="java" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="1" name="Sonar Way" language="java" parent_kee="[null]" kee="java_sonar_way"/> - <rules_profiles id="2" name="Sonar Way" language="js" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way"/> + + <rules_profiles id="3" name="ABCDE" language="xoo" parent_kee="[null]" kee="abcde"/> - <rules_profiles id="3" name="Sonar Way with Findbugs" language="xoo" parent_name="Sonar Way" version="2" - used_profile="[true]"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/projects.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/projects.xml index 9605c2377b1..9cda0691474 100644 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/projects.xml +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/projects.xml @@ -1,7 +1,7 @@ <dataset> - <rules_profiles id="1" name="Sonar Way" language="java" parent_name="[null]" version="1" used_profile="[false]"/> - <rules_profiles id="2" name="Sonar Way" language="js" parent_name="[null]" version="1" used_profile="[false]"/> + <rules_profiles id="1" name="Sonar Way" language="java" parent_kee="[null]" kee="java_sonar_way"/> + <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way"/> <projects id="1" kee="org.codehaus.sonar:sonar" name="SonarQube"/> <projects id="2" kee="org.codehaus.sonar-plugins.java:java" name="SonarQube Java"/> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/select_all_is_sorted_by_profile_name.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/select_all_is_sorted_by_profile_name.xml index 563009506cf..d43fbf5aa4d 100644 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/select_all_is_sorted_by_profile_name.xml +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/select_all_is_sorted_by_profile_name.xml @@ -1,12 +1,10 @@ <dataset> - <rules_profiles id="3" name="Third" language="java" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="3" name="Third" language="js" parent_kee="[null]" kee="js_third"/> - <rules_profiles id="1" name="First" language="java" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="1" name="First" language="js" parent_kee="[null]" kee="js_first"/> + + <rules_profiles id="2" name="Second" language="js" parent_kee="[null]" kee="js_second"/> - <rules_profiles id="2" name="Second" language="java" parent_name="[null]" version="1" - used_profile="[false]"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/select_by_language.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/select_by_language.xml index d3c7038e369..552995b1dfb 100644 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/select_by_language.xml +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/select_by_language.xml @@ -1,12 +1,10 @@ <dataset> - <rules_profiles id="1" name="Sonar Way 1" language="java" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="1" name="Sonar Way 1" language="java" parent_kee="[null]" kee="java_sonar_way"/> - <rules_profiles id="2" name="Sonar Way" language="js" parent_name="[null]" version="1" + <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way" used_profile="[false]"/> - <rules_profiles id="3" name="Sonar Way 2" language="java" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="3" name="Sonar Way 2" language="java" parent_kee="[null]" kee="java_sonar_way2"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/shared.xml index e4fd036f631..bfa61fc45bc 100644 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/shared.xml +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/shared.xml @@ -1,10 +1,8 @@ <dataset> - <rules_profiles id="1" name="Sonar Way" language="java" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="1" name="Sonar Way" language="java" parent_kee="[null]" kee="java_sonar_way"/> - <rules_profiles id="2" name="Sonar Way" language="js" parent_name="[null]" version="1" - used_profile="[false]"/> + <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way"/> <properties id="1" prop_key="sonar.profile.java" text_value="Sonar Way" resource_id="[null]"/> <properties id="2" prop_key="sonar.profile.java" text_value="Sonar Way" resource_id="1"/> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update-result.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update-result.xml index 474f8d55e7b..e2455348891 100644 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update-result.xml @@ -1,9 +1,8 @@ <dataset> - <rules_profiles id="1" name="New Sonar Way with Findbugs" language="js" parent_name="New Sonar Way" version="3" - used_profile="[false]"/> + <rules_profiles id="1" name="New Name" language="js" parent_kee="fghij" kee="java_sonar_way"/> + + <rules_profiles id="2" name="Sonar Way" language="js" parent_kee="[null]" kee="js_sonar_way"/> - <rules_profiles id="2" name="Sonar Way" language="js" parent_name="[null]" version="1" - used_profile="[false]"/> </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column-result.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column-result.xml deleted file mode 100644 index 8d050e782ee..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column-result.xml +++ /dev/null @@ -1,6 +0,0 @@ -<dataset> - - <rules_profiles id="123" name="Sonar Way" language="java" parent_name="[null]" version="1" - used_profile="[true]"/> - -</dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column.xml b/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column.xml deleted file mode 100644 index 8b135112f5a..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/qualityprofile/db/QualityProfileDaoTest/update_used_column.xml +++ /dev/null @@ -1,6 +0,0 @@ -<dataset> - - <rules_profiles id="123" name="Sonar Way" language="java" parent_name="[null]" version="1" - used_profile="[false]"/> - -</dataset> |