// Path: src/main/java/com/google/jenkins/plugins/storage/AbstractUploadDescriptor.java
// public static final String GCS_SCHEME = "gs://";
// 
// Path: src/main/java/com/google/jenkins/plugins/storage/GoogleCloudStorageUploader.java
// @Extension
// public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> {
// 
//   /** {@inheritDoc} */
//   @Override
//   public boolean isApplicable(
//       @SuppressWarnings("rawtypes") Class<? extends AbstractProject> aClass) {
//     // Indicates that this builder can be used with all kinds of project types
//     return true;
//   }
// 
//   /** {@inheritDoc} */
//   @Override
//   public String getDisplayName() {
//     return Messages.GoogleCloudStorageUploader_DisplayName();
//   }
// 
//   /**
//    * @return the default uploads when the user configure {@link GoogleCloudStorageUploader} for
//    *     the first time.
//    */
//   public List<AbstractUpload> getDefaultUploads() {
//     StdoutUpload upload =
//         new StdoutUpload(
//             GCS_SCHEME, null, "build-log.txt", null /* legacy arg: bucketNameWithVars */);
//     upload.setForFailedJobs(true);
//     return ImmutableList.<AbstractUpload>of(upload);
//   }
// 
//   /** @return All registered {@link AbstractUpload}s. */
//   public List<AbstractUploadDescriptor> getUploads() {
//     return AbstractUpload.all();
//   }
// }


import static com.google.jenkins.plugins.storage.AbstractUploadDescriptor.GCS_SCHEME;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.when;
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.services.storage.Storage;
import com.google.api.services.storage.model.StorageObject;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.jenkins.plugins.credentials.oauth.GoogleOAuth2ScopeRequirement;
import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials;
import com.google.jenkins.plugins.storage.GoogleCloudStorageUploader.DescriptorImpl;
import com.google.jenkins.plugins.util.ConflictException;
import com.google.jenkins.plugins.util.ForbiddenException;
import com.google.jenkins.plugins.util.MockExecutor;
import com.google.jenkins.plugins.util.NotFoundException;
import hudson.model.AbstractProject;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Result;
import hudson.model.Run;
import hudson.tasks.Shell;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.SystemUtils;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Verifier;
import org.jvnet.hudson.test.FailureBuilder;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.WithoutJenkins;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
  public void testMultiFileGlob() throws Exception {
    glob = "*.txt";
    underTest =
        new GoogleCloudStorageUploader(
            CREDENTIALS_ID,
            ImmutableList.<AbstractUpload>of(
                setOptionalParams(
                    new ClassicUpload(
                        bucket,
                        new MockUploadModule(executor),
                        glob,
                        null /* legacy arg */,
                        null /* legacy arg */))));

    project.getBuildersList().add(new Shell("echo foo > foo.txt; echo bar > bar.txt"));
    project.getPublishersList().add(underTest);

    executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
    executor.passThruWhen(Storage.Buckets.Insert.class);
    executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
    executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);

    FreeStyleBuild build = project.scheduleBuild2(0).get();

    assertEquals(Result.SUCCESS, build.getResult());
  }

  @Test
  @WithoutJenkins
  public void testDescriptor() {
// Path: src/main/java/com/google/jenkins/plugins/storage/AbstractUploadDescriptor.java
// public static final String GCS_SCHEME = "gs://";
// 
// Path: src/main/java/com/google/jenkins/plugins/storage/GoogleCloudStorageUploader.java
// @Extension
// public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> {
// 
//   /** {@inheritDoc} */
//   @Override
//   public boolean isApplicable(
//       @SuppressWarnings("rawtypes") Class<? extends AbstractProject> aClass) {
//     // Indicates that this builder can be used with all kinds of project types
//     return true;
//   }
// 
//   /** {@inheritDoc} */
//   @Override
//   public String getDisplayName() {
//     return Messages.GoogleCloudStorageUploader_DisplayName();
//   }
// 
//   /**
//    * @return the default uploads when the user configure {@link GoogleCloudStorageUploader} for
//    *     the first time.
//    */
//   public List<AbstractUpload> getDefaultUploads() {
//     StdoutUpload upload =
//         new StdoutUpload(
//             GCS_SCHEME, null, "build-log.txt", null /* legacy arg: bucketNameWithVars */);
//     upload.setForFailedJobs(true);
//     return ImmutableList.<AbstractUpload>of(upload);
//   }
// 
//   /** @return All registered {@link AbstractUpload}s. */
//   public List<AbstractUploadDescriptor> getUploads() {
//     return AbstractUpload.all();
//   }
// }


// Path: src/test/java/com/google/jenkins/plugins/storage/GoogleCloudStorageUploaderTest.java
import static com.google.jenkins.plugins.storage.AbstractUploadDescriptor.GCS_SCHEME;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.when;
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.services.storage.Storage;
import com.google.api.services.storage.model.StorageObject;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.jenkins.plugins.credentials.oauth.GoogleOAuth2ScopeRequirement;
import com.google.jenkins.plugins.credentials.oauth.GoogleRobotCredentials;
import com.google.jenkins.plugins.storage.GoogleCloudStorageUploader.DescriptorImpl;
import com.google.jenkins.plugins.util.ConflictException;
import com.google.jenkins.plugins.util.ForbiddenException;
import com.google.jenkins.plugins.util.MockExecutor;
import com.google.jenkins.plugins.util.NotFoundException;
import hudson.model.AbstractProject;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Result;
import hudson.model.Run;
import hudson.tasks.Shell;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.SystemUtils;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Verifier;
import org.jvnet.hudson.test.FailureBuilder;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.WithoutJenkins;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

  public void testMultiFileGlob() throws Exception {
    glob = "*.txt";
    underTest =
        new GoogleCloudStorageUploader(
            CREDENTIALS_ID,
            ImmutableList.<AbstractUpload>of(
                setOptionalParams(
                    new ClassicUpload(
                        bucket,
                        new MockUploadModule(executor),
                        glob,
                        null /* legacy arg */,
                        null /* legacy arg */))));

    project.getBuildersList().add(new Shell("echo foo > foo.txt; echo bar > bar.txt"));
    project.getPublishersList().add(underTest);

    executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
    executor.passThruWhen(Storage.Buckets.Insert.class);
    executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);
    executor.passThruWhen(Storage.Objects.Insert.class, checkFieldsMatch);

    FreeStyleBuild build = project.scheduleBuild2(0).get();

    assertEquals(Result.SUCCESS, build.getResult());
  }

  @Test
  @WithoutJenkins
  public void testDescriptor() {
    DescriptorImpl descriptor = new DescriptorImpl();