stoty commented on code in PR #6318:
URL: https://github.com/apache/hbase/pull/6318#discussion_r1793501305


##########
hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java:
##########
@@ -623,4 +626,149 @@ public void testSlowLogParamsMutateRequest() {
     assertTrue(slowLogParams.getParams()
       .contains(Bytes.toStringBinary(mutationProto.getRow().toByteArray())));
   }
+
+  @Test
+  public void testGetShortTextFormatNull() {
+    String actual = ProtobufUtil.getShortTextFormat(null);
+    assertNotNull(actual);
+    assertEquals("null", actual);
+  }
+
+  @Test
+  public void testGetShortTextFormatScanRequest() {
+    ClientProtos.ScanRequest.Builder builder = 
ClientProtos.ScanRequest.newBuilder();
+    builder.setRegion(givenRegion());
+    ClientProtos.ScanRequest scanRequest = builder.build();
+
+    String actual = ProtobufUtil.getShortTextFormat(scanRequest);
+
+    assertNotNull(actual);
+    assertEquals("region { type: REGION_NAME value: \"test\" }", actual);
+  }
+
+  @Test
+  public void testGetShortTextFormatRegionServerReportRequest() {
+    RegionServerStatusProtos.RegionServerReportRequest.Builder builder =
+      RegionServerStatusProtos.RegionServerReportRequest.newBuilder();
+    builder.setServer(givenServerName());
+    RegionServerStatusProtos.RegionServerReportRequest request = 
builder.build();
+
+    String actual = ProtobufUtil.getShortTextFormat(request);
+
+    assertNotNull(actual);
+    assertEquals("server host_name: \"a.b.com\" load { numberOfRequests: 0 }", 
actual);
+  }
+
+  @Test
+  public void testGetShortTextFormatRegionServerStartupRequest() {
+    RegionServerStatusProtos.RegionServerStartupRequest.Builder builder =
+      RegionServerStatusProtos.RegionServerStartupRequest.newBuilder();
+    builder.setPort(8080);
+    builder.setServerCurrentTime(111111L);
+    builder.setServerStartCode(15L);
+    builder.setUseThisHostnameInstead("some-host-name");
+    RegionServerStatusProtos.RegionServerStartupRequest 
regionServerStartupRequest =
+      builder.build();
+
+    String actual = 
ProtobufUtil.getShortTextFormat(regionServerStartupRequest);
+
+    assertNotNull(actual);
+    assertEquals(
+      "port: 8080 server_start_code: 15 server_current_time: 111111 
use_this_hostname_instead: \"some-host-name\"",
+      actual);
+  }
+
+  @Test
+  public void testGetShortTextFormatMutationProto() {
+    MutationProto mutationProto =
+      
ClientProtos.MutationProto.newBuilder().setRow(ByteString.copyFromUtf8("row123")).build();
+
+    String actual = ProtobufUtil.getShortTextFormat(mutationProto);
+
+    assertNotNull(actual);
+    assertEquals("row=row123, type=APPEND", actual);
+  }
+
+  @Test
+  public void testGetShortTextFormatGetRequest() throws IOException {
+    ClientProtos.GetRequest getRequest = ClientProtos.GetRequest.newBuilder()
+      .setRegion(givenRegion()).setGet(ProtobufUtil.toGet(new 
Get(Bytes.toBytes("foo")))).build();
+
+    String actual = ProtobufUtil.getShortTextFormat(getRequest);
+
+    assertNotNull(actual);
+    assertEquals("region= test, row=foo", actual);
+  }
+
+  @Test
+  public void testGetShortTextFormatMultiRequest() throws IOException {
+    ClientProtos.Action action = ClientProtos.Action.newBuilder()
+      .setGet(ProtobufUtil.toGet(new Get(Bytes.toBytes("foo")))).build();
+    ClientProtos.RegionAction regionAction =
+      
ClientProtos.RegionAction.newBuilder().addAction(action).setRegion(givenRegion()).build();
+
+    ClientProtos.MultiRequest multiRequest =
+      
ClientProtos.MultiRequest.newBuilder().addRegionAction(regionAction).build();
+
+    String actual = ProtobufUtil.getShortTextFormat(multiRequest);
+
+    assertNotNull(actual);
+    assertEquals("region= test, for 1 action(s) and 1st row key=foo", actual);
+  }
+
+  @Test
+  public void testGetShortTextFormatMutateRequest() throws IOException {
+    ClientProtos.MutateRequest mutateRequest = 
ClientProtos.MutateRequest.newBuilder()
+      .setMutation(
+        ProtobufUtil.toMutation(MutationType.INCREMENT, new 
Increment(Bytes.toBytes("foo"))))
+      .setRegion(givenRegion()).build();
+
+    String actual = ProtobufUtil.getShortTextFormat(mutateRequest);
+
+    assertNotNull(actual);
+    assertEquals("region= test, row=foo", actual);
+  }
+
+  @Test
+  public void testGetShortTextFormatCoprocessorServiceRequest() {
+    ClientProtos.CoprocessorServiceCall call = 
ClientProtos.CoprocessorServiceCall.newBuilder()
+      
.setRow(UnsafeByteOperations.unsafeWrap(Bytes.toBytes("foo"))).setMethodName("awesomeMethod")
+      .setServiceName("awesomeService")
+      
.setRequest(UnsafeByteOperations.unsafeWrap(Bytes.toBytes("foo-request"))).build();
+
+    ClientProtos.CoprocessorServiceRequest.Builder builder =
+      ClientProtos.CoprocessorServiceRequest.newBuilder();
+    builder.setRegion(givenRegion());
+    builder.setCall(call);
+    ClientProtos.CoprocessorServiceRequest coprocessorServiceRequest = 
builder.build();
+
+    String actual = ProtobufUtil.getShortTextFormat(coprocessorServiceRequest);
+
+    assertNotNull(actual);
+    assertEquals("coprocessorService= awesomeService:awesomeMethod", actual);
+  }
+
+  @Test
+  public void testGetShortTextFormatMoveRegionRequest() {
+    MasterProtos.MoveRegionRequest.Builder builder = 
MasterProtos.MoveRegionRequest.newBuilder();
+    builder.setRegion(givenRegion());
+    builder.setDestServerName(givenServerName());
+    MasterProtos.MoveRegionRequest moveRegionRequest = builder.build();
+
+    String actual = ProtobufUtil.getShortTextFormat(moveRegionRequest);
+
+    assertNotNull(actual);
+    assertEquals(
+      "region { type: REGION_NAME value: \"test\" } dest_server_name { 
host_name: \"a.b.com\" }",

Review Comment:
   It's ok, that's the point of this ticket.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@hbase.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to