@@ -0,0 +1,2588 @@
+package com.github.rholder.esthree.command;%0A%0Aimport com.amazonaws.services.s3.AmazonS3Client;%0Aimport com.amazonaws.services.s3.model.GetObjectRequest;%0Aimport com.amazonaws.services.s3.model.ObjectMetadata;%0Aimport com.amazonaws.services.s3.model.S3Object;%0Aimport com.amazonaws.services.s3.model.S3ObjectInputStream;%0Aimport com.github.rholder.esthree.util.FileChunker;%0Aimport com.google.common.primitives.Ints;%0Aimport org.apache.commons.io.IOUtils;%0Aimport org.apache.ivy.util.StringUtils;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport java.io.File;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport static com.github.rholder.esthree.util.FileChunker.FilePart;%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Matchers.anyString;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0Apublic class GetMultiTest %7B%0A%0A    // MD5 of 100 'a' characters%0A    public static final String A_MD5 = %2236a92cc94a9e0fa21f625f8bfb007adf%22;%0A%0A    public static final long CONTENT_LENGTH = 100;%0A    public static final int CHUNK_SIZE = 23;%0A%0A    @Test%0A    public void happyGetMulti() throws Exception %7B%0A        File tmpFile = File.createTempFile(%22testFile%22, %22.test%22);%0A        tmpFile.deleteOnExit();%0A%0A        // mock the ObjectMetadata for a 100 bytes of a's%0A        ObjectMetadata om = mock(ObjectMetadata.class);%0A        when(om.getContentLength()).thenReturn(CONTENT_LENGTH);%0A        when(om.getETag()).thenReturn(A_MD5);%0A%0A        List%3CS3Object%3E os = new ArrayList%3CS3Object%3E();%0A        List%3CFilePart%3E parts = FileChunker.chunk(CONTENT_LENGTH, CHUNK_SIZE);%0A        for(final FilePart p : parts) %7B%0A            // fake some content InputStream's by filling in chunks of a's%0A            S3Object o = mock(S3Object.class);%0A            S3ObjectInputStream input = new S3ObjectInputStream(%0A                    IOUtils.toInputStream(StringUtils.repeat(%22a%22, Ints.checkedCast(p.end - p.start + 1))),%0A                    null);%0A            // mock the returned content%0A            when(o.getObjectContent()).thenReturn(input);%0A            os.add(o);%0A        %7D%0A        Assert.assertEquals(5, os.size());%0A%0A        // mock the AmazonS3Client%0A        AmazonS3Client client = mock(AmazonS3Client.class);%0A        when(client.getObjectMetadata(anyString(), anyString())).thenReturn(om);%0A        when(client.getObject(any(GetObjectRequest.class))).thenReturn(os.get(0), os.get(1), os.get(2), os.get(3), os.get(4));%0A%0A        GetMultipart gm = new GetMultipart(client, %22testBucket%22, %22testKey%22, tmpFile);%0A        gm.withChunkSize(CHUNK_SIZE);%0A        gm.call();%0A    %7D%0A%7D%0A

add a GetMulti happy path test