]> source.dussan.org Git - sonarqube.git/commitdiff
Add name to api/rules/list
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 30 Jul 2015 13:58:16 +0000 (15:58 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 30 Jul 2015 13:58:16 +0000 (15:58 +0200)
server/sonar-server/src/main/java/org/sonar/server/rule/ws/ListAction.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java
sonar-ws/src/main/gen-java/org/sonarqube/ws/Rules.java
sonar-ws/src/main/protobuf/ws-rules.proto

index 52be58caef379c10cb7bfc4bba948b3d6eab00cd..8a4d5d0ce4c54cefbb0fc5faaacb14e7a9545748 100644 (file)
@@ -63,6 +63,10 @@ public class ListAction implements RulesWsAction {
             .clear()
             .setRepository(dto.getRepositoryKey())
             .setKey(dto.getRuleKey());
+          String name = dto.getName();
+          if (!Strings.isNullOrEmpty(name)) {
+            ruleBuilder.setName(name);
+          }
           String internalKey = dto.getConfigKey();
           if (!Strings.isNullOrEmpty(internalKey)) {
             ruleBuilder.setInternalKey(internalKey);
index fd9aea6d1eb00a730d5f87748aa70c6d6d1c9c0e..21578d44051757eb43ead9bfd71da8153b808885 100644 (file)
@@ -50,8 +50,8 @@ public class ListActionTest {
 
   @Test
   public void return_rules_in_protobuf() throws Exception {
-    dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RuleTesting.newDto(RuleKey.of("java", "S001")).setConfigKey(null));
-    dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RuleTesting.newDto(RuleKey.of("java", "S002")).setConfigKey("I002"));
+    dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RuleTesting.newDto(RuleKey.of("java", "S001")).setConfigKey(null).setName(null));
+    dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), RuleTesting.newDto(RuleKey.of("java", "S002")).setConfigKey("I002").setName("Rule Two"));
     dbTester.getSession().commit();
 
     TestResponse response = tester.newRequest()
@@ -64,7 +64,9 @@ public class ListActionTest {
 
     assertThat(listResponse.getRules(0).getKey()).isEqualTo("S001");
     assertThat(listResponse.getRules(0).hasInternalKey()).isFalse();
+    assertThat(listResponse.getRules(0).hasName()).isFalse();
     assertThat(listResponse.getRules(1).getKey()).isEqualTo("S002");
     assertThat(listResponse.getRules(1).getInternalKey()).isEqualTo("I002");
+    assertThat(listResponse.getRules(1).getName()).isEqualTo("Rule Two");
   }
 }
index 346793fee19bc54b79745f9a1de22ef409668b4d..7786e5aa761ac81da3c58a6e83e78520150f8f6e 100644 (file)
@@ -187,6 +187,20 @@ public final class Rules {
        */
       com.google.protobuf.ByteString
           getInternalKeyBytes();
+
+      /**
+       * <code>optional string name = 4;</code>
+       */
+      boolean hasName();
+      /**
+       * <code>optional string name = 4;</code>
+       */
+      java.lang.String getName();
+      /**
+       * <code>optional string name = 4;</code>
+       */
+      com.google.protobuf.ByteString
+          getNameBytes();
     }
     /**
      * Protobuf type {@code sonarqube.ws.rules.ListResponse.Rule}
@@ -258,6 +272,12 @@ public final class Rules {
                 internalKey_ = bs;
                 break;
               }
+              case 34: {
+                com.google.protobuf.ByteString bs = input.readBytes();
+                bitField0_ |= 0x00000008;
+                name_ = bs;
+                break;
+              }
             }
           }
         } catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -424,10 +444,53 @@ public final class Rules {
         }
       }
 
+      public static final int NAME_FIELD_NUMBER = 4;
+      private java.lang.Object name_;
+      /**
+       * <code>optional string name = 4;</code>
+       */
+      public boolean hasName() {
+        return ((bitField0_ & 0x00000008) == 0x00000008);
+      }
+      /**
+       * <code>optional string name = 4;</code>
+       */
+      public java.lang.String getName() {
+        java.lang.Object ref = name_;
+        if (ref instanceof java.lang.String) {
+          return (java.lang.String) ref;
+        } else {
+          com.google.protobuf.ByteString bs = 
+              (com.google.protobuf.ByteString) ref;
+          java.lang.String s = bs.toStringUtf8();
+          if (bs.isValidUtf8()) {
+            name_ = s;
+          }
+          return s;
+        }
+      }
+      /**
+       * <code>optional string name = 4;</code>
+       */
+      public com.google.protobuf.ByteString
+          getNameBytes() {
+        java.lang.Object ref = name_;
+        if (ref instanceof java.lang.String) {
+          com.google.protobuf.ByteString b = 
+              com.google.protobuf.ByteString.copyFromUtf8(
+                  (java.lang.String) ref);
+          name_ = b;
+          return b;
+        } else {
+          return (com.google.protobuf.ByteString) ref;
+        }
+      }
+
       private void initFields() {
         repository_ = "";
         key_ = "";
         internalKey_ = "";
+        name_ = "";
       }
       private byte memoizedIsInitialized = -1;
       public final boolean isInitialized() {
@@ -451,6 +514,9 @@ public final class Rules {
         if (((bitField0_ & 0x00000004) == 0x00000004)) {
           output.writeBytes(3, getInternalKeyBytes());
         }
+        if (((bitField0_ & 0x00000008) == 0x00000008)) {
+          output.writeBytes(4, getNameBytes());
+        }
         getUnknownFields().writeTo(output);
       }
 
@@ -472,6 +538,10 @@ public final class Rules {
           size += com.google.protobuf.CodedOutputStream
             .computeBytesSize(3, getInternalKeyBytes());
         }
+        if (((bitField0_ & 0x00000008) == 0x00000008)) {
+          size += com.google.protobuf.CodedOutputStream
+            .computeBytesSize(4, getNameBytes());
+        }
         size += getUnknownFields().getSerializedSize();
         memoizedSerializedSize = size;
         return size;
@@ -595,6 +665,8 @@ public final class Rules {
           bitField0_ = (bitField0_ & ~0x00000002);
           internalKey_ = "";
           bitField0_ = (bitField0_ & ~0x00000004);
+          name_ = "";
+          bitField0_ = (bitField0_ & ~0x00000008);
           return this;
         }
 
@@ -635,6 +707,10 @@ public final class Rules {
             to_bitField0_ |= 0x00000004;
           }
           result.internalKey_ = internalKey_;
+          if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
+            to_bitField0_ |= 0x00000008;
+          }
+          result.name_ = name_;
           result.bitField0_ = to_bitField0_;
           onBuilt();
           return result;
@@ -666,6 +742,11 @@ public final class Rules {
             internalKey_ = other.internalKey_;
             onChanged();
           }
+          if (other.hasName()) {
+            bitField0_ |= 0x00000008;
+            name_ = other.name_;
+            onChanged();
+          }
           this.mergeUnknownFields(other.getUnknownFields());
           return this;
         }
@@ -921,6 +1002,82 @@ public final class Rules {
           return this;
         }
 
+        private java.lang.Object name_ = "";
+        /**
+         * <code>optional string name = 4;</code>
+         */
+        public boolean hasName() {
+          return ((bitField0_ & 0x00000008) == 0x00000008);
+        }
+        /**
+         * <code>optional string name = 4;</code>
+         */
+        public java.lang.String getName() {
+          java.lang.Object ref = name_;
+          if (!(ref instanceof java.lang.String)) {
+            com.google.protobuf.ByteString bs =
+                (com.google.protobuf.ByteString) ref;
+            java.lang.String s = bs.toStringUtf8();
+            if (bs.isValidUtf8()) {
+              name_ = s;
+            }
+            return s;
+          } else {
+            return (java.lang.String) ref;
+          }
+        }
+        /**
+         * <code>optional string name = 4;</code>
+         */
+        public com.google.protobuf.ByteString
+            getNameBytes() {
+          java.lang.Object ref = name_;
+          if (ref instanceof String) {
+            com.google.protobuf.ByteString b = 
+                com.google.protobuf.ByteString.copyFromUtf8(
+                    (java.lang.String) ref);
+            name_ = b;
+            return b;
+          } else {
+            return (com.google.protobuf.ByteString) ref;
+          }
+        }
+        /**
+         * <code>optional string name = 4;</code>
+         */
+        public Builder setName(
+            java.lang.String value) {
+          if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00000008;
+          name_ = value;
+          onChanged();
+          return this;
+        }
+        /**
+         * <code>optional string name = 4;</code>
+         */
+        public Builder clearName() {
+          bitField0_ = (bitField0_ & ~0x00000008);
+          name_ = getDefaultInstance().getName();
+          onChanged();
+          return this;
+        }
+        /**
+         * <code>optional string name = 4;</code>
+         */
+        public Builder setNameBytes(
+            com.google.protobuf.ByteString value) {
+          if (value == null) {
+    throw new NullPointerException();
+  }
+  bitField0_ |= 0x00000008;
+          name_ = value;
+          onChanged();
+          return this;
+        }
+
         // @@protoc_insertion_point(builder_scope:sonarqube.ws.rules.ListResponse.Rule)
       }
 
@@ -1501,11 +1658,12 @@ public final class Rules {
       descriptor;
   static {
     java.lang.String[] descriptorData = {
-      "\n\016ws-rules.proto\022\022sonarqube.ws.rules\"\203\001\n" +
+      "\n\016ws-rules.proto\022\022sonarqube.ws.rules\"\221\001\n" +
       "\014ListResponse\0224\n\005rules\030\001 \003(\0132%.sonarqube" +
-      ".ws.rules.ListResponse.Rule\032=\n\004Rule\022\022\n\nr" +
+      ".ws.rules.ListResponse.Rule\032K\n\004Rule\022\022\n\nr" +
       "epository\030\001 \001(\t\022\013\n\003key\030\002 \001(\t\022\024\n\014internal" +
-      "_key\030\003 \001(\tB\033\n\020org.sonarqube.wsB\005RulesH\001"
+      "_key\030\003 \001(\t\022\014\n\004name\030\004 \001(\tB\033\n\020org.sonarqub" +
+      "e.wsB\005RulesH\001"
     };
     com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
         new com.google.protobuf.Descriptors.FileDescriptor.    InternalDescriptorAssigner() {
@@ -1530,7 +1688,7 @@ public final class Rules {
     internal_static_sonarqube_ws_rules_ListResponse_Rule_fieldAccessorTable = new
       com.google.protobuf.GeneratedMessage.FieldAccessorTable(
         internal_static_sonarqube_ws_rules_ListResponse_Rule_descriptor,
-        new java.lang.String[] { "Repository", "Key", "InternalKey", });
+        new java.lang.String[] { "Repository", "Key", "InternalKey", "Name", });
   }
 
   // @@protoc_insertion_point(outer_class_scope)
index 264137d0935d74d5bb69d03c9d994fab560c17b2..43a04956ebb9b00d5d3b3d86e538469264243347 100644 (file)
@@ -31,6 +31,7 @@ message ListResponse {
     optional string repository = 1;
     optional string key = 2;
     optional string internal_key = 3;
+    optional string name = 4;
   }
 
   repeated Rule rules = 1;