From 38c66893f86aeea9f6e550f3d7a65dd45c291999 Mon Sep 17 00:00:00 2001 From: marcogagliardi Date: Fri, 8 Dec 2023 09:57:47 +0000 Subject: [PATCH] VIH-10353 - Admin web Unable to sent notifications for Edit hearings (#149) * Update NotificationParameterMapper.cs * added test * Update MapToHearingAmendmentNotificationTests.cs * Update MapToHearingAmendmentNotificationTests.cs --- .../MapToHearingAmendmentNotificationTests.cs | 50 +++++++++++++++++++ .../Services/NotificationParameterMapper.cs | 1 + 2 files changed, 51 insertions(+) create mode 100644 NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMapper/MapToHearingAmendmentNotificationTests.cs diff --git a/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMapper/MapToHearingAmendmentNotificationTests.cs b/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMapper/MapToHearingAmendmentNotificationTests.cs new file mode 100644 index 00000000..38bcdfb2 --- /dev/null +++ b/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMapper/MapToHearingAmendmentNotificationTests.cs @@ -0,0 +1,50 @@ +using System; +using FluentAssertions; +using NotificationApi.Common; +using NotificationApi.Contract.Requests; +using NUnit.Framework; + +namespace NotificationApi.UnitTests.Mappers.NotificationParameterMapper +{ + public class MapToHearingAmendmentNotificationTests + { + + [Test] + public void should_map_to_amendment_notification_for_individual() + { + //Arrange + 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 = "Automation_226153990@hmcts.net", + 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 = "Automation_338564597@hmcts.net" + }; + + //Act + var result = NotificationApi.Services.NotificationParameterMapper.MapToHearingAmendment(request); + + //Assert + result.Should().NotBeNull(); + result[NotifyParams.CaseName].Should().Be("Case name"); + result[NotifyParams.UserName].Should().Be("automation_338564597@hmcts.net"); + result[NotifyParams.CaseNumber].Should().Be("Original Hearing"); + result[NotifyParams.OldTime].Should().Be("11:30 AM"); + result[NotifyParams.NewTime].Should().Be("2:10 PM"); + result[NotifyParams.OldDayMonthYear].Should().Be("10 February 2020"); + result[NotifyParams.NewDayMonthYear].Should().Be("12 October 2020"); + result[NotifyParams.Name].Should().Be("Automation_FirstName Automation_LastName"); + } + } +} diff --git a/NotificationApi/NotificationApi/Services/NotificationParameterMapper.cs b/NotificationApi/NotificationApi/Services/NotificationParameterMapper.cs index 864bef49..344dc1ee 100644 --- a/NotificationApi/NotificationApi/Services/NotificationParameterMapper.cs +++ b/NotificationApi/NotificationApi/Services/NotificationParameterMapper.cs @@ -187,6 +187,7 @@ public static Dictionary MapToHearingAmendment(HearingAmendmentR var parameters = new Dictionary { {NotifyParams.CaseName, request.CaseName}, + {NotifyParams.UserName, request.Username.ToLower()}, {NotifyParams.CaseNumber, request.CaseNumber}, {NotifyParams.OldTime, request.PreviousScheduledDateTime.ToEmailTimeGbLocale()}, {NotifyParams.NewTime, request.NewScheduledDateTime.ToEmailTimeGbLocale()},