public async Task GivenAFhirMediator_WhenGettingAnExistingBulkImportTaskWithNotCompletedStatus_ThenHttpResponseCodeShouldBeAccepted(TaskStatus taskStatus)
        {
            GetImportResponse result = await SetupAndExecuteGetBulkImportTaskByIdAsync(taskStatus);

            Assert.Equal(HttpStatusCode.Accepted, result.StatusCode);
            Assert.Null(result.TaskResult);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetImportResponse response = new GetImportResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("createdDate", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.CreatedDate = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("failureReason", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance);
                    response.FailureReason = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("importId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ImportId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("importStatus", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ImportStatus = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("mergeStrategy", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.MergeStrategy = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("name", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Name = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("resourceType", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ResourceType = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        public static async Task <GetImportResponse> GetImportStatusAsync(this IMediator mediator, string jobId, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(mediator, nameof(mediator));
            EnsureArg.IsNotNullOrWhiteSpace(jobId, nameof(jobId));

            var request = new GetImportRequest(jobId);

            GetImportResponse response = await mediator.Send(request, cancellationToken);

            return(response);
        }
        public async Task GivenAFhirMediator_WhenGettingAnExistingBulkImportTaskWithCompletedStatus_ThenHttpResponseCodeShouldBeOk()
        {
            ImportTaskResult expectedResult = new ImportTaskResult();

            expectedResult.Request = "test";

            TaskResultData taskResultData = new TaskResultData()
            {
                Result     = TaskResult.Success,
                ResultData = JsonConvert.SerializeObject(expectedResult),
            };

            GetImportResponse result = await SetupAndExecuteGetBulkImportTaskByIdAsync(TaskStatus.Completed, false, taskResultData);

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
            Assert.NotNull(result.TaskResult);
        }