]> source.dussan.org Git - sonarqube.git/commitdiff
Fix PermissionTemplateCharacteristicDaoTest
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 17 Oct 2016 10:30:02 +0000 (12:30 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 17 Oct 2016 10:30:26 +0000 (12:30 +0200)
Test was passing for a bad reason: ids of template and
 characteristic were the sames in the test.

sonar-db/src/main/java/org/sonar/db/permission/template/PermissionTemplateCharacteristicMapper.java
sonar-db/src/main/resources/org/sonar/db/permission/template/PermissionTemplateCharacteristicMapper.xml
sonar-db/src/test/java/org/sonar/db/permission/template/PermissionTemplateCharacteristicDaoTest.java

index 801456402b95280230e47b9739fb4792c6b5b3c2..d8e648487e3768e93804ae6710bcf73ef8dc2333 100644 (file)
@@ -24,6 +24,9 @@ import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
 public interface PermissionTemplateCharacteristicMapper {
+
+  PermissionTemplateCharacteristicDto selectById(@Param("id") long id);
+
   List<PermissionTemplateCharacteristicDto> selectByTemplateIds(@Param("templateIds") List<Long> templateId);
 
   PermissionTemplateCharacteristicDto selectByPermissionAndTemplateId(@Param("permission") String permission, @Param("templateId") long templateId);
index 13664b4293e0e3eac90f9abea565aa3fda57cd2c..cd60828514f5884225b7c64b06fc690c0f38d3ee 100644 (file)
     ptc.updated_at as updatedAt
   </sql>
 
+  <select id="selectById" parameterType="long" resultType="PermissionTemplateCharacteristic">
+    select
+    <include refid="columns" />
+    from perm_tpl_characteristics ptc
+    where ptc.id=#{id,jdbcType=BIGINT}
+  </select>
+
   <select id="selectByTemplateIds" parameterType="long" resultType="PermissionTemplateCharacteristic">
     select
     <include refid="columns" />
index 996118eac508e46fbebc0347d1b3da8dccc39cb0..16525797c1ee792a3cec25bcada8624f1dd9d886 100644 (file)
@@ -117,7 +117,7 @@ public class PermissionTemplateCharacteristicDaoTest {
       .setCreatedAt(123_456_789L)
       .setUpdatedAt(2_000_000_000L));
 
-    PermissionTemplateCharacteristicDto result = selectById(expectedResult.getId());
+    PermissionTemplateCharacteristicDto result = dbSession.getMapper(PermissionTemplateCharacteristicMapper.class).selectById(expectedResult.getId());
     assertThat(result.getId()).isNotNull();
     assertThat(result).isEqualToComparingFieldByField(expectedResult);
   }
@@ -203,8 +203,4 @@ public class PermissionTemplateCharacteristicDaoTest {
     assertThat(underTest.selectByTemplateIds(dbSession, asList(1L))).hasSize(0);
     assertThat(underTest.selectByTemplateIds(dbSession, asList(1L, 2L))).hasSize(1);
   }
-
-  private PermissionTemplateCharacteristicDto selectById(long id) {
-    return db.getDbClient().permissionTemplateCharacteristicDao().selectByTemplateIds(dbSession, asList(id)).get(0);
-  }
 }