Skip to content

Commit b7ea31e

Browse files
fix: now returns when the mocking is set to true
1 parent 67ede81 commit b7ea31e

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

application/CohortManager/src/Functions/Shared/Common/PdsHttpClientMock.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Common;
77
using System.Threading.Tasks;
88
using System.Text.Json;
99
using Model;
10+
using Common.Interfaces;
1011

1112
/// <summary>
1213
/// Mock implementation of IHttpClientFunction specifically designed for PDS (Personal Demographics Service) calls.
@@ -17,6 +18,14 @@ namespace Common;
1718
/// </summary>
1819
public class PdsHttpClientMock : IHttpClientFunction
1920
{
21+
22+
private readonly IFhirPatientDemographicMapper _fhirPatientDemographicMapper;
23+
24+
public PdsHttpClientMock(IFhirPatientDemographicMapper fhirPatientDemographicMapper)
25+
{
26+
_fhirPatientDemographicMapper = fhirPatientDemographicMapper;
27+
}
28+
2029
public async Task<HttpResponseMessage> SendPost(string url, string data)
2130
{
2231
await Task.CompletedTask;
@@ -26,7 +35,11 @@ public async Task<HttpResponseMessage> SendPost(string url, string data)
2635
public async Task<string> SendGet(string url, Dictionary<string, string> parameters)
2736
{
2837
await Task.CompletedTask;
29-
return JsonSerializer.Serialize(new PdsDemographic());
38+
var patient = GetPatientMockObject("complete-patient.json");
39+
var pdsDemographic = _fhirPatientDemographicMapper.ParseFhirJson(patient);
40+
var participantDemographic = pdsDemographic.ToParticipantDemographic();
41+
42+
return JsonSerializer.Serialize(participantDemographic);
3043
}
3144

3245
public async Task<string> SendGet(string url)

application/CohortManager/src/Functions/Shared/DataServices.Client/DataServiceClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ public async Task<TEntity> GetSingleByFilter(Expression<Func<TEntity, bool>> pre
8686
var jsonString = await GetJsonStringByFilter(predicate, true);
8787
if (string.IsNullOrEmpty(jsonString))
8888
{
89-
return null;
89+
return null!;
9090
}
91-
TEntity result = JsonSerializer.Deserialize<TEntity>(jsonString);
92-
return result;
91+
TEntity result = JsonSerializer.Deserialize<TEntity>(jsonString)!;
92+
return result!;
9393
}
9494

9595
public async Task<bool> Delete(string id)

0 commit comments

Comments
 (0)