From c6d074bc2b2d450a3602b24f10a9dcf0c9b63b3e Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 14 Sep 2016 17:19:46 +0200 Subject: [PATCH] SONAR-8079 drop methods suffixed with "kee" in RuleRepositoryDto --- .../java/org/sonar/server/rule/ws/AppAction.java | 2 +- .../org/sonar/server/rule/ws/RepositoriesAction.java | 4 ++-- .../java/org/sonar/db/rule/RuleRepositoryDto.java | 12 +++--------- .../org/sonar/db/rule/RuleRepositoryDaoTest.java | 8 ++++---- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java index 41f4f6e5fc3..015fe37f35d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java @@ -115,7 +115,7 @@ public class AppAction implements RulesWsAction { dbClient.ruleRepositoryDao() .selectAll(dbSession) .forEach(r -> json.beginObject() - .prop("key", r.getKee()) + .prop("key", r.getKey()) .prop("name", r.getName()) .prop("language", r.getLanguage()) .endObject()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RepositoriesAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RepositoriesAction.java index f1c8462d081..e21a44b874a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RepositoriesAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RepositoriesAction.java @@ -75,7 +75,7 @@ public class RepositoriesAction implements RulesWsAction { for (RuleRepositoryDto repo : listMatchingRepositories(query, languageKey)) { json .beginObject() - .prop("key", repo.getKee()) + .prop("key", repo.getKey()) .prop("name", repo.getName()) .prop(LANGUAGE, repo.getLanguage()) .endObject(); @@ -87,7 +87,7 @@ public class RepositoriesAction implements RulesWsAction { Pattern pattern = Pattern.compile(query == null ? MATCH_ALL : MATCH_ALL + query + MATCH_ALL, Pattern.CASE_INSENSITIVE); return selectFromDb(languageKey).stream() - .filter(r -> pattern.matcher(r.getKee()).matches() || pattern.matcher(r.getName()).matches()) + .filter(r -> pattern.matcher(r.getKey()).matches() || pattern.matcher(r.getName()).matches()) .collect(Collectors.toList()); } diff --git a/sonar-db/src/main/java/org/sonar/db/rule/RuleRepositoryDto.java b/sonar-db/src/main/java/org/sonar/db/rule/RuleRepositoryDto.java index 150c1d3924b..772395b4f88 100644 --- a/sonar-db/src/main/java/org/sonar/db/rule/RuleRepositoryDto.java +++ b/sonar-db/src/main/java/org/sonar/db/rule/RuleRepositoryDto.java @@ -21,12 +21,13 @@ package org.sonar.db.rule; public class RuleRepositoryDto { + // do not rename "key" as MyBatis maps it with the db column "kee" private String kee; private String language; private String name; public RuleRepositoryDto() { - + // used by MyBatis } public RuleRepositoryDto(String kee, String language, String name) { @@ -35,13 +36,6 @@ public class RuleRepositoryDto { this.name = name; } - public String getKee() { - return kee; - } - - /** - * Kept for compatibility with ruby code - */ public String getKey() { return kee; } @@ -54,7 +48,7 @@ public class RuleRepositoryDto { return name; } - public RuleRepositoryDto setKee(String s) { + public RuleRepositoryDto setKey(String s) { this.kee = s; return this; } diff --git a/sonar-db/src/test/java/org/sonar/db/rule/RuleRepositoryDaoTest.java b/sonar-db/src/test/java/org/sonar/db/rule/RuleRepositoryDaoTest.java index 32989ef4807..d50b4497e39 100644 --- a/sonar-db/src/test/java/org/sonar/db/rule/RuleRepositoryDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/rule/RuleRepositoryDaoTest.java @@ -48,7 +48,7 @@ public class RuleRepositoryDaoTest { List rows = underTest.selectAll(dbSession); assertThat(rows).hasSize(1); RuleRepositoryDto row = rows.get(0); - assertThat(row.getKee()).isEqualTo("findbugs"); + assertThat(row.getKey()).isEqualTo("findbugs"); assertThat(row.getName()).isEqualTo("Findbugs"); assertThat(row.getLanguage()).isEqualTo("java"); } @@ -61,7 +61,7 @@ public class RuleRepositoryDaoTest { RuleRepositoryDto dto3 = new RuleRepositoryDto("cobol-lint", "cobol", "Cobol Lint"); underTest.insert(dbSession, asList(dto1, dto2, dto3)); - assertThat(underTest.selectAll(dbSession)).extracting(RuleRepositoryDto::getKee) + assertThat(underTest.selectAll(dbSession)).extracting(RuleRepositoryDto::getKey) // ordered by key .containsExactly("cobol-lint", "findbugs", "squid"); } @@ -74,7 +74,7 @@ public class RuleRepositoryDaoTest { RuleRepositoryDto dto3 = new RuleRepositoryDto("cobol-lint", "cobol", "Cobol Lint"); underTest.insert(dbSession, asList(dto1, dto2, dto3)); - assertThat(underTest.selectByLanguage(dbSession, "java")).extracting(RuleRepositoryDto::getKee) + assertThat(underTest.selectByLanguage(dbSession, "java")).extracting(RuleRepositoryDto::getKey) // ordered by key .containsExactly("findbugs", "squid"); } @@ -94,7 +94,7 @@ public class RuleRepositoryDaoTest { RuleRepositoryDto dto1 = new RuleRepositoryDto("findbugs", "java", "Findbugs"); underTest.insert(dbSession, asList(dto1)); - assertThat(underTest.selectByKey(dbSession, "findbugs").get().getKee()).isEqualTo("findbugs"); + assertThat(underTest.selectByKey(dbSession, "findbugs").get().getKey()).isEqualTo("findbugs"); assertThat(underTest.selectByKey(dbSession, "missing")).isNotPresent(); } -- 2.39.5