public void ICanDeserializeJobSubmissionResultFromRawJson()
        {
            var converter = new PayloadConverter();
            var jobId = converter.DeserializeJobSubmissionResponse(RawJobSubmissionResultsPayload);

            Assert.AreEqual("job_001", jobId);
        }
 public void ICanDeserializeJobSubmissionResultFromJsonWithErrorMessage()
 {
     var converter = new PayloadConverter();
     try
     {
         converter.DeserializeJobSubmissionResponse(RawJobSubmissionResultsPayloadWithError);
     }
     catch (InvalidOperationException ex)
     {
         Assert.AreEqual("some error", ex.Message);
     }
 }
 public void ICanDeserializeJobDetailsWithEmptyJobNameInArgumentProperty()
 {
     var converter = new PayloadConverter();
     var jobDetails = converter.DeserializeJobDetails(JobDetailsPayloadWithEmptyNameInArgsProperty);
     Assert.AreEqual(string.Empty, jobDetails.Name);
 }
 public void ICanDeserializeJobDetailsWithCommandInUserArgs()
 {
     var converter = new PayloadConverter();
     var jobDetails = converter.DeserializeJobDetails(JobDetailsPayloadWithCommandProperty);
     Assert.AreEqual("show tables", jobDetails.Query);
 }
 public void ICanDeserializeJobDetailsWithJobNameInArgumentProperty()
 {
     var converter = new PayloadConverter();
     var jobDetails = converter.DeserializeJobDetails(JobDetailsPayloadWithNameInArgsProperty);
     Assert.AreEqual("Pig: records = LOAD '/sah", jobDetails.Name);
 }
 public void DeserializeFailsWithEmptyJobDetailsJson()
 {
     var converter = new PayloadConverter();
     converter.DeserializeJobDetails(EmptyJsonObject);
 }
        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 ICanDeserializeJobSubmissionResultWithMissingId()
 {
     var converter = new PayloadConverter();
     converter.DeserializeJobSubmissionResponse(JobSubmissionResultsPayloadMissingIdAndError);
 }
 public void ICanDeserializeJobSubmissionResultWithBadJson()
 {
     var converter = new PayloadConverter();
     converter.DeserializeJobSubmissionResponse(BadJson);
 }
 public void ICanDeserializeJobDetailsWithMissingJobId()
 {
     var converter = new PayloadConverter();
     converter.DeserializeJobDetails(JobDetailsPayloadWithMissingJobId);
 }
        public void ICanDeserializeJobDetailsWithMissingStartTime()
        {
            var converter = new PayloadConverter();
            var jobDetails = converter.DeserializeJobDetails(JobDetailsPayloadWithMissingStartTime);

            Assert.AreEqual("job_001", jobDetails.JobId);
            Assert.AreEqual(0, jobDetails.ExitCode);
            Assert.AreEqual(DateTime.MinValue, jobDetails.SubmissionTime);
            Assert.AreEqual(JobStatusCode.Completed, jobDetails.StatusCode);
            Assert.AreEqual("TestJob1", jobDetails.Name);
            Assert.AreEqual("some query", jobDetails.Query);
            Assert.AreEqual("/some/place", jobDetails.StatusDirectory);
        }
        public void ICanDeserializeJobDetailsWithNullExitValue()
        {
            var converter = new PayloadConverter();
            var jobDetails = converter.DeserializeJobDetails(JobDetailsPayloadWithNullExitValue);

            Assert.AreEqual("job_001", jobDetails.JobId);
            Assert.IsNull(jobDetails.ExitCode);
            Assert.AreEqual(unixEpoch.AddMilliseconds(1375484358898), jobDetails.SubmissionTime);
            Assert.AreEqual(JobStatusCode.Completed, jobDetails.StatusCode);
            Assert.AreEqual("TestJob1", jobDetails.Name);
            Assert.AreEqual("some query", jobDetails.Query);
            Assert.AreEqual("/some/place", jobDetails.StatusDirectory);
        }
        public void ICanDeserializeJobDetailsWithMissingDefinesArray()
        {
            var converter = new PayloadConverter();
            var jobDetails = converter.DeserializeJobDetails(JobDetailsPayloadWithMissingDefineArray);

            Assert.AreEqual("job_001", jobDetails.JobId);
            Assert.AreEqual(0, jobDetails.ExitCode);
            Assert.AreEqual(unixEpoch.AddMilliseconds(1375484358898), jobDetails.SubmissionTime);
            Assert.AreEqual(JobStatusCode.Completed, jobDetails.StatusCode);
            Assert.AreEqual(string.Empty, jobDetails.Name);
            Assert.AreEqual("/some/place", jobDetails.StatusDirectory);
            Assert.AreEqual("some query", jobDetails.Query);
        }
        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 ICanDeserializeJobDetailsWithJobNameInArgumentAndDefineProperty()
 {
     var converter = new PayloadConverter();
     var jobDetails = converter.DeserializeJobDetails(JobDetailsPayloadWithNameInArgsAnDefinesProperty);
     Assert.AreEqual("Name In Define", jobDetails.Name);
 }
 public void ICanDeserializeJobDetailsWithParentIdAndMissingJobId()
 {
     var converter = new PayloadConverter();
     var jobDetails = converter.DeserializeJobDetails(JobDetailsPayloadWithParentIdAndMissingJobId);
     Assert.AreEqual("job_000", jobDetails.JobId);
     Assert.AreEqual(0, jobDetails.ExitCode);
     Assert.AreEqual(unixEpoch.AddMilliseconds(1375484358898), jobDetails.SubmissionTime);
     Assert.AreEqual(JobStatusCode.Completed, jobDetails.StatusCode);
 }
 public void DeserializeFailsWithInvalidJobDetailsJson()
 {
     var converter = new PayloadConverter();
     converter.DeserializeJobDetails(InvalidJobDetailsJson);
 }
 public void ICanDeserializeJobSubmissionResultWithNonJsonObject()
 {
     var converter = new PayloadConverter();
     converter.DeserializeJobSubmissionResponse(EmptyJsonArray);
 }
 public void DeserializeFailsWithMalformedobDetailsJson()
 {
     var converter = new PayloadConverter();
     converter.DeserializeJobDetails(MalformedJobDetailsJson);
 }
        public void CanDeserializeJobRequestWithInvalidJobId()
        {
            var payloadConverter = new PayloadConverter();
            var payload = payloadConverter.DeserializeJobDetails("{ \"error\": \"job_1111 does not exist\"}");

            Assert.IsNull(payload);
        }
        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);
        }