gguptp commented on code in PR #146:
URL: 
https://github.com/apache/flink-connector-aws/pull/146#discussion_r1670682574


##########
flink-connector-aws/flink-connector-dynamodb/src/test/java/org/apache/flink/connector/dynamodb/source/util/DynamoDbStreamsClientProvider.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.dynamodb.source.util;
+
+import software.amazon.awssdk.awscore.exception.AwsServiceException;
+import software.amazon.awssdk.core.exception.SdkClientException;
+import software.amazon.awssdk.services.dynamodb.model.DescribeStreamRequest;
+import software.amazon.awssdk.services.dynamodb.model.DescribeStreamResponse;
+import software.amazon.awssdk.services.dynamodb.model.GetRecordsRequest;
+import software.amazon.awssdk.services.dynamodb.model.GetRecordsResponse;
+import software.amazon.awssdk.services.dynamodb.model.GetShardIteratorRequest;
+import software.amazon.awssdk.services.dynamodb.model.GetShardIteratorResponse;
+import software.amazon.awssdk.services.dynamodb.model.Shard;
+import software.amazon.awssdk.services.dynamodb.model.StreamDescription;
+import software.amazon.awssdk.services.dynamodb.model.StreamStatus;
+import software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClient;
+import 
software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsServiceClientConfiguration;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.List;
+import java.util.function.Consumer;
+
+/** Provides {@link DynamoDbStreamsClient} with mocked DynamoDbStreams 
behavior. */
+public class DynamoDbStreamsClientProvider {
+
+    /**
+     * An implementation of the {@link DynamoDbStreamsClient} that allows 
control over DynamoDb
+     * Service responses.
+     */
+    public static class TestingDynamoDbStreamsClient implements 
DynamoDbStreamsClient {
+
+        private Deque<DescribeStreamItem> describeStreamItems = new 
ArrayDeque<>();
+        private Deque<String> shardIterators = new ArrayDeque<>();
+        private Consumer<GetShardIteratorRequest> getShardIteratorValidation;
+        private GetRecordsResponse getRecordsResponse;
+        private Consumer<GetRecordsRequest> getRecordsValidation;
+        private boolean closed = false;
+
+        @Override
+        public String serviceName() {
+            return "dynamodb";
+        }
+
+        @Override
+        public void close() {
+            closed = true;
+        }
+
+        public boolean isClosed() {
+            return closed;
+        }
+
+        public void setNextShardIterator(String shardIterator) {
+            this.shardIterators.add(shardIterator);
+        }
+
+        public void 
setShardIteratorValidation(Consumer<GetShardIteratorRequest> validation) {
+            this.getShardIteratorValidation = validation;
+        }
+
+        @Override
+        public GetShardIteratorResponse getShardIterator(
+                GetShardIteratorRequest getShardIteratorRequest)
+                throws AwsServiceException, SdkClientException {
+            getShardIteratorValidation.accept(getShardIteratorRequest);
+            return 
GetShardIteratorResponse.builder().shardIterator(shardIterators.poll()).build();
+        }
+
+        public void setDescribeStreamResponse(List<DescribeStreamItem> items) {
+            describeStreamItems.addAll(items);
+        }

Review Comment:
   i don't think we require it here. We are only testing validation in request



-- 
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