From d9d8acff83c68ba6d9e7f9492a2ff4b309d45e65 Mon Sep 17 00:00:00 2001 From: marcogagliardi Date: Thu, 7 Dec 2023 11:34:32 +0000 Subject: [PATCH 1/4] Update NotificationParameterMapper.cs --- .../NotificationApi/Services/NotificationParameterMapper.cs | 1 + 1 file changed, 1 insertion(+) 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()}, From 4b5b9ec5ebc8eba1e9f9bbbf4c1944fb9573587e Mon Sep 17 00:00:00 2001 From: marcogagliardi Date: Thu, 7 Dec 2023 14:40:10 +0000 Subject: [PATCH 2/4] added test --- .../MapToHearingAmendmentNotificationTests.cs | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 NotificationApi/NotificationApi.UnitTests/Mappers/NotificationMappers/MapToHearingAmendmentNotificationTests.cs diff --git a/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationMappers/MapToHearingAmendmentNotificationTests.cs b/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationMappers/MapToHearingAmendmentNotificationTests.cs new file mode 100644 index 00000000..51164413 --- /dev/null +++ b/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationMappers/MapToHearingAmendmentNotificationTests.cs @@ -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 +{ + public class MapToHearingAmendmentNotificationTests + { + + [Test] + public void should_map_to_amendment_notification() + { + //Arrange + const NotificationType expectedNotificationType = NotificationType.HearingAmendmentEJudJoh; + 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" + }; + + var expectedParameters = GetExpectedParameters(request); + + //Act + var result = NotificationParameterMapper.MapToHearingAmendment(request); + + //Assert + result.Should().NotBeNull(); + result[NotifyParams.CaseName].Should().Be(expectedParameters[NotifyParams.CaseName]); + 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 GetExpectedParameters(HearingAmendmentRequest request) + { + return 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()}, + {NotifyParams.OldDayMonthYear, request.PreviousScheduledDateTime.ToEmailDateGbLocale()}, + {NotifyParams.NewDayMonthYear, request.NewScheduledDateTime.ToEmailDateGbLocale()}, + {NotifyParams.Name, request.Name} + }; + } + } +} From 6efeac2c464b36c9fae452f4b37e3a3117c1f971 Mon Sep 17 00:00:00 2001 From: marcogagliardi Date: Thu, 7 Dec 2023 15:31:14 +0000 Subject: [PATCH 3/4] Update MapToHearingAmendmentNotificationTests.cs --- .../MapToHearingAmendmentNotificationTests.cs | 72 ------------------- .../MapToHearingAmendmentNotificationTests.cs | 54 ++++++++++++++ 2 files changed, 54 insertions(+), 72 deletions(-) delete mode 100644 NotificationApi/NotificationApi.UnitTests/Mappers/NotificationMappers/MapToHearingAmendmentNotificationTests.cs create mode 100644 NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMappers/MapToHearingAmendmentNotificationTests.cs diff --git a/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationMappers/MapToHearingAmendmentNotificationTests.cs b/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationMappers/MapToHearingAmendmentNotificationTests.cs deleted file mode 100644 index 51164413..00000000 --- a/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationMappers/MapToHearingAmendmentNotificationTests.cs +++ /dev/null @@ -1,72 +0,0 @@ -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 -{ - public class MapToHearingAmendmentNotificationTests - { - - [Test] - public void should_map_to_amendment_notification() - { - //Arrange - const NotificationType expectedNotificationType = NotificationType.HearingAmendmentEJudJoh; - 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" - }; - - var expectedParameters = GetExpectedParameters(request); - - //Act - var result = NotificationParameterMapper.MapToHearingAmendment(request); - - //Assert - result.Should().NotBeNull(); - result[NotifyParams.CaseName].Should().Be(expectedParameters[NotifyParams.CaseName]); - 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 GetExpectedParameters(HearingAmendmentRequest request) - { - return 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()}, - {NotifyParams.OldDayMonthYear, request.PreviousScheduledDateTime.ToEmailDateGbLocale()}, - {NotifyParams.NewDayMonthYear, request.NewScheduledDateTime.ToEmailDateGbLocale()}, - {NotifyParams.Name, request.Name} - }; - } - } -} diff --git a/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMappers/MapToHearingAmendmentNotificationTests.cs b/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMappers/MapToHearingAmendmentNotificationTests.cs new file mode 100644 index 00000000..e57db576 --- /dev/null +++ b/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMappers/MapToHearingAmendmentNotificationTests.cs @@ -0,0 +1,54 @@ +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 NotificationApi.UnitTests.Mappers.NotificationParameterMappers +{ + 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 = 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"); + } + } +} From 52885b73bc940961537d1f39f3f50bd8353baae4 Mon Sep 17 00:00:00 2001 From: marcogagliardi Date: Fri, 8 Dec 2023 08:09:04 +0000 Subject: [PATCH 4/4] Update MapToHearingAmendmentNotificationTests.cs --- .../MapToHearingAmendmentNotificationTests.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) rename NotificationApi/NotificationApi.UnitTests/Mappers/{NotificationParameterMappers => NotificationParameterMapper}/MapToHearingAmendmentNotificationTests.cs (90%) diff --git a/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMappers/MapToHearingAmendmentNotificationTests.cs b/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMapper/MapToHearingAmendmentNotificationTests.cs similarity index 90% rename from NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMappers/MapToHearingAmendmentNotificationTests.cs rename to NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMapper/MapToHearingAmendmentNotificationTests.cs index e57db576..38bcdfb2 100644 --- a/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMappers/MapToHearingAmendmentNotificationTests.cs +++ b/NotificationApi/NotificationApi.UnitTests/Mappers/NotificationParameterMapper/MapToHearingAmendmentNotificationTests.cs @@ -1,14 +1,10 @@ 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 NotificationApi.UnitTests.Mappers.NotificationParameterMappers +namespace NotificationApi.UnitTests.Mappers.NotificationParameterMapper { public class MapToHearingAmendmentNotificationTests { @@ -37,7 +33,7 @@ public void should_map_to_amendment_notification_for_individual() }; //Act - var result = NotificationParameterMapper.MapToHearingAmendment(request); + var result = NotificationApi.Services.NotificationParameterMapper.MapToHearingAmendment(request); //Assert result.Should().NotBeNull();