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();
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());
}
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) {
this.name = name;
}
- public String getKee() {
- return kee;
- }
-
- /**
- * Kept for compatibility with ruby code
- */
public String getKey() {
return kee;
}
return name;
}
- public RuleRepositoryDto setKee(String s) {
+ public RuleRepositoryDto setKey(String s) {
this.kee = s;
return this;
}
List<RuleRepositoryDto> 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");
}
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");
}
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");
}
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();
}