Skip to content

Commit

Permalink
Merge branch 'master' into CON-1640-add-timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
cofaulco committed Apr 22, 2020
2 parents b388d32 + 51f86f4 commit adbe67e
Showing 60 changed files with 610 additions and 684 deletions.
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="SFA.DAS.Common.Domain" Version="1.4.278" />
<PackageReference Include="SFA.DAS.Common.Domain" Version="1.4.283" />
</ItemGroup>
<PropertyGroup>
<PackageId>SFA.DAS.Account.Api.Types</PackageId>
Original file line number Diff line number Diff line change
@@ -156,7 +156,7 @@
<Version>6.0.51</Version>
</PackageReference>
<PackageReference Include="SFA.DAS.Common.Domain">
<Version>1.4.278</Version>
<Version>1.4.283</Version>
</PackageReference>
<PackageReference Include="SFA.DAS.EmployerAccounts.Api.Types">
<Version>1.6.1852</Version>
Original file line number Diff line number Diff line change
@@ -20,13 +20,14 @@
@sector NVARCHAR(100),
@aorn VARCHAR(50),
@agreementType TINYINT,
@apprenticeshipEmployerType TINYINT,
@agreementVersion INT OUTPUT
)
AS
BEGIN
SET NOCOUNT ON;

INSERT INTO [employer_account].[Account](Name, CreatedDate) VALUES (@employerName, @addedDate);
INSERT INTO [employer_account].[Account](Name, CreatedDate, ApprenticeshipEmployerType) VALUES (@employerName, @addedDate, @apprenticeshipEmployerType);
SELECT @accountId = SCOPE_IDENTITY();

DECLARE @accountLegalEntityCreated AS BIT;
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@
(
@userId BIGINT,
@employerName NVARCHAR(100),
@apprenticeshipEmployerType TINYINT,
@accountId BIGINT OUTPUT,
@addedDate DATETIME
)
AS
BEGIN
SET NOCOUNT ON;

INSERT INTO [employer_account].[Account](Name, CreatedDate) VALUES (@employerName, @addedDate);
INSERT INTO [employer_account].[Account](Name, CreatedDate, ApprenticeshipEmployerType) VALUES (@employerName, @addedDate, @apprenticeshipEmployerType);
SELECT @accountId = SCOPE_IDENTITY();

INSERT INTO [employer_account].[Membership](UserId, AccountId, [Role]) VALUES (@userId, @accountId, 1);
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
[CreatedDate] DATETIME NOT NULL,
[ModifiedDate] DATETIME NULL,
[PublicHashedId] NVARCHAR(100) NULL,
[ApprenticeshipEmployerType] TINYINT NOT NULL DEFAULT 0
[ApprenticeshipEmployerType] TINYINT NOT NULL
)
GO

Original file line number Diff line number Diff line change
@@ -176,7 +176,7 @@
<Version>6.0.52</Version>
</PackageReference>
<PackageReference Include="SFA.DAS.Common.Domain">
<Version>1.4.278</Version>
<Version>1.4.283</Version>
</PackageReference>
<PackageReference Include="SFA.DAS.Configuration.AzureTableStorage">
<Version>3.0.75</Version>
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="SFA.DAS.Common.Domain" Version="1.4.278" />
<PackageReference Include="SFA.DAS.Common.Domain" Version="1.4.283" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@
<PackageReference Include="SFA.DAS.Authorization.WebApi">
<Version>6.0.52</Version>
</PackageReference>
<PackageReference Include="SFA.DAS.Common.Domain" Version="1.4.278" />
<PackageReference Include="SFA.DAS.Common.Domain" Version="1.4.283" />
<PackageReference Include="SFA.DAS.EmployerUsers.WebClientComponents" Version="1.0.0.4388" />
<PackageReference Include="SFA.DAS.HashingService" Version="1.0.183" />
<PackageReference Include="SFA.DAS.Logging">

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.Threading.Tasks;
using MediatR;
using Moq;
using NUnit.Framework;
using SFA.DAS.Common.Domain.Types;
using SFA.DAS.EmployerAccounts.Commands.AccountLevyStatus;
using SFA.DAS.EmployerAccounts.Events.Messages;
using SFA.DAS.EmployerAccounts.MessageHandlers.EventHandlers.EmployerFinance;
using SFA.DAS.EmployerFinance.Messages.Events;
@@ -23,7 +26,6 @@ public Task WhenMessageIsHandled_RefreshEmployerLevyDataCompletedMessageIsPublis
const short periodMonth = 7;
const string periodYear = "2018";


return TestAsync(f => f.Handle(new RefreshEmployerLevyDataCompletedEvent
{
AccountId = accountId,
@@ -37,18 +39,45 @@ public Task WhenMessageIsHandled_RefreshEmployerLevyDataCompletedMessageIsPublis
f.VerifyRefreshEmployerLevyDataCompletedMessageIsPublished(accountId, levyImported, periodMonth, periodYear, timestamp);
});
}

[TestCase(0, ApprenticeshipEmployerType.NonLevy)]
[TestCase(100, ApprenticeshipEmployerType.Levy)]
public Task WhenMessageIsHandled_AccountLevyStatusCommandIsSent(decimal levyValue, ApprenticeshipEmployerType apprenticeshipEmployerType)
{
var timestamp = DateTime.UtcNow;
const long accountId = 666;
const bool levyImported = true;
const short periodMonth = 7;
const string periodYear = "2018";

return TestAsync(f => f.Handle(new RefreshEmployerLevyDataCompletedEvent
{
AccountId = accountId,
LevyImported = levyImported,
PeriodMonth = periodMonth,
PeriodYear = periodYear,
LevyTransactionValue = levyValue,
Created = timestamp
})
, (f) =>
{
f.VerifyAccountLevyStatusCommandIsSent(accountId, apprenticeshipEmployerType);
});
}
}

public class RefreshEmployerLevyDataCompletedEventHandlerTestsFixture
{
private readonly RefreshEmployerLevyDataCompletedEventHandler _handler;
private readonly Mock<IMessagePublisher> _mockMessagePublisher;
private readonly Mock<IMediator> _mediator;

public RefreshEmployerLevyDataCompletedEventHandlerTestsFixture()
{
_mockMessagePublisher = new Mock<IMessagePublisher>();
_mediator = new Mock<IMediator>();

_handler = new RefreshEmployerLevyDataCompletedEventHandler(_mockMessagePublisher.Object);
_handler = new RefreshEmployerLevyDataCompletedEventHandler(_mockMessagePublisher.Object, _mediator.Object);
}

public Task Handle(RefreshEmployerLevyDataCompletedEvent refreshEmployerLevyDataCompletedEvent)
@@ -66,5 +95,13 @@ public void VerifyRefreshEmployerLevyDataCompletedMessageIsPublished(long accoun
&& m.PeriodYear.Equals(periodYear)
&& m.CreatedAt.Equals(timestamp))));
}

public void VerifyAccountLevyStatusCommandIsSent(long accountId, ApprenticeshipEmployerType apprenticeshipEmployerType)
{
_mediator.Verify(e => e.SendAsync(It.Is<AccountLevyStatusCommand>(m =>
m.AccountId.Equals(accountId) &&
m.ApprenticeshipEmployerType.Equals(apprenticeshipEmployerType))),
Times.Once);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Threading.Tasks;
using MediatR;
using NServiceBus;
using SFA.DAS.Common.Domain.Types;
using SFA.DAS.EmployerAccounts.Commands.AccountLevyStatus;
using SFA.DAS.EmployerAccounts.Events.Messages;
using SFA.DAS.EmployerFinance.Messages.Events;
using SFA.DAS.Messaging.Interfaces;
@@ -9,23 +12,30 @@ namespace SFA.DAS.EmployerAccounts.MessageHandlers.EventHandlers.EmployerFinance
public class RefreshEmployerLevyDataCompletedEventHandler : IHandleMessages<RefreshEmployerLevyDataCompletedEvent>
{
private readonly IMessagePublisher _messagePublisher;
private readonly IMediator _mediator;

public RefreshEmployerLevyDataCompletedEventHandler(IMessagePublisher messagePublisher)
public RefreshEmployerLevyDataCompletedEventHandler(IMessagePublisher messagePublisher, IMediator mediator)
{
_messagePublisher = messagePublisher;
_mediator = mediator;
}

public async Task Handle(RefreshEmployerLevyDataCompletedEvent message, IMessageHandlerContext context)
{
await _messagePublisher.PublishAsync(
new RefreshEmployerLevyDataCompletedMessage(
message.AccountId,
message.LevyImported,
message.PeriodMonth,
message.PeriodYear,
message.Created,
string.Empty,
string.Empty));
await _messagePublisher.PublishAsync(new RefreshEmployerLevyDataCompletedMessage(
message.AccountId,
message.LevyImported,
message.PeriodMonth,
message.PeriodYear,
message.Created,
string.Empty,
string.Empty));

await _mediator.SendAsync(new AccountLevyStatusCommand
{
AccountId = message.AccountId,
ApprenticeshipEmployerType = message.LevyTransactionValue == decimal.Zero ? ApprenticeshipEmployerType.NonLevy : ApprenticeshipEmployerType.Levy
});
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
<PackageReference Include="SFA.DAS.AutoConfiguration" Version="2.0.1" />
<PackageReference Include="SFA.DAS.Authentication" Version="1.1.2" />
<PackageReference Include="SFA.DAS.Commitments.Events" Version="2.1.1073" />
<PackageReference Include="SFA.DAS.EmployerFinance.Messages" Version="1.6.1140" />
<PackageReference Include="SFA.DAS.EmployerFinance.Messages" Version="1.6.2933" />
<PackageReference Include="SFA.DAS.Messaging" Version="3.0.0.63765" />
<PackageReference Include="SFA.DAS.NLog.Logger" Version="1.2.1" />
<PackageReference Include="SFA.DAS.NLog.Targets.Redis" Version="1.2.1" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using SFA.DAS.Common.Domain.Types;
using SFA.DAS.NServiceBus;

namespace SFA.DAS.EmployerAccounts.Messages.Events
{
public class ApprenticeshipEmployerTypeChangeEvent : Event
{
public long AccountId { get; set; }
public ApprenticeshipEmployerType ApprenticeshipEmployerType { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19270-01" PrivateAssets="All" />
<PackageReference Include="SFA.DAS.Common.Domain" Version="1.4.278" />
<PackageReference Include="SFA.DAS.Common.Domain" Version="1.4.283" />
<PackageReference Include="SFA.DAS.NServiceBus" Version="15.0.25" />
</ItemGroup>

Original file line number Diff line number Diff line change
@@ -155,7 +155,7 @@
<Version>4.1.355</Version>
</PackageReference>
<PackageReference Include="SFA.DAS.Common.Domain">
<Version>1.4.278</Version>
<Version>1.4.283</Version>
</PackageReference>
<PackageReference Include="SFA.DAS.Configuration">
<Version>1.0.0.53229</Version>
Loading

0 comments on commit adbe67e

Please sign in to comment.