private AzureHDInsightHiveJobDefinition UploadFileToStorage(
            AzureHDInsightHiveJobDefinition jobDefinition, AzureHDInsightClusterConnection currentConnection)
        {
            currentConnection.Cluster.DefaultStorageAccount.ArgumentNotNull("DefaultStorageAccount");
            WabStorageAccountConfiguration storageAccount = currentConnection.Cluster.DefaultStorageAccount.ToWabStorageAccountConfiguration();
            var storageHandler = ServiceLocator.Instance.Locate<IAzureHDInsightStorageHandlerFactory>().Create(storageAccount);
            string hiveQueryFilePath = string.Format(
                CultureInfo.InvariantCulture,
                HiveQueryFileStoragePath,
                currentConnection.Cluster.DefaultStorageAccount.StorageAccountName,
                currentConnection.Cluster.DefaultStorageAccount.StorageContainerName,
                currentConnection.Cluster.HttpUserName,
                Guid.NewGuid().ToString("N"));
            using (Stream hiveQueryFileStream = this.GetStreamForText(jobDefinition.Query))
            {
                var hiveQueryFileUri = new Uri(hiveQueryFilePath, UriKind.RelativeOrAbsolute);
                storageHandler.UploadFile(hiveQueryFileUri, hiveQueryFileStream);
                jobDefinition.Query = string.Empty;
                jobDefinition.File = storageHandler.GetStoragePath(hiveQueryFileUri).OriginalString;
            }

            return jobDefinition;
        }
        public void CanCreateNewHiveJob_WithoutJobName_WithQuery()
        {
            var hiveJobDefinition = new AzureHDInsightHiveJobDefinition { Query = "show tables" };

            AzureHDInsightJob startedJob = TestJobStart(hiveJobDefinition);
            Assert.AreEqual(startedJob.Name, "Hive: show tables");
        }
        public void CanStartHiveJob()
        {
            var hiveJobDefinition = new AzureHDInsightHiveJobDefinition { JobName = "pi estimation jobDetails", Query = "show tables;" };

            TestJobStart(hiveJobDefinition);
        }
        public void CanCreateNewHiveJob_WithoutJobName_WithFile()
        {
            var hiveJobDefinition = new AzureHDInsightHiveJobDefinition
            {
                File = TestConstants.WabsProtocolSchemeName + "container@hostname/Container1/myqueryfile.hql"
            };

            AzureHDInsightJob startedJob = TestJobStart(hiveJobDefinition);
            Assert.AreEqual(startedJob.Name, "Hive: myqueryfile.hql");
        }