public async Task CanFetchJobReports() { var client = _factory.CreateClient(); var request = new CreateJobsRequest { Data = new [] { "random data 1", "random data 2" }, Type = "Bulk" }; var jsonRequest = JsonConvert.SerializeObject(request); await client.PostAsync("/api/v1/job", new StringContent(jsonRequest, Encoding.UTF8, "application/json")); var createResponse = await client.GetAsync("/api/v1/job/state"); var statesBody = await createResponse.GetJsonBody <JobsStateResponse>(); var reportResponse = await client.GetAsync($"/api/v1/job/report/{statesBody.States[0].Id}"); reportResponse.EnsureSuccessStatusCode(); var reportBody = await reportResponse.GetJsonBody <JobReportResponse>(); Assert.Empty(reportBody.Logs); }
public async Task <CreateJobResponse> Process([FromBody] CreateJobsRequest createJobsRequest) { var now = new DateTime(); var result = await _createJob.Process(createJobsRequest, now); return(result); }
public async Task CanCreateJobs() { var client = _factory.CreateClient(); var request = new CreateJobsRequest { Data = new[] { "random data 1", "random data 2" }, Type = "Bulk" }; var response = await client.PostJsonAsync("/api/v1/job", request); response.EnsureSuccessStatusCode(); var bodyResponse = await response.GetJsonBody <CreateJobResponse>(); Assert.Equal(2, bodyResponse.DataPointsCreated); }
public async Task CanProccessJobs() { var client = _factory.CreateClient(); var request = new CreateJobsRequest { Data = new[] { "random data 1", "random data 2" }, Type = "Bulk" }; var response = await client.PostJsonAsync("/api/v1/job", request); response.EnsureSuccessStatusCode(); var aFewSeconds = new TimeSpan(0, 0, 10); await Task.Delay(aFewSeconds); var createResponse = await client.GetAsync("/api/v1/job/state"); var statesBody = await createResponse.GetJsonBody <JobsStateResponse>(); Assert.NotEmpty(statesBody.States); Assert.NotEmpty(statesBody.States[0].Id); Assert.Equal(JobState.Finished, statesBody.States[0].JobState); var reportResponse = await client.GetAsync($"/api/v1/job/report/{statesBody.States[0].Id}"); reportResponse.EnsureSuccessStatusCode(); var reportBody = await reportResponse.GetJsonBody <JobReportResponse>(); Assert.NotEmpty(reportBody.Logs); Assert.Equal(JobState.Running, reportBody.Logs[0].To); }
public async Task CanFetchJobStates() { var client = _factory.CreateClient(); var request = new CreateJobsRequest { Data = new [] { "random data 1", "random data 2" }, Type = "Bulk" }; var jsonRequest = JsonConvert.SerializeObject(request); await client.PostAsync("/api/v1/job", new StringContent(jsonRequest, Encoding.UTF8, "application/json")); var createResponse = await client.GetAsync("/api/v1/job/state"); var statesBody = await createResponse.GetJsonBody <JobsStateResponse>(); Assert.NotEmpty(statesBody.States); Assert.NotEmpty(statesBody.States[0].Id); Assert.Equal(JobState.Waiting, statesBody.States[0].JobState); }