Skip to content

Commit a9603ec

Browse files
refactor: remove unused logger and fix maintainability issues (#1173)
1 parent c148d9f commit a9603ec

File tree

6 files changed

+8
-40
lines changed

6 files changed

+8
-40
lines changed

application/CohortManager/src/Functions/CaasIntegration/receiveCaasFile/ProcessFileClasses/AddBatchToQueue.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
namespace NHS.Screening.ReceiveCaasFile;
22

33
using System.Collections.Concurrent;
4-
using System.Text;
5-
using System.Text.Json;
6-
using Azure.Storage.Queues;
74
using Common;
8-
using Microsoft.Extensions.Logging;
95
using Model;
106

117
public class AddBatchToQueue : IAddBatchToQueue
128
{
139

14-
private readonly ILogger<AddBatchToQueue> _logger;
1510
private readonly IQueueClient _queueClient;
1611

17-
public AddBatchToQueue(ILogger<AddBatchToQueue> logger, IQueueClient queueClient)
12+
public AddBatchToQueue(IQueueClient queueClient)
1813
{
19-
_logger = logger;
2014
_queueClient = queueClient;
2115
}
2216

@@ -45,7 +39,6 @@ private async Task AddMessagesAsync(ConcurrentQueue<BasicParticipantCsvRecord> c
4539

4640
// Wait for all tasks to complete
4741
await Task.WhenAll(tasks.ToArray());
48-
4942
}
5043

5144
private async Task AddMessage(BasicParticipantCsvRecord basicParticipantCsvRecord, string queueName)

application/CohortManager/src/Functions/Shared/Data/Database/CreateCohortDistributionData.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,19 @@ namespace Data.Database;
66
using System.Threading.Tasks;
77
using Common.Interfaces;
88
using DataServices.Client;
9-
using Microsoft.Extensions.Logging;
109
using Model;
1110
using Model.DTO;
1211
using Model.Enums;
1312
using NHS.CohortManager.Shared.Utilities;
1413

1514
public class CreateCohortDistributionData : ICreateCohortDistributionData
1615
{
17-
private readonly ILogger<CreateCohortDistributionData> _logger;
18-
1916
private readonly IDataServiceClient<CohortDistribution> _cohortDistributionDataServiceClient;
2017

2118
private readonly IDataServiceClient<BsSelectRequestAudit> _bsSelectRequestAuditDataServiceClient;
2219

23-
public CreateCohortDistributionData(ILogger<CreateCohortDistributionData> logger, IDataServiceClient<CohortDistribution> cohortDistributionDataServiceClient, IDataServiceClient<BsSelectRequestAudit> bsSelectRequestAuditDataServiceClient)
20+
public CreateCohortDistributionData(IDataServiceClient<CohortDistribution> cohortDistributionDataServiceClient, IDataServiceClient<BsSelectRequestAudit> bsSelectRequestAuditDataServiceClient)
2421
{
25-
_logger = logger;
2622
_cohortDistributionDataServiceClient = cohortDistributionDataServiceClient;
2723
_bsSelectRequestAuditDataServiceClient = bsSelectRequestAuditDataServiceClient;
2824
}
@@ -173,7 +169,7 @@ public async Task<CohortRequestAudit> GetNextCohortRequestAudit(Guid requestId)
173169

174170
var previousRequest = await _bsSelectRequestAuditDataServiceClient.GetSingleByFilter(x => x.RequestId == requestId);
175171

176-
if(previousRequest == null)
172+
if (previousRequest == null)
177173
{
178174
throw new KeyNotFoundException("No RequestId Found");
179175
}
@@ -186,7 +182,7 @@ public async Task<CohortRequestAudit> GetNextCohortRequestAudit(Guid requestId)
186182

187183
var recordToReturn = res.OrderBy(x => x.CreatedDateTime).FirstOrDefault();
188184

189-
if(recordToReturn == null)
185+
if (recordToReturn == null)
190186
{
191187
return null;
192188
}

tests/UnitTests/CaasIntegrationTests/AddBatchToQueueTest/AddBatchToQueueTest.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,12 @@
1414
[TestClass]
1515
public class AddBatchToQueueTest
1616
{
17-
private readonly Mock<ILogger<AddBatchToQueue>> _loggerMock = new();
1817
private readonly Mock<IQueueClient> _mockQueueStorageHelper = new();
1918
private AddBatchToQueue _addBatchToQueue;
2019

21-
22-
2320
public AddBatchToQueueTest()
2421
{
25-
26-
27-
_addBatchToQueue = new AddBatchToQueue(_loggerMock.Object, _mockQueueStorageHelper.Object);
22+
_addBatchToQueue = new AddBatchToQueue(_mockQueueStorageHelper.Object);
2823
}
2924

3025
[TestMethod]
@@ -84,6 +79,4 @@ public async Task ProcessBatch_BatchIsNull_SendMessageNotCalled()
8479
//Assert
8580
_mockQueueStorageHelper.Verify(x => x.AddAsync(It.IsAny<BasicParticipantCsvRecord>(), It.IsAny<string>()), Times.Never);
8681
}
87-
8882
}
89-

tests/UnitTests/CohortDistributionTests/CohortDistributionDataTests/AddCohortDistributionTests.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
namespace NHS.CohortManager.Tests.UnitTests.AddCohortDistributionDataTests;
22

3-
using System.Collections.Concurrent;
43
using System.Linq.Expressions;
54
using System.Threading.Tasks;
6-
using Castle.Core.Logging;
75
using Data.Database;
86
using DataServices.Client;
9-
using Microsoft.Extensions.Logging;
107
using Model;
11-
using Model.DTO;
128
using Moq;
13-
using NHS.CohortManager.Tests.TestUtils;
149

1510
[TestClass]
1611
public class AddCohortDistributionTests
1712
{
1813
private readonly CreateCohortDistributionData _createCohortDistributionData;
1914
private readonly Guid _requestId = Guid.NewGuid();
20-
21-
private readonly Mock<ILogger<CreateCohortDistributionData>> _loggerMock = new();
2215
private List<CohortDistribution> _cohortDistributionList;
2316
private readonly Mock<IDataServiceClient<CohortDistribution>> _cohortDistributionDataServiceClient = new();
2417
private readonly Mock<IDataServiceClient<BsSelectRequestAudit>> _bsSelectRequestAuditDataServiceClient = new();
2518

2619
public AddCohortDistributionTests()
2720
{
28-
_createCohortDistributionData = new CreateCohortDistributionData(_loggerMock.Object, _cohortDistributionDataServiceClient.Object, _bsSelectRequestAuditDataServiceClient.Object);
21+
_createCohortDistributionData = new CreateCohortDistributionData(_cohortDistributionDataServiceClient.Object, _bsSelectRequestAuditDataServiceClient.Object);
2922
}
3023

3124
[TestMethod]

tests/UnitTests/CohortDistributionTests/RetrieveCohortDistributionTests/RetrieveCohortDistributionTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class RetrieveCohortDistributionTests
2323
private readonly RetrieveCohortDistributionData _sut;
2424
private readonly ICreateCohortDistributionData _createCohortDistribution;
2525
private readonly Mock<ILogger<RetrieveCohortDistributionData>> _retrieveCohortLogger = new();
26-
private readonly Mock<ILogger<CreateCohortDistributionData>> _createCohortLogger = new();
2726
private readonly Mock<IDataServiceClient<CohortDistribution>> _cohortDistributionDataClient = new();
2827
private readonly Mock<IDataServiceClient<BsSelectRequestAudit>> _requestAuditDistributionDataClient = new();
2928
private readonly Mock<ICreateResponse> _createResponse = new();
@@ -34,7 +33,7 @@ public RetrieveCohortDistributionTests()
3433
{
3534

3635
_config.Setup(i => i.Value).Returns(new RetrieveCohortDistributionConfig());
37-
_createCohortDistribution = new CreateCohortDistributionData(_createCohortLogger.Object, _cohortDistributionDataClient.Object, _requestAuditDistributionDataClient.Object);
36+
_createCohortDistribution = new CreateCohortDistributionData(_cohortDistributionDataClient.Object, _requestAuditDistributionDataClient.Object);
3837
_sut = new RetrieveCohortDistributionData(_retrieveCohortLogger.Object, _createCohortDistribution, _createResponse.Object, _exceptionHandler.Object, _config.Object);
3938

4039
_createResponse.Setup(x => x.CreateHttpResponse(It.IsAny<HttpStatusCode>(), It.IsAny<HttpRequestData>(), It.IsAny<string?>()))
@@ -273,6 +272,5 @@ public async Task Run_GetBatchWithRequestIdNextBatchNull_ReturnsSuccessful()
273272

274273
// assert
275274
Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
276-
277275
}
278276
}

tests/UnitTests/CohortDistributionTests/RetrieveCohortRequestAuditTests/RetrieveCohortRequestAuditTests.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,19 @@ namespace NHS.CohortManager.Tests.UnitTests.RetrieveCohortRequestAuditTests;
33
using System.Linq.Expressions;
44
using Data.Database;
55
using DataServices.Client;
6-
using Microsoft.Extensions.Logging;
76
using Model;
87
using Moq;
98
[TestClass]
109
public class RetrieveCohortRequestAuditTests
1110
{
1211

1312
private readonly CreateCohortDistributionData _createCohortDistributionData;
14-
private readonly Guid _requestId = Guid.NewGuid();
15-
16-
private readonly Mock<ILogger<CreateCohortDistributionData>> _loggerMock = new();
1713
private readonly Mock<IDataServiceClient<CohortDistribution>> _cohortDistributionDataServiceClient = new();
1814
private readonly Mock<IDataServiceClient<BsSelectRequestAudit>> _bsSelectRequestAuditDataServiceClient = new();
1915

2016
public RetrieveCohortRequestAuditTests()
2117
{
22-
_createCohortDistributionData = new CreateCohortDistributionData(_loggerMock.Object, _cohortDistributionDataServiceClient.Object, _bsSelectRequestAuditDataServiceClient.Object);
18+
_createCohortDistributionData = new CreateCohortDistributionData(_cohortDistributionDataServiceClient.Object, _bsSelectRequestAuditDataServiceClient.Object);
2319
}
2420

2521

@@ -79,7 +75,6 @@ public async Task GetCohortRequestAudit_WithNullParameters_ReturnsValidCohortReq
7975
Assert.IsNotNull(result);
8076
Assert.AreEqual(1, result.Count);
8177
Assert.IsInstanceOfType(result, typeof(List<CohortRequestAudit>));
82-
8378
}
8479

8580
[TestMethod]

0 commit comments

Comments
 (0)