Search in sources :

Example 1 with ScanResponse

use of software.amazon.awssdk.services.dynamodb.model.ScanResponse in project iep by Netflix.

the class PaginationTest method dynamoDB.

@Test
public void dynamoDB() throws Exception {
    Map<String, AttributeValue> nextPage = new HashMap<>();
    nextPage.put("abc", AttributeValue.builder().build());
    Map<String, AttributeValue> donePage = new HashMap<>();
    Function<ScanRequest, ScanResponse> f = r -> {
        if (r.exclusiveStartKey() != null) {
            Assert.assertTrue(r.exclusiveStartKey().containsKey("abc"));
        }
        return ScanResponse.builder().lastEvaluatedKey((r.exclusiveStartKey() == null) ? nextPage : donePage).build();
    };
    Publisher<ScanResponse> publisher = Pagination.createPublisher(ScanRequest.builder().build(), f);
    Iterable<ScanResponse> iter = Flowable.fromPublisher(publisher).blockingIterable();
    int count = 0;
    for (ScanResponse r : iter) {
        ++count;
    }
    Assert.assertEquals(2, count);
}
Also used : SortedSet(java.util.SortedSet) ListResourceRecordSetsResponse(software.amazon.awssdk.services.route53.model.ListResourceRecordSetsResponse) DescribeTargetGroupsRequest(software.amazon.awssdk.services.elasticloadbalancingv2.model.DescribeTargetGroupsRequest) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) Function(java.util.function.Function) TreeSet(java.util.TreeSet) ListMetricsRequest(software.amazon.awssdk.services.cloudwatch.model.ListMetricsRequest) ListHostedZonesResponse(software.amazon.awssdk.services.route53.model.ListHostedZonesResponse) DescribeAutoScalingGroupsResponse(software.amazon.awssdk.services.autoscaling.model.DescribeAutoScalingGroupsResponse) ListClustersRequest(software.amazon.awssdk.services.emr.model.ListClustersRequest) Flowable(io.reactivex.Flowable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ScanRequest(software.amazon.awssdk.services.dynamodb.model.ScanRequest) DescribeInstancesResponse(software.amazon.awssdk.services.ec2.model.DescribeInstancesResponse) Map(java.util.Map) DescribeInstancesRequest(software.amazon.awssdk.services.ec2.model.DescribeInstancesRequest) PutMetricDataRequest(software.amazon.awssdk.services.cloudwatch.model.PutMetricDataRequest) Iterator(java.util.Iterator) ScanResponse(software.amazon.awssdk.services.dynamodb.model.ScanResponse) Publisher(org.reactivestreams.Publisher) ListClustersResponse(software.amazon.awssdk.services.emr.model.ListClustersResponse) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) DescribeTargetGroupsResponse(software.amazon.awssdk.services.elasticloadbalancingv2.model.DescribeTargetGroupsResponse) PutMetricDataResponse(software.amazon.awssdk.services.cloudwatch.model.PutMetricDataResponse) ListHostedZonesRequest(software.amazon.awssdk.services.route53.model.ListHostedZonesRequest) DescribeAutoScalingGroupsRequest(software.amazon.awssdk.services.autoscaling.model.DescribeAutoScalingGroupsRequest) ListResourceRecordSetsRequest(software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest) AttributeValue(software.amazon.awssdk.services.dynamodb.model.AttributeValue) DescribeLoadBalancersRequest(software.amazon.awssdk.services.autoscaling.model.DescribeLoadBalancersRequest) Assert(org.junit.Assert) DescribeLoadBalancersResponse(software.amazon.awssdk.services.autoscaling.model.DescribeLoadBalancersResponse) ListMetricsResponse(software.amazon.awssdk.services.cloudwatch.model.ListMetricsResponse) ScanRequest(software.amazon.awssdk.services.dynamodb.model.ScanRequest) AttributeValue(software.amazon.awssdk.services.dynamodb.model.AttributeValue) HashMap(java.util.HashMap) ScanResponse(software.amazon.awssdk.services.dynamodb.model.ScanResponse) Test(org.junit.Test)

Aggregations

Flowable (io.reactivex.Flowable)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Function (java.util.function.Function)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 JUnit4 (org.junit.runners.JUnit4)1 Publisher (org.reactivestreams.Publisher)1 DescribeAutoScalingGroupsRequest (software.amazon.awssdk.services.autoscaling.model.DescribeAutoScalingGroupsRequest)1 DescribeAutoScalingGroupsResponse (software.amazon.awssdk.services.autoscaling.model.DescribeAutoScalingGroupsResponse)1 DescribeLoadBalancersRequest (software.amazon.awssdk.services.autoscaling.model.DescribeLoadBalancersRequest)1 DescribeLoadBalancersResponse (software.amazon.awssdk.services.autoscaling.model.DescribeLoadBalancersResponse)1 ListMetricsRequest (software.amazon.awssdk.services.cloudwatch.model.ListMetricsRequest)1 ListMetricsResponse (software.amazon.awssdk.services.cloudwatch.model.ListMetricsResponse)1 PutMetricDataRequest (software.amazon.awssdk.services.cloudwatch.model.PutMetricDataRequest)1