]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7676 remove PropertyDto#id
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 8 Sep 2016 13:17:11 +0000 (15:17 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 9 Sep 2016 07:11:42 +0000 (09:11 +0200)
sonar-db/src/main/java/org/sonar/db/property/PropertyDto.java
sonar-db/src/main/resources/org/sonar/db/property/PropertiesMapper.xml
sonar-db/src/test/java/org/sonar/db/property/PropertiesDaoTest.java

index 22f0998b3532d63bf539995743670337abd0cc86..59c9455e4d49f00ab2e7b845763ae790e358cdc1 100644 (file)
@@ -29,21 +29,11 @@ import static com.google.common.base.Preconditions.checkArgument;
 public class PropertyDto {
   private static final int MAX_KEY_LENGTH = 512;
 
-  private Long id;
   private String key;
   private String value;
   private Long resourceId;
   private Long userId;
 
-  public Long getId() {
-    return id;
-  }
-
-  public PropertyDto setId(Long id) {
-    this.id = id;
-    return this;
-  }
-
   public String getKey() {
     return key;
   }
index eb6a14664f1698717cdeade7a426ee0f281de776..206195eab86838db65d9076605c6bf2a9f95fc72 100644 (file)
@@ -51,7 +51,6 @@
   </select>
 
   <sql id="columnsToScrapPropertyDto">
-    p.id as id,
     p.prop_key as "key",
     p.is_empty as empty,
     p.text_value as textValue,
index 4ad5862b347b4a1acf99e901382556aaaa549d92..e95511e8a3eab446bd00974275f3f6665ceceea7 100644 (file)
@@ -190,13 +190,13 @@ public class PropertiesDaoTest {
     assertThat(properties.size())
       .isEqualTo(2);
 
-    assertThatDto(findById(properties, id1))
+    assertThatDto(findByKey(properties, "global.one"))
       .hasKey("global.one")
       .hasNoUserId()
       .hasNoResourceId()
       .hasValue("one");
 
-    assertThatDto(findById(properties, id2))
+    assertThatDto(findByKey(properties, "global.two"))
       .hasKey("global.two")
       .hasNoResourceId()
       .hasNoUserId()
@@ -257,17 +257,17 @@ public class PropertiesDaoTest {
     insertProperty("global.one", "one", null, null);
     insertProperty("global.two", "two", null, null);
     // project
-    long id3 = insertProperty("project.one", "Pone", projectId, null);
-    long id4 = insertProperty("project.two", "Ptwo", projectId, null);
+    insertProperty("project.one", "Pone", projectId, null);
+    insertProperty("project.two", "Ptwo", projectId, null);
 
     List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.key());
     assertThat(dtos)
       .hasSize(2);
-    assertThatDto(findById(dtos, id3))
+    assertThatDto(findByKey(dtos, "project.one"))
       .hasKey("project.one")
       .hasResourceId(projectId)
       .hasValue("Pone");
-    assertThatDto(findById(dtos, id4))
+    assertThatDto(findByKey(dtos, "project.two"))
       .hasKey("project.two")
       .hasResourceId(projectId)
       .hasValue("Ptwo");
@@ -994,9 +994,9 @@ public class PropertiesDaoTest {
     underTest.renamePropertyKey(null, "foo");
   }
 
-  private PropertyDto findById(List<PropertyDto> properties, long id) {
+  private PropertyDto findByKey(List<PropertyDto> properties, String key) {
     for (PropertyDto property : properties) {
-      if (property.getId() == id) {
+      if (key.equals(property.getKey())) {
         return property;
       }
     }