package com.github.rholder.esthree.command;

import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.PutObjectResult;
import com.google.common.collect.Maps;
import org.junit.Assert;
import org.junit.Test;

import java.io.File;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.isNull;
import static org.mockito.Matchers.matches;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

public class PutTest {

    @Test
    public void noParameters() throws Exception {
        AmazonS3Client client = mock(AmazonS3Client.class);
        when(client.putObject(any(PutObjectRequest.class))).thenReturn(new PutObjectResult());

        Put put = new Put(client, null, null, null, null);
        put.call();

        verify(client, times(1)).putObject(any(PutObjectRequest.class));
    }

    @Test
    public void happyPath() throws Exception {
        AmazonS3Client client = mock(AmazonS3Client.class);
        when(client.putObject(any(PutObjectRequest.class))).thenReturn(new PutObjectResult());

        Put put = new Put(client, "beep", "boop", new File("testfile"), Maps.<String, String>newHashMap());

        Assert.assertEquals(put.bucket, "beep");
        Assert.assertEquals(put.key, "boop");
        Assert.assertEquals(put.inputFile, new File("testfile"));
        put.call();

        verify(client, times(1)).putObject(any(PutObjectRequest.class));
    }

//    @Test
//    public void happyPathBucketRegion() throws Exception {
//        AmazonS3Client client = mock(AmazonS3Client.class);
//        Mb mb = new Mb(client, "beep", "boop");
//
//        Assert.assertEquals(mb.bucket, "beep");
//        Assert.assertEquals(mb.region, "boop");
//        mb.call();
//
//        verify(client, times(1)).createBucket(matches("beep"), matches("boop"));
//    }
}

@@ -354,95 +354,8 @@
 ny;%0A
-import static org.mockito.Matchers.isNull;%0Aimport static org.mockito.Matchers.matches;%0A
 impo
@@ -1500,411 +1500,7 @@
    %7D
-%0A%0A//    @Test%0A//    public void happyPathBucketRegion() throws Exception %7B%0A//        AmazonS3Client client = mock(AmazonS3Client.class);%0A//        Mb mb = new Mb(client, %22beep%22, %22boop%22);%0A//%0A//        Assert.assertEquals(mb.bucket, %22beep%22);%0A//        Assert.assertEquals(mb.region, %22boop%22);%0A//        mb.call();%0A//%0A//        verify(client, times(1)).createBucket(matches(%22beep%22), matches(%22boop%22));%0A//    %7D
 %0A%7D%0A

remove some crap