Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIH-10353 - Admin web Unable to sent notifications for Edit hearings #149

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using FluentAssertions;
using NotificationApi.Common;
using NotificationApi.Contract;
using NotificationApi.Contract.Requests;
using NotificationApi.Extensions;
using NotificationApi.Services;
using NUnit.Framework;

namespace BookingQueueSubscriber.UnitTests.Mappers.NotificationMappers
marcogagliardi marked this conversation as resolved.
Show resolved Hide resolved
{
public class MapToHearingAmendmentNotificationTests
{

[Test]
public void should_map_to_amendment_notification()
oliver-scott marked this conversation as resolved.
Show resolved Hide resolved
{
//Arrange
const NotificationType expectedNotificationType = NotificationType.HearingAmendmentEJudJoh;
oliver-scott marked this conversation as resolved.
Show resolved Hide resolved
var oldDate = new DateTime(2020, 2, 10, 11, 30, 0, DateTimeKind.Utc);
var newDate = new DateTime(2020, 10, 12, 13, 10, 0, DateTimeKind.Utc);

var request = new HearingAmendmentRequest
{
HearingId = new Guid("73f2053e-74f1-4d6c-b817-246f4b22e666"),
ContactEmail = "[email protected]",
ParticipantId = new Guid("73f2053e-74f1-4d6c-b817-246f4b22e665"),
CaseName = "Case name",
PreviousScheduledDateTime = oldDate,
NewScheduledDateTime = newDate,
RoleName = "Individual",
CaseNumber = "Original Hearing",
Name = $"Automation_FirstName Automation_LastName",
DisplayName = "Automation_FirstName Automation_LastName",
Representee = "",
Username = "[email protected]"
};

var expectedParameters = GetExpectedParameters(request);

//Act
var result = NotificationParameterMapper.MapToHearingAmendment(request);

//Assert
result.Should().NotBeNull();
result[NotifyParams.CaseName].Should().Be(expectedParameters[NotifyParams.CaseName]);
oliver-scott marked this conversation as resolved.
Show resolved Hide resolved
result[NotifyParams.UserName].Should().Be(expectedParameters[NotifyParams.UserName]);
result[NotifyParams.CaseNumber].Should().Be(expectedParameters[NotifyParams.CaseNumber]);
result[NotifyParams.OldTime].Should().Be(expectedParameters[NotifyParams.OldTime]);
result[NotifyParams.NewTime].Should().Be(expectedParameters[NotifyParams.NewTime]);
result[NotifyParams.OldDayMonthYear].Should().Be(expectedParameters[NotifyParams.OldDayMonthYear]);
result[NotifyParams.NewDayMonthYear].Should().Be(expectedParameters[NotifyParams.NewDayMonthYear]);
result[NotifyParams.Name].Should().Be(expectedParameters[NotifyParams.Name]);
}

private static Dictionary<string, string> GetExpectedParameters(HearingAmendmentRequest request)
{
return new Dictionary<string, string>
{
{NotifyParams.CaseName, request.CaseName},
{NotifyParams.UserName, request.Username.ToLower()},
{NotifyParams.CaseNumber, request.CaseNumber},
{NotifyParams.OldTime, request.PreviousScheduledDateTime.ToEmailTimeGbLocale()},
{NotifyParams.NewTime, request.NewScheduledDateTime.ToEmailTimeGbLocale()},
{NotifyParams.OldDayMonthYear, request.PreviousScheduledDateTime.ToEmailDateGbLocale()},
{NotifyParams.NewDayMonthYear, request.NewScheduledDateTime.ToEmailDateGbLocale()},
{NotifyParams.Name, request.Name}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public static Dictionary<string, string> MapToHearingAmendment(HearingAmendmentR
var parameters = new Dictionary<string, string>
{
{NotifyParams.CaseName, request.CaseName},
{NotifyParams.UserName, request.Username.ToLower()},
{NotifyParams.CaseNumber, request.CaseNumber},
{NotifyParams.OldTime, request.PreviousScheduledDateTime.ToEmailTimeGbLocale()},
{NotifyParams.NewTime, request.NewScheduledDateTime.ToEmailTimeGbLocale()},
Expand Down
Loading