public void ICanListJobs()
        {
            var expectedJob = new JobDetails() { ExitCode = 12, Name = "some jobDetails", StatusCode = JobStatusCode.Completed, JobId = "2345" };

            var factory = new MockRemotePocoLayerFactory();
            var pocoMock = new MockRemotePoco { JobId = string.Empty, JobDetails = expectedJob };
            factory.Mock = pocoMock;

            ServiceLocator.Instance.Locate<IServiceLocationIndividualTestManager>().Override<IRemoteHadoopJobSubmissionPocoClientFactory>(factory);

            // var creds = new JobSubmissionCertificateCredential(Guid.NewGuid(), null, "someCluster");
            var creds = new BasicAuthCredential()
            {
                Password = "******",
                Server = new Uri("http://somewhere"),
                UserName = "******"
            };

            var poco = new HDInsightJobSubmissionPocoClient(creds, GetAbstractionContext(), false, pocoMock.GetUserAgentString());
            var task = poco.ListJobs();
            task.Wait();

            Assert.IsNotNull(task.Result);
            Assert.IsTrue(pocoMock.ListJobsCalled);
            Assert.AreEqual(1, task.Result.Jobs.Count);

            var job = task.Result.Jobs.First();
            Assert.AreEqual("2345", job.JobId);
            Assert.AreEqual(expectedJob, job);
        }
 public void DisableHttpServices_GetJobHistory()
 {
     var testCluster = GetHttpAccessDisabledCluster();
     var connectionCredentials = new BasicAuthCredential()
     {
         Server = new Uri(testCluster.ConnectionUrl),
         Password = testCluster.HttpPassword,
         UserName = testCluster.HttpUserName
     };
     var jobSubmissionClient = new HDInsightJobSubmissionPocoClient(connectionCredentials, GetAbstractionContext(), false, customUserAgent);
     jobSubmissionClient.ListJobs().WaitForResult();
 }
        public void ICanSubmitASqoopJob()
        {
            var factory = new MockRemotePocoLayerFactory();
            var pocoMock = new MockRemotePoco();
            pocoMock.JobId = "54321";
            factory.Mock = pocoMock;

            ServiceLocator.Instance.Locate<IServiceLocationIndividualTestManager>().Override<IRemoteHadoopJobSubmissionPocoClientFactory>(factory);

            // var creds = new JobSubmissionCertificateCredential(Guid.NewGuid(), null, "someCluster");
            var creds = new BasicAuthCredential()
            {
                Password = "******",
                Server = new Uri("http://somewhere"),
                UserName = "******"
            };

            var poco = new HDInsightJobSubmissionPocoClient(creds, GetAbstractionContext(), false, pocoMock.GetUserAgentString());
            var task = poco.SubmitSqoopJob(new SqoopJobCreateParameters() { Command = "load remote;" });
            task.Wait();

            Assert.AreEqual("54321", task.Result.JobId);
            Assert.IsTrue(pocoMock.SubmitSqoopJobCalled);
        }
 public void EnableHttpServices_GetJobHistory()
 {
     var testCluster = GetHttpAccessEnabledCluster(false);
     var connectionCredentials = new BasicAuthCredential()
     {
         Server = new Uri(testCluster.ConnectionUrl),
         Password = testCluster.HttpPassword,
         UserName = testCluster.HttpUserName
     };
     var jobSubmissionClient = new HDInsightJobSubmissionPocoClient(connectionCredentials, GetAbstractionContext(), false, customUserAgent);
     var jobHistory = jobSubmissionClient.ListJobs().WaitForResult();
     var expectedJobHistory = SyncClientScenarioTests.GetJobHistory(connectionCredentials.Server.OriginalString);
     Assert.AreEqual(jobHistory.Jobs.Count, expectedJobHistory.Jobs.Count);
 }