From 9be2a2c1ccf4b1eec4a77c12c0ff57db2c9afc44 Mon Sep 17 00:00:00 2001 From: Martyn Whitwell Date: Thu, 6 Jun 2024 10:12:45 +0100 Subject: [PATCH 1/2] work in progress --- .../Contracts/ApplyCandidateApiTests.cs | 3 +++ ...ith_a_new_candidaite_and_no_application_form.json.OLD} | 0 ...ndidate_and_fully_populated_application_form.json.OLD} | 0 ...h_an_existing_candidate_and_application_form.json.OLD} | 0 ...ndidate_and_fully_populated_application_form.json.OLD} | 0 GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj | 8 ++++---- 6 files changed, 7 insertions(+), 4 deletions(-) rename GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/{sync_with_a_new_candidaite_and_no_application_form.json => sync_with_a_new_candidaite_and_no_application_form.json.OLD} (100%) rename GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/{sync_with_a_new_candidate_and_fully_populated_application_form.json => sync_with_a_new_candidate_and_fully_populated_application_form.json.OLD} (100%) rename GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/{sync_with_an_existing_candidate_and_application_form.json => sync_with_an_existing_candidate_and_application_form.json.OLD} (100%) rename GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/{sync_with_an_existing_candidate_and_fully_populated_application_form.json => sync_with_an_existing_candidate_and_fully_populated_application_form.json.OLD} (100%) diff --git a/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs b/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs index 0c779fdbb..bb9d99a9c 100644 --- a/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs +++ b/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs @@ -22,6 +22,9 @@ public async void Contract(string scenario) await Setup(); var candidate = ConstructCandidate(ReadInput(scenario)); + + Assert.Equal( "john@doe.com", candidate.Attributes.Email); + JobClient.Enqueue(c => c.Run(candidate)); await AssertRequestMatchesSnapshot(scenario); diff --git a/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidaite_and_no_application_form.json b/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidaite_and_no_application_form.json.OLD similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidaite_and_no_application_form.json rename to GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidaite_and_no_application_form.json.OLD diff --git a/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_fully_populated_application_form.json b/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_fully_populated_application_form.json.OLD similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_fully_populated_application_form.json rename to GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_fully_populated_application_form.json.OLD diff --git a/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_application_form.json b/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_application_form.json.OLD similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_application_form.json rename to GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_application_form.json.OLD diff --git a/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_fully_populated_application_form.json b/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_fully_populated_application_form.json.OLD similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_fully_populated_application_form.json rename to GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_fully_populated_application_form.json.OLD diff --git a/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj b/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj index d3c24d76e..6748f0a30 100644 --- a/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj +++ b/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj @@ -199,13 +199,13 @@ PreserveNewest - + PreserveNewest PreserveNewest - + PreserveNewest @@ -214,10 +214,10 @@ PreserveNewest - + PreserveNewest - + PreserveNewest From 22db9623b2500750620c5c66a20c0d1889e173e0 Mon Sep 17 00:00:00 2001 From: Martyn Whitwell Date: Thu, 6 Jun 2024 11:57:45 +0100 Subject: [PATCH 2/2] Enforce use of FlurlHttp.Clients.UseNewtonsoft --- GetIntoTeachingApi/GetIntoTeachingApi.csproj | 1 + GetIntoTeachingApi/Jobs/ApplyBackfillJob.cs | 10 +++++++--- GetIntoTeachingApi/Jobs/ApplySyncJob.cs | 6 +++++- GetIntoTeachingApi/Properties/launchSettings.json | 3 ++- .../Contracts/ApplyCandidateApiTests.cs | 4 ++-- ...ync_with_a_new_candidate_and_application_form.json} | 0 ...andidate_and_fully_populated_application_form.json} | 0 ..._with_a_new_candidate_and_no_application_form.json} | 0 ...th_an_existing_candidate_and_application_form.json} | 0 ...andidate_and_fully_populated_application_form.json} | 0 ...ync_with_a_new_candidate_and_application_form.json} | 0 ..._with_a_new_candidate_and_no_application_form.json} | 0 GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj | 10 +++++----- 13 files changed, 22 insertions(+), 12 deletions(-) rename GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/{sync_with_a_new_candidaite_and_application_form.json => sync_with_a_new_candidate_and_application_form.json} (100%) rename GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/{sync_with_a_new_candidate_and_fully_populated_application_form.json.OLD => sync_with_a_new_candidate_and_fully_populated_application_form.json} (100%) rename GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/{sync_with_a_new_candidaite_and_no_application_form.json.OLD => sync_with_a_new_candidate_and_no_application_form.json} (100%) rename GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/{sync_with_an_existing_candidate_and_application_form.json.OLD => sync_with_an_existing_candidate_and_application_form.json} (100%) rename GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/{sync_with_an_existing_candidate_and_fully_populated_application_form.json.OLD => sync_with_an_existing_candidate_and_fully_populated_application_form.json} (100%) rename GetIntoTeachingApiTests/Contracts/Output/ApplyCandidateApi/{sync_with_a_new_candidaite_and_application_form.json => sync_with_a_new_candidate_and_application_form.json} (100%) rename GetIntoTeachingApiTests/Contracts/Output/ApplyCandidateApi/{sync_with_a_new_candidaite_and_no_application_form.json => sync_with_a_new_candidate_and_no_application_form.json} (100%) diff --git a/GetIntoTeachingApi/GetIntoTeachingApi.csproj b/GetIntoTeachingApi/GetIntoTeachingApi.csproj index 266f4ef28..152255728 100644 --- a/GetIntoTeachingApi/GetIntoTeachingApi.csproj +++ b/GetIntoTeachingApi/GetIntoTeachingApi.csproj @@ -12,6 +12,7 @@ + diff --git a/GetIntoTeachingApi/Jobs/ApplyBackfillJob.cs b/GetIntoTeachingApi/Jobs/ApplyBackfillJob.cs index fb9e33020..a04986fbe 100644 --- a/GetIntoTeachingApi/Jobs/ApplyBackfillJob.cs +++ b/GetIntoTeachingApi/Jobs/ApplyBackfillJob.cs @@ -1,9 +1,10 @@ -using System; -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Flurl; using Flurl.Http; +using Flurl.Http.Newtonsoft; using GetIntoTeachingApi.Adapters; using GetIntoTeachingApi.Models; using GetIntoTeachingApi.Models.Apply; @@ -19,7 +20,7 @@ namespace GetIntoTeachingApi.Jobs [AutomaticRetry(Attempts = 0)] public class ApplyBackfillJob : BaseJob { - public static readonly int PagesPerJob = 10; + public static readonly int PagesPerJob = 10; private readonly IBackgroundJobClient _jobClient; private readonly ILogger _logger; private readonly IAppSettings _appSettings; @@ -54,6 +55,9 @@ private static int EndPage(int startPage) private async Task QueueCandidateSyncJobs(DateTime updatedSince, int startPage) { + // Enforce use of the Newtonsoft Json serializer + FlurlHttp.Clients.UseNewtonsoft(); + var request = Env.ApplyCandidateApiUrl .AppendPathSegment("candidates") .SetQueryParam("updated_since", updatedSince) diff --git a/GetIntoTeachingApi/Jobs/ApplySyncJob.cs b/GetIntoTeachingApi/Jobs/ApplySyncJob.cs index 30fe7f876..e8e726c6e 100644 --- a/GetIntoTeachingApi/Jobs/ApplySyncJob.cs +++ b/GetIntoTeachingApi/Jobs/ApplySyncJob.cs @@ -1,9 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Flurl; using Flurl.Http; +using Flurl.Http.Newtonsoft; using GetIntoTeachingApi.Models.Apply; using GetIntoTeachingApi.Services; using GetIntoTeachingApi.Utils; @@ -53,6 +54,9 @@ public async Task RunAsync() private async Task QueueCandidateSyncJobs() { + // Enforce use of the Newtonsoft Json serializer + FlurlHttp.Clients.UseNewtonsoft(); + var request = Env.ApplyCandidateApiUrl .AppendPathSegment("candidates") .SetQueryParam("updated_since", UpdatedSince()) diff --git a/GetIntoTeachingApi/Properties/launchSettings.json b/GetIntoTeachingApi/Properties/launchSettings.json index 85e215d80..788466a27 100644 --- a/GetIntoTeachingApi/Properties/launchSettings.json +++ b/GetIntoTeachingApi/Properties/launchSettings.json @@ -23,7 +23,8 @@ "launchUrl": "swagger", "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "Sentry__Dsn": "" } } } diff --git a/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs b/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs index bb9d99a9c..1aafd73bd 100644 --- a/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs +++ b/GetIntoTeachingApiTests/Contracts/ApplyCandidateApiTests.cs @@ -23,8 +23,8 @@ public async void Contract(string scenario) var candidate = ConstructCandidate(ReadInput(scenario)); - Assert.Equal( "john@doe.com", candidate.Attributes.Email); - + Assert.NotNull(candidate.Attributes.Email); + JobClient.Enqueue(c => c.Run(candidate)); await AssertRequestMatchesSnapshot(scenario); diff --git a/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidaite_and_application_form.json b/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_application_form.json similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidaite_and_application_form.json rename to GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_application_form.json diff --git a/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_fully_populated_application_form.json.OLD b/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_fully_populated_application_form.json similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_fully_populated_application_form.json.OLD rename to GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_fully_populated_application_form.json diff --git a/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidaite_and_no_application_form.json.OLD b/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_no_application_form.json similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidaite_and_no_application_form.json.OLD rename to GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_a_new_candidate_and_no_application_form.json diff --git a/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_application_form.json.OLD b/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_application_form.json similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_application_form.json.OLD rename to GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_application_form.json diff --git a/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_fully_populated_application_form.json.OLD b/GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_fully_populated_application_form.json similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_fully_populated_application_form.json.OLD rename to GetIntoTeachingApiTests/Contracts/Input/ApplyCandidateApi/sync_with_an_existing_candidate_and_fully_populated_application_form.json diff --git a/GetIntoTeachingApiTests/Contracts/Output/ApplyCandidateApi/sync_with_a_new_candidaite_and_application_form.json b/GetIntoTeachingApiTests/Contracts/Output/ApplyCandidateApi/sync_with_a_new_candidate_and_application_form.json similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Output/ApplyCandidateApi/sync_with_a_new_candidaite_and_application_form.json rename to GetIntoTeachingApiTests/Contracts/Output/ApplyCandidateApi/sync_with_a_new_candidate_and_application_form.json diff --git a/GetIntoTeachingApiTests/Contracts/Output/ApplyCandidateApi/sync_with_a_new_candidaite_and_no_application_form.json b/GetIntoTeachingApiTests/Contracts/Output/ApplyCandidateApi/sync_with_a_new_candidate_and_no_application_form.json similarity index 100% rename from GetIntoTeachingApiTests/Contracts/Output/ApplyCandidateApi/sync_with_a_new_candidaite_and_no_application_form.json rename to GetIntoTeachingApiTests/Contracts/Output/ApplyCandidateApi/sync_with_a_new_candidate_and_no_application_form.json diff --git a/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj b/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj index 6748f0a30..09e0a3c9d 100644 --- a/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj +++ b/GetIntoTeachingApiTests/GetIntoTeachingApiTests.csproj @@ -199,13 +199,13 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest @@ -214,10 +214,10 @@ PreserveNewest - + PreserveNewest - + PreserveNewest