Map<String, String> getShardIterators() {
        if (streamArn == null) {
            streamArn = getStreamArn();
        }
        // Either return cached ones or get new ones via GetShardIterator requests.
        if (currentShardIterators.isEmpty()) {
            DescribeStreamResponse streamDescriptionResult
                    = getClient().describeStream(DescribeStreamRequest.builder().streamArn(streamArn).build());
            shardTree.populate(streamDescriptionResult.streamDescription().shards());

            StreamIteratorType streamIteratorType = getEndpoint().getConfiguration().getStreamIteratorType();
            currentShardIterators = getCurrentShardIterators(streamIteratorType);
        } else {
            Map<String, String> childShardIterators = new HashMap<>();
            for (Entry<String, String> currentShardIterator : currentShardIterators.entrySet()) {
                List<Shard> children = shardTree.getChildren(currentShardIterator.getKey());
                if (children.isEmpty()) { // This is still an active leaf shard, reuse it.
                    childShardIterators.put(currentShardIterator.getKey(), currentShardIterator.getValue());
                } else {
                    for (Shard child : children) { // Inactive shard, move down to its children.
                        String shardIterator = getShardIterator(child.shardId(), ShardIteratorType.TRIM_HORIZON);
                        childShardIterators.put(child.shardId(), shardIterator);
                    }
                }
            }
            currentShardIterators = childShardIterators;
        }
        LOG.trace("Shard Iterators are: {}", currentShardIterators);
        return currentShardIterators;
    }
@Test
    void shouldThrowIllegalArgumentExceptionIfNoStreamsAreReturned() throws Exception {
        AmazonDDBStreamlessClientMock dynamoDbStreamsClient = new AmazonDDBStreamlessClientMock();
        component.getConfiguration().setAmazonDynamoDbStreamsClient(dynamoDbStreamsClient);

        Ddb2StreamEndpoint endpoint = (Ddb2StreamEndpoint) component.createEndpoint("aws2-ddbstreams://myTable");
        ShardIteratorHandler underTest = new ShardIteratorHandler(endpoint);
        endpoint.doStart();

        assertThrows(IllegalArgumentException.class, () -> underTest.getShardIterators());
    }