Skip to content

Commit

Permalink
Merge branch 'master' into CON-1492-Organisations-&-Agreements
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Howes committed Apr 22, 2020
2 parents 5730917 + 51f86f4 commit 31a9bae
Show file tree
Hide file tree
Showing 50 changed files with 476 additions and 561 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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">
Expand Down

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;
Expand All @@ -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,
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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
Expand Up @@ -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" />
Expand Down
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
Expand Up @@ -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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Loading

0 comments on commit 31a9bae

Please sign in to comment.