/// <inheritdoc />
 public async Task<JobList> ListJobs()
 {
     //NEIN: Any code modification here should add unit tests for this class
     var converter = new PayloadConverter();
     var client = ServiceLocator.Instance.Locate<IHadoopRemoteJobSubmissionRestClientFactory>().Create(this.credentials, this.context, this.ignoreSslErrors, this.GetUserAgentString());
     var result = await client.ListJobs();
     return converter.DeserializeListJobResult(result.Content);
 }
        public void ICanDeserializeJobListWithNoValidJobDetails()
        {
            var converter = new PayloadConverter();
            var jobList = converter.DeserializeListJobResult(JobListWithNoValidJobDetails);

            Assert.IsNotNull(jobList);
            Assert.IsNotNull(jobList.Jobs);
            var jobs = jobList.Jobs.ToList();

            Assert.AreEqual(0, jobs.Count);
        }
        public void ICanDeserializeJobListWithMultipleItems()
        {
            var converter = new PayloadConverter();
            var jobList = converter.DeserializeListJobResult(ValidAllFieldsListJobsPayloadWithMultipleItems);

            Assert.IsNotNull(jobList);
            Assert.IsNotNull(jobList.Jobs);
            var jobs = jobList.Jobs.ToList();

            Assert.AreEqual(2, jobs.Count);

            var firstJob = jobs[0];
            Assert.AreEqual("job_002", firstJob.JobId);
            Assert.AreEqual(0, firstJob.ExitCode);
            Assert.AreEqual(unixEpoch.AddMilliseconds(1375484358898).ToLocalTime(), firstJob.SubmissionTime);
            Assert.AreEqual("TestJob1", firstJob.Name);
            Assert.AreEqual(JobStatusCode.Completed, firstJob.StatusCode);
            Assert.AreEqual("/some/place", firstJob.StatusDirectory);
            Assert.AreEqual("some query", firstJob.Query);

            var secondJob = jobs[1];
            Assert.AreEqual("job_004", secondJob.JobId);
            Assert.AreEqual(0, secondJob.ExitCode);
            Assert.AreEqual(unixEpoch.AddMilliseconds(1475484358898).ToLocalTime(), secondJob.SubmissionTime);
            Assert.AreEqual("TestJob2", secondJob.Name);
            Assert.AreEqual(JobStatusCode.Completed, secondJob.StatusCode);
            Assert.AreEqual("/some/place", secondJob.StatusDirectory);
            Assert.AreEqual("some query", secondJob.Query);
        }
        public void ICanDeserializeEmptyJobList()
        {
            var converter = new PayloadConverter();
            var jobList = converter.DeserializeListJobResult(EmptyJsonArray);

            Assert.IsNotNull(jobList);
            Assert.IsNotNull(jobList.Jobs);
            var jobs = jobList.Jobs.ToList();

            Assert.AreEqual(0, jobs.Count);
        }
        public void ICanDeserializeJobListWithOneItemFromRawJson()
        {
            var converter = new PayloadConverter();
            var jobList = converter.DeserializeListJobResult(RawAllFieldsListJobsPayloadWithOneItem);

            Assert.AreEqual(1, jobList.Jobs.Count);
            var jobDetails = jobList.Jobs.First();
            Assert.AreEqual("job_002", jobDetails.JobId);
            Assert.AreEqual(0, jobDetails.ExitCode);
            Assert.AreEqual(unixEpoch.AddMilliseconds(1375484358898).ToLocalTime(), jobDetails.SubmissionTime);
            Assert.AreEqual("TestJob1", jobDetails.Name);
            Assert.AreEqual(JobStatusCode.Completed, jobDetails.StatusCode);
            Assert.AreEqual("/some/place", jobDetails.StatusDirectory);
            Assert.AreEqual("some query", jobDetails.Query);
            Assert.AreEqual("map 100% reduce 100%", jobDetails.PercentComplete);
        }