Skip to content

Commit 9cc65d6

Browse files
chore: rename get method
1 parent 705e16b commit 9cc65d6

5 files changed

Lines changed: 14 additions & 33 deletions

File tree

application/CohortManager/src/Functions/NemsSubscriptionService/ProcessNemsUpdate/ProcessNemsUpdate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private async Task<HttpResponseMessage> RetrievePdsRecord(string nhsNumber)
190190
{"nhsNumber", nhsNumber }
191191
};
192192

193-
return await _httpClientFunction.SendGetHttpResponse(_config.RetrievePdsDemographicURL, queryParams);
193+
return await _httpClientFunction.SendGetResponse(_config.RetrievePdsDemographicURL, queryParams);
194194
}
195195

196196
private async Task ProcessRecord(Participant participant)

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public async Task<string> SendGet(string url, Dictionary<string, string> paramet
6060
return await GetAsync(client);
6161
}
6262

63-
public async Task<HttpResponseMessage> SendGetHttpResponse(string url, Dictionary<string, string> parameters)
63+
public async Task<HttpResponseMessage> SendGetResponse(string url, Dictionary<string, string> parameters)
6464
{
6565
using var client = _factory.CreateClient();
6666

@@ -83,18 +83,6 @@ public async Task<HttpResponseMessage> SendGetResponse(string url)
8383
return await client.GetAsync(url);
8484
}
8585

86-
public async Task<HttpResponseMessage> SendGetResponse(string url, Dictionary<string, string> parameters)
87-
{
88-
using var client = _factory.CreateClient();
89-
90-
url = QueryHelpers.AddQueryString(url, parameters);
91-
92-
client.BaseAddress = new Uri(url);
93-
client.Timeout = _timeout;
94-
95-
return await client.GetAsync(url);
96-
}
97-
9886
public async Task<string> SendGetOrThrowAsync(string url)
9987
{
10088
using var client = _factory.CreateClient();

application/CohortManager/src/Functions/Shared/Common/Interfaces/IHttpClientFunction.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ public interface IHttpClientFunction
2424
/// <returns>string</returns>
2525
Task<string> SendGet(string url, Dictionary<string, string> parameters);
2626

27-
Task<HttpResponseMessage> SendGetHttpResponse(string url, Dictionary<string, string> parameters);
28-
2927
/// <summary>
3028
/// Performs a GET request using HttpClient and returns the entire HTTP response.
3129
/// </summary>

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,4 @@ private static HttpResponseMessage CreateFakeHttpResponse(string url, string con
111111
httpResponseData.StatusCode = HttpStatusCode.OK;
112112
return httpResponseData;
113113
}
114-
115-
public Task<HttpResponseMessage> SendGetHttpResponse(string url, Dictionary<string, string> parameters)
116-
{
117-
throw new NotImplementedException();
118-
}
119114
}

tests/UnitTests/NemsSubscriptionServiceTests/ProcessNemsUpdateTests/ProcessNemsUpdateTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ public async Task Run_FailsToRetrievePdsRecord_LogsError()
103103
HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
104104
httpResponseMessage.StatusCode = HttpStatusCode.OK;
105105

106-
_httpClientFunctionMock.Setup(x => x.SendGetHttpResponse(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>())).ThrowsAsync(new Exception("error"));
106+
_httpClientFunctionMock.Setup(x => x.SendGetResponse(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>())).ThrowsAsync(new Exception("error"));
107107

108108
// Act
109109
await _sut.Run(fileStream, _fileName);
110110

111111
// Assert
112112
_fhirPatientDemographicMapperMock.Verify(x => x.ParseFhirJsonNhsNumber(It.IsAny<string>()), Times.Once);
113113

114-
_httpClientFunctionMock.Verify(x => x.SendGetHttpResponse("RetrievePdsDemographic", It.IsAny<Dictionary<string, string>>()), Times.Once);
114+
_httpClientFunctionMock.Verify(x => x.SendGetResponse("RetrievePdsDemographic", It.IsAny<Dictionary<string, string>>()), Times.Once);
115115

116116
_loggerMock.Verify(x => x.Log(
117117
LogLevel.Error,
@@ -133,15 +133,15 @@ public async Task Run_NhsNumberFromNemsUpdateFileDoesNotMatchRetrievedPdsRecordN
133133
httpResponseMessage.Content = new StringContent(JsonSerializer.Serialize(new PdsDemographic { NhsNumber = "123" }));
134134
httpResponseMessage.StatusCode = HttpStatusCode.OK;
135135

136-
_httpClientFunctionMock.Setup(x => x.SendGetHttpResponse(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>())).ReturnsAsync(httpResponseMessage);
136+
_httpClientFunctionMock.Setup(x => x.SendGetResponse(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>())).ReturnsAsync(httpResponseMessage);
137137

138138
// Act
139139
await _sut.Run(fileStream, _fileName);
140140

141141
// Assert
142142
_fhirPatientDemographicMapperMock.Verify(x => x.ParseFhirJsonNhsNumber(It.IsAny<string>()), Times.Once);
143143

144-
_httpClientFunctionMock.Verify(x => x.SendGetHttpResponse("RetrievePdsDemographic", It.IsAny<Dictionary<string, string>>()), Times.Once);
144+
_httpClientFunctionMock.Verify(x => x.SendGetResponse("RetrievePdsDemographic", It.IsAny<Dictionary<string, string>>()), Times.Once);
145145

146146
_loggerMock.Verify(x => x.Log(
147147
LogLevel.Information,
@@ -175,7 +175,7 @@ public async Task Run_NhsNumberFromNemsUpdateFileDoesNotMatchRetrievedPdsRecordN
175175
httpResponseMessage.Content = new StringContent(JsonSerializer.Serialize(new PdsDemographic { NhsNumber = "123" }));
176176
httpResponseMessage.StatusCode = HttpStatusCode.OK;
177177

178-
_httpClientFunctionMock.Setup(x => x.SendGetHttpResponse(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>())).ReturnsAsync(httpResponseMessage);
178+
_httpClientFunctionMock.Setup(x => x.SendGetResponse(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>())).ReturnsAsync(httpResponseMessage);
179179

180180
_httpClientFunctionMock.Setup(x => x.SendPost("Unsubscribe", It.IsAny<string>())).Throws(new Exception("error"));
181181

@@ -185,7 +185,7 @@ public async Task Run_NhsNumberFromNemsUpdateFileDoesNotMatchRetrievedPdsRecordN
185185
// Assert
186186
_fhirPatientDemographicMapperMock.Verify(x => x.ParseFhirJsonNhsNumber(It.IsAny<string>()), Times.Once);
187187

188-
_httpClientFunctionMock.Verify(x => x.SendGetHttpResponse("RetrievePdsDemographic", It.IsAny<Dictionary<string, string>>()), Times.Once);
188+
_httpClientFunctionMock.Verify(x => x.SendGetResponse("RetrievePdsDemographic", It.IsAny<Dictionary<string, string>>()), Times.Once);
189189

190190
_loggerMock.Verify(x => x.Log(
191191
LogLevel.Information,
@@ -219,15 +219,15 @@ public async Task Run_NemsUpdateMatchesPdsRecord_ProcessesRecord()
219219
httpResponseMessage.Content = new StringContent(JsonSerializer.Serialize(new PdsDemographic { NhsNumber = "9000000009" }));
220220
httpResponseMessage.StatusCode = HttpStatusCode.OK;
221221

222-
_httpClientFunctionMock.Setup(x => x.SendGetHttpResponse(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>())).ReturnsAsync(httpResponseMessage);
222+
_httpClientFunctionMock.Setup(x => x.SendGetResponse(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>())).ReturnsAsync(httpResponseMessage);
223223

224224
// Act
225225
await _sut.Run(fileStream, _fileName);
226226

227227
// Assert
228228
_fhirPatientDemographicMapperMock.Verify(x => x.ParseFhirJsonNhsNumber(It.IsAny<string>()), Times.Once);
229229

230-
_httpClientFunctionMock.Verify(x => x.SendGetHttpResponse("RetrievePdsDemographic", It.IsAny<Dictionary<string, string>>()), Times.Once);
230+
_httpClientFunctionMock.Verify(x => x.SendGetResponse("RetrievePdsDemographic", It.IsAny<Dictionary<string, string>>()), Times.Once);
231231

232232

233233
_loggerMock.Verify(x => x.Log(
@@ -256,14 +256,14 @@ public async Task Run_NhsNumberFromNemsUpdateFileDoesNotMatchRetrievedPdsRecordN
256256
httpResponseMessage.Content = new StringContent(JsonSerializer.Serialize(new PdsDemographic { NhsNumber = "123" }));
257257
httpResponseMessage.StatusCode = HttpStatusCode.OK;
258258

259-
_httpClientFunctionMock.Setup(x => x.SendGetHttpResponse(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>())).ReturnsAsync(httpResponseMessage);
259+
_httpClientFunctionMock.Setup(x => x.SendGetResponse(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>())).ReturnsAsync(httpResponseMessage);
260260

261261
// Act
262262
await _sut.Run(fileStream, _fileName);
263263

264264
// Assert
265265
_fhirPatientDemographicMapperMock.Verify(x => x.ParseFhirJsonNhsNumber(It.IsAny<string>()), Times.Once);
266-
_httpClientFunctionMock.Verify(x => x.SendGetHttpResponse("RetrievePdsDemographic", It.IsAny<Dictionary<string, string>>()), Times.Once);
266+
_httpClientFunctionMock.Verify(x => x.SendGetResponse("RetrievePdsDemographic", It.IsAny<Dictionary<string, string>>()), Times.Once);
267267

268268

269269

@@ -345,7 +345,7 @@ public async Task Run_ExtractedNhsNumber_PassedToPdsService()
345345
await _sut.Run(fileStream, _fileName);
346346

347347
// Assert - Verify correct NHS number is passed to PDS service
348-
_httpClientFunctionMock.Verify(x => x.SendGetHttpResponse(
348+
_httpClientFunctionMock.Verify(x => x.SendGetResponse(
349349
"RetrievePdsDemographic",
350350
It.Is<Dictionary<string, string>>(dict =>
351351
dict.ContainsKey("nhsNumber") && dict["nhsNumber"] == expectedNhsNumber)),
@@ -368,7 +368,7 @@ public async Task Run_XmlBundleFile_PassesNhsNumberToPdsService()
368368
await _sut.Run(fileStream, xmlFileName);
369369

370370
// Assert - Verify correct NHS number is passed to PDS service
371-
_httpClientFunctionMock.Verify(x => x.SendGetHttpResponse(
371+
_httpClientFunctionMock.Verify(x => x.SendGetResponse(
372372
"RetrievePdsDemographic",
373373
It.Is<Dictionary<string, string>>(dict =>
374374
dict.ContainsKey("nhsNumber") && dict["nhsNumber"] == expectedNhsNumber)),

0 commit comments

Comments
 (0)