Skip to content

Commit

Permalink
CON-1640-fix broken build
Browse files Browse the repository at this point in the history
  • Loading branch information
shomavg committed Apr 21, 2020
1 parent 96d969a commit def0a7d
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -24,6 +24,7 @@ public class WhenIGetApprenticeship : QueryBaseTest<GetApprenticeshipsHandler, G
private Mock<ILog> _logger;
private long _accountId;
private string _hashedAccountId;
public EmployerAccountsConfiguration EmployerAccountsConfiguration { get; set; }

[SetUp]
public void Arrange()
Expand All @@ -40,8 +41,11 @@ public void Arrange()
_commitmentV2Service.Setup(m => m.GetApprenticeships(_accountId)).ReturnsAsync(new List<Apprenticeship> { new Apprenticeship { Id = 3 } });
_hashingService = new Mock<IHashingService>();
_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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,10 +23,11 @@ public class WhenIGetReservations : QueryBaseTest<GetReservationsRequestHandler,
private Mock<IHashingService> _hashingService;
private Reservation _reservation;
private Mock<ILog> _logger;

public EmployerAccountsConfiguration EmployerAccountsConfiguration { get; set; }
private string _hashedAccountId;
private long _accountId;


[SetUp]
public void Arrange()
{
Expand All @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -23,7 +21,8 @@ public class WhenIGetSingleCohort : QueryBaseTest<GetSingleCohortRequestHandler,
private Mock<IHashingService> _hashingService;
private long _accountId;
private long _cohortId;
public string hashedAccountId;
public string hashedAccountId;
public EmployerAccountsConfiguration EmployerAccountsConfiguration { get; set; }

[SetUp]
public void Arrange()
Expand All @@ -43,6 +42,8 @@ public void Arrange()

_hashingService = new Mock<IHashingService>();
_hashingService.Setup(x => x.DecodeValue(hashedAccountId)).Returns(_accountId);
EmployerAccountsConfiguration = EmployerAccountsConfiguration = new EmployerAccountsConfiguration()
{

RequestHandler = new GetSingleCohortRequestHandler(RequestValidator.Object, _commitmentV2Service.Object, _hashingService.Object, Mock.Of<ILog>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,7 +21,7 @@ public class GetVacancies : QueryBaseTest<GetVacanciesRequestHandler, GetVacanci
private Mock<IRecruitService> _recruitService;
private Vacancy _vacancy;
private Mock<ILog> _logger;

public EmployerAccountsConfiguration EmployerAccountsConfiguration { get; set; }
private string _hashedAccountId;

[SetUp]
Expand All @@ -37,8 +38,11 @@ public void Arrange()
_recruitService
.Setup(s => s.GetVacancies(_hashedAccountId, int.MaxValue))
.ReturnsAsync(new List<Vacancy> { _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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ public class EmployerApprenticeshipsServiceConfiguration : ITopicMessagePublishe
public string PublicHashstring { get; set; }
public string ServiceBusConnectionString { get; set; }
public Dictionary<string, string> ServiceBusConnectionStrings { get; set; }
public int AddApprenticeCallToActionTimeout { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ public class GetApprenticeshipsHandler : IAsyncRequestHandler<GetApprenticeships
private readonly ILog _logger;
private readonly ICommitmentV2Service _commitmentV2Service;
private readonly IHashingService _hashingService;
private readonly EmployerApprenticeshipsServiceConfiguration _employerApprenticeshipsServiceConfiguration;
private readonly EmployerAccountsConfiguration _employerAccountsConfiguration;
public GetApprenticeshipsHandler(
IValidator<GetApprenticeshipsRequest> 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<GetApprenticeshipsResponse> Handle(GetApprenticeshipsRequest message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ public class GetReservationsRequestHandler : IAsyncRequestHandler<GetReservation
private readonly ILog _logger;
private readonly IReservationsService _service;
private readonly IHashingService _hashingService;
private readonly EmployerApprenticeshipsServiceConfiguration _employerApprenticeshipsServiceConfiguration;
private readonly EmployerAccountsConfiguration _employerAccountsConfiguration;

public GetReservationsRequestHandler(
IValidator<GetReservationsRequest> 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<GetReservationsResponse> Handle(GetReservationsRequest message)
Expand All @@ -47,7 +47,7 @@ public async Task<GetReservationsResponse> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public class GetVacanciesRequestHandler : IAsyncRequestHandler<GetVacanciesReque
private readonly IValidator<GetVacanciesRequest> _validator;
private readonly ILog _logger;
private readonly IRecruitService _service;
private readonly EmployerApprenticeshipsServiceConfiguration _employerApprenticeshipsServiceConfiguration;
private readonly EmployerAccountsConfiguration _employerAccountsConfiguration;

public GetVacanciesRequestHandler(
IValidator<GetVacanciesRequest> validator,
ILog logger,
IRecruitService service, EmployerApprenticeshipsServiceConfiguration employerApprenticeshipsServiceConfiguration)
IRecruitService service, EmployerAccountsConfiguration employerAccountsConfiguration)
{
_validator = validator;
_logger = logger;
_service = service;
_employerApprenticeshipsServiceConfiguration = employerApprenticeshipsServiceConfiguration;
_employerAccountsConfiguration = employerAccountsConfiguration;
}

public async Task<GetVacanciesResponse> Handle(GetVacanciesRequest message)
Expand All @@ -40,7 +40,7 @@ public async Task<GetVacanciesResponse> 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
Expand Down

0 comments on commit def0a7d

Please sign in to comment.