From def0a7dc27ea739aab1df8db2f68a10c887ed942 Mon Sep 17 00:00:00 2001 From: Shoma Gujjar Date: Tue, 14 Apr 2020 22:36:08 +0100 Subject: [PATCH] CON-1640-fix broken build --- .../GetApprenticeship/WhenIGetApprenticeship.cs | 8 ++++++-- .../Queries/GetReservations/WhenIGetReservations.cs | 10 ++++++++-- .../Queries/GetSingleCohort/WhenIGetSingleCohort.cs | 9 +++++---- .../Queries/GetVacancies/WhenIGetVacancies.cs | 8 ++++++-- .../Configuration/EmployerAccountsConfiguration.cs | 1 + .../EmployerApprenticeshipsServiceConfiguration.cs | 1 - .../GetApprenticeship/GetApprenticeshipsHandler.cs | 6 +++--- .../GetReservations/GetReservationsRequestHandler.cs | 10 +++++----- .../Queries/GetVacancies/GetVacanciesRequestHandler.cs | 8 ++++---- 9 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetApprenticeship/WhenIGetApprenticeship.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetApprenticeship/WhenIGetApprenticeship.cs index 0545fb979a..2c7bdb9119 100644 --- a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetApprenticeship/WhenIGetApprenticeship.cs +++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetApprenticeship/WhenIGetApprenticeship.cs @@ -6,8 +6,8 @@ using NUnit.Framework; using SFA.DAS.NLog.Logger; using System.Threading.Tasks; -using SFA.DAS.CommitmentsV2.Api.Types.Responses; using System.Collections.Generic; +using SFA.DAS.EmployerAccounts.Configuration; using SFA.DAS.EmployerAccounts.Models.CommitmentsV2; using SFA.DAS.HashingService; @@ -24,6 +24,7 @@ public class WhenIGetApprenticeship : QueryBaseTest _logger; private long _accountId; private string _hashedAccountId; + public EmployerAccountsConfiguration EmployerAccountsConfiguration { get; set; } [SetUp] public void Arrange() @@ -40,8 +41,11 @@ public void Arrange() _commitmentV2Service.Setup(m => m.GetApprenticeships(_accountId)).ReturnsAsync(new List { new Apprenticeship { Id = 3 } }); _hashingService = new Mock(); _hashingService.Setup(x => x.DecodeValue(_hashedAccountId)).Returns(_accountId); + EmployerAccountsConfiguration = new EmployerAccountsConfiguration() + { - RequestHandler = new GetApprenticeshipsHandler(RequestValidator.Object, _logger.Object, _commitmentV2Service.Object, _hashingService.Object); + }; + RequestHandler = new GetApprenticeshipsHandler(RequestValidator.Object, _logger.Object, _commitmentV2Service.Object, _hashingService.Object, EmployerAccountsConfiguration); Query = new GetApprenticeshipsRequest { diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetReservations/WhenIGetReservations.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetReservations/WhenIGetReservations.cs index 7b000b53ce..7e617ac429 100644 --- a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetReservations/WhenIGetReservations.cs +++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetReservations/WhenIGetReservations.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Moq; using NUnit.Framework; +using SFA.DAS.EmployerAccounts.Configuration; using SFA.DAS.EmployerAccounts.Interfaces; using SFA.DAS.EmployerAccounts.Models.Reservations; using SFA.DAS.EmployerAccounts.Queries.GetReservations; @@ -22,10 +23,11 @@ public class WhenIGetReservations : QueryBaseTest _hashingService; private Reservation _reservation; private Mock _logger; - + public EmployerAccountsConfiguration EmployerAccountsConfiguration { get; set; } private string _hashedAccountId; private long _accountId; + [SetUp] public void Arrange() { @@ -46,8 +48,12 @@ public void Arrange() _hashingService .Setup(m => m.DecodeValue(_hashedAccountId)) .Returns(_accountId); + EmployerAccountsConfiguration = EmployerAccountsConfiguration = new EmployerAccountsConfiguration() + { + + }; - RequestHandler = new GetReservationsRequestHandler(RequestValidator.Object, _logger.Object, _reservationsService.Object, _hashingService.Object); + RequestHandler = new GetReservationsRequestHandler(RequestValidator.Object, _logger.Object, _reservationsService.Object, _hashingService.Object,EmployerAccountsConfiguration); Query = new GetReservationsRequest { diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetSingleCohort/WhenIGetSingleCohort.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetSingleCohort/WhenIGetSingleCohort.cs index cf4ef0866d..a96c740820 100644 --- a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetSingleCohort/WhenIGetSingleCohort.cs +++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetSingleCohort/WhenIGetSingleCohort.cs @@ -3,14 +3,12 @@ using SFA.DAS.EmployerAccounts.Interfaces; using SFA.DAS.EmployerAccounts.Models.CommitmentsV2; using SFA.DAS.EmployerAccounts.Queries.GetSingleCohort; -using SFA.DAS.Encoding; using SFA.DAS.HashingService; -using SFA.DAS.NLog.Logger; using SFA.DAS.Validation; -using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using SFA.DAS.EmployerAccounts.Configuration; namespace SFA.DAS.EmployerAccounts.UnitTests.Queries.GetSingleCohort { @@ -23,7 +21,8 @@ public class WhenIGetSingleCohort : QueryBaseTest _hashingService; private long _accountId; private long _cohortId; - public string hashedAccountId; + public string hashedAccountId; + public EmployerAccountsConfiguration EmployerAccountsConfiguration { get; set; } [SetUp] public void Arrange() @@ -43,6 +42,8 @@ public void Arrange() _hashingService = new Mock(); _hashingService.Setup(x => x.DecodeValue(hashedAccountId)).Returns(_accountId); + EmployerAccountsConfiguration = EmployerAccountsConfiguration = new EmployerAccountsConfiguration() + { RequestHandler = new GetSingleCohortRequestHandler(RequestValidator.Object, _commitmentV2Service.Object, _hashingService.Object, Mock.Of()); diff --git a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetVacancies/WhenIGetVacancies.cs b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetVacancies/WhenIGetVacancies.cs index 188a0aaebb..ca87d0bead 100644 --- a/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetVacancies/WhenIGetVacancies.cs +++ b/src/SFA.DAS.EmployerAccounts.UnitTests/Queries/GetVacancies/WhenIGetVacancies.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Moq; using NUnit.Framework; +using SFA.DAS.EmployerAccounts.Configuration; using SFA.DAS.EmployerAccounts.Interfaces; using SFA.DAS.EmployerAccounts.Models.Recruit; using SFA.DAS.EmployerAccounts.Queries.GetVacancies; @@ -20,7 +21,7 @@ public class GetVacancies : QueryBaseTest _recruitService; private Vacancy _vacancy; private Mock _logger; - + public EmployerAccountsConfiguration EmployerAccountsConfiguration { get; set; } private string _hashedAccountId; [SetUp] @@ -37,8 +38,11 @@ public void Arrange() _recruitService .Setup(s => s.GetVacancies(_hashedAccountId, int.MaxValue)) .ReturnsAsync(new List { _vacancy }); + EmployerAccountsConfiguration = EmployerAccountsConfiguration = new EmployerAccountsConfiguration() + { - RequestHandler = new GetVacanciesRequestHandler(RequestValidator.Object, _logger.Object, _recruitService.Object); + }; + RequestHandler = new GetVacanciesRequestHandler(RequestValidator.Object, _logger.Object, _recruitService.Object, EmployerAccountsConfiguration); Query = new GetVacanciesRequest { diff --git a/src/SFA.DAS.EmployerAccounts/Configuration/EmployerAccountsConfiguration.cs b/src/SFA.DAS.EmployerAccounts/Configuration/EmployerAccountsConfiguration.cs index aabaf9261f..d735c9610b 100644 --- a/src/SFA.DAS.EmployerAccounts/Configuration/EmployerAccountsConfiguration.cs +++ b/src/SFA.DAS.EmployerAccounts/Configuration/EmployerAccountsConfiguration.cs @@ -48,5 +48,6 @@ public class EmployerAccountsConfiguration : ITopicMessagePublisherConfiguration public string ZenDeskCobrowsingSnippetKey { get; set; } public CommitmentsApiV2ClientConfiguration CommitmentsApi { get; set; } public RecruitClientApiConfiguration RecruitApi { get; set; } + public int AddApprenticeCallToActionTimeout { get; set; } } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts/Configuration/EmployerApprenticeshipsServiceConfiguration.cs b/src/SFA.DAS.EmployerAccounts/Configuration/EmployerApprenticeshipsServiceConfiguration.cs index 851abacf8f..27defd0bc3 100644 --- a/src/SFA.DAS.EmployerAccounts/Configuration/EmployerApprenticeshipsServiceConfiguration.cs +++ b/src/SFA.DAS.EmployerAccounts/Configuration/EmployerApprenticeshipsServiceConfiguration.cs @@ -32,6 +32,5 @@ public class EmployerApprenticeshipsServiceConfiguration : ITopicMessagePublishe public string PublicHashstring { get; set; } public string ServiceBusConnectionString { get; set; } public Dictionary ServiceBusConnectionStrings { get; set; } - public int AddApprenticeCallToActionTimeout { get; set; } } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerAccounts/Queries/GetApprenticeship/GetApprenticeshipsHandler.cs b/src/SFA.DAS.EmployerAccounts/Queries/GetApprenticeship/GetApprenticeshipsHandler.cs index 0e0a79cbde..a997340ffb 100644 --- a/src/SFA.DAS.EmployerAccounts/Queries/GetApprenticeship/GetApprenticeshipsHandler.cs +++ b/src/SFA.DAS.EmployerAccounts/Queries/GetApprenticeship/GetApprenticeshipsHandler.cs @@ -16,18 +16,18 @@ public class GetApprenticeshipsHandler : IAsyncRequestHandler validator, ILog logger, ICommitmentV2Service commitmentV2Service, - IHashingService hashingService, EmployerApprenticeshipsServiceConfiguration employerApprenticeshipsServiceConfiguration) + IHashingService hashingService, EmployerAccountsConfiguration employerAccountsConfiguration) { _validator = validator; _logger = logger; _commitmentV2Service = commitmentV2Service; _hashingService = hashingService; - _employerApprenticeshipsServiceConfiguration = employerApprenticeshipsServiceConfiguration; + _employerAccountsConfiguration = employerAccountsConfiguration; } public async Task Handle(GetApprenticeshipsRequest message) diff --git a/src/SFA.DAS.EmployerAccounts/Queries/GetReservations/GetReservationsRequestHandler.cs b/src/SFA.DAS.EmployerAccounts/Queries/GetReservations/GetReservationsRequestHandler.cs index bebf268fc4..30dbd27232 100644 --- a/src/SFA.DAS.EmployerAccounts/Queries/GetReservations/GetReservationsRequestHandler.cs +++ b/src/SFA.DAS.EmployerAccounts/Queries/GetReservations/GetReservationsRequestHandler.cs @@ -15,20 +15,20 @@ public class GetReservationsRequestHandler : IAsyncRequestHandler validator, ILog logger, IReservationsService service, - IHashingService hashingService, - EmployerApprenticeshipsServiceConfiguration employerApprenticeshipsServiceConfiguration) + IHashingService hashingService, + EmployerAccountsConfiguration employerAccountsConfiguration) { _validator = validator; _logger = logger; _service = service; _hashingService = hashingService; - _employerApprenticeshipsServiceConfiguration = employerApprenticeshipsServiceConfiguration; + _employerAccountsConfiguration = employerAccountsConfiguration; } public async Task Handle(GetReservationsRequest message) @@ -47,7 +47,7 @@ public async Task Handle(GetReservationsRequest message try { var task = _service.Get(accountId); - if (await Task.WhenAny(task, Task.Delay(_employerApprenticeshipsServiceConfiguration.AddApprenticeCallToActionTimeout)) == task) + if (await Task.WhenAny(task, Task.Delay(_employerAccountsConfiguration.AddApprenticeCallToActionTimeout)) == task) { await task; } diff --git a/src/SFA.DAS.EmployerAccounts/Queries/GetVacancies/GetVacanciesRequestHandler.cs b/src/SFA.DAS.EmployerAccounts/Queries/GetVacancies/GetVacanciesRequestHandler.cs index 07f5bb22a7..c9040a17c0 100644 --- a/src/SFA.DAS.EmployerAccounts/Queries/GetVacancies/GetVacanciesRequestHandler.cs +++ b/src/SFA.DAS.EmployerAccounts/Queries/GetVacancies/GetVacanciesRequestHandler.cs @@ -13,17 +13,17 @@ public class GetVacanciesRequestHandler : IAsyncRequestHandler _validator; private readonly ILog _logger; private readonly IRecruitService _service; - private readonly EmployerApprenticeshipsServiceConfiguration _employerApprenticeshipsServiceConfiguration; + private readonly EmployerAccountsConfiguration _employerAccountsConfiguration; public GetVacanciesRequestHandler( IValidator validator, ILog logger, - IRecruitService service, EmployerApprenticeshipsServiceConfiguration employerApprenticeshipsServiceConfiguration) + IRecruitService service, EmployerAccountsConfiguration employerAccountsConfiguration) { _validator = validator; _logger = logger; _service = service; - _employerApprenticeshipsServiceConfiguration = employerApprenticeshipsServiceConfiguration; + _employerAccountsConfiguration = employerAccountsConfiguration; } public async Task Handle(GetVacanciesRequest message) @@ -40,7 +40,7 @@ public async Task Handle(GetVacanciesRequest message) try { var task = _service.GetVacancies(message.HashedAccountId); - if (await Task.WhenAny(task, Task.Delay(_employerApprenticeshipsServiceConfiguration.AddApprenticeCallToActionTimeout)) == task) + if (await Task.WhenAny(task, Task.Delay(_employerAccountsConfiguration.AddApprenticeCallToActionTimeout)) == task) { await task; return new GetVacanciesResponse