diegomez17 commented on code in PR #16939:
URL: https://github.com/apache/beam/pull/16939#discussion_r877474604


##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableServiceImplTest.java:
##########
@@ -178,4 +631,71 @@ private void verifyMetricWasSet(String method, String 
status, long count) {
         (MetricsContainerImpl) MetricsEnvironment.getProcessWideContainer();
     assertEquals(count, (long) container.getCounter(name).getCumulative());
   }
+
+  public Answer<ScanHandler> mockReadRowsAnswer(List<FlatRow> rows) {
+    return new Answer<ScanHandler>() {
+      @Override
+      public ScanHandler answer(InvocationOnMock invocationOnMock) throws 
Throwable {
+        StreamObserver<FlatRow> flatRowObserver = 
invocationOnMock.getArgument(1);
+        new Thread() {
+          @Override
+          public void run() {
+            for (int i = 0; i < rows.size(); i++) {
+              flatRowObserver.onNext(rows.get(i));
+            }
+            flatRowObserver.onCompleted();
+          }
+        }.start();
+
+        return scanHandler;
+      }
+    };
+  }
+
+  public RowRange generateRowRange(ByteString start, ByteString end) {
+    return 
RowRange.newBuilder().setStartKeyClosed(start).setEndKeyOpen(end).build();
+  }
+
+  public List<FlatRow> generateSegmentResult(String prefix, int startIndex, 
int count) {
+    return generateSegmentResult(prefix, startIndex, count, false);
+  }
+
+  public List<FlatRow> generateLargeSegmentResult(String prefix, int 
startIndex, int count) {
+    return generateSegmentResult(prefix, startIndex, count, true);
+  }
+
+  public List<FlatRow> generateSegmentResult(
+      String prefix, int startIndex, int count, boolean largeRow) {
+    byte[] largeMemory = new byte[(int) DEFAULT_ROW_SIZE];
+    return IntStream.range(startIndex, startIndex + count)
+        .mapToObj(
+            i -> {
+              FlatRow.Builder builder = FlatRow.newBuilder();
+              if (!largeRow) {
+                builder.withRowKey(generateByteString(prefix, i));
+              } else {
+                builder
+                    .withRowKey(generateByteString(prefix, i))
+                    .addCell(
+                        "Family",
+                        ByteString.copyFromUtf8("LargeMemoryRow"),
+                        System.currentTimeMillis(),
+                        ByteString.copyFrom(largeMemory));
+              }
+              return builder.build();
+            })
+        .collect(Collectors.toList());
+  }
+
+  public <T> OngoingStubbing<T> expectRowResults(

Review Comment:
   Changed this to private, can't be static due to mockReadRows being 
non-static w/ scanHandler. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to