import java.util.Collection;
import java.util.List;
-import java.util.Optional;
import org.sonar.api.utils.System2;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
return dbSession.getMapper(RuleRepositoryMapper.class).selectByLanguage(language);
}
- public Optional<RuleRepositoryDto> selectByKey(DbSession dbSession, String key) {
- return Optional.ofNullable(dbSession.getMapper(RuleRepositoryMapper.class).selectByKey(key));
- }
-
public void truncate(DbSession dbSession) {
dbSession.getMapper(RuleRepositoryMapper.class).truncate();
}
order by kee
</select>
- <select id="selectByKey" parameterType="String" resultType="org.sonar.db.rule.RuleRepositoryDto">
- select <include refid="sqlColumns"/>
- from rule_repositories
- where kee = #{key}
- </select>
-
<update id="truncate">
delete from rule_repositories
</update>
assertThat(underTest.selectByLanguage(dbSession, "missing")).hasSize(0);
}
- @Test
- public void selectByKey() {
- DbSession dbSession = dbTester.getSession();
- RuleRepositoryDto dto1 = new RuleRepositoryDto("findbugs", "java", "Findbugs");
- underTest.insert(dbSession, asList(dto1));
-
- assertThat(underTest.selectByKey(dbSession, "findbugs").get().getKey()).isEqualTo("findbugs");
- assertThat(underTest.selectByKey(dbSession, "missing")).isNotPresent();
- }
-
@Test
public void truncate() {
DbSession dbSession = dbTester.getSession();