From 6543c3306d9c41f9abfed08e1486a9f9229edfab Mon Sep 17 00:00:00 2001 From: Scott Wakefield Date: Tue, 9 Oct 2018 16:07:04 +0100 Subject: [PATCH 01/10] DPP-1653 added dependency for message publisher. --- ....AcademicYearEndProcessor.UnitTests.csproj | 6 +- ...ingUpdate.cs => WhenCallingRunDataLock.cs} | 6 +- .../WhenRunningApprenticeshipUpdateJob.cs | 4 +- ...enTestingAcademicYearEndExpiryProcessor.cs | 77 ------------------- .../app.config | 2 +- .../packages.config | 1 + .../App.config | 2 +- ...nts.AcademicYearEndProcessor.WebJob.csproj | 3 + .../Updater/AcademicYearEndExpiryProcessor.cs | 15 ++-- .../packages.config | 1 + 10 files changed, 24 insertions(+), 93 deletions(-) rename src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/{WhenRunningUpdate.cs => WhenCallingRunDataLock.cs} (96%) delete mode 100644 src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenTestingAcademicYearEndExpiryProcessor.cs diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests.csproj b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests.csproj index 4f4d02ba3c..325f78ff59 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests.csproj +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests.csproj @@ -74,6 +74,9 @@ ..\packages\Polly.5.7.0\lib\net45\Polly.dll + + ..\packages\SFA.DAS.Messaging.3.0.0.53230\lib\net45\SFA.DAS.Messaging.dll + ..\packages\SFA.DAS.NLog.Logger.1.0.0.43242\lib\net45\SFA.DAS.NLog.Logger.dll @@ -106,10 +109,9 @@ - + - diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningUpdate.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenCallingRunDataLock.cs similarity index 96% rename from src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningUpdate.cs rename to src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenCallingRunDataLock.cs index 8adf50d737..eac04ec1ac 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningUpdate.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenCallingRunDataLock.cs @@ -5,12 +5,13 @@ using SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.Updater; using SFA.DAS.Commitments.Domain.Data; using SFA.DAS.Commitments.Domain.Interfaces; +using SFA.DAS.Messaging.Interfaces; using SFA.DAS.NLog.Logger; namespace SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests { [TestFixture] - public class WhenRunningUpdate + public class WhenCallingRunDataLock { private Mock _logger; private Mock _academicYearProvider; @@ -60,7 +61,8 @@ DateTime atTheTime _academicYearProvider.Object, _dataLockRepository.Object, _apprenticeshipUpdateRepository.Object, - currentDatetime); + currentDatetime, + Mock.Of()); _dataLockRepository.Setup(r => r.GetExpirableDataLocks(_academicYearProvider.Object.CurrentAcademicYearStartDate)).ReturnsAsync(testDatalockStatusItems); diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs index cc046f1485..76fa15146b 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs @@ -10,6 +10,7 @@ using SFA.DAS.Commitments.Domain.Data; using SFA.DAS.Commitments.Domain.Entities; using SFA.DAS.Commitments.Domain.Interfaces; +using SFA.DAS.Messaging.Interfaces; using SFA.DAS.NLog.Logger; namespace SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests @@ -40,7 +41,8 @@ public void Arrange() _academicYearProvider.Object, _dataLockRepository.Object, _apprenticeshipUpdateRepository.Object, - _currentDateTime.Object); + _currentDateTime.Object, + Mock.Of()); } diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenTestingAcademicYearEndExpiryProcessor.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenTestingAcademicYearEndExpiryProcessor.cs deleted file mode 100644 index 78f798a733..0000000000 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenTestingAcademicYearEndExpiryProcessor.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using Moq; -using NUnit.Framework; -using SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.Updater; -using SFA.DAS.Commitments.Domain.Data; -using SFA.DAS.Commitments.Domain.Interfaces; -using SFA.DAS.NLog.Logger; - -namespace SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests -{ - [TestFixture] - public class WhenTestingAcademicYearEndExpiryProcessor - { - private Mock _logger; - private Mock _academicYearProvider; - private Mock _dataLockRepository; - private Mock _apprenticeshipUpdateRepository; - - [SetUp] - public void Arrange() - { - // ARRANGE - _logger = new Mock(); - _academicYearProvider = new Mock(); - _dataLockRepository = new Mock(); - _apprenticeshipUpdateRepository = new Mock(); - - } - - [Test] - public void AndANullLoggerIsPassedItThrowsAnArgumentNullException() - { - Assert.Throws(() => new AcademicYearEndExpiryProcessor( - null, - _academicYearProvider.Object, - _dataLockRepository.Object, - _apprenticeshipUpdateRepository.Object, - new StubCurrentDateTime(DateTime.UtcNow))); - } - - [Test] - public void AndANullAccademicYearProviderIsPassedItThrowsAnArgumentNullException() - { - Assert.Throws(() => new AcademicYearEndExpiryProcessor( - _logger.Object, - null, - _dataLockRepository.Object, - _apprenticeshipUpdateRepository.Object, - new StubCurrentDateTime(DateTime.UtcNow))); - } - - - [Test] - public void AndANullDataLockStatusRepositoryIsPassedItThrowsAnArgumentNullException() - { - Assert.Throws(() => new AcademicYearEndExpiryProcessor( - _logger.Object, - _academicYearProvider.Object, - null, - _apprenticeshipUpdateRepository.Object, - new StubCurrentDateTime(DateTime.UtcNow))); - } - - - [Test] - public void AndANulltimeMachineIsPassedItThrowsAnArgumentNullException() - { - Assert.Throws(() => new AcademicYearEndExpiryProcessor( - _logger.Object, - _academicYearProvider.Object, - _dataLockRepository.Object, - _apprenticeshipUpdateRepository.Object, - null)); - } - - } -} \ No newline at end of file diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/app.config b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/app.config index 08b6dc784f..9f663f8de0 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/app.config +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/app.config @@ -56,7 +56,7 @@ - + diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/packages.config b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/packages.config index df0e795b8f..2b29af04d6 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/packages.config +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/packages.config @@ -15,6 +15,7 @@ + diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/App.config b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/App.config index 2ccde4d899..3443ed8cf7 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/App.config +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/App.config @@ -80,7 +80,7 @@ - + diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj index a7c829771f..d801406068 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj @@ -91,6 +91,9 @@ ..\packages\SFA.DAS.Configuration.AzureTableStorage.1.0.0.43116\lib\net45\SFA.DAS.Configuration.AzureTableStorage.dll True + + ..\packages\SFA.DAS.Messaging.3.0.0.53230\lib\net45\SFA.DAS.Messaging.dll + ..\packages\SFA.DAS.NLog.Logger.1.0.0.43242\lib\net45\SFA.DAS.NLog.Logger.dll diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs index f26867e2e3..21305a4f86 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using SFA.DAS.Commitments.Domain.Data; using SFA.DAS.Commitments.Domain.Interfaces; +using SFA.DAS.Messaging.Interfaces; using SFA.DAS.NLog.Logger; namespace SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.Updater @@ -20,16 +21,9 @@ public AcademicYearEndExpiryProcessor( IAcademicYearDateProvider academicYearProvider, IDataLockRepository dataLockRepository, IApprenticeshipUpdateRepository apprenticeshipUpdateRepository, - ICurrentDateTime currentDateTime) + ICurrentDateTime currentDateTime, + IMessagePublisher messagePublisher) { - - if (logger == null) throw new ArgumentException(nameof(logger)); - if (dataLockRepository == null) throw new ArgumentException(nameof(dataLockRepository)); - if (currentDateTime == null) throw new ArgumentException(nameof(currentDateTime)); - if (academicYearProvider == null) throw new ArgumentException(nameof(academicYearProvider)); - if (apprenticeshipUpdateRepository== null) throw new ArgumentException(nameof(apprenticeshipUpdateRepository)); - - _logger = logger; _dataLockRepository = dataLockRepository; _apprenticeshipUpdateRepository = apprenticeshipUpdateRepository; @@ -70,6 +64,9 @@ public async Task RunApprenticeshipUpdateJob(string jobId) { _logger.Info($"Updating ApprenticeshipUpdate to expired, ApprenticeshipUpdateId: {update.Id}, JobId: {jobId}"); await _apprenticeshipUpdateRepository.ExpireApprenticeshipUpdate(update.Id); + //todo send msg to task q + // task is to raise new ApprenticeshipUpdateCancelled event and put onto new task bus + // does task bus have api? client nuget? } var expiredApprenticeshipUpdatesAfterJob = diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config index 6c494ec732..0378334338 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config @@ -17,6 +17,7 @@ + From 6499ec444fa753840c2207627c292552bf3111fc Mon Sep 17 00:00:00 2001 From: Scott Wakefield Date: Wed, 10 Oct 2018 14:46:09 +0100 Subject: [PATCH 02/10] DPP-1653 sends message, but needs to get correct params. --- ...ments.AcademicYearEndProcessor.UnitTests.csproj | 4 ++++ .../WhenRunningApprenticeshipUpdateJob.cs | 14 ++++++++++---- ...mitments.AcademicYearEndProcessor.WebJob.csproj | 4 ++++ .../Updater/AcademicYearEndExpiryProcessor.cs | 7 +++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests.csproj b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests.csproj index 325f78ff59..8b7940a24b 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests.csproj +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests.csproj @@ -130,6 +130,10 @@ {C4C803AF-747E-4747-A23B-DA43219009A4} SFA.DAS.Commitments.Domain + + {7B636FB3-F4A9-479B-A371-0E82A67B4FD2} + SFA.DAS.Commitments.Events + {59b9f340-4489-4942-8ea2-0df38c4db3b9} SFA.DAS.Commitments.Notification.WebJob diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs index 76fa15146b..7b85517eb4 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs @@ -10,6 +10,7 @@ using SFA.DAS.Commitments.Domain.Data; using SFA.DAS.Commitments.Domain.Entities; using SFA.DAS.Commitments.Domain.Interfaces; +using SFA.DAS.Commitments.Events; using SFA.DAS.Messaging.Interfaces; using SFA.DAS.NLog.Logger; @@ -23,6 +24,7 @@ public class WhenRunningApprenticeshipUpdateJob private Mock _dataLockRepository; private Mock _apprenticeshipUpdateRepository; private Mock _currentDateTime; + private Mock _mockMessageBuilder; private AcademicYearEndExpiryProcessor _sut; @@ -35,6 +37,7 @@ public void Arrange() _dataLockRepository = new Mock(); _apprenticeshipUpdateRepository = new Mock(); _currentDateTime = new Mock(); + _mockMessageBuilder = new Mock(); _sut = new AcademicYearEndExpiryProcessor( _logger.Object, @@ -42,7 +45,7 @@ public void Arrange() _dataLockRepository.Object, _apprenticeshipUpdateRepository.Object, _currentDateTime.Object, - Mock.Of()); + _mockMessageBuilder.Object); } @@ -62,10 +65,10 @@ public async Task WhenNoUpdatesFound() [Test] public async Task WhenApprenticeshpUpdatesFound() { - var records = 4; + var recordCount = 4; var apprenticeshipUpdates = new List(); var fixture = new Fixture(); - fixture.AddManyTo(apprenticeshipUpdates, records); + fixture.AddManyTo(apprenticeshipUpdates, recordCount); _apprenticeshipUpdateRepository.Setup(m => m.GetExpiredApprenticeshipUpdates(_currentDateTime.Object.Now)) .ReturnsAsync(apprenticeshipUpdates); @@ -87,7 +90,10 @@ public async Task WhenApprenticeshpUpdatesFound() .Verify(m => m.GetExpiredApprenticeshipUpdates(It.IsAny()), Times.Exactly(2), "Should call one time to get all updates and one to verify that all have been updated"); _apprenticeshipUpdateRepository.Verify(m => m.ExpireApprenticeshipUpdate(It.IsAny()), - Times.Exactly(records), + Times.Exactly(recordCount), + "Should be called once for each update record"); + _mockMessageBuilder.Verify(m => m.PublishAsync(It.IsAny()), + Times.Exactly(recordCount), "Should be called once for each update record"); } diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj index d801406068..a1aa7b9ee6 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj @@ -162,6 +162,10 @@ {C4C803AF-747E-4747-A23B-DA43219009A4} SFA.DAS.Commitments.Domain + + {7B636FB3-F4A9-479B-A371-0E82A67B4FD2} + SFA.DAS.Commitments.Events + {7C2C2688-ABF9-4A08-9FC3-BA169A5888C4} SFA.DAS.Commitments.Infrastructure diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs index 21305a4f86..a79074f103 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using SFA.DAS.Commitments.Domain.Data; using SFA.DAS.Commitments.Domain.Interfaces; +using SFA.DAS.Commitments.Events; using SFA.DAS.Messaging.Interfaces; using SFA.DAS.NLog.Logger; @@ -15,6 +16,7 @@ public class AcademicYearEndExpiryProcessor : IAcademicYearEndExpiryProcessor private readonly IDataLockRepository _dataLockRepository; private readonly IApprenticeshipUpdateRepository _apprenticeshipUpdateRepository; private readonly ICurrentDateTime _currentDateTime; + private readonly IMessagePublisher _messagePublisher; public AcademicYearEndExpiryProcessor( ILog logger, @@ -28,6 +30,7 @@ public AcademicYearEndExpiryProcessor( _dataLockRepository = dataLockRepository; _apprenticeshipUpdateRepository = apprenticeshipUpdateRepository; _currentDateTime = currentDateTime; + _messagePublisher = messagePublisher; _academicYearProvider = academicYearProvider; } @@ -64,6 +67,10 @@ public async Task RunApprenticeshipUpdateJob(string jobId) { _logger.Info($"Updating ApprenticeshipUpdate to expired, ApprenticeshipUpdateId: {update.Id}, JobId: {jobId}"); await _apprenticeshipUpdateRepository.ExpireApprenticeshipUpdate(update.Id); + + await _messagePublisher.PublishAsync( + new ApprenticeshipUpdateCancelled(1, 1, + 1)); //update.EmployerRef, update.ProviderRef, update.ApprenticeshipId)); //todo send msg to task q // task is to raise new ApprenticeshipUpdateCancelled event and put onto new task bus // does task bus have api? client nuget? From 59a0d4851b62d56f523890b6117fe62eefcdbaa8 Mon Sep 17 00:00:00 2001 From: Scott Wakefield Date: Thu, 11 Oct 2018 11:08:24 +0100 Subject: [PATCH 03/10] DPP-1653 sets update message correctly. --- .../WhenCallingRunDataLock.cs | 3 +- .../WhenRunningApprenticeshipUpdateJob.cs | 49 ++++++++++++++++--- .../Updater/AcademicYearEndExpiryProcessor.cs | 24 +++++---- 3 files changed, 57 insertions(+), 19 deletions(-) diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenCallingRunDataLock.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenCallingRunDataLock.cs index eac04ec1ac..b9dd874f38 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenCallingRunDataLock.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenCallingRunDataLock.cs @@ -62,7 +62,8 @@ DateTime atTheTime _dataLockRepository.Object, _apprenticeshipUpdateRepository.Object, currentDatetime, - Mock.Of()); + Mock.Of(), + Mock.Of()); _dataLockRepository.Setup(r => r.GetExpirableDataLocks(_academicYearProvider.Object.CurrentAcademicYearStartDate)).ReturnsAsync(testDatalockStatusItems); diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs index 7b85517eb4..bff548725f 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.UnitTests/WhenRunningApprenticeshipUpdateJob.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using AutoFixture; +using AutoFixture.NUnit3; using Moq; using NUnit.Framework; @@ -25,6 +27,8 @@ public class WhenRunningApprenticeshipUpdateJob private Mock _apprenticeshipUpdateRepository; private Mock _currentDateTime; private Mock _mockMessageBuilder; + private Mock _mockApprenticeshipRepository; + private AcademicYearEndExpiryProcessor _sut; @@ -38,6 +42,7 @@ public void Arrange() _apprenticeshipUpdateRepository = new Mock(); _currentDateTime = new Mock(); _mockMessageBuilder = new Mock(); + _mockApprenticeshipRepository = new Mock(); _sut = new AcademicYearEndExpiryProcessor( _logger.Object, @@ -45,7 +50,8 @@ public void Arrange() _dataLockRepository.Object, _apprenticeshipUpdateRepository.Object, _currentDateTime.Object, - _mockMessageBuilder.Object); + _mockMessageBuilder.Object, + _mockApprenticeshipRepository.Object); } @@ -67,13 +73,21 @@ public async Task WhenApprenticeshpUpdatesFound() { var recordCount = 4; var apprenticeshipUpdates = new List(); + var apprenticeships = new List(); var fixture = new Fixture(); fixture.AddManyTo(apprenticeshipUpdates, recordCount); + apprenticeshipUpdates.ForEach(update => + apprenticeships.Add( + fixture.Build() + .With(a => a.Id, update.ApprenticeshipId) + .Create())); - _apprenticeshipUpdateRepository.Setup(m => m.GetExpiredApprenticeshipUpdates(_currentDateTime.Object.Now)) + _apprenticeshipUpdateRepository + .Setup(m => m.GetExpiredApprenticeshipUpdates(_currentDateTime.Object.Now)) .ReturnsAsync(apprenticeshipUpdates); - _apprenticeshipUpdateRepository.Setup(m => m.ExpireApprenticeshipUpdate(It.IsAny())) + _apprenticeshipUpdateRepository + .Setup(m => m.ExpireApprenticeshipUpdate(It.IsAny())) .Callback( () => { @@ -84,6 +98,13 @@ public async Task WhenApprenticeshpUpdatesFound() }) .Returns(Task.FromResult(0)); + _mockApprenticeshipRepository + .Setup(repository => + repository.GetApprenticeship( + It.IsIn(apprenticeshipUpdates.Select(update => update.ApprenticeshipId)))) + .ReturnsAsync((long apprenticeshipId) => + apprenticeships.Single(apprenticeship => apprenticeship.Id == apprenticeshipId)); + await _sut.RunApprenticeshipUpdateJob("jobId"); _apprenticeshipUpdateRepository @@ -92,13 +113,21 @@ public async Task WhenApprenticeshpUpdatesFound() _apprenticeshipUpdateRepository.Verify(m => m.ExpireApprenticeshipUpdate(It.IsAny()), Times.Exactly(recordCount), "Should be called once for each update record"); - _mockMessageBuilder.Verify(m => m.PublishAsync(It.IsAny()), - Times.Exactly(recordCount), - "Should be called once for each update record"); + apprenticeshipUpdates.ForEach(update => + { + var apprenticeship = apprenticeships.Single(a => a.Id == update.ApprenticeshipId); + _mockMessageBuilder.Verify(m => + m.PublishAsync(It.Is(cancelled => + cancelled.ApprenticeshipId == apprenticeship.Id && + cancelled.AccountId == apprenticeship.EmployerAccountId && + cancelled.ProviderId == apprenticeship.ProviderId)), + "Should be called once for each update record, with correct params"); + }); } - [Test] - public async Task ShouldOnlyUpdateRecordsWithCostOrTrainingChanges() + [Test, AutoData] + public async Task ShouldOnlyUpdateRecordsWithCostOrTrainingChanges( + Apprenticeship apprenticeship) { var apprenticeshipUpdates = new List { @@ -125,6 +154,10 @@ public async Task ShouldOnlyUpdateRecordsWithCostOrTrainingChanges() }) .Returns(Task.FromResult(0)); + _mockApprenticeshipRepository + .Setup(repository => repository.GetApprenticeship(It.IsAny())) + .ReturnsAsync(apprenticeship); + await _sut.RunApprenticeshipUpdateJob("jobId"); _apprenticeshipUpdateRepository diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs index a79074f103..24b258a28c 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Updater/AcademicYearEndExpiryProcessor.cs @@ -4,6 +4,7 @@ using SFA.DAS.Commitments.Domain.Data; using SFA.DAS.Commitments.Domain.Interfaces; using SFA.DAS.Commitments.Events; +using SFA.DAS.Commitments.Infrastructure.Data; using SFA.DAS.Messaging.Interfaces; using SFA.DAS.NLog.Logger; @@ -17,20 +18,22 @@ public class AcademicYearEndExpiryProcessor : IAcademicYearEndExpiryProcessor private readonly IApprenticeshipUpdateRepository _apprenticeshipUpdateRepository; private readonly ICurrentDateTime _currentDateTime; private readonly IMessagePublisher _messagePublisher; + private readonly IApprenticeshipRepository _apprenticeshipRepository; - public AcademicYearEndExpiryProcessor( - ILog logger, - IAcademicYearDateProvider academicYearProvider, + public AcademicYearEndExpiryProcessor(ILog logger, + IAcademicYearDateProvider academicYearProvider, IDataLockRepository dataLockRepository, IApprenticeshipUpdateRepository apprenticeshipUpdateRepository, ICurrentDateTime currentDateTime, - IMessagePublisher messagePublisher) + IMessagePublisher messagePublisher, + IApprenticeshipRepository apprenticeshipRepository) { _logger = logger; _dataLockRepository = dataLockRepository; _apprenticeshipUpdateRepository = apprenticeshipUpdateRepository; _currentDateTime = currentDateTime; _messagePublisher = messagePublisher; + _apprenticeshipRepository = apprenticeshipRepository; _academicYearProvider = academicYearProvider; } @@ -68,12 +71,13 @@ public async Task RunApprenticeshipUpdateJob(string jobId) _logger.Info($"Updating ApprenticeshipUpdate to expired, ApprenticeshipUpdateId: {update.Id}, JobId: {jobId}"); await _apprenticeshipUpdateRepository.ExpireApprenticeshipUpdate(update.Id); - await _messagePublisher.PublishAsync( - new ApprenticeshipUpdateCancelled(1, 1, - 1)); //update.EmployerRef, update.ProviderRef, update.ApprenticeshipId)); - //todo send msg to task q - // task is to raise new ApprenticeshipUpdateCancelled event and put onto new task bus - // does task bus have api? client nuget? + var apprenticeship = + await _apprenticeshipRepository.GetApprenticeship(update.ApprenticeshipId); + + await _messagePublisher.PublishAsync(new ApprenticeshipUpdateCancelled( + apprenticeship.EmployerAccountId, + apprenticeship.ProviderId, + apprenticeship.Id)); } var expiredApprenticeshipUpdatesAfterJob = From 15805bed4212d49e95d331d3eb960470048843cb Mon Sep 17 00:00:00 2001 From: Scott Wakefield Date: Thu, 11 Oct 2018 15:23:18 +0100 Subject: [PATCH 04/10] DPP-1653 fixed ioc issues. --- .../App.config | 26 +++++++++++++++++++ ...tsAcademicYearEndProcessorConfiguration.cs | 4 ++- .../DependencyResolution/DefaultRegistry.cs | 8 ++++-- .../DependencyResolution/IoC.cs | 10 ++++++- ...nts.AcademicYearEndProcessor.WebJob.csproj | 15 +++++++++++ .../packages.config | 4 +++ 6 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/App.config b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/App.config index 3443ed8cf7..1dde5ddc31 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/App.config +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/App.config @@ -93,4 +93,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Configuration/CommitmentsAcademicYearEndProcessorConfiguration.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Configuration/CommitmentsAcademicYearEndProcessorConfiguration.cs index 09b6718529..8a497136b5 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Configuration/CommitmentsAcademicYearEndProcessorConfiguration.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Configuration/CommitmentsAcademicYearEndProcessorConfiguration.cs @@ -1,11 +1,13 @@ using SFA.DAS.Commitments.Domain.Interfaces; +using SFA.DAS.Messaging.AzureServiceBus.StructureMap; namespace SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.Configuration { - public class CommitmentsAcademicYearEndProcessorConfiguration : IConfiguration + public class CommitmentsAcademicYearEndProcessorConfiguration : IConfiguration, ITopicMessagePublisherConfiguration { public string DatabaseConnectionString { get; set; } public string ServiceBusConnectionString { get; set; } public string CurrentStartTime { get; set; } + public string MessageServiceBusConnectionString { get; } } } diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs index d6295abe99..550e7dc00f 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs @@ -39,11 +39,15 @@ public DefaultRegistry() For().Use(x => new CurrentDateTime(currentDatetime)); - For().Use().Ctor().Is(config.DatabaseConnectionString); + For() + .Use() + .Ctor().Is(config.DatabaseConnectionString); For() .Use() .Ctor().Is(config.DatabaseConnectionString); - + For() + .Use() + .Ctor().Is(config.DatabaseConnectionString); } private CommitmentsAcademicYearEndProcessorConfiguration GetConfiguration(string serviceName) diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs index 0557653298..0634821b52 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs @@ -1,14 +1,22 @@ -using StructureMap; +using SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.Configuration; +using SFA.DAS.Messaging.AzureServiceBus; +using SFA.DAS.Messaging.AzureServiceBus.StructureMap; +using SFA.DAS.NLog.Logger; +using StructureMap; namespace SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.DependencyResolution { public static class IoC { + private const string ServiceName = "SFA.DAS.Commitments"; + private const string ServiceVersion = "1.0"; + public static IContainer Initialize() { return new Container(c => { c.AddRegistry(); + c.Policies.Add(new TopicMessagePublisherPolicy(ServiceName, ServiceVersion, new NLogLogger(typeof(TopicMessagePublisher)))); }); } } diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj index a1aa7b9ee6..40d4f0ba1e 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj @@ -68,6 +68,9 @@ ..\packages\Microsoft.Data.Services.Client.5.7.0\lib\net40\Microsoft.Data.Services.Client.dll + + ..\packages\WindowsAzure.ServiceBus.3.1.7\lib\net45-full\Microsoft.ServiceBus.dll + ..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.3\lib\net40\Microsoft.WindowsAzure.Configuration.dll @@ -91,9 +94,18 @@ ..\packages\SFA.DAS.Configuration.AzureTableStorage.1.0.0.43116\lib\net45\SFA.DAS.Configuration.AzureTableStorage.dll True + + ..\packages\SFA.DAS.Configuration.FileStorage.1.0.0.4757\lib\net45\SFA.DAS.Configuration.FileStorage.dll + ..\packages\SFA.DAS.Messaging.3.0.0.53230\lib\net45\SFA.DAS.Messaging.dll + + ..\packages\SFA.DAS.Messaging.AzureServiceBus.3.0.0.53230\lib\net45\SFA.DAS.Messaging.AzureServiceBus.dll + + + ..\packages\SFA.DAS.Messaging.AzureServiceBus.StructureMap.3.0.0.53230\lib\net45\SFA.DAS.Messaging.AzureServiceBus.StructureMap.dll + ..\packages\SFA.DAS.NLog.Logger.1.0.0.43242\lib\net45\SFA.DAS.NLog.Logger.dll @@ -120,12 +132,15 @@ ..\packages\Microsoft.AspNet.WebApi.Client.5.2.6\lib\net45\System.Net.Http.Formatting.dll + + ..\packages\System.Spatial.5.7.0\lib\net40\System.Spatial.dll ..\packages\Microsoft.AspNet.WebApi.Core.5.2.6\lib\net45\System.Web.Http.dll + diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config index 0378334338..99e222b97c 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config @@ -17,7 +17,10 @@ + + + @@ -27,5 +30,6 @@ + \ No newline at end of file From 594b896c474cb7876ec49fa0f2bc4f9582059650 Mon Sep 17 00:00:00 2001 From: Scott Wakefield Date: Fri, 19 Oct 2018 09:33:46 +0100 Subject: [PATCH 05/10] DPP-1653 changed config to point to web jobs, not commitments. --- .../DependencyResolution/IoC.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs index 0634821b52..9396e0cb84 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs @@ -8,7 +8,7 @@ namespace SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.DependencyResoluti { public static class IoC { - private const string ServiceName = "SFA.DAS.Commitments"; + private const string ServiceName = "SFA.DAS.CommitmentsAcademicYearEndProcessor"; private const string ServiceVersion = "1.0"; public static IContainer Initialize() From dcb60a6f495155480544512b4a53337f2c9f140e Mon Sep 17 00:00:00 2001 From: chrisfoster76 Date: Fri, 19 Oct 2018 10:02:36 +0100 Subject: [PATCH 06/10] Adds property setter --- .../CommitmentsAcademicYearEndProcessorConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Configuration/CommitmentsAcademicYearEndProcessorConfiguration.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Configuration/CommitmentsAcademicYearEndProcessorConfiguration.cs index 8a497136b5..1470ccde89 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Configuration/CommitmentsAcademicYearEndProcessorConfiguration.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/Configuration/CommitmentsAcademicYearEndProcessorConfiguration.cs @@ -8,6 +8,6 @@ public class CommitmentsAcademicYearEndProcessorConfiguration : IConfiguration, public string DatabaseConnectionString { get; set; } public string ServiceBusConnectionString { get; set; } public string CurrentStartTime { get; set; } - public string MessageServiceBusConnectionString { get; } + public string MessageServiceBusConnectionString { get; set; } } } From ea51b09fa15ec36be1cbb203479bc349ea54fe4e Mon Sep 17 00:00:00 2001 From: Scott Wakefield Date: Fri, 19 Oct 2018 11:56:47 +0100 Subject: [PATCH 07/10] DPP-1653 adding logging to show if sb connection string ok. --- .../DependencyResolution/DefaultRegistry.cs | 10 ---------- .../DependencyResolution/IoC.cs | 9 ++++++++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs index 550e7dc00f..ac84190c94 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs @@ -57,10 +57,6 @@ private CommitmentsAcademicYearEndProcessorConfiguration GetConfiguration(string { environment = CloudConfigurationManager.GetSetting("EnvironmentName"); } - if (environment.Equals("LOCAL") || environment.Equals("AT") || environment.Equals("TEST")) - { - PopulateSystemDetails(environment); - } var configurationRepository = GetConfigurationRepository(); var configurationService = new ConfigurationService(configurationRepository, @@ -75,11 +71,5 @@ private static IConfigurationRepository GetConfigurationRepository() { return new AzureTableStorageConfigurationRepository(CloudConfigurationManager.GetSetting("ConfigurationStorageConnectionString")); } - private void PopulateSystemDetails(string envName) - { - SystemDetails.EnvironmentName = envName; - SystemDetails.VersionNumber = Assembly.GetExecutingAssembly().GetName().Version.ToString(); - } - } } diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs index 9396e0cb84..759602302a 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs @@ -13,11 +13,18 @@ public static class IoC public static IContainer Initialize() { - return new Container(c => + var container = new Container(c => { c.AddRegistry(); c.Policies.Add(new TopicMessagePublisherPolicy(ServiceName, ServiceVersion, new NLogLogger(typeof(TopicMessagePublisher)))); }); + + var logger = container.GetInstance(); + var msgBus = container.GetInstance() + .MessageServiceBusConnectionString; + logger.Debug($"MessageServiceBusConnectionString IsNullOrWhiteSpace:[{string.IsNullOrWhiteSpace(msgBus)}] length:[{msgBus?.Length}]"); + + return container; } } } From 8d1cd81bf77fa214fb951b8b309e2b875622c986 Mon Sep 17 00:00:00 2001 From: Scott Wakefield Date: Fri, 19 Oct 2018 12:14:50 +0100 Subject: [PATCH 08/10] DPP-1653 updated nugets to have version with logging. --- ...DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj | 8 ++++---- .../packages.config | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj index 40d4f0ba1e..f9555f0397 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj @@ -97,11 +97,11 @@ ..\packages\SFA.DAS.Configuration.FileStorage.1.0.0.4757\lib\net45\SFA.DAS.Configuration.FileStorage.dll - - ..\packages\SFA.DAS.Messaging.3.0.0.53230\lib\net45\SFA.DAS.Messaging.dll + + ..\packages\SFA.DAS.Messaging.3.1.100\lib\net45\SFA.DAS.Messaging.dll - - ..\packages\SFA.DAS.Messaging.AzureServiceBus.3.0.0.53230\lib\net45\SFA.DAS.Messaging.AzureServiceBus.dll + + ..\packages\SFA.DAS.Messaging.AzureServiceBus.3.1.100\lib\net45\SFA.DAS.Messaging.AzureServiceBus.dll ..\packages\SFA.DAS.Messaging.AzureServiceBus.StructureMap.3.0.0.53230\lib\net45\SFA.DAS.Messaging.AzureServiceBus.StructureMap.dll diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config index 99e222b97c..ba77b787b9 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config @@ -18,8 +18,8 @@ - - + + From efab6ab3142764b6d8243a00433c1bb3f82591e3 Mon Sep 17 00:00:00 2001 From: Scott Wakefield Date: Fri, 19 Oct 2018 13:27:24 +0100 Subject: [PATCH 09/10] DPP-1653 removed ioc setup of config. --- .../DependencyResolution/DefaultRegistry.cs | 13 ++----------- .../DependencyResolution/IoC.cs | 9 +-------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs index ac84190c94..3388c2c683 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/DefaultRegistry.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using Microsoft.Azure; using SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.Configuration; using SFA.DAS.Commitments.Domain.Data; @@ -10,7 +9,6 @@ using SFA.DAS.Configuration.AzureTableStorage; using SFA.DAS.NLog.Logger; using StructureMap; -using IConfiguration = SFA.DAS.Commitments.Domain.Interfaces.IConfiguration; namespace SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.DependencyResolution { @@ -27,8 +25,6 @@ public DefaultRegistry() var config = GetConfiguration("SFA.DAS.CommitmentsAcademicYearEndProcessor"); - For().Use(config); - For().Use(config); For().Use(x => new NLogLogger(x.ParentType, new ConsoleLoggingContext(), null)).AlwaysUnique(); DateTime? currentDatetime = null; @@ -52,18 +48,13 @@ public DefaultRegistry() private CommitmentsAcademicYearEndProcessorConfiguration GetConfiguration(string serviceName) { - var environment = Environment.GetEnvironmentVariable("DASENV"); - if (string.IsNullOrEmpty(environment)) - { - environment = CloudConfigurationManager.GetSetting("EnvironmentName"); - } - + var environment = CloudConfigurationManager.GetSetting("EnvironmentName"); + var configurationRepository = GetConfigurationRepository(); var configurationService = new ConfigurationService(configurationRepository, new ConfigurationOptions(serviceName, environment, "1.0")); var result = configurationService.Get(); - return result; } diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs index 759602302a..9396e0cb84 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/DependencyResolution/IoC.cs @@ -13,18 +13,11 @@ public static class IoC public static IContainer Initialize() { - var container = new Container(c => + return new Container(c => { c.AddRegistry(); c.Policies.Add(new TopicMessagePublisherPolicy(ServiceName, ServiceVersion, new NLogLogger(typeof(TopicMessagePublisher)))); }); - - var logger = container.GetInstance(); - var msgBus = container.GetInstance() - .MessageServiceBusConnectionString; - logger.Debug($"MessageServiceBusConnectionString IsNullOrWhiteSpace:[{string.IsNullOrWhiteSpace(msgBus)}] length:[{msgBus?.Length}]"); - - return container; } } } From db719fb30974681c716a96545edd987b4c9e319a Mon Sep 17 00:00:00 2001 From: Scott Wakefield Date: Fri, 19 Oct 2018 14:22:54 +0100 Subject: [PATCH 10/10] DPP-1653 updated nugets to latest stable from master. --- ...ommitments.AcademicYearEndProcessor.WebJob.csproj | 12 ++++++------ .../packages.config | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj index f9555f0397..6436a7bf69 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob.csproj @@ -97,14 +97,14 @@ ..\packages\SFA.DAS.Configuration.FileStorage.1.0.0.4757\lib\net45\SFA.DAS.Configuration.FileStorage.dll - - ..\packages\SFA.DAS.Messaging.3.1.100\lib\net45\SFA.DAS.Messaging.dll + + ..\packages\SFA.DAS.Messaging.3.1.19\lib\net45\SFA.DAS.Messaging.dll - - ..\packages\SFA.DAS.Messaging.AzureServiceBus.3.1.100\lib\net45\SFA.DAS.Messaging.AzureServiceBus.dll + + ..\packages\SFA.DAS.Messaging.AzureServiceBus.3.1.19\lib\net45\SFA.DAS.Messaging.AzureServiceBus.dll - - ..\packages\SFA.DAS.Messaging.AzureServiceBus.StructureMap.3.0.0.53230\lib\net45\SFA.DAS.Messaging.AzureServiceBus.StructureMap.dll + + ..\packages\SFA.DAS.Messaging.AzureServiceBus.StructureMap.3.1.19\lib\net45\SFA.DAS.Messaging.AzureServiceBus.StructureMap.dll ..\packages\SFA.DAS.NLog.Logger.1.0.0.43242\lib\net45\SFA.DAS.NLog.Logger.dll diff --git a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config index ba77b787b9..1f59dd2802 100644 --- a/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config +++ b/src/SFA.DAS.Commitments.AcademicYearEndProcessor.WebJob/packages.config @@ -18,9 +18,9 @@ - - - + + +