Sha256: 699a87329f438cc619bce90befc4e919f818859d1d5115e09cd82994d4a76658
Contents?: true
Size: 1.62 KB
Versions: 10
Compression:
Stored size: 1.62 KB
Contents
package org.embulk.input.s3; import static org.junit.Assert.*; import java.util.List; import org.junit.Test; import org.mockito.Mockito; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.model.ListObjectsRequest; import com.amazonaws.services.s3.model.ObjectListing; import com.amazonaws.services.s3.model.S3ObjectSummary; public class TestS3FileInputPlugin { @Test public void listS3FilesByPrefix() { // AWSS3Client returns list1 for the first iteration and list2 next. List<S3ObjectSummary> list1 = ImmutableList.<S3ObjectSummary> of(bucket("in/", 0), bucket("in/file/", 0), bucket("in/file/sample.csv.gz", 12345)); List<S3ObjectSummary> list2 = ImmutableList.<S3ObjectSummary> of(bucket("sample2.csv.gz", 0)); ObjectListing ol = Mockito.mock(ObjectListing.class); Mockito.doReturn(list1).doReturn(list2).when(ol).getObjectSummaries(); AmazonS3Client client = Mockito.mock(AmazonS3Client.class); Mockito.doReturn(ol).when(client).listObjects(Mockito.any(ListObjectsRequest.class)); Mockito.doReturn("in/file/").doReturn(null).when(ol).getNextMarker(); // It counts only size != 0 files. assertEquals(1, S3FileInputPlugin.listS3FilesByPrefix(client, "bucketName", "prefix", Optional.<String>absent()).size()); } private S3ObjectSummary bucket(String key, long size) { S3ObjectSummary bucket = new S3ObjectSummary(); bucket.setKey(key); bucket.setSize(size); return bucket; } }
Version data entries
10 entries across 10 versions & 1 rubygems